// File: chahk0129[P]hash_bench/./index/cuckoo_hash.h
// Function: CuckooHash<char [32]>::Get(char (&) [32])
char* CuckooHash<Key_t>::Get(Key_t& key) {
  if (resizing_lock) {
    for (unsigned i = 0; i < kNumHash; ++i) {
	    int idx;
	    if constexpr(sizeof(Key_t) > 8)
		    idx = hash_funcs[i](key, sizeof(Key_t), _seed) % old_cap;
	    else
		    idx = hash_funcs[i](&key, sizeof(Key_t), _seed) % old_cap;
      std::shared_lock<std::shared_mutex> lock(mutex[idx/locksize]);
      if constexpr(sizeof(Key_t) > 8){
	      if(memcmp(old_tab[idx].key, key, sizeof(Key_t)) == 0)
		      return (char*)old_tab[idx].value;
      }
      else
	      if(memcmp(&old_tab[idx].key, &key, sizeof(Key_t)) == 0)
		      return (char*)old_tab[idx].value;
      }

  } else {
    for (int i = 0; i < kNumHash; i++) {
	    int idx;
	    if constexpr(sizeof(Key_t) > 8)
		    idx = hash_funcs[i](key, sizeof(Key_t), _seed) % capacity;
	    else
		    idx = hash_funcs[i](&key, sizeof(Key_t), _seed) % capacity;
      std::shared_lock<std::shared_mutex> lock(mutex[idx/locksize]);
      if constexpr(sizeof(Key_t) > 8){
	      if(memcmp(table[idx].key, key, sizeof(Key_t)) == 0)
		      return (char*)table[idx].value;
      }
      else
	      if(memcmp(&table[idx].key, &key, sizeof(Key_t)) == 0)
		      return (char*)table[idx].value;
      }
    }
    return (char*)NONE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpl $0x0, 0xc8(%rax)
je 0x1f408
movl $0x0, -0x1c(%rbp)
movq -0x58(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpq 0x18(%rcx), %rax
jae 0x1f403
movq -0x58(%rbp), %rcx
movl -0x1c(%rbp), %eax
movl %eax, %edx
leaq 0x3b143(%rip), %rax     # 0x5a480
movq (%rax,%rdx,8), %rax
movq -0x18(%rbp), %rdi
movq 0x8(%rcx), %rdx
movl $0x20, %esi
callq *%rax
movq -0x58(%rbp), %rcx
xorl %edx, %edx
divq 0xb8(%rcx)
movl %edx, %eax
movl %eax, -0x20(%rbp)
movq 0xd0(%rcx), %rsi
movl -0x20(%rbp), %eax
cltd
idivl 0xdc(%rcx)
cltq
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x1e3b0
movq -0x58(%rbp), %rax
movq 0xc0(%rax), %rdi
movslq -0x20(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl $0x20, %edx
callq 0x6190
cmpl $0x0, %eax
jne 0x1f3d5
movq -0x58(%rbp), %rax
movq 0xc0(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x1f3dc
movl $0x0, -0x34(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x1e3e0
movl -0x34(%rbp), %eax
testl %eax, %eax
je 0x1f3f3
jmp 0x1f3ee
jmp 0x1f4f4
jmp 0x1f3f5
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1f31c
jmp 0x1f4ec
movl $0x0, -0x38(%rbp)
movq -0x58(%rbp), %rcx
movslq -0x38(%rbp), %rax
cmpq 0x18(%rcx), %rax
jae 0x1f4ea
movq -0x58(%rbp), %rcx
movslq -0x38(%rbp), %rdx
leaq 0x3b050(%rip), %rax     # 0x5a480
movq (%rax,%rdx,8), %rax
movq -0x18(%rbp), %rdi
movq 0x8(%rcx), %rdx
movl $0x20, %esi
callq *%rax
movq -0x58(%rbp), %rcx
xorl %edx, %edx
divq 0x30(%rcx)
movl %edx, %eax
movl %eax, -0x3c(%rbp)
movq 0xd0(%rcx), %rsi
movl -0x3c(%rbp), %eax
cltd
idivl 0xdc(%rcx)
cltq
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x1e3b0
movq -0x58(%rbp), %rax
movq 0x38(%rax), %rdi
movslq -0x3c(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl $0x20, %edx
callq 0x6190
cmpl $0x0, %eax
jne 0x1f4bf
movq -0x58(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x1f4c6
movl $0x0, -0x34(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x1e3e0
movl -0x34(%rbp), %eax
testl %eax, %eax
je 0x1f4da
jmp 0x1f4d8
jmp 0x1f4f4
jmp 0x1f4dc
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1f40f
jmp 0x1f4ec
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop