// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %rdi, 0x40(%rsp)
movq %rdx, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq 0x10(%rsi), %rsi
callq 0x9d0c
shlq $0x4, %rbx
addq 0x38(%r15), %rbx
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x9db4
movq 0x8(%rsp), %r12
xorl %ebp, %ebp
pushq $0x8
popq %r13
movq 0x38(%r15), %r14
movq %r12, %rax
shlq $0x4, %rax
movq (%r14,%rax), %rcx
cmpq 0xaab8(%rip), %rcx      # 0x14288
je 0x987a
addq %rax, %r14
movq 0x8(%r15), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2040
movq %rax, %rbx
movq 0x8(%r15), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x8470
movq %rax, %rsi
movq 0x30(%r15), %rdi
movq %rbx, %rax
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 %r12, %rcx
jne 0x983f
shlq $0x4, %rdx
addq 0x38(%r15), %rdx
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x9db4
jmp 0x9865
cmpq %r12, %rdx
jne 0x98cc
shlq $0x4, %rcx
addq 0x38(%r15), %rcx
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %rcx, %rdx
callq 0x9db4
movq (%rbx), %r12
incq %rbp
movq 0x10(%r15), %rax
cmpq %rbp, %rax
ja 0x97ba
jmp 0x987e
movq 0x10(%r15), %rax
movslq %ebp, %rcx
cmpq %rcx, %rax
jne 0x9892
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x9df4
leaq 0x20(%rsp), %rdi
movaps (%rdi), %xmm0
movq 0x40(%rsp), %rbx
movups %xmm0, (%rbx)
movq 0x10(%rdi), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0xa8ec
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa6ed(%rip), %rdi      # 0x13fc0
leaq 0x2b5c(%rip), %rsi      # 0xc436
callq 0x2180
movq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x20f0
leaq 0x2b85(%rip), %rsi      # 0xc478
movq %rax, %rdi
callq 0x2180
movq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x20f0
leaq 0x2b69(%rip), %rsi      # 0xc478
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r12, %rsi
callq 0x20f0
leaq 0x2b4f(%rip), %rsi      # 0xc478
movq %rax, %rdi
callq 0x2180
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20a0
movq (%r14), %rsi
movq 0xa670(%rip), %rdi      # 0x13fc0
callq 0x20f0
movq %rax, %rdi
callq 0x20a0
pushq $0x1
popq %rdi
callq 0x21b0
jmp 0x996d
jmp 0x996d
jmp 0x996d
jmp 0x996d
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xa8ec
movq %rbx, %rdi
callq 0x22c0