// File: BU-DiSC[P]BF-Shared-Hashing/BF_bit.cpp
// Function: BFHash::get_hash_digest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, HashType, unsigned int)
uint64_t BFHash::get_hash_digest(string & key, HashType ht, uint32_t seed){
    uint64_t result = 0;
    switch(ht){
        case MD5:
            memcpy(&result, md5(key).c_str(), sizeof(result));
            break;
        case SHA2:{
            uint8_t hash[32];
            const uint8_t * a = (const uint8_t*)key.c_str();
            calc_sha_256(hash, a, key.length());
	    for(int i = 0; i < 32; i++){
               result = (result << 1) + (hash[i]&0x1);
	    }
            break;
        }
            
        case MurMurhash: {
            result = MurmurHash2(key.c_str(), key.size(), seed);
            break;
	}
	case MurMur64: {
	    result = MurmurHash64A( key.c_str(), key.size(), seed);
	    break;
	}
        case XXhash:
        {
            // result = MurmurHash2(key.c_str(), key.size(), seed);
            XXH64_hash_t const p = seed;
            const void * key_void = key.c_str();
            XXH64_hash_t const h = XXH64(key_void, key.size(), p);
            result = h;
            break;
        }
        case CRC:{
            const void * key_void = key.c_str();
            result = crc32_fast( key_void, (unsigned long)key.size(), seed );
            break;
        }
        case CITY:{
            const char * key_void = key.c_str();
            result = CityHash64WithSeed( key_void, (unsigned long)key.size(), (unsigned long) seed);
	    break;
        }
	default:
            result = MurmurHash2(key.c_str(), key.size(), seed);
            break;
    }
    
    return result;
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movl %esi, 0x10c(%rsp)
movl %edx, 0x108(%rsp)
movq $0x0, 0x100(%rsp)
movl 0x10c(%rsp), %eax
movq %rax, 0x50(%rsp)
subq $0x6, %rax
ja 0x1e309
movq 0x50(%rsp), %rax
leaq 0x46661(%rip), %rcx     # 0x646bc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x110(%rsp), %rsi
leaq 0xc0(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x6260
movq 0x48(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x4bea0
jmp 0x1e092
leaq 0xe0(%rsp), %rdi
callq 0x6250
movq (%rax), %rax
movq %rax, 0x100(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x6340
leaq 0xc0(%rsp), %rdi
callq 0x6340
jmp 0x1e345
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x6340
jmp 0x1e355
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6770
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq %rax, %rdx
callq 0x4c670
movl $0x0, 0x84(%rsp)
cmpl $0x20, 0x84(%rsp)
jge 0x1e191
movq 0x100(%rsp), %rax
shlq %rax
movslq 0x84(%rsp), %rcx
movzbl 0x90(%rsp,%rcx), %ecx
andl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x100(%rsp)
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x1e148
jmp 0x1e345
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x30(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6390
movq 0x30(%rsp), %rdi
movl %eax, %esi
movl 0x108(%rsp), %edx
callq 0x4c3b0
movl %eax, %eax
movq %rax, 0x100(%rsp)
jmp 0x1e345
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x28(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6390
movq 0x28(%rsp), %rdi
movl %eax, %esi
movl 0x108(%rsp), %edx
callq 0x4c180
movq %rax, 0x100(%rsp)
jmp 0x1e345
movl 0x108(%rsp), %eax
movq %rax, 0x78(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6390
movq 0x20(%rsp), %rdi
movq %rax, %rsi
movq 0x78(%rsp), %rdx
callq 0x4e0a0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x100(%rsp)
jmp 0x1e345
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6390
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movl 0x108(%rsp), %edx
callq 0x60e80
movl %eax, %eax
movq %rax, 0x100(%rsp)
jmp 0x1e345
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6390
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movl 0x108(%rsp), %eax
movl %eax, %edx
callq 0x625e0
movq %rax, 0x100(%rsp)
jmp 0x1e345
movq 0x110(%rsp), %rdi
callq 0x6250
movq %rax, 0x8(%rsp)
movq 0x110(%rsp), %rdi
callq 0x6390
movq 0x8(%rsp), %rdi
movl %eax, %esi
movl 0x108(%rsp), %edx
callq 0x4c3b0
movl %eax, %eax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xb8(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)