// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
xorl %eax, %eax
leaq 0x28(%rsp), %rdx
movq %rax, (%rdx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x8(%rdx)
leaq 0x18(%rsp), %rdx
movq %rax, (%rdx)
movl %ecx, 0x8(%rdx)
leaq 0x38(%rsp), %rbp
leaq 0x10(%rsp), %r13
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r13, %r8
leaq 0x28(%rsp), %r9
callq 0x4938
movl %eax, %ebx
testb %al, %al
je 0x5401
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
testb $0x1, %al
jne 0x52e8
movq 0x10(%rsp), %rcx
movq %rax, %rdx
orq $0x1, %rdx
lock
cmpxchgq %rdx, 0x18(%rcx)
jne 0x52e8
movq %rax, %rcx
movq 0x38(%rsp), %rdx
movq 0x10(%rsp), %rax
lock
cmpxchgq %rcx, 0x18(%rdx)
jne 0x53b7
lock
decq 0x8(%r12)
callq 0x4b88
movq %rax, %r14
movq 0x10(%rsp), %rsi
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
leaq -0x743(%rip), %rax      # 0x4c30
movq %rax, (%rdx)
leaq -0x1e9(%rip), %rax      # 0x5194
movq %rax, 0x18(%rdx)
leaq -0x1ec(%rip), %rax      # 0x519c
movq %rax, 0x10(%rdx)
movq %r14, %rdi
callq 0x4bae
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x53ad
leaq 0x40(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %r14, %rdi
callq 0x263e
jmp 0x5401
leaq 0x10(%rsp), %r13
movq %rax, (%r13)
leaq 0x28(%rsp), %rbp
movq (%rbp), %rdi
movl 0x8(%rbp), %esi
callq 0x4dc8
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x4dc8
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
leaq 0x38(%rsp), %rcx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %r8
movq %rbp, %r9
callq 0x4938
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x4dc8
movq 0x28(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0x4dc8
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x544e
movq %rax, %rbx
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x545d
leaq 0x40(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x545d
movq %rax, %rdi
callq 0x3584
jmp 0x545a
jmp 0x545a
movq %rax, %rbx
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x4dc8
movq 0x28(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0x4dc8
movq %rbx, %rdi
callq 0x2230
nop