// File: /workspace/github_cpp_makefile_star2_O3/chahk0129[P]hash_bench/./index/cuckoo_hash.h
// Function: CuckooHash<unsigned long>::find_path(unsigned long)
vector<pair<size_t,Key_t>> CuckooHash<Key_t>::find_path(size_t target) {
  vector<pair<size_t,Key_t>> path;
  path.reserve(kCuckooThreshold);
  path.emplace_back(target, table[target].key);
  auto cur = target;
  auto i = 0;
  do {
    Key_t* key;
    size_t f_hash, s_hash;
    key = &table[cur].key;
    if(memcmp(key, &INVALID<Key_t>, sizeof(Key_t)) == 0) break;
    f_hash = hash_funcs[0](key, sizeof(Key_t), _seed);
    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) {
      path.emplace_back(s_idx, table[s_idx].key);
      cur = s_idx;
    } else if (s_idx == cur) {
      path.emplace_back(f_idx, table[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 $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, 0x40(%rsp)
movq %rdx, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x10(%rsi), %rsi
callq 0xbf12
shlq $0x4, %rbx
addq 0x38(%r12), %rbx
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0xbfba
movq 0x8(%rsp), %r15
xorl %r13d, %r13d
leaq 0x20(%rsp), %rbp
leaq 0x18(%rsp), %rbx
movq 0x38(%r12), %r14
movq %r15, %rax
shlq $0x4, %rax
movq (%r14,%rax), %rcx
cmpq 0x994e(%rip), %rcx      # 0x15298
je 0xba1e
addq %rax, %r14
movq 0x8(%r12), %rdx
movl $0x8, %esi
movq %r14, %rdi
callq 0x2050
movl 0x8(%r12), %ecx
xorl $0x8, %ecx
xorl %edx, %edx
imull $0x5bd1e995, (%r14,%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 $0x8, %rdx
jne 0xb96f
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(%r12), %rdi
xorl %edx, %edx
divq %rdi
movq %rdx, %rcx
movq %rdx, 0x18(%rsp)
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, 0x10(%rsp)
cmpq %r15, %rcx
jne 0xb9e9
shlq $0x4, %rdx
addq 0x38(%r12), %rdx
movq %rbp, %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0xbfba
jmp 0xba08
cmpq %r15, %rdx
jne 0xba5c
shlq $0x4, %rcx
addq 0x38(%r12), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
callq 0xbfba
movq %rbx, %r14
movq (%r14), %r15
incq %r13
movq 0x10(%r12), %rax
cmpq %r13, %rax
ja 0xb933
jmp 0xba23
movq 0x10(%r12), %rax
movslq %r13d, %rcx
cmpq %rcx, %rax
jne 0xba37
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0xbffa
movaps 0x20(%rsp), %xmm0
movq 0x40(%rsp), %rax
movups %xmm0, (%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x955d(%rip), %rdi      # 0x14fc0
leaq 0x29e4(%rip), %rsi      # 0xe44e
movl $0x3, %edx
callq 0x21d0
movq 0x18(%rsp), %rsi
movq 0x9540(%rip), %rdi      # 0x14fc0
callq 0x2100
movq %rax, %rbx
leaq 0x2a01(%rip), %rsi      # 0xe490
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x29dd(%rip), %rsi      # 0xe490
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rbx
leaq 0x29bb(%rip), %rsi      # 0xe490
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x20b0
movq (%r14), %rsi
movq 0x94bf(%rip), %rdi      # 0x14fc0
callq 0x2100
movq %rax, %rdi
callq 0x20b0
movl $0x1, %edi
callq 0x21e0
jmp 0xbb20
jmp 0xbb20
jmp 0xbb20
jmp 0xbb20
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xbb3a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x22e0