// File: /workspace/github_c_makefile_star2_O0/negge[P]xlink/src/util.c
// Function: xlink_set_remove
int xlink_set_remove(xlink_set *set, const void *key) {
  unsigned int hash;
  int *index;
  hash = set->hash_code(key);
  index = &set->table[xlink_set_index(set, hash)];
  while (*index != 0) {
    xlink_entry *entry;
    void *value;
    entry = xlink_list_get(&set->entries, *index - 1);
    value = xlink_list_get(&set->values, *index - 1);
    if (set->equals == NULL ||
     (entry->hash == hash && set->equals(key, value))) {
      int old;
      int last;
      /* Move the entry / value from the end into the empty slot and reindex */
      old = *index - 1;
      *index = entry->down;
      XLINK_ERROR(
       xlink_list_length(&set->entries) != xlink_list_length(&set->values),
       ("Invalid xlink_set state, entries = %i but values = %i\n",
       xlink_list_length(&set->entries), xlink_list_length(&set->values)));
      last = xlink_list_length(&set->entries) - 1;
      if (old != last) {
        xlink_list_set(&set->entries, old, xlink_list_get(&set->entries, last));
        xlink_list_set(&set->values, old, xlink_list_get(&set->values, last));
        index = &set->table[xlink_set_index(set, entry->hash)];
        XLINK_ERROR(*index == 0,
         ("Invalid xlink_set state, index = 0 but should contain an entry"));
        while (*index != 0) {
          if (*index == last + 1) {
            *index = old + 1;
            break;
          }
          index = &entry->down;
        }
        XLINK_ERROR(*index == 0,
         ("Invalid xlink_set state, cound not find last entry to reindex"));
      }
      set->entries.length--;
      set->values.length--;
      set->size--;
      return EXIT_SUCCESS;
    }
    index = &entry->down;
  }
  return EXIT_FAILURE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0xd070
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xd492
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movq -0x28(%rbp), %rax
movl (%rax), %esi
subl $0x1, %esi
callq 0xc870
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
movq -0x28(%rbp), %rax
movl (%rax), %esi
subl $0x1, %esi
callq 0xc870
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xd2a5
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0xd481
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
je 0xd481
movq -0x28(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0xc6a0
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0xc6a0
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
je 0xd31e
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0xc6a0
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0xc6a0
movl -0x50(%rbp), %esi
movl %eax, %edx
leaq 0x3201(%rip), %rdi      # 0x1050e
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0xd320
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0xc6a0
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
je 0xd451
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x78(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movl -0x40(%rbp), %esi
callq 0xc870
movq -0x78(%rbp), %rdi
movl -0x6c(%rbp), %esi
movq %rax, %rdx
callq 0xc8e0
movq -0x10(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x68(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
movl -0x40(%rbp), %esi
callq 0xc870
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %esi
movq %rax, %rdx
callq 0xc8e0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl (%rax), %esi
callq 0xd070
movl %eax, %ecx
movq -0x58(%rbp), %rax
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xd3f1
leaq 0x3165(%rip), %rdi      # 0x10545
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0xd3f3
jmp 0xd3f5
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xd42a
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd41c
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0xd42a
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0xd3f5
jmp 0xd42c
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xd44d
leaq 0x3148(%rip), %rdi      # 0x10584
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0xd44f
jmp 0xd451
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rax
movl 0x50(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x50(%rax)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x20(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xd499
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0xd22f
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)