// File: 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>::cuckoo_status cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::run_cuckoo<std::integral_constant<bool, false>>(cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::TwoBuckets&, unsigned long&, unsigned long&)
cuckoo_status run_cuckoo(TwoBuckets &b, size_type &insert_bucket,
                           size_type &insert_slot) {
    // We must unlock the buckets here, so that cuckoopath_search and
    // cuckoopath_move can lock buckets as desired without deadlock.
    // cuckoopath_move has to move something out of one of the original
    // buckets as its last operation, and it will lock both buckets and
    // leave them locked after finishing. This way, we know that if
    // cuckoopath_move succeeds, then the buckets needed for insertion are
    // still locked. If cuckoopath_move fails, the buckets are unlocked and
    // we try again. This unlocking does present two problems. The first is
    // that another insert on the same key runs and, finding that the key
    // isn't in the table, inserts the key into the table. Then we insert
    // the key into the table, causing a duplication. To check for this, we
    // search the buckets for the key we are trying to insert before doing
    // so (this is done in cuckoo_insert, and requires that both buckets are
    // locked). Another problem is that an expansion runs and changes the
    // hashpower, meaning the buckets may not be valid anymore. In this
    // case, the cuckoopath functions will have thrown a hashpower_changed
    // exception, which we catch and handle here.
    size_type hp = hashpower();
    b.unlock();
    CuckooRecords cuckoo_path;
    bool done = false;
    try {
      while (!done) {
        const int depth =
            cuckoopath_search<TABLE_MODE>(hp, cuckoo_path, b.i1, b.i2);
        if (depth < 0) {
          break;
        }

        if (cuckoopath_move<TABLE_MODE>(hp, cuckoo_path, depth, b)) {
          insert_bucket = cuckoo_path[0].bucket;
          insert_slot = cuckoo_path[0].slot;
          assert(insert_bucket == b.i1 || insert_bucket == b.i2);
          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));
          done = true;
          break;
        }
      }
    } catch (hashpower_changed &) {
      // The hashpower changed while we were trying to cuckoo, which means
      // we want to retry. b.i1 and b.i2 should not be locked
      // in this case.
      return failure_under_expansion;
    }
    return done ? ok : failure;
  }

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x108(%rsp)
movq %rsi, 0x100(%rsp)
movq %rdx, 0xf8(%rsp)
movq %rcx, 0xf0(%rsp)
movq 0x108(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x4f30
movq %rax, 0xe8(%rsp)
movq 0x100(%rsp), %rdi
callq 0x6430
movb $0x0, 0x47(%rsp)
movb 0x47(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5ea2
jmp 0x6121
movq 0x20(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0x100(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %r8
leaq 0x48(%rsp), %rdx
callq 0x6470
movl %eax, 0x1c(%rsp)
jmp 0x5ece
movl 0x1c(%rsp), %eax
movl %eax, 0x40(%rsp)
cmpl $0x0, 0x40(%rsp)
jge 0x5f25
jmp 0x6121
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x614a
movq 0x38(%rsp), %rdi
callq 0x2090
movq %rax, 0x28(%rsp)
movl $0x5, 0x114(%rsp)
callq 0x2210
jmp 0x613b
movq 0x20(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movslq 0x40(%rsp), %rcx
movq 0x100(%rsp), %r8
leaq 0x48(%rsp), %rdx
callq 0x6a70
movb %al, 0x1b(%rsp)
jmp 0x5f4f
movb 0x1b(%rsp), %al
testb $0x1, %al
jne 0x5f5c
jmp 0x611c
leaq 0x48(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6fd0
movq (%rax), %rcx
movq 0xf8(%rsp), %rax
movq %rcx, (%rax)
leaq 0x48(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6fd0
movq 0x8(%rax), %rcx
movq 0xf0(%rsp), %rax
movq %rcx, (%rax)
movq 0xf8(%rsp), %rax
movq (%rax), %rcx
movq 0x100(%rsp), %rdx
movb $0x1, %al
cmpq (%rdx), %rcx
movb %al, 0x1a(%rsp)
je 0x5fd1
movq 0xf8(%rsp), %rax
movq (%rax), %rax
movq 0x100(%rsp), %rcx
cmpq 0x8(%rcx), %rax
sete %al
movb %al, 0x1a(%rsp)
movb 0x1a(%rsp), %al
testb $0x1, %al
jne 0x5fdb
jmp 0x5fdd
jmp 0x5ffc
leaq 0x8895(%rip), %rdi      # 0xe879
leaq 0x82c3(%rip), %rsi      # 0xe2ae
movl $0x4f7, %edx            # imm = 0x4F7
leaq 0x88b1(%rip), %rcx      # 0xe8a8
callq 0x2110
movq 0x20(%rsp), %rdi
callq 0x5170
movq %rax, 0x10(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rdi
callq 0x5110
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x5190
movq %rax, %rdi
callq 0x6160
xorb $-0x1, %al
testb $0x1, %al
jne 0x6038
jmp 0x603a
jmp 0x6059
leaq 0x854c(%rip), %rdi      # 0xe58d
leaq 0x8266(%rip), %rsi      # 0xe2ae
movl $0x4f9, %edx            # imm = 0x4F9
leaq 0x8854(%rip), %rcx      # 0xe8a8
callq 0x2110
movq 0x20(%rsp), %rdi
callq 0x5170
movq %rax, 0x8(%rsp)
movq 0x100(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x5110
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x5190
movq %rax, %rdi
callq 0x6160
xorb $-0x1, %al
testb $0x1, %al
jne 0x6096
jmp 0x6098
jmp 0x60b7
leaq 0x86bb(%rip), %rdi      # 0xe75a
leaq 0x8208(%rip), %rsi      # 0xe2ae
movl $0x4fb, %edx            # imm = 0x4FB
leaq 0x87f6(%rip), %rcx      # 0xe8a8
callq 0x2110
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x4db0
movq %rax, (%rsp)
jmp 0x60d6
movq (%rsp), %rdi
movq 0xf0(%rsp), %rax
movq (%rax), %rsi
callq 0x3590
movb (%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x60f4
jmp 0x60f6
jmp 0x6115
leaq 0x86b4(%rip), %rdi      # 0xe7b1
leaq 0x81aa(%rip), %rsi      # 0xe2ae
movl $0x4fc, %edx            # imm = 0x4FC
leaq 0x8798(%rip), %rcx      # 0xe8a8
callq 0x2110
movb $0x1, 0x47(%rsp)
jmp 0x6121
jmp 0x5e93
jmp 0x6123
movb 0x47(%rsp), %dl
movl $0x1, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, 0x114(%rsp)
movl 0x114(%rsp), %eax
addq $0x118, %rsp            # imm = 0x118
retq
movq 0x38(%rsp), %rdi
callq 0x2240
nopw %cs:(%rax,%rax)
nop