// File: attractivechaos[P]udb2/verstable/./verstable.h
// Function: intmap_t_evict
static inline bool VT_CAT( NAME, _evict )( NAME *table, size_t bucket )
{
  // Find the previous key in chain.
  size_t home_bucket = HASH_FN( table->buckets[ bucket ].key ) & ( table->bucket_count - 1 );
  size_t prev = home_bucket;
  while( true )
  {
    size_t next = ( home_bucket + VT_QUADRATIC( table->metadata[ prev ] & VT_DISPLACEMENT_MASK ) ) & (
      table->bucket_count - 1 );
    if( next == bucket )
      break;

    prev = next;
  }

  // Disconnect the key from chain.
  table->metadata[ prev ] = ( table->metadata[ prev ] & ~VT_DISPLACEMENT_MASK ) | ( table->metadata[ bucket ] &
    VT_DISPLACEMENT_MASK );

  // Find the empty bucket to which to move the key.
  size_t empty;
  uint16_t displacement;
  if( !VT_CAT( NAME, _find_first_empty )( table, home_bucket, &empty, &displacement ) )
    return false;

  // Find the key in the chain after which to link the moved key.
  prev = VT_CAT( NAME, _find_insert_location_in_chain )( table, home_bucket, displacement );

  // Move the key (and value) data.
  table->buckets[ empty ] = table->buckets[ bucket ];

  // Re-link the key to the chain from its new bucket.
  table->metadata[ empty ] = ( table->metadata[ bucket ] & VT_HASH_FRAG_MASK ) | ( table->metadata[ prev ] &
    VT_DISPLACEMENT_MASK );
  table->metadata[ prev ] = ( table->metadata[ prev ] & ~VT_DISPLACEMENT_MASK ) | displacement;

  return true;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x30(%rsp), %rcx
movl (%rax,%rcx,8), %edi
callq 0x21c0
movl %eax, %eax
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x7ff, %eax            # imm = 0x7FF
movq 0x38(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x20(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
imull %ecx, %eax
movq 0x38(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x20(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq (%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x22a1
jmp 0x22b0
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x2215
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
movq 0x38(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x30(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
orl %ecx, %eax
movw %ax, %dx
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xe(%rsp), %rcx
callq 0x2410
testb $0x1, %al
jne 0x231d
movb $0x0, 0x47(%rsp)
jmp 0x23da
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movzwl 0xe(%rsp), %eax
movl %eax, %edx
callq 0x24c0
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x30(%rsp), %rsi
movq (%rdx,%rsi,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0xf000, %eax           # imm = 0xF000
movq 0x38(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x20(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
orl %ecx, %eax
movw %ax, %dx
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
movzwl 0xe(%rsp), %ecx
orl %ecx, %eax
movw %ax, %dx
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movb $0x1, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)