// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movq %rdx, 0x38(%rsp)
pxor %xmm0, %xmm0
leaq 0x40(%rsp), %rdi
movdqa %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x10(%rsi), %rsi
callq 0xc330
leaq (%rbx,%rbx,4), %rbx
shlq $0x3, %rbx
addq 0x38(%r14), %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x7e9a
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc434
movq %r12, 0x60(%rsp)
leaq 0x8(%rsp), %rdi
callq 0xc5f8
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0xc472
movq 0x38(%rsp), %r15
xorl %ebp, %ebp
leaq 0x7(%rsp), %r12
leaq 0x8(%rsp), %r13
movq 0x38(%r14), %rax
leaq (%r15,%r15,4), %rcx
movdqu (%rax,%rcx,8), %xmm0
movdqu 0x10(%rax,%rcx,8), %xmm1
pcmpeqb 0x96c9(%rip), %xmm1     # 0x152e0
pcmpeqb 0x96b1(%rip), %xmm0     # 0x152d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xbd69
leaq (%rax,%rcx,8), %rbx
movq 0x8(%r14), %rdx
movl $0x20, %esi
movq %rbx, %rdi
callq 0x2050
movl 0x8(%r14), %ecx
xorl $0x20, %ecx
xorl %edx, %edx
imull $0x5bd1e995, (%rbx,%rdx), %esi # imm = 0x5BD1E995
movl %esi, %edi
shrl $0x18, %edi
xorl %esi, %edi
imull $0x5bd1e995, %edi, %esi # imm = 0x5BD1E995
imull $0x5bd1e995, %ecx, %ecx # imm = 0x5BD1E995
xorl %esi, %ecx
addq $0x4, %rdx
cmpq $0x20, %rdx
jne 0xbc51
movl %ecx, %edx
shrl $0xd, %edx
xorl %ecx, %edx
imull $0x5bd1e995, %edx, %ecx # imm = 0x5BD1E995
movl %ecx, %esi
shrl $0xf, %esi
xorl %ecx, %esi
movq 0x30(%r14), %rdi
xorl %edx, %edx
divq %rdi
movq %rdx, %rcx
movq %rdx, 0x30(%rsp)
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, 0x28(%rsp)
cmpq %r15, %rcx
jne 0xbcf1
leaq (%rdx,%rdx,4), %rbx
shlq $0x3, %rbx
addq 0x38(%r14), %rbx
movq %r12, %rdi
callq 0x7e9a
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xc434
movq %r12, %rdi
callq 0xc5f8
leaq 0x40(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r13, %rdx
callq 0xc472
movq 0x28(%rsp), %r15
jmp 0xbd3b
cmpq %r15, %rdx
jne 0xbde2
leaq (%rcx,%rcx,4), %rbx
shlq $0x3, %rbx
addq 0x38(%r14), %rbx
movq %r12, %rdi
callq 0x7e9a
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xc434
movq %r12, %rdi
callq 0xc5f8
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %r13, %rdx
callq 0xc472
movq 0x30(%rsp), %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xbd57
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2200
incq %rbp
movq 0x10(%r14), %rax
cmpq %rbp, %rax
ja 0xbbfc
jmp 0xbd6d
movq 0x10(%r14), %rax
movslq %ebp, %rcx
cmpq %rcx, %rax
jne 0xbd81
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0xc500
movaps 0x40(%rsp), %xmm0
movq 0x60(%rsp), %rbx
movups %xmm0, (%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbdc3
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x40(%rsp), %rdi
callq 0xc2d2
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x91d7(%rip), %rdi      # 0x14fc0
leaq 0x263d(%rip), %rsi      # 0xe42d
movl $0x3, %edx
callq 0x2210
movq 0x30(%rsp), %rsi
movq 0x91ba(%rip), %rdi      # 0x14fc0
callq 0x2110
movq %rax, %r14
leaq 0x2684(%rip), %rsi      # 0xe499
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x2110
movq %rax, %r14
leaq 0x2660(%rip), %rsi      # 0xe499
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq %r14, %rdi
movq %r15, %rsi
callq 0x2110
movq %rax, %r14
leaq 0x263e(%rip), %rsi      # 0xe499
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20c0
movq 0x913c(%rip), %rdi      # 0x14fc0
movq %rbx, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x20c0
movl $0x1, %edi
callq 0x2220
jmp 0xbeec
jmp 0xbeec
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xc5f8
jmp 0xbf0a
movq %rax, %rbx
jmp 0xbf0a
jmp 0xbeec
jmp 0xbebc
jmp 0xbecb
movq %rax, %rbx
leaq 0x7(%rsp), %rdi
callq 0xc5f8
jmp 0xbeef
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xbeef
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xbeef
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf0a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x40(%rsp), %rdi
callq 0xc2d2
movq %rbx, %rdi
callq 0x2330