// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %r14
movq %rdi, %r12
movq %rdx, 0x8(%rsp)
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movdqa %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x10(%rsi), %rsi
callq 0xb6f0
movq 0x8(%rsp), %rax
leaq (%rax,%rax,4), %rbx
shlq $0x3, %rbx
addq 0x38(%r14), %rbx
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x70ca
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb7f4
movq %r12, 0x60(%rsp)
leaq 0x30(%rsp), %rdi
callq 0xb9aa
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0xb832
movq 0x8(%rsp), %r15
xorl %r12d, %r12d
leaq 0x30(%rsp), %rbp
movq 0x38(%r14), %rax
leaq (%r15,%r15,4), %rcx
movdqu 0x10(%rax,%rcx,8), %xmm0
pcmpeqb 0x932e(%rip), %xmm0     # 0x142e0
movdqu (%rax,%rcx,8), %xmm1
pcmpeqb 0x9311(%rip), %xmm1     # 0x142d0
pand %xmm0, %xmm1
pmovmskb %xmm1, %edx
xorl %r13d, %r13d
cmpl $0xffff, %edx           # imm = 0xFFFF
setne %dl
je 0xb112
movb %dl, 0x7(%rsp)
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 0xaffb
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, 0x58(%rsp)
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, 0x50(%rsp)
cmpq %r15, %rcx
jne 0xb0a0
leaq (%rdx,%rdx,4), %rbx
shlq $0x3, %rbx
addq 0x38(%r14), %rbx
leaq 0x6(%rsp), %r15
movq %r15, %rdi
callq 0x70ca
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb7f4
movq %r15, %rdi
callq 0xb9aa
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbp, %rdx
callq 0xb832
movq 0x50(%rsp), %r15
jmp 0xb0ef
cmpq %r15, %rdx
jne 0xb1a5
leaq (%rcx,%rcx,4), %rbx
shlq $0x3, %rbx
addq 0x38(%r14), %rbx
leaq 0x6(%rsp), %r15
movq %r15, %rdi
callq 0x70ca
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb7f4
movq %r15, %rdi
callq 0xb9aa
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movq %rbp, %rdx
callq 0xb832
movq 0x58(%rsp), %r15
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb10b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2200
incl %r12d
movb 0x7(%rsp), %dl
movb %dl, %r13b
movslq %r12d, %rax
testl %r13d, %r13d
je 0xb127
cmpq %rax, 0x10(%r14)
ja 0xaf9c
cmpq %rax, 0x10(%r14)
jne 0xb139
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0xb8b8
movq 0x10(%rsp), %rax
movq 0x60(%rsp), %rbx
movq %rax, (%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb186
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x10(%rsp), %rdi
callq 0xb694
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8e14(%rip), %rdi      # 0x13fc0
leaq 0x223a(%rip), %rsi      # 0xd3ed
movl $0x3, %edx
callq 0x2210
movq 0x58(%rsp), %rsi
movq 0x8df7(%rip), %rdi      # 0x13fc0
callq 0x2110
movq %rax, %r14
leaq 0x2281(%rip), %rsi      # 0xd459
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x2110
movq %rax, %r14
leaq 0x225d(%rip), %rsi      # 0xd459
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq %r14, %rdi
movq %r15, %rsi
callq 0x2110
movq %rax, %r14
leaq 0x223b(%rip), %rsi      # 0xd459
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20c0
movq 0x8d79(%rip), %rdi      # 0x13fc0
movq %rbx, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x20c0
movl $0x1, %edi
callq 0x2220
jmp 0xb2af
jmp 0xb2af
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xb9aa
jmp 0xb2cd
movq %rax, %rbx
jmp 0xb2cd
jmp 0xb2af
jmp 0xb27f
jmp 0xb28e
movq %rax, %rbx
leaq 0x6(%rsp), %rdi
callq 0xb9aa
jmp 0xb2b2
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb2b2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb2b2
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb2cd
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x10(%rsp), %rdi
callq 0xb694
movq %rbx, %rdi
callq 0x2330
nop