// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x10(%rsp), %rax
andq $0x0, (%rax)
orl $-0x1, 0x8(%rax)
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
movq %rdx, %r14
orl $-0x1, 0x8(%rax)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x20(%rsp), %rbp
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r13, %r8
leaq 0x10(%rsp), %r9
callq 0x4706
movl %eax, %ebx
testb %al, %al
je 0x51f3
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdx
testb $0x1, %dl
jne 0x50f7
movq 0x8(%rsp), %rcx
movq %rdx, %rsi
orq $0x1, %rsi
movq %rdx, %rax
lock
cmpxchgq %rsi, 0x18(%rcx)
jne 0x50f7
movq 0x20(%rsp), %rdi
addq $0x18, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x3
popq %rcx
callq 0x496e
testb %al, %al
je 0x51bb
lock
decq 0x8(%r12)
callq 0x4902
movq %rax, %r14
leaq 0x38(%rsp), %rdx
andq $0x0, 0x8(%rdx)
movq 0x8(%rsp), %rsi
leaq -0x76c(%rip), %rax      # 0x4a1a
movq %rax, (%rdx)
leaq -0x24e(%rip), %rax      # 0x4f42
movq %rax, 0x18(%rdx)
leaq -0x251(%rip), %rax      # 0x4f4a
movq %rax, 0x10(%rdx)
movq %r14, %rdi
callq 0x49c6
leaq 0x38(%rsp), %rdi
callq 0x36a4
movq %r14, %rdi
callq 0x2558
jmp 0x51f3
leaq 0x10(%rsp), %rdi
callq 0x4960
leaq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x4960
movq %r13, (%rsp)
leaq 0x20(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0x10(%rsp), %r9
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4706
leaq 0x28(%rsp), %rdi
callq 0x48f2
leaq 0x10(%rsp), %rdi
callq 0x48f2
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x36a4
jmp 0x522e
jmp 0x522b
jmp 0x522b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x48f2
leaq 0x10(%rsp), %rdi
callq 0x48f2
movq %rbx, %rdi
callq 0x2230