// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::table_position cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::cuckoo_insert<std::integral_constant<bool, false>, unsigned int>(cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::hash_value, cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::TwoBuckets&, unsigned int&)
table_position cuckoo_insert(const hash_value hv, TwoBuckets &b, K &key) {
    int res1, res2;
    bucket &b1 = buckets_[b.i1];
    if (!try_find_insert_bucket(b1, res1, hv.partial, key)) {
      return table_position{b.i1, static_cast<size_type>(res1),
                            failure_key_duplicated};
    }
    bucket &b2 = buckets_[b.i2];
    if (!try_find_insert_bucket(b2, res2, hv.partial, key)) {
      return table_position{b.i2, static_cast<size_type>(res2),
                            failure_key_duplicated};
    }
    if (res1 != -1) {
      return table_position{b.i1, static_cast<size_type>(res1), ok};
    }
    if (res2 != -1) {
      return table_position{b.i2, static_cast<size_type>(res2), ok};
    }

    // We are unlucky, so let's perform cuckoo hashing.
    size_type insert_bucket = 0;
    size_type insert_slot = 0;
    cuckoo_status st = run_cuckoo<TABLE_MODE>(b, insert_bucket, insert_slot);
    if (st == failure_under_expansion) {
      // The run_cuckoo operation operated on an old version of the table,
      // so we have to try again. We signal to the calling insert method
      // to try again by returning failure_under_expansion.
      return table_position{0, 0, failure_under_expansion};
    } else if (st == ok) {
      assert(TABLE_MODE() == locked_table_mode() ||
             !get_current_locks()[lock_ind(b.i1)].try_lock());
      assert(TABLE_MODE() == locked_table_mode() ||
             !get_current_locks()[lock_ind(b.i2)].try_lock());
      assert(!buckets_[insert_bucket].occupied(insert_slot));
      assert(insert_bucket == index_hash(hashpower(), hv.hash) ||
             insert_bucket == alt_index(hashpower(), hv.partial,
                                        index_hash(hashpower(), hv.hash)));
      // Since we unlocked the buckets during run_cuckoo, another insert
      // could have inserted the same key into either b.i1 or
      // b.i2, so we check for that before doing the insert.
      table_position pos = cuckoo_find(key, hv.partial, b.i1, b.i2);
      if (pos.status == ok) {
        pos.status = failure_key_duplicated;
        return pos;
      }
      return table_position{insert_bucket, insert_slot, ok};
    }
    assert(st == failure);
    LIBCUCKOO_DBG("hash table is full (hashpower = %zu, hash_items = %zu,"
                  "load factor = %.2f), need to increase hashpower\n",
                  hashpower(), size(), load_factor());
    return table_position{0, 0, failure_table_full};
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r14
movq %r8, %r12
movl %ecx, %ebp
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movq (%r8), %rax
movq 0x18(%rsi), %rsi
leaq (%rax,%rax,4), %rcx
leaq (%rsi,%rcx,8), %rdx
movl (%r9), %edi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpb $0x1, 0x24(%rdx,%r8)
jne 0x3032
cmpl %edi, (%rdx,%r8,8)
jne 0x3035
jmp 0x304c
movl %r8d, %ecx
cmpq $0x3, %r8
leaq 0x1(%r8), %r10
setae %r9b
movq %r10, %r8
cmpq $0x4, %r10
jne 0x3022
jmp 0x304f
movl %r8d, %ecx
testb $0x1, %r9b
je 0x309a
movq 0x8(%r12), %rdx
leaq (%rdx,%rdx,4), %rdi
leaq (%rsi,%rdi,8), %rdi
movl (%r14), %r8d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
xorl %r10d, %r10d
cmpb $0x1, 0x24(%rdi,%r9)
jne 0x3080
cmpl %r8d, (%rdi,%r9,8)
jne 0x3083
jmp 0x30a2
movl %r9d, %esi
cmpq $0x3, %r9
leaq 0x1(%r9), %r11
setae %r10b
movq %r11, %r9
cmpq $0x4, %r11
jne 0x3070
jmp 0x30a5
movq %rax, (%rbx)
movslq %ecx, %rax
jmp 0x30be
movl %r9d, %esi
testb $0x1, %r10b
je 0x30b8
cmpl $-0x1, %ecx
je 0x30cb
movq %rax, (%rbx)
movslq %ecx, %rax
jmp 0x30d6
movq %rdx, (%rbx)
movslq %esi, %rax
movq %rax, 0x8(%rbx)
movl $0x3, 0x10(%rbx)
jmp 0x30e1
cmpl $-0x1, %esi
je 0x30f3
movq %rdx, (%rbx)
movslq %esi, %rax
movq %rax, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movq %rsp, %rdx
movq %rax, (%rdx)
leaq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq %r15, %rdi
movq %r12, %rsi
callq 0x3468
testl %eax, %eax
je 0x314e
cmpl $0x1, %eax
je 0x3137
cmpl $0x5, %eax
jne 0x3269
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movl $0x5, 0x10(%rbx)
jmp 0x30e1
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movl $0x4, 0x10(%rbx)
jmp 0x30e1
movq 0x28(%r15), %rax
movzwl (%r12), %ecx
movq 0x10(%rax), %rdx
shll $0x6, %ecx
movb $0x1, %al
movb $0x1, %sil
xchgb %sil, (%rdx,%rcx)
testb %sil, %sil
je 0x3288
movq 0x28(%r15), %rcx
movzwl 0x8(%r12), %edx
movq 0x10(%rcx), %rcx
shll $0x6, %edx
xchgb %al, (%rcx,%rdx)
testb %al, %al
je 0x32a7
movq (%rsp), %rdx
movq 0x8(%rsp), %rax
leaq (%rdx,%rdx,4), %rcx
shlq $0x3, %rcx
addq 0x18(%r15), %rcx
cmpb $0x1, 0x24(%rax,%rcx)
je 0x32c6
movq 0x10(%r15), %rcx
movq $-0x1, %rsi
movq $-0x1, %rdi
shlq %cl, %rdi
notq %rdi
andq %r13, %rdi
movzbl %bpl, %eax
cmpq %rdi, %rdx
je 0x3214
movq 0x10(%r15), %rdx
movq 0x10(%r15), %rcx
movq $-0x1, %rdi
shlq %cl, %rdi
notq %rdi
andq %r13, %rdi
movabsq $0x46a4a7935bd1e995, %rcx # imm = 0x46A4A7935BD1E995
movq %rax, %r8
imulq %rcx, %r8
addq %rcx, %r8
xorq %rdi, %r8
movl %edx, %ecx
shlq %cl, %rsi
notq %rsi
andq %r8, %rsi
cmpq %rsi, (%rsp)
jne 0x32e5
movq (%r12), %r8
movq 0x8(%r12), %r9
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %eax, %ecx
callq 0x363c
cmpl $0x0, 0x10(%r12)
je 0x324b
movq (%rsp), %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %rax
jmp 0x30d6
movl $0x3, 0x20(%rsp)
movups 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x30e1
leaq 0x25cb(%rip), %rdi      # 0x583b
leaq 0x2007(%rip), %rsi      # 0x527e
leaq 0x2336(%rip), %rcx      # 0x55b4
movl $0x48e, %edx            # imm = 0x48E
callq 0x20f0
leaq 0x22ce(%rip), %rdi      # 0x555d
leaq 0x1fe8(%rip), %rsi      # 0x527e
leaq 0x2317(%rip), %rcx      # 0x55b4
movl $0x47d, %edx            # imm = 0x47D
callq 0x20f0
leaq 0x247c(%rip), %rdi      # 0x572a
leaq 0x1fc9(%rip), %rsi      # 0x527e
leaq 0x22f8(%rip), %rcx      # 0x55b4
movl $0x47f, %edx            # imm = 0x47F
callq 0x20f0
leaq 0x24b4(%rip), %rdi      # 0x5781
leaq 0x1faa(%rip), %rsi      # 0x527e
leaq 0x22d9(%rip), %rcx      # 0x55b4
movl $0x480, %edx            # imm = 0x480
callq 0x20f0
leaq 0x24c4(%rip), %rdi      # 0x57b0
leaq 0x1f8b(%rip), %rsi      # 0x527e
leaq 0x22ba(%rip), %rcx      # 0x55b4
movl $0x483, %edx            # imm = 0x483
callq 0x20f0