// File: attractivechaos[P]udb2/tsl_hopscotch_map/./hopscotch_hash.h
// Function: tsl::detail_hopscotch_hash::hopscotch_bucket<std::pair<unsigned int const, unsigned int>, 62u, false> const* tsl::detail_hopscotch_hash::hopscotch_hash<std::pair<unsigned int const, unsigned int>, tsl::bhopscotch_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 62u, false, tsl::hh::power_of_two_growth_policy<2ul>>::KeySelect, tsl::bhopscotch_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 62u, false, tsl::hh::power_of_two_growth_policy<2ul>>::ValueSelect, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 62u, false, tsl::hh::power_of_two_growth_policy<2ul>, std::map<unsigned int, unsigned int, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>>>::find_in_buckets<unsigned int>(unsigned int const&, unsigned long, tsl::detail_hopscotch_hash::hopscotch_bucket<std::pair<unsigned int const, unsigned int>, 62u, false> const*) const
const hopscotch_bucket* find_in_buckets(const K& key, std::size_t hash, const hopscotch_bucket* bucket_for_hash) const {      
        (void) hash; // Avoid warning of unused variable when StoreHash is false;

        // TODO Try to optimize the function. 
        // I tried to use ffs and  __builtin_ffs functions but I could not reduce the time the function
        // takes with -march=native
        
        neighborhood_bitmap neighborhood_infos = bucket_for_hash->neighborhood_infos();
        while(neighborhood_infos != 0) {
            if((neighborhood_infos & 1) == 1) {
                // Check StoreHash before calling bucket_hash_equal. Functionally it doesn't change anythin. 
                // If StoreHash is false, bucket_hash_equal is a no-op. Avoiding the call is there to help 
                // GCC optimizes `hash` parameter away, it seems to not be able to do without this hint.
                if((!StoreHash || bucket_for_hash->bucket_hash_equal(hash)) && 
                    compare_keys(KeySelect()(bucket_for_hash->value()), key)) 
                {
                    return bucket_for_hash;
                }
            }
            
            ++bucket_for_hash;
            neighborhood_infos = neighborhood_bitmap(neighborhood_infos >> 1);
        }
        
        return nullptr;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
callq 0x4fc0
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x4fa2
movq 0x18(%rsp), %rax
andq $0x1, %rax
cmpq $0x1, %rax
jne 0x4f85
movq 0x20(%rsp), %rdi
callq 0x5020
movq %rax, %rsi
leaq 0x17(%rsp), %rdi
callq 0x5010
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq 0x30(%rsp), %rdx
callq 0x4fe0
testb $0x1, %al
jne 0x4f77
jmp 0x4f83
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x4fab
jmp 0x4f85
movq 0x20(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
shrq %rax
movq %rax, 0x18(%rsp)
jmp 0x4f31
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)
nop