// File: /workspace/github_cpp_makefile_star2_O3/bhhbazinga[P]LockFreeHashTable/./lockfree_hashtable.h
// Function: LockFreeHashTable<int, int, std::hash<int>>::DeleteNode(LockFreeHashTable<int, int, std::hash<int>>::DummyNode*, LockFreeHashTable<int, int, std::hash<int>>::Node*)
bool LockFreeHashTable<K, V, Hash>::DeleteNode(DummyNode* head,
                                               Node* delete_node) {
  Node* prev;
  Node* cur;
  Node* next;
  HazardPointer prev_hp, cur_hp;
  do {
    do {
      if (!SearchNode(head, delete_node, &prev, &cur, prev_hp, cur_hp)) {
        return false;
      }
      next = cur->get_next();
    } while (is_marked_reference(next));
    // Logically delete cur by marking cur->next.
  } while (!cur->next.compare_exchange_weak(next, get_marked_reference(next),
                                            std::memory_order_release,
                                            std::memory_order_relaxed));

  if (prev->next.compare_exchange_strong(cur, next,
                                         std::memory_order_release)) {
    size_.fetch_sub(1, std::memory_order_relaxed);
    auto& reclaimer = TableReclaimer<K, V>::GetInstance();
    reclaimer.ReclaimLater(cur, LockFreeHashTable<K, V, Hash>::OnDeleteNode);
    reclaimer.ReclaimNoHazardPointer();
  } else {
    prev_hp.UnMark();
    cur_hp.UnMark();
    SearchNode(head, delete_node, &prev, &cur, prev_hp, cur_hp);
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
xorl %eax, %eax
leaq 0x20(%rsp), %rdx
movq %rax, (%rdx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x8(%rdx)
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movl %ecx, 0x8(%rdx)
leaq 0x30(%rsp), %rbp
leaq 0x8(%rsp), %r13
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r13, %r8
leaq 0x20(%rsp), %r9
callq 0x488c
movl %eax, %ebx
testb %al, %al
je 0x52bc
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rcx
testb $0x1, %cl
jne 0x51a4
movq 0x8(%rsp), %rdx
movq %rcx, %rsi
orq $0x1, %rsi
movq %rcx, %rax
lock
cmpxchgq %rsi, 0x18(%rdx)
jne 0x51a4
movq 0x30(%rsp), %rdx
movq 0x8(%rsp), %rax
lock
cmpxchgq %rcx, 0x18(%rdx)
jne 0x5272
lock
decq 0x8(%r12)
callq 0x4ab4
movq %rax, %r14
movq 0x8(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq $0x0, 0x8(%rdx)
leaq -0x6d2(%rip), %rax      # 0x4b5c
movq %rax, (%rdx)
leaq -0x1e2(%rip), %rax      # 0x5056
movq %rax, 0x18(%rdx)
leaq -0x1e5(%rip), %rax      # 0x505e
movq %rax, 0x10(%rdx)
movq %r14, %rdi
callq 0x4ada
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0x5268
leaq 0x38(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %r14, %rdi
callq 0x2620
jmp 0x52bc
leaq 0x8(%rsp), %r13
movq %rax, (%r13)
leaq 0x20(%rsp), %rbp
movq (%rbp), %rdi
movl 0x8(%rbp), %esi
callq 0x4cf0
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %esi
callq 0x4cf0
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rcx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %r8
movq %rbp, %r9
callq 0x488c
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %esi
callq 0x4cf0
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x4cf0
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5309
movq %rax, %rbx
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0x5318
leaq 0x38(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x5318
movq %rax, %rdi
callq 0x3504
jmp 0x5315
jmp 0x5315
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %esi
callq 0x4cf0
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x4cf0
movq %rbx, %rdi
callq 0x2230