// File: /workspace/github_cpp_makefile_star2_O3/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), %rdi
leaq (%rax,%rax,4), %rcx
leaq (%rdi,%rcx,8), %r8
movl (%r9), %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %r9d, %r9d
cmpb $0x1, 0x24(%r8,%rsi)
jne 0x304b
cmpl %edx, (%r8,%rsi,8)
jne 0x304d
jmp 0x3064
movl %esi, %ecx
cmpq $0x3, %rsi
leaq 0x1(%rsi), %r10
setae %r9b
movq %r10, %rsi
cmpq $0x4, %r10
jne 0x303b
jmp 0x306c
testb $0x1, %r9b
je 0x30dc
movl %esi, %ecx
movq 0x8(%r12), %rsi
leaq (%rsi,%rsi,4), %r8
leaq (%rdi,%r8,8), %r9
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
xorl %r10d, %r10d
cmpb $0x1, 0x24(%r9,%r8)
jne 0x3094
cmpl %edx, (%r9,%r8,8)
jne 0x3097
jmp 0x30ae
movl %r8d, %edi
cmpq $0x3, %r8
leaq 0x1(%r8), %r11
setae %r10b
movq %r11, %r8
cmpq $0x4, %r11
jne 0x3084
jmp 0x30b7
testb $0x1, %r10b
je 0x30e5
movl %r8d, %edi
cmpl $-0x1, %ecx
je 0x30c4
movq %rax, (%rbx)
movslq %ecx, %rax
jmp 0x30cf
cmpl $-0x1, %edi
je 0x3105
movq %rsi, (%rbx)
movslq %edi, %rax
movq %rax, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
jmp 0x30f3
movq %rax, (%rbx)
movq %rsi, 0x8(%rbx)
jmp 0x30ec
movq %rsi, (%rbx)
movq %r8, 0x8(%rbx)
movl $0x3, 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 0x347e
testl %eax, %eax
je 0x3160
cmpl $0x1, %eax
je 0x3149
cmpl $0x5, %eax
jne 0x327b
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movl $0x5, 0x10(%rbx)
jmp 0x30f3
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movl $0x4, 0x10(%rbx)
jmp 0x30f3
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 0x329a
movq 0x28(%r15), %rcx
movzwl 0x8(%r12), %edx
movq 0x10(%rcx), %rcx
shll $0x6, %edx
xchgb %al, (%rcx,%rdx)
testb %al, %al
je 0x32b9
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 0x32d8
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 0x3226
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 0x32f7
movq (%r12), %r8
movq 0x8(%r12), %r9
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %eax, %ecx
callq 0x3636
cmpl $0x0, 0x10(%r12)
je 0x325d
movq (%rsp), %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %rax
jmp 0x30cf
movl $0x3, 0x20(%rsp)
movups 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x30f3
leaq 0x25b9(%rip), %rdi      # 0x583b
leaq 0x1ff5(%rip), %rsi      # 0x527e
leaq 0x2324(%rip), %rcx      # 0x55b4
movl $0x48e, %edx            # imm = 0x48E
callq 0x20f0
leaq 0x22bc(%rip), %rdi      # 0x555d
leaq 0x1fd6(%rip), %rsi      # 0x527e
leaq 0x2305(%rip), %rcx      # 0x55b4
movl $0x47d, %edx            # imm = 0x47D
callq 0x20f0
leaq 0x246a(%rip), %rdi      # 0x572a
leaq 0x1fb7(%rip), %rsi      # 0x527e
leaq 0x22e6(%rip), %rcx      # 0x55b4
movl $0x47f, %edx            # imm = 0x47F
callq 0x20f0
leaq 0x24a2(%rip), %rdi      # 0x5781
leaq 0x1f98(%rip), %rsi      # 0x527e
leaq 0x22c7(%rip), %rcx      # 0x55b4
movl $0x480, %edx            # imm = 0x480
callq 0x20f0
leaq 0x24b2(%rip), %rdi      # 0x57b0
leaq 0x1f79(%rip), %rsi      # 0x527e
leaq 0x22a8(%rip), %rcx      # 0x55b4
movl $0x483, %edx            # imm = 0x483
callq 0x20f0