// File: chahk0129[P]hash_bench/./index/cuckoo_hash.h
// Function: CuckooHash<char [32]>::find_path[abi:cxx11](unsigned long, bool)
vector<pair<size_t,string>> CuckooHash<Key_t>::find_path(size_t target, bool flag) {
  vector<pair<size_t,string>> path;
  path.reserve(kCuckooThreshold);
  string key_v(table[target].key);
  path.emplace_back(target, key_v);
  auto cur = target;
  auto i = 0;
  do {
    const char* key = table[cur].key;
    if(memcmp(key, INVALID<Key_t>, sizeof(Key_t)) == 0){ 
	    break;
    }
    auto f_hash = hash_funcs[0](key, sizeof(Key_t), _seed);
    auto s_hash = hash_funcs[1](key, sizeof(Key_t), _seed);

    auto f_idx = f_hash % capacity;
    auto s_idx = s_hash % capacity;

    if (f_idx == cur) {
	    string s_idx_key(table[s_idx].key);
	    path.emplace_back(s_idx, s_idx_key);
	    cur = s_idx;
    } else if (s_idx == cur) {
	    string f_idx_key(table[f_idx].key);
	    path.emplace_back(f_idx, f_idx_key);
	    cur = f_idx;
    } else {  // something terribly wrong
	    cout << "E: " << f_idx << " " << s_idx << " " << cur << " " << target << endl;
	    cout << key << endl;
	    exit(1);
    }
    i++;
  } while (i < kCuckooThreshold);

  if (i == kCuckooThreshold) {
    path.resize(0);
  }

  return move(path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x118(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0x110(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x20730
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rdi
movq 0x10(%rax), %rsi
callq 0x20750
jmp 0x1f663
movq -0x108(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x18(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x128(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x14b60
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x20850
jmp 0x1f6aa
leaq -0x69(%rbp), %rdi
callq 0x14bd0
leaq -0x38(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x20900
jmp 0x1f6c6
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x108(%rbp), %rax
movq 0x38(%rax), %rax
imulq $0x28, -0x78(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
leaq 0x3b5a3(%rip), %rsi     # 0x5aca0
movl $0x20, %edx
callq 0x6190
cmpl $0x0, %eax
jne 0x1f74d
jmp 0x1faec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1fb49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x14bd0
jmp 0x1fb49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1fb40
movq -0x108(%rbp), %rcx
movq 0x3ad25(%rip), %rax     # 0x5a480
movq -0x88(%rbp), %rdi
movq 0x8(%rcx), %rdx
movl $0x20, %esi
callq *%rax
movq %rax, -0x130(%rbp)
jmp 0x1f776
movq -0x108(%rbp), %rcx
movq -0x130(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x3acf6(%rip), %rax     # 0x5a488
movq -0x88(%rbp), %rdi
movq 0x8(%rcx), %rdx
movl $0x20, %esi
callq *%rax
movq %rax, -0x138(%rbp)
jmp 0x1f7ad
movq -0x108(%rbp), %rcx
movq -0x138(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
xorl %edx, %edx
divq 0x30(%rcx)
movq %rdx, -0xa0(%rbp)
movq -0x98(%rbp), %rax
xorl %edx, %edx
divq 0x30(%rcx)
movq %rdx, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0x1f8c6
movq -0x108(%rbp), %rax
movq 0x38(%rax), %rax
movq -0xa8(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x148(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x14b60
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdx
leaq -0xc8(%rbp), %rdi
callq 0x20850
jmp 0x1f84b
leaq -0xc9(%rbp), %rdi
callq 0x14bd0
leaq -0x38(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x20900
jmp 0x1f870
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x6250
jmp 0x1face
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc9(%rbp), %rdi
callq 0x14bd0
jmp 0x1fb40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x6250
jmp 0x1fb40
movq -0xa8(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0x1f9a2
movq -0x108(%rbp), %rax
movq 0x38(%rax), %rax
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x158(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x14b60
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
callq 0x20850
jmp 0x1f927
leaq -0xf1(%rbp), %rdi
callq 0x14bd0
leaq -0x38(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x20900
jmp 0x1f94c
movq -0xa0(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6250
jmp 0x1facc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf1(%rbp), %rdi
callq 0x14bd0
jmp 0x1fb40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6250
jmp 0x1fb40
movq 0x3a60f(%rip), %rdi     # 0x59fb8
leaq 0x22a1d(%rip), %rsi     # 0x423cd
callq 0x6400
movq %rax, -0x160(%rbp)
jmp 0x1f9be
movq -0x160(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x60a0
movq %rax, -0x168(%rbp)
jmp 0x1f9da
movq -0x168(%rbp), %rdi
leaq 0x240ae(%rip), %rsi     # 0x43a96
callq 0x6400
movq %rax, -0x170(%rbp)
jmp 0x1f9f6
movq -0x170(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x60a0
movq %rax, -0x178(%rbp)
jmp 0x1fa12
movq -0x178(%rbp), %rdi
leaq 0x24076(%rip), %rsi     # 0x43a96
callq 0x6400
movq %rax, -0x180(%rbp)
jmp 0x1fa2e
movq -0x180(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x60a0
movq %rax, -0x188(%rbp)
jmp 0x1fa47
movq -0x188(%rbp), %rdi
leaq 0x24041(%rip), %rsi     # 0x43a96
callq 0x6400
movq %rax, -0x190(%rbp)
jmp 0x1fa63
movq -0x190(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x60a0
movq %rax, -0x198(%rbp)
jmp 0x1fa7c
movq -0x198(%rbp), %rdi
movq 0x3a516(%rip), %rsi     # 0x59fa0
callq 0x6460
jmp 0x1fa91
movq -0x88(%rbp), %rsi
movq 0x3a519(%rip), %rdi     # 0x59fb8
callq 0x6400
movq %rax, -0x1a0(%rbp)
jmp 0x1faad
movq -0x1a0(%rbp), %rdi
movq 0x3a4e5(%rip), %rsi     # 0x59fa0
callq 0x6460
jmp 0x1fac2
movl $0x1, %edi
callq 0x6500
jmp 0x1face
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movq -0x108(%rbp), %rcx
movslq -0x7c(%rbp), %rax
cmpq 0x10(%rcx), %rax
jb 0x1f6d5
movq -0x108(%rbp), %rcx
movslq -0x7c(%rbp), %rax
cmpq 0x10(%rcx), %rax
jne 0x1fb0e
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x20980
jmp 0x1fb0c
jmp 0x1fb0e
movq -0x118(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x20a10
leaq -0x68(%rbp), %rdi
callq 0x6250
leaq -0x38(%rbp), %rdi
callq 0x206d0
movq -0x110(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x6250
leaq -0x38(%rbp), %rdi
callq 0x206d0
movq -0x40(%rbp), %rdi
callq 0x6780
nopl (%rax,%rax)