_getOwnerOf

solidity
function _getOwnerOf(
    uint256 id_
) internal view virtual returns (address ownerOf_) {
    uint256 data = _ownedData[id_];
    
    assembly {
        ownerOf_ := and(data, _BITMASK_ADDRESS)
    }
}

_ownedData配列からトークンIDである_idのデータを取得します。 取得した値と_BITMASK_ADDRESS(21602^{160})の論理積を取り、下位160ビットの値が格納されます。 これにより_ownedDataに格納されたNFTの所有者アドレスを取り出すことができます。

_retrieveOrMintERC721

solidity
function _retrieveOrMintERC721(address to_) internal virtual {
    if (to_ == address(0)) {
        revert InvalidRecipient();
    }
    
    uint256 id;
    
    if (!_storedERC721Ids.empty()) {
        id = _storedERC721Ids.popBack();
    } else {
        ++minted;
    
        if (minted == type(uint256).max) {
            revert MintLimitReached();
        }
        
        id = ID_ENCODING_PREFIX + minted;
    }
    
    address erc721Owner = _getOwnerOf(id);
    
    if (erc721Owner != address(0)) {
        revert AlreadyExists();
    }
    
    _transferERC721(erc721Owner, to_, id);
}

既存のトークンIDが保存されているか確認し、もし保存されていたらその値を取り出します。 もし保存されていない場合は新たにトークンIDを発行します。 mintedをインクリメントさせ、ID_ENCODING_PREFIX(22552^{255})を足し合わせてトークンIDを生成しています。

_getOwnerOf関数を実行してNFTの所有者アドレスを取得し、NFTを送付しています。