// File: /workspace/github_cpp_makefile_star2_O3/DRSY[P]MyRBTree/main.cpp
// Function: RBTree::remove(int)
bool remove(int value) {
        NodePtr_t node_to_remove = findNodeToRemove(value);
        if(!node_to_remove) {
            std::cerr << red("Value to be removed not in the tree\n");
            return false;
        }
        if(!isfull(node_to_remove)) {
            remove_atleastonenull(node_to_remove);
            return true;
        }
        else {
            // find successor node first
            NodePtr_t successor_node = findSuccessor(node_to_remove);
            node_to_remove->value = successor_node->value;
            successor_node->color = node_to_remove->color;
            remove_atleastonenull(successor_node); // successor's left is NULL
            return true;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa0, %rsp
movl %esi, %eax
movq (%rdi), %rsi
testq %rsi, %rsi
je 0x17ab
cmpl %eax, (%rsi)
je 0x184f
setle %cl
movzbl %cl, %ecx
movq 0x10(%rsi,%rcx,8), %rsi
jmp 0x1791
leaq -0xb0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x1847(%rip), %rsi      # 0x3004
leaq 0x1847(%rip), %rdx      # 0x300b
leaq -0xc0(%rbp), %rdi
callq 0x2032
leaq -0x90(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x18af(%rip), %rsi      # 0x3091
leaq 0x18cc(%rip), %rdx      # 0x30b5
leaq -0xa0(%rbp), %rdi
callq 0x2032
movq -0xc0(%rbp), %rcx
movq -0xb8(%rbp), %r8
movq -0x98(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r14, %rcx
je 0x181f
movq -0xb0(%rbp), %rdi
movq -0xa0(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x1841
movl $0xf, %edi
cmpq %r15, %rsi
je 0x183c
movq -0x90(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x1884
leaq -0xc0(%rbp), %rdi
callq 0x1040
jmp 0x1894
cmpq $0x0, 0x10(%rsi)
je 0x1878
movq 0x18(%rsi), %rcx
testq %rcx, %rcx
je 0x1878
movq %rcx, %rax
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
jne 0x185f
movl (%rax), %ecx
movl %ecx, (%rsi)
movl 0x4(%rsi), %ecx
movl %ecx, 0x4(%rax)
movq %rax, %rsi
callq 0x263c
movb $0x1, %al
jmp 0x1a1f
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10f0
leaq -0x30(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x18b5
movq %rsi, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x18bb
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x38(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x70(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1749(%rip), %rsi      # 0x3030
leaq 0x1746(%rip), %rdx      # 0x3034
leaq -0x80(%rbp), %rdi
callq 0x2032
leaq -0x30(%rbp), %rbx
movq -0x10(%rbx), %rcx
movq -0x8(%rbx), %r8
movq -0x78(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %rbx, %rcx
je 0x1919
movq -0x30(%rbp), %rdi
movq -0x80(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x1935
movl $0xf, %edi
cmpq %r12, %rsi
je 0x1930
movq -0x70(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x1940
leaq -0x40(%rbp), %rdi
callq 0x1040
jmp 0x194d
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10f0
leaq -0x50(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x196e
movq %rsi, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x1974
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x58(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq 0x3651(%rip), %rdi      # 0x4ff0
callq 0x1100
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19bd
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x10e0
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x19d2
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x10e0
movq -0x40(%rbp), %rdi
cmpq %rbx, %rdi
je 0x19e7
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x10e0
movq -0xa0(%rbp), %rdi
cmpq %r15, %rdi
je 0x1a02
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x10e0
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x1a1d
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x10e0
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a50
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x1a50
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a6a
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x1a6a
movq %rax, %rbx
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a88
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x1a88
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r15, %rdi
je 0x1aa8
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x1aa8
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x1ac3
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1160
nop