// File: /workspace/github_cpp_makefile_star2_O1/chahk0129[P]hash_bench/./index/cuckoo_hash.h
// Function: CuckooHash<char [32]>::insert4resize(char (&) [32], long)
bool CuckooHash<Key_t>::insert4resize(Key_t& key, Value_t value) {
  size_t f_hash, s_hash;
  if constexpr(sizeof(Key_t) > 8){
      f_hash = hash_funcs[0](key, sizeof(Key_t), _seed);
      s_hash = hash_funcs[1](key, sizeof(Key_t), _seed);
  }
  else{
      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 constexpr(sizeof(Key_t) > 8){
      if(memcmp(table[f_idx].key, INVALID<Key_t>, sizeof(Key_t)) == 0){
	  memcpy(table[f_idx].key, key, sizeof(Key_t));
	  memcpy(&table[f_idx].value, &value, sizeof(Value_t));
      }
      else if(memcmp(table[s_idx].key, INVALID<Key_t>, sizeof(Key_t)) == 0){
	  memcpy(table[s_idx].key, key, sizeof(Key_t));
	  memcpy(&table[s_idx].value, &value, sizeof(Value_t));
      }
      else{
	  auto path1 = find_path(f_idx, true);
	  auto path2 = find_path(s_idx, true);
	  memcpy(pushed[0].key, key, sizeof(Key_t));
	  memcpy(&pushed[0].value, &value, sizeof(Value_t));
	  if(path1.size() == 0 && path2.size() == 0)
		  return false;
	  else{
		  if(path1.size() == 0)
			  execute_path(path2, true);
		  else if(path2.size() == 0)
			  execute_path(path1, true);
		  else if(path1.size() < path2.size())
			  execute_path(path1, true);
		  else
			  execute_path(path2, true);
	  }
      }
  }
  else{
      if(memcmp(&table[f_idx].key, &INVALID<Key_t>, sizeof(Key_t)) == 0){
	  memcpy(&table[f_idx].key, &key, sizeof(Key_t));
	  memcpy(&table[f_idx].value, &value, sizeof(Value_t));
      }
      else if(memcmp(&table[s_idx].key, &INVALID<Key_t>, sizeof(Key_t)) == 0){
	  memcpy(&table[s_idx].key, &key, sizeof(Key_t));
	  memcpy(&table[s_idx].value, &value, sizeof(Value_t));
      }
      else{
	  auto path1 = find_path(f_idx);
	  auto path2 = find_path(s_idx);
	  memcpy(&pushed[0].key, &key, sizeof(Key_t));
	  memcpy(&pushed[0].value, &value, sizeof(Value_t));
	  if(path1.size() == 0 && path2.size() == 0)
		  return false;
	  else{
		  if(path1.size() == 0)
			  execute_path(path2);
		  else if(path2.size() == 0)
			  execute_path(path1);
		  else if(path1.size() < path2.size())
			  execute_path(path1);
		  else
			  execute_path(path2);
	  }
      }
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rdi), %rdx
movl $0x20, %esi
movq %r15, %rdi
callq 0x2050
movl 0x8(%rbx), %ecx
xorl $0x20, %ecx
xorl %edx, %edx
imull $0x5bd1e995, (%r15,%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 0xc42c
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(%rbx), %r8
movq 0x38(%rbx), %rdi
xorl %edx, %edx
divq %r8
movq %rdx, %rcx
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %r13
leaq (%rcx,%rcx,4), %rax
movdqu (%rdi,%rax,8), %xmm0
movdqu 0x10(%rdi,%rax,8), %xmm1
pcmpeqb 0x7e47(%rip), %xmm1     # 0x142e0
pcmpeqb 0x7e2f(%rip), %xmm0     # 0x142d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xc58b
leaq (,%r13,4), %rax
addq %r13, %rax
movdqu (%rdi,%rax,8), %xmm0
movdqu 0x10(%rdi,%rax,8), %xmm1
pcmpeqb 0x7e0d(%rip), %xmm1     # 0x142e0
pcmpeqb 0x7df5(%rip), %xmm0     # 0x142d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xc58b
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl $0x1, %ecx
callq 0xaf04
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xaf04
movdqu (%r15), %xmm0
movdqu 0x10(%r15), %xmm1
movdqu %xmm1, 0x50(%rbx)
movdqu %xmm0, 0x40(%rbx)
movq %r14, 0x60(%rbx)
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq %rdx, %rax
subq %rcx, %rax
je 0xc5bd
movq 0x10(%rsp), %rcx
subq 0x8(%rsp), %rcx
je 0xc565
cmpq %rcx, %rax
leaq 0x20(%rsp), %rax
cmovbq %rax, %rbp
movq %rbp, %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xc610
leaq 0x8(%rsp), %rdi
callq 0xb694
leaq 0x20(%rsp), %rdi
callq 0xb694
jmp 0xc5ac
leaq (%rdi,%rax,8), %rcx
movdqu (%r15), %xmm0
movdqu 0x10(%r15), %xmm1
movdqu %xmm1, 0x10(%rcx)
movdqu %xmm0, (%rcx)
movq 0x38(%rbx), %rcx
movq %r14, 0x20(%rcx,%rax,8)
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rsi
cmpq 0x8(%rsp), %rsi
je 0xc5d4
cmpq %rcx, %rdx
jne 0xc54a
jmp 0xc562
leaq 0x8(%rsp), %rdi
callq 0xb694
leaq 0x20(%rsp), %rdi
callq 0xb694
xorl %eax, %eax
jmp 0xc5ae
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xb694
jmp 0xc5fe
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb694
movq %rbx, %rdi
callq 0x2330