// File: /workspace/github_cpp_makefile_star2_O3/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 0xcfe6
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 0x828d(%rip), %xmm1     # 0x152e0
pcmpeqb 0x8275(%rip), %xmm0     # 0x152d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xd11a
leaq (,%r13,4), %rax
addq %r13, %rax
movdqu (%rdi,%rax,8), %xmm0
movdqu 0x10(%rdi,%rax,8), %xmm1
pcmpeqb 0x8253(%rip), %xmm1     # 0x152e0
pcmpeqb 0x823b(%rip), %xmm0     # 0x152d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xd11a
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl $0x1, %ecx
callq 0xbb62
leaq 0x20(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xbb62
movdqu (%r15), %xmm0
movdqu 0x10(%r15), %xmm1
movdqu %xmm1, 0x50(%rbx)
movdqu %xmm0, 0x40(%rbx)
movq %r14, 0x60(%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
subq 0x8(%rsp), %rax
je 0xd13d
subq %rdx, %rcx
je 0xd145
cmpq %rcx, %rax
leaq 0x8(%rsp), %rax
cmovbq %rax, %rbp
movq %rbp, %r12
jmp 0xd145
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)
jmp 0xd169
movq %rbp, %r12
cmpq %rdx, %rcx
je 0xd17a
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xd1b6
leaq 0x20(%rsp), %rdi
callq 0xc2d2
leaq 0x8(%rsp), %rdi
callq 0xc2d2
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20(%rsp), %rdi
callq 0xc2d2
leaq 0x8(%rsp), %rdi
callq 0xc2d2
xorl %eax, %eax
jmp 0xd16b
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xc2d2
jmp 0xd1a4
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xc2d2
movq %rbx, %rdi
callq 0x2330