// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movq %rsi, 0x20(%rsp)
movq %rsi, %rdi
callq *(%r14)
movl %eax, %ebp
xorl %edx, %edx
divl 0x10(%r14)
movslq %edx, %r15
shlq $0x2, %r15
addq 0x18(%r14), %r15
leaq 0x28(%r14), %rax
movq %rax, 0x18(%rsp)
leaq 0x40(%r14), %rax
movq %rax, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movl (%r15), %esi
testl %esi, %esi
je 0x9acb
decl %esi
movq 0x18(%rsp), %rdi
callq 0x9366
movq %rax, %r13
movl (%r15), %esi
decl %esi
movq 0x10(%rsp), %rdi
callq 0x9366
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x9a01
cmpl %ebp, (%r13)
jne 0x9ab6
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq *%rcx
testl %eax, %eax
je 0x9ab6
movl (%r15), %r12d
movl 0x4(%r13), %eax
movl %eax, (%r15)
movl 0x38(%r14), %ebx
movl 0x50(%r14), %edx
cmpl %edx, %ebx
jne 0x9adf
cmpl %ebx, %r12d
je 0x9aa6
leal -0x1(%r12), %r15d
leal -0x1(%rbx), %esi
movl %esi, 0xc(%rsp)
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x9366
movq %rbp, %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x9396
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movl 0xc(%rsp), %esi
callq 0x9366
movq %rbp, %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x9396
movq 0x18(%r14), %rcx
movl (%r13), %eax
xorl %edx, %edx
divl 0x10(%r14)
movslq %edx, %rax
cmpl $0x0, (%rcx,%rax,4)
je 0x9afa
addq $0x4, %r13
leaq (%rcx,%rax,4), %rax
movl 0x8(%rsp), %ebp
movq %rax, %r15
movl (%rax), %ecx
testl %ecx, %ecx
je 0x9aa0
movq %r13, %rax
cmpl %ebx, %ecx
jne 0x9a8d
movl %r12d, (%r15)
cmpl $0x0, (%r15)
je 0x9af1
decl 0x38(%r14)
decl 0x50(%r14)
decl 0x20(%r14)
xorl %eax, %eax
jmp 0x9abf
addq $0x4, %r13
movb $0x1, %al
movq %r13, %r15
testb %al, %al
jne 0x99b3
xorl %eax, %eax
jmp 0x9ad0
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x275e(%rip), %rdi      # 0xc244
movl %ebx, %esi
xorl %eax, %eax
callq 0x22ef
jmp 0x9b08
leaq 0x27c2(%rip), %rdi      # 0xc2ba
jmp 0x9b01
leaq 0x277a(%rip), %rdi      # 0xc27b
xorl %eax, %eax
callq 0x22ef
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0