     
     @_inlineable
     public mutating func isLockFree() -> Bool {
-        @_transparent
-        func _isLockFree(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> Bool {
-            return theVal.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicPtrIsLockFree($0) }
-        }
-        return _isLockFree(&self)
+        return withUnsafeMutablePointer(to: &self) { $0.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicPtrIsLockFree($0) } }
     }
     
     /// Atomic fetch the current value with barrier.
     @_inlineable
     public mutating func fetchSelf() -> (current: OpaquePointer, value: OpaquePointer) {
-        @_transparent
-        func load(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> UnsafeMutableRawPointer {
-            return theVal.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicLoadPtrBarrier($0) }
-        }
-        let val = OpaquePointer(load(&self))
+        let result = withUnsafeMutablePointer(to: &self) { $0.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicLoadPtrBarrier($0) } }
+        let val = OpaquePointer(result!)
         return (val, val)
     }
     
     /// Atomic sets the value with barrier.
     @_inlineable
     public mutating func store(_ new: OpaquePointer) {
-        @_transparent
-        func store(_ theVal: UnsafeMutablePointer<OpaquePointer>) {
-            theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicStorePtrBarrier(UnsafeMutableRawPointer(new), $0) }
-        }
-        store(&self)
+        withUnsafeMutablePointer(to: &self) { $0.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicStorePtrBarrier(UnsafeMutableRawPointer(new), $0) } }
     }
     
     /// Compare and set pointers with barrier.
     @_inlineable
     public mutating func compareSet(old: OpaquePointer, new: OpaquePointer) -> Bool {
-        @_transparent
-        func cas(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> Bool {
-            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicCompareAndSwapPtrBarrier(UnsafeMutableRawPointer(old), UnsafeMutableRawPointer(new), $0) }
-        }
-        return cas(&self)
+        return withUnsafeMutablePointer(to: &self) { $0.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicCompareAndSwapPtrBarrier(UnsafeMutableRawPointer(old), UnsafeMutableRawPointer(new), $0) } }
     }
     
     /// Set pointers with barrier.
     @_inlineable
     public mutating func fetchStore(_ new: OpaquePointer) -> OpaquePointer {
-        @_transparent
-        func exchange(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> UnsafeMutableRawPointer {
-            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(UnsafeMutableRawPointer(new), $0) }
-        }
-        return OpaquePointer(exchange(&self))
+        let result = withUnsafeMutablePointer(to: &self) { $0.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(UnsafeMutableRawPointer(new), $0) } }
+        return OpaquePointer(result!)
     }
 }
 

    
    @_inlineable
    public mutating func isLockFree() -> Bool {
        @_transparent
        func _isLockFree(_ theVal: UnsafeMutablePointer<UnsafePointer<Pointee>>) -> Bool {
            return theVal.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicPtrIsLockFree($0) }
        }
        return _isLockFree(&self)
    }
    
    /// Atomic fetch the current value with barrier.
    @_inlineable
    public mutating func fetchSelf() -> (current: UnsafePointer, value: UnsafePointer) {
        @_transparent
        func load(_ theVal: UnsafeMutablePointer<UnsafePointer<Pointee>>) -> UnsafeMutableRawPointer {
            return theVal.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicLoadPtrBarrier($0) }
        }
        let val = UnsafePointer(load(&self).assumingMemoryBound(to: Pointee.self))
        return (val, val)
    }
    
    /// Atomic sets the value with barrier.
    @_inlineable
    public mutating func store(_ new: UnsafePointer) {
        @_transparent
        func store(_ theVal: UnsafeMutablePointer<UnsafePointer<Pointee>>) {
            theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicStorePtrBarrier(UnsafeMutableRawPointer(mutating: new), $0) }
        }
        store(&self)
    }
    
    /// Compare and set pointers with barrier.
    @_inlineable
    public mutating func compareSet(old: UnsafePointer, new: UnsafePointer) -> Bool {
        @_transparent
        func cas(_ theVal: UnsafeMutablePointer<UnsafePointer<Pointee>>) -> Bool {
            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicCompareAndSwapPtrBarrier(UnsafeMutableRawPointer(mutating: old), UnsafeMutableRawPointer(mutating: new), $0) }
        }
        return cas(&self)
    }
    
    /// Set pointers with barrier.
    @_inlineable
    public mutating func fetchStore(_ new: UnsafePointer) -> UnsafePointer {
        @_transparent
        func exchange(_ theVal: UnsafeMutablePointer<UnsafePointer<Pointee>>) -> UnsafeMutableRawPointer {
            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(UnsafeMutableRawPointer(mutating: new), $0) }
        }
        return UnsafePointer(exchange(&self).assumingMemoryBound(to: Pointee.self))
    }
}


        return result
    }
    
    @_transparent
    @discardableResult
    private mutating func _fetchStore(_ new: AtomicBase<Instance>) -> AtomicBase<Instance> {
        let _new = Unmanaged.passRetained(new)
        let result = withUnsafeMutablePointer(to: &base) { $0.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(_new.toOpaque(), $0) } }
        let _old = Unmanaged<AtomicBase<Instance>>.fromOpaque(UnsafeRawPointer(result!))
        return _old.takeRetainedValue()
    }
}
