// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %r9, %r14
movq %r8, %r15
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %rbx
imulq $0x28, (%r8), %rsi
addq 0x18(%r12), %rsi
movzbl %cl, %r13d
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movl %r13d, %ecx
movq %r9, %r8
callq 0x33be
testb %al, %al
je 0x3026
imulq $0x28, 0x8(%r15), %rsi
addq 0x18(%r12), %rsi
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movl %r13d, %ecx
movq %r14, %r8
callq 0x33be
testb %al, %al
je 0x3033
movslq 0xc(%rsp), %rax
cmpq $-0x1, %rax
je 0x304c
movq (%r15), %rcx
jmp 0x305b
movq (%r15), %rax
movq %rax, (%rbx)
movslq 0xc(%rsp), %rax
jmp 0x303f
movq 0x8(%r15), %rax
movq %rax, (%rbx)
movslq 0x8(%rsp), %rax
movq %rax, 0x8(%rbx)
movl $0x3, 0x10(%rbx)
jmp 0x3066
movslq 0x8(%rsp), %rax
cmpq $-0x1, %rax
je 0x3078
movq 0x8(%r15), %rcx
movq %rcx, (%rbx)
movq %rax, 0x8(%rbx)
andl $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x18(%rsp), %rcx
andq $0x0, (%rcx)
movq %r12, %rdi
movq %r15, %rsi
callq 0x33ec
testl %eax, %eax
je 0x30cf
cmpl $0x1, %eax
je 0x30bb
cmpl $0x5, %eax
jne 0x31db
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movl $0x5, 0x10(%rbx)
jmp 0x3066
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movl $0x4, 0x10(%rbx)
jmp 0x3066
movq 0x28(%r12), %rax
movzwl (%r15), %ecx
movq 0x10(%rax), %rdx
shll $0x6, %ecx
movb $0x1, %al
movb $0x1, %sil
xchgb %sil, (%rdx,%rcx)
testb %sil, %sil
je 0x31fa
movq 0x28(%r12), %rcx
movzwl 0x8(%r15), %edx
movq 0x10(%rcx), %rcx
shll $0x6, %edx
xchgb %al, (%rcx,%rdx)
testb %al, %al
je 0x3219
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, %rax, %rdx
addq 0x18(%r12), %rdx
cmpb $0x1, 0x24(%rcx,%rdx)
je 0x3238
movq 0x10(%r12), %rcx
pushq $-0x1
popq %rdx
movq %rdx, %rsi
shlq %cl, %rsi
notq %rsi
andq %rbp, %rsi
cmpq %rsi, %rax
je 0x3187
movq 0x10(%r12), %rax
movq 0x10(%r12), %rcx
movq %rdx, %rsi
shlq %cl, %rsi
notq %rsi
andq %rbp, %rsi
movabsq $0x46a4a7935bd1e995, %rcx # imm = 0x46A4A7935BD1E995
movq %r13, %rdi
imulq %rcx, %rdi
addq %rcx, %rdi
xorq %rsi, %rdi
movl %eax, %ecx
shlq %cl, %rdx
notq %rdx
andq %rdi, %rdx
cmpq %rdx, 0x10(%rsp)
jne 0x3257
movq (%r15), %r8
movq 0x8(%r15), %r9
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r13d, %ecx
callq 0x3572
cmpl $0x0, 0x10(%r15)
je 0x31bd
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
movq 0x18(%rsp), %rax
jmp 0x305e
movl $0x3, 0x30(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rbx)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x3066
leaq 0x2669(%rip), %rdi      # 0x584b
leaq 0x20a5(%rip), %rsi      # 0x528e
leaq 0x23d4(%rip), %rcx      # 0x55c4
movl $0x48e, %edx            # imm = 0x48E
callq 0x20f0
leaq 0x236c(%rip), %rdi      # 0x556d
leaq 0x2086(%rip), %rsi      # 0x528e
leaq 0x23b5(%rip), %rcx      # 0x55c4
movl $0x47d, %edx            # imm = 0x47D
callq 0x20f0
leaq 0x251a(%rip), %rdi      # 0x573a
leaq 0x2067(%rip), %rsi      # 0x528e
leaq 0x2396(%rip), %rcx      # 0x55c4
movl $0x47f, %edx            # imm = 0x47F
callq 0x20f0
leaq 0x2552(%rip), %rdi      # 0x5791
leaq 0x2048(%rip), %rsi      # 0x528e
leaq 0x2377(%rip), %rcx      # 0x55c4
movl $0x480, %edx            # imm = 0x480
callq 0x20f0
leaq 0x2562(%rip), %rdi      # 0x57c0
leaq 0x2029(%rip), %rsi      # 0x528e
leaq 0x2358(%rip), %rcx      # 0x55c4
movl $0x483, %edx            # imm = 0x483
callq 0x20f0