// File: /workspace/github_cpp_makefile_star2_O2/DRSY[P]MyRBTree/main.cpp
// Function: RBTree::remove_atleastonenull(Node*)
void remove_atleastonenull(NodePtr_t node_to_remove) {
        // red leaf node
        if(isred(node_to_remove) && isleaf(node_to_remove)) {
            auto father = node_to_remove->father;
            if(node_to_remove==father->left)
                father->left = NULL;
            else
                father->right = NULL;
        }
        // black leaf node
        else if(isblack(node_to_remove) && isleaf(node_to_remove)) {
            if(node_to_remove==this->root) {delete node_to_remove; this->root=NULL;return;}
            assert(node_to_remove->father!=NULL);
            NodePtr_t father = node_to_remove->father;
            NodePtr_t brother = NULL;
            if(node_to_remove==father->left) {
                father->left = NULL;
                brother = father->right;
            }else {
                father->right = NULL;
                brother = father->left;
            }
            delete node_to_remove;
            assert(brother!=NULL);
            if(brother->color==Color::black) {
                black_black(father, brother);
            }else if(brother==father->right) {
                brother->color = Color::black;
                father->color = Color::red;
                rotate_left(father, brother);
                black_black(father, father->right);
            }
            else{
                brother->color = Color::black;
                father->color = Color::red;
                rotate_right(brother, father);
                black_black(father, father->left);
            }
        }
        // black node with one red leaf node
        else {
            assert(node_to_remove->color==Color::black);
            NodePtr_t child = (node_to_remove->left)?node_to_remove->left:node_to_remove->right;
            assert(isred(child));
            node_to_remove->value = child->value;
            if(child==node_to_remove->left)  node_to_remove->left=NULL;
            else  node_to_remove->right=NULL;
            delete child;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x4(%rsi), %eax
cmpl $0x1, %eax
je 0x330d
testl %eax, %eax
jne 0x341b
cmpq $0x0, 0x10(%rsi)
jne 0x341b
cmpq $0x0, 0x18(%rsi)
jne 0x341b
movq 0x8(%rsi), %rax
cmpq %rsi, 0x10(%rax)
je 0x3355
andq $0x0, 0x18(%rax)
jmp 0x335a
movq %rdi, %rbx
movq 0x10(%rsi), %rax
movq %rax, %rdi
testq %rax, %rax
jne 0x3327
cmpq $0x0, 0x18(%rsi)
je 0x3365
movq 0x18(%rsi), %rdi
cmpl $0x0, 0x4(%rdi)
jne 0x343a
movl (%rdi), %ecx
movl %ecx, (%rsi)
xorl %ecx, %ecx
cmpq %rax, %rdi
setne %cl
andq $0x0, 0x10(%rsi,%rcx,8)
pushq $0x20
popq %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2110
andq $0x0, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpq %rsi, (%rbx)
je 0x3387
movq 0x8(%rsi), %r14
testq %r14, %r14
je 0x3459
movq 0x10(%r14), %r15
cmpq %rsi, %r15
je 0x339b
andq $0x0, 0x18(%r14)
jmp 0x33a4
pushq $0x20
popq %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2110
andq $0x0, (%rbx)
jmp 0x335a
andq $0x0, 0x10(%r14)
movq 0x18(%r14), %r15
pushq $0x20
popq %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2110
testq %r15, %r15
je 0x3478
cmpl $0x1, 0x4(%r15)
jne 0x33cd
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
jmp 0x340c
movq 0x18(%r14), %rax
movl $0x1, 0x4(%r15)
andl $0x0, 0x4(%r14)
movq %rbx, %rdi
cmpq %rax, %r15
je 0x33f7
movq %r15, %rsi
movq %r14, %rdx
callq 0x2bae
movq 0x10(%r14), %rdx
jmp 0x3406
movq %r14, %rsi
movq %r15, %rdx
callq 0x2bec
movq 0x18(%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x34d2
leaq 0xcf6(%rip), %rdi       # 0x4118
leaq 0xcaa(%rip), %rsi       # 0x40d3
leaq 0xcac(%rip), %rcx       # 0x40dc
movl $0x126, %edx            # imm = 0x126
callq 0x2090
leaq 0xcfb(%rip), %rdi       # 0x413c
leaq 0xc8b(%rip), %rsi       # 0x40d3
leaq 0xc8d(%rip), %rcx       # 0x40dc
movl $0x128, %edx            # imm = 0x128
callq 0x2090
leaq 0xc56(%rip), %rdi       # 0x40b6
leaq 0xc6c(%rip), %rsi       # 0x40d3
leaq 0xc6e(%rip), %rcx       # 0x40dc
movl $0x109, %edx            # imm = 0x109
callq 0x2090
leaq 0xc8b(%rip), %rdi       # 0x410a
leaq 0xc4d(%rip), %rsi       # 0x40d3
leaq 0xc4f(%rip), %rcx       # 0x40dc
movl $0x114, %edx            # imm = 0x114
callq 0x2090
nop