LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: is_bs_tree
int is_bs_tree(const bs_tree *tree) {

    // Basic Sanity Checks:
    if (tree == NULL) {
        fprintf(stderr, "ERROR: NULL pointer to bs_tree\n");
        return NO;
    }
    if (tree->comp == NULL) {
        fprintf(stderr, "ERROR: NULL comparing function in bs_tree\n");
        return NO;
    }

    // Trivial Case: empty tree
    if (tree->root == NULL) { return YES; }

    // General Case:
    return is_bs_subtree(tree, tree->root, NULL, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xf9f4
movq 0xa61e(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x6c97(%rip), %rsi      # 0x1667b
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0xfa4d
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xfa20
movq 0xa5f2(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x6c8b(%rip), %rsi      # 0x1669b
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0xfa4d
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xfa33
movl $0x1, -0x4(%rbp)
jmp 0xfa4d
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0xfa60
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: is_bs_subtree
static int is_bs_subtree(const bs_tree *tree, const bs_node *node,
                         const void *min, const void *max) {

    // Make sure that node is (strictly) between specified limits:
    if (min != NULL && (tree->comp)(min, node->data) >= 0) {
        fprintf(stderr,"ERROR: Symmetric order not satisfied in bs_tree\n");
        return NO;
    }
    if (max != NULL && (tree->comp)(node->data, max) >= 0) {
        fprintf(stderr,"ERROR: Symmetric order not satisfied in bs_tree\n");
        return NO;
    }

    // Check recursively the left subtree of node:
    if (node->left != NULL) {
        if (is_bs_subtree(tree, node->left, min, node->data) == NO) {
            return NO;
        }
    }

    // Check recursively the right subtree of node:
    if (node->right != NULL) {
        if (is_bs_subtree(tree, node->right, node->data, max) == NO) {
            return NO;
        }
    }

    // All test are fine:
    return YES;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xfabd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
cmpl $0x0, %eax
jl 0xfabd
movq 0xa558(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x740f(%rip), %rsi      # 0x16eb9
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0xfb74
cmpq $0x0, -0x28(%rbp)
je 0xfaff
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdi
movq -0x28(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
jl 0xfaff
movq 0xa513(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x73ca(%rip), %rsi      # 0x16eb9
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0xfb74
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xfb36
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
callq 0xfa60
cmpl $0x0, %eax
jne 0xfb34
movl $0x0, -0x4(%rbp)
jmp 0xfb74
jmp 0xfb36
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xfb6d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
callq 0xfa60
cmpl $0x0, %eax
jne 0xfb6b
movl $0x0, -0x4(%rbp)
jmp 0xfb74
jmp 0xfb6d
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: print_bs_tree
void print_bs_tree(const bs_tree *tree, void (* print_node) (const void *)) {

    // Avoid the trivial cases:
    if (tree != NULL && tree->root != NULL) {

        // Print right subtree recursively:
        if (tree->root->right != NULL) {
            print_bs_subtree(tree->root->right, YES, "     ", print_node);
        }

        // Print current node:
        fprintf(stdout, "----");
        if (print_node == NULL) { fprintf(stdout, "(#)"); }
        else     { print_node(tree->root->data); }
        fprintf(stdout, "\n");

        // Print left subtree recursively:
        if (tree->root->left != NULL) {
            print_bs_subtree(tree->root->left, NO, "     ", print_node);
        }
    }

    // Empty the "stdout" buffer:
    fflush(stdout);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xfc65
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0xfc65
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0xfbd7
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
leaq 0x7383(%rip), %rdx      # 0x16f55
callq 0xfc80
movq 0xa3fa(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x737d(%rip), %rsi      # 0x16f65
movb $0x0, %al
callq 0x1080
cmpq $0x0, -0x10(%rbp)
jne 0xfc10
movq 0xa3db(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x6abf(%rip), %rsi      # 0x166c6
movb $0x0, %al
callq 0x1080
jmp 0xfc20
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdi
callq *%rax
movq 0xa3b1(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x64a0(%rip), %rsi      # 0x160d1
movb $0x0, %al
callq 0x1080
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0xfc63
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rcx
xorl %esi, %esi
leaq 0x72f7(%rip), %rdx      # 0x16f55
callq 0xfc80
jmp 0xfc65
movq 0xa36c(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
callq 0x10b0
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: new_rb_tree
rb_tree *new_rb_tree(int (* comp) (const void *, const void *)) {

    // Sanity check:
    assert(comp != NULL);

    // Allocate memory:
    rb_tree *tree = (rb_tree *) malloc(sizeof(rb_tree));
    if (tree == NULL) {
        fprintf(stderr, "ERROR: Unable to allocate memory for rb_tree\n");
    }

    // Initialize the empty tree:
    else {
        tree->root = NULL;
        tree->comp = comp;
    }

    return tree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xfe55
jmp 0xfe74
leaq 0x6393(%rip), %rdi      # 0x161ef
leaq 0x6399(%rip), %rsi      # 0x161fc
movl $0x8aa, %edx            # imm = 0x8AA
leaq 0x685b(%rip), %rcx      # 0x166ca
callq 0x1060
movl $0x10, %edi
callq 0x10a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xfea3
movq 0xa168(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x686a(%rip), %rsi      # 0x16704
movb $0x0, %al
callq 0x1080
jmp 0xfeba
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: rb_tree_min
void *rb_tree_min(const rb_tree *tree) {

    rb_node *node;

    // Sanity check:
    assert(tree != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // General case: Find the smallest node
    node = tree->root;
    while (node->left != NULL) { node = node->left; }

    // Return a pointer to the data:
    return node->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x10c35
jmp 0x10c54
leaq 0x5636(%rip), %rdi      # 0x16272
leaq 0x55b9(%rip), %rsi      # 0x161fc
movl $0xa77, %edx            # imm = 0xA77
leaq 0x5c14(%rip), %rcx      # 0x16863
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x10c68
movq $0x0, -0x8(%rbp)
jmp 0x10c97
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x10c8c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x10c73
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: rb_tree_max
void *rb_tree_max(const rb_tree *tree) {

    rb_node *node;

    // Sanity check:
    assert(tree != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // General case: Find the biggest node
    node = tree->root;
    while (node->right != NULL) { node = node->right; }

    // Return a pointer to the data:
    return node->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x10cc5
jmp 0x10ce4
leaq 0x55a6(%rip), %rdi      # 0x16272
leaq 0x5529(%rip), %rsi      # 0x161fc
movl $0xa8c, %edx            # imm = 0xA8C
leaq 0x5ba7(%rip), %rcx      # 0x16886
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x10cf8
movq $0x0, -0x8(%rbp)
jmp 0x10d27
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x10d1c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x10d03
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: rb_tree_prev
void *rb_tree_prev(const rb_tree *tree, const void *data) {

    rb_node *node;
    rb_node *pred;
    int      comp;

    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // Search:
    pred = NULL;
    node = tree->root;
    while (node != NULL) {

        // Compare data:
        comp = (tree->comp)(data, node->data);

        // Data is smaller:
        if (comp < 0) { node = node->left; }

        // Data is bigger:
        else if (comp > 0) {
            pred = node;
            node = node->right;
        }

        // We have found the node:
        else if (node->left != NULL) {
            pred = node->left;
            while (pred->right != NULL) { pred = pred->right; }
            break;
        } else { break; }
    }

    // Return predecesor:
    if (pred == NULL) { return NULL; }
    return pred->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x10d59
jmp 0x10d78
leaq 0x5512(%rip), %rdi      # 0x16272
leaq 0x5495(%rip), %rsi      # 0x161fc
movl $0xaa5, %edx            # imm = 0xAA5
leaq 0x5b36(%rip), %rcx      # 0x168a9
callq 0x1060
cmpq $0x0, -0x18(%rbp)
je 0x10d81
jmp 0x10da0
leaq 0x5569(%rip), %rdi      # 0x162f1
leaq 0x546d(%rip), %rsi      # 0x161fc
movl $0xaa6, %edx            # imm = 0xAA6
leaq 0x5b0e(%rip), %rcx      # 0x168a9
callq 0x1060
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x10e41
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x10dea
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x10e3c
cmpl $0x0, -0x2c(%rbp)
jle 0x10e06
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x10e3a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x10e38
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x10e36
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x10e1d
jmp 0x10e41
jmp 0x10e41
jmp 0x10e3c
jmp 0x10db3
cmpq $0x0, -0x28(%rbp)
jne 0x10e52
movq $0x0, -0x8(%rbp)
jmp 0x10e5d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: rb_tree_next
void *rb_tree_next(const rb_tree *tree, const void *data) {

    rb_node *node;
    rb_node *succ;
    int      comp;

    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // Search:
    succ = NULL;
    node = tree->root;
    while (node != NULL) {

        // Compare data:
        comp = (tree->comp)(data, node->data);

        // Data is smaller:
        if (comp < 0) {
            succ = node;
            node = node->left;
        }

        // Data is bigger:
        else if (comp > 0) { node = node->right; }

        // We have found the node:
        else if (node->right != NULL) {
            succ = node->right;
            while (succ->left != NULL) { succ = succ->left; }
            break;
        } else { break; }
    }

    // Return succesor:
    if (succ == NULL) { return NULL; }
    return succ->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x10e89
jmp 0x10ea8
leaq 0x53e2(%rip), %rdi      # 0x16272
leaq 0x5365(%rip), %rsi      # 0x161fc
movl $0xad2, %edx            # imm = 0xAD2
leaq 0x5a38(%rip), %rcx      # 0x168db
callq 0x1060
cmpq $0x0, -0x18(%rbp)
je 0x10eb1
jmp 0x10ed0
leaq 0x5439(%rip), %rdi      # 0x162f1
leaq 0x533d(%rip), %rsi      # 0x161fc
movl $0xad3, %edx            # imm = 0xAD3
leaq 0x5a10(%rip), %rcx      # 0x168db
callq 0x1060
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x10f71
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x10f22
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x10f6c
cmpl $0x0, -0x2c(%rbp)
jle 0x10f36
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x10f6a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x10f68
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x10f66
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x10f4d
jmp 0x10f71
jmp 0x10f71
jmp 0x10f6c
jmp 0x10ee3
cmpq $0x0, -0x28(%rbp)
jne 0x10f82
movq $0x0, -0x8(%rbp)
jmp 0x10f8d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: rb_tree_remove_all
void rb_tree_remove_all(rb_tree *tree, void (* free_data) (void *)) {

    rb_node *root;
    rb_node *left;
    rb_node *right;

    // Sanity check:
    assert(tree != NULL);

    // Initialize:
    root = tree->root;
    tree->root = NULL;

    // While the tree is not empty:
    while (root != NULL) {

        // Unravel the tree: Rotate right "root" & "left"
        if (root->left != NULL) {
            left        = root->left;
            right       = left->right;
            left->right = root;
            root->left  = right;
            root        = left;

        // Erase the current "root" node:
        } else {
            right = root->right;
            if (free_data != NULL) { free_data(root->data); }
            free(root);
            root = right;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x11fc9
jmp 0x11fe8
leaq 0x42a2(%rip), %rdi      # 0x16272
leaq 0x4225(%rip), %rsi      # 0x161fc
movl $0xd26, %edx            # imm = 0xD26
leaq 0x49a0(%rip), %rcx      # 0x16983
callq 0x1060
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x1207d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1204a
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x1207b
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1206a
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdi
callq *%rax
movq -0x18(%rbp), %rdi
callq 0x10e0
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x11ffe
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: is_rb_tree
int is_rb_tree(const rb_tree *tree) {

    // Basic Sanity Checks:
    if (tree == NULL) {
        fprintf(stderr, "ERROR: NULL pointer to rb_tree\n");
        return NO;
    }
    if (tree->comp == NULL) {
        fprintf(stderr, "ERROR: NULL comparing function in rb_tree\n");
        return NO;
    }

    // Trivial Case: empty tree
    if (tree->root == NULL) { return YES; }

    // General Case:
    if (is_rb_subtree(tree, tree->root, NULL, NULL) == -1) { return NO;  }
    else                                                   { return YES; }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x13bc4
movq 0x644e(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x2ef1(%rip), %rsi      # 0x16aa5
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0x13c2f
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x13bf0
movq 0x6422(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x2ee5(%rip), %rsi      # 0x16ac5
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0x13c2f
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x13c03
movl $0x1, -0x4(%rbp)
jmp 0x13c2f
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x13c40
cmpl $-0x1, %eax
jne 0x13c28
movl $0x0, -0x4(%rbp)
jmp 0x13c2f
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: print_rb_tree
void print_rb_tree(const rb_tree *tree, void (* print_node) (const void *)) {

    // Avoid the trivial cases:
    if (tree != NULL && tree->root != NULL) {

        // Print right subtree recursively:
        if (tree->root->right != NULL) {
            print_rb_subtree(tree->root->right, YES, "     ", print_node);
        }

        // Print current node:
        if (tree->root->color == RED) { fprintf(stdout, "===="); }
        else                          { fprintf(stdout, "----"); }
        if (print_node == NULL) {
            if (tree->root->color == RED) { fprintf(stdout, "(#)"); }
            else                          { fprintf(stdout, "( )"); }
        } else { print_node(tree->root->data); }
        fprintf(stdout, "\n");

        // Print left subtree recursively:
        if (tree->root->left != NULL) {
            print_rb_subtree(tree->root->left, NO, "     ", print_node);
        }
    }

    // Empty the "stdout" buffer:
    fflush(stdout);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x13f89
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x13f89
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x13ea7
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
leaq 0x30b3(%rip), %rdx      # 0x16f55
callq 0x13fa0
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl 0x18(%rax), %eax
cmpl $0x1, %eax
jne 0x13ed1
movq 0x611a(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x318b(%rip), %rsi      # 0x17053
movb $0x0, %al
callq 0x1080
jmp 0x13ee9
movq 0x6100(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x3083(%rip), %rsi      # 0x16f65
movb $0x0, %al
callq 0x1080
cmpq $0x0, -0x10(%rbp)
jne 0x13f34
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl 0x18(%rax), %eax
cmpl $0x1, %eax
jne 0x13f1a
movq 0x60d1(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x27b5(%rip), %rsi      # 0x166c6
movb $0x0, %al
callq 0x1080
jmp 0x13f32
movq 0x60b7(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x2bc5(%rip), %rsi      # 0x16af0
movb $0x0, %al
callq 0x1080
jmp 0x13f44
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdi
callq *%rax
movq 0x608d(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x217c(%rip), %rsi      # 0x160d1
movb $0x0, %al
callq 0x1080
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x13f87
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rcx
xorl %esi, %esi
leaq 0x2fd3(%rip), %rdx      # 0x16f55
callq 0x13fa0
jmp 0x13f89
movq 0x6048(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
callq 0x10b0
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: new_sp_tree
sp_tree *new_sp_tree(int (* comp) (const void *, const void *)) {

    // Sanity check:
    assert(comp != NULL);

    // Allocate memory:
    sp_tree *tree = (sp_tree *) malloc(sizeof(sp_tree));
    if (tree == NULL) {
        fprintf(stderr, "ERROR: Unable to allocate memory for sp_tree\n");
    }

    // Initialize the empty tree:
    else {
        tree->root = NULL;
        tree->comp = comp;
    }

    return tree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x14255
jmp 0x14274
leaq 0x1f93(%rip), %rdi      # 0x161ef
leaq 0x1f99(%rip), %rsi      # 0x161fc
movl $0x121f, %edx           # imm = 0x121F
leaq 0x2885(%rip), %rcx      # 0x16af4
callq 0x1060
movl $0x10, %edi
callq 0x10a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x142a3
movq 0x5d68(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x2894(%rip), %rsi      # 0x16b2e
movb $0x0, %al
callq 0x1080
jmp 0x142ba
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_copy
sp_tree *sp_tree_copy(sp_tree *tree) {

    sp_tree *new_tree;
    void    *data;
    
    // Sanity check:
    assert(tree != NULL);
    
    // Create a new tree:
    new_tree = new_sp_tree(tree->comp);
    if (tree == NULL) { return NULL; }

    // Get the smallest element of tree:
    data = sp_tree_min(tree);

    // Insert all data from tree into new_tree:
    while (data != NULL) {

        // insert data in new_tree:
        sp_tree_insert_max(new_tree, data);

        // advance data:
        data = sp_tree_next(tree, data);
    }

    // Return the resulting tree:
    return new_tree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x142e5
jmp 0x14304
leaq 0x1f86(%rip), %rdi      # 0x16272
leaq 0x1f09(%rip), %rsi      # 0x161fc
movl $0x123b, %edx           # imm = 0x123B
leaq 0x285d(%rip), %rcx      # 0x16b5c
callq 0x1060
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x14240
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x14326
movq $0x0, -0x8(%rbp)
jmp 0x14362
movq -0x10(%rbp), %rdi
callq 0x14370
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1435a
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x143e0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x14530
movq %rax, -0x20(%rbp)
jmp 0x14333
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_min
void *sp_tree_min(sp_tree *tree) {

    // Sanity Check:
    assert(tree != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // General case: Move the smallest element to the root
    splay_left(tree);

    // And return a pointer to its data:
    return tree->root->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x14385
jmp 0x143a4
leaq 0x1ee6(%rip), %rdi      # 0x16272
leaq 0x1e69(%rip), %rsi      # 0x161fc
movl $0x1322, %edx           # imm = 0x1322
leaq 0x28d5(%rip), %rcx      # 0x16c74
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x143b8
movq $0x0, -0x8(%rbp)
jmp 0x143cf
movq -0x10(%rbp), %rdi
callq 0x14c20
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_insert_max
void *sp_tree_insert_max(sp_tree *tree, void *data) {

    sp_node *old_root;
    void    *old_data;
    int      comp = 1;
    
    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // General case: Splay data to the root
    splay_right(tree);
    old_root = tree->root;

    // Compare the current root with data:
    if (old_root != NULL) { comp = (tree->comp)(data, old_root->data); }

    // If data is in the tree: overwrite it!
    if (comp == 0) {
        old_data = tree->root->data;
        tree->root->data = data;
        return old_data;
    }

    // Otherwise insert a new node as a root and link the previous root to it:
    tree->root = (sp_node *) malloc(sizeof(sp_node));
    if (tree->root == NULL) {
        fprintf(stderr, "ERROR: Unable to allocate sp_node\n");
        tree->root = old_root;
    } else {
        tree->root->data  = data;
        tree->root->left  = old_root;
        tree->root->right = NULL;
    }

    // Data was not here!
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, -0x2c(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x14400
jmp 0x1441f
leaq 0x1e6b(%rip), %rdi      # 0x16272
leaq 0x1dee(%rip), %rsi      # 0x161fc
movl $0x12d7, %edx           # imm = 0x12D7
leaq 0x27da(%rip), %rcx      # 0x16bf4
callq 0x1060
cmpq $0x0, -0x18(%rbp)
je 0x14428
jmp 0x14447
leaq 0x1ec2(%rip), %rdi      # 0x162f1
leaq 0x1dc6(%rip), %rsi      # 0x161fc
movl $0x12d8, %edx           # imm = 0x12D8
leaq 0x27b2(%rip), %rcx      # 0x16bf4
callq 0x1060
movq -0x10(%rbp), %rdi
callq 0x14d20
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1447a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x144a6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1451d
movl $0x18, %edi
callq 0x10a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x144e9
movq 0x5b2d(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x26d0(%rip), %rsi      # 0x16ba5
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x14515
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_next
void *sp_tree_next(sp_tree *tree, const void *data) {

    sp_node *old_root;
    int      comp;

    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // Trivial case: null data == return minimum
    if (data == NULL) {
        splay_left(tree);
        return tree->root->data;
    }

    // General case: Splay data to the root
    splay(tree, data);

    // Take a look at the current root:
    comp = (tree->comp)(tree->root->data, data);

    // If its smaller or equal we must find the successor in the right subtree:
    if (comp <= 0) {
        if (tree->root->right == NULL) { return NULL; }
        else {
            old_root   = tree->root;
            tree->root = tree->root->right;
            old_root->right = NULL;
            splay_left(tree);
            tree->root->left = old_root;
        }
    }

    // Predecessor is at root now:
    return tree->root->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x14549
jmp 0x14568
leaq 0x1d22(%rip), %rdi      # 0x16272
leaq 0x1ca5(%rip), %rsi      # 0x161fc
movl $0x1378, %edx           # imm = 0x1378
leaq 0x2777(%rip), %rcx      # 0x16cda
callq 0x1060
cmpq $0x0, -0x18(%rbp)
je 0x14571
jmp 0x14590
leaq 0x1d79(%rip), %rdi      # 0x162f1
leaq 0x1c7d(%rip), %rsi      # 0x161fc
movl $0x1379, %edx           # imm = 0x1379
leaq 0x274f(%rip), %rcx      # 0x16cda
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x145a7
movq $0x0, -0x8(%rbp)
jmp 0x14661
cmpq $0x0, -0x18(%rbp)
jne 0x145ca
movq -0x10(%rbp), %rdi
callq 0x14c20
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x14661
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x14890
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jg 0x14653
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x14610
movq $0x0, -0x8(%rbp)
jmp 0x14661
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0x14c20
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x14653
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: splay_left
static inline void splay_left(sp_tree *tree) {

    sp_node  root;
    sp_node *right;
    sp_node *node;
    sp_node *temp;

    // Sanity check:
    assert(tree != NULL);

    // Initialize:
    root.right = root.left = NULL;
    right = &root;
    node = tree->root;
    if (node == NULL) { return; }

    for (;;) {
        
        // Act as if splaying "data" which is always smaller
        if (node->left == NULL) { break; }

        // Rotate right:
        temp        = node->left;
        node->left  = temp->right;
        temp->right = node;
        node        = temp;
        if (node->left == NULL) { break; }

        // Link right:
        right->left = node;
        right       = node;
        node        = node->left;
    }

    // Assemble:
    right->left = node->right;
    node->right = root.left;
    tree->root  = node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x14c35
jmp 0x14c54
leaq 0x1636(%rip), %rdi      # 0x16272
leaq 0x15b9(%rip), %rsi      # 0x161fc
movl $0x11b5, %edx           # imm = 0x11B5
leaq 0x2435(%rip), %rcx      # 0x17084
callq 0x1060
movq $0x0, -0x18(%rbp)
movq $0x0, -0x10(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x14c83
jmp 0x14d18
jmp 0x14c85
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x14c92
jmp 0x14cf1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x14ccf
jmp 0x14cf1
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x14c85
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: splay_right
static inline void splay_right(sp_tree *tree) {

    sp_node  root;
    sp_node *left;
    sp_node *node;
    sp_node *temp;

    // Sanity check:
    assert(tree != NULL);

    // Initialize:
    root.right = root.left = NULL;
    left = &root;
    node = tree->root;
    if (node == NULL) { return; }

    for (;;) {
        
        // Act as if splaying "data" which is always bigger
        if (node->right == NULL) { break; }

        // Rotate left:
        temp        = node->right;
        node->right = temp->left;
        temp->left  = node;
        node        = temp;
        if (node->right == NULL) { break; }

        // Link left:
        left->right = node;
        left        = node;
        node        = node->right;
    }

    // Assemble:
    left->right = node->left;
    node->left  = root.right;
    tree->root  = node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x14d35
jmp 0x14d54
leaq 0x1536(%rip), %rdi      # 0x16272
leaq 0x14b9(%rip), %rsi      # 0x161fc
movl $0x11df, %edx           # imm = 0x11DF
leaq 0x2350(%rip), %rcx      # 0x1709f
callq 0x1060
movq $0x0, -0x18(%rbp)
movq $0x0, -0x10(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x14d83
jmp 0x14e18
jmp 0x14d85
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x14d92
jmp 0x14df1
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x14dcf
jmp 0x14df1
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x14d85
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_search
void *sp_tree_search(sp_tree *tree, const void *data) {

    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // General case: Splay data to the root
    splay(tree, data);

    // If data is in the tree return a pointer to it:
    if ((tree->comp)(data, tree->root->data) == 0) { return tree->root->data; }

    // Not found:
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x14e99
jmp 0x14eb8
leaq 0x13d2(%rip), %rdi      # 0x16272
leaq 0x1355(%rip), %rsi      # 0x161fc
movl $0x130c, %edx           # imm = 0x130C
leaq 0x1d93(%rip), %rcx      # 0x16c46
callq 0x1060
cmpq $0x0, -0x18(%rbp)
je 0x14ec1
jmp 0x14ee0
leaq 0x1429(%rip), %rdi      # 0x162f1
leaq 0x132d(%rip), %rsi      # 0x161fc
movl $0x130d, %edx           # imm = 0x130D
leaq 0x1d6b(%rip), %rcx      # 0x16c46
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x14ef4
movq $0x0, -0x8(%rbp)
jmp 0x14f36
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x14890
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rsi
callq *%rax
cmpl $0x0, %eax
jne 0x14f2e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x14f36
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_max
void *sp_tree_max(sp_tree *tree) {

    // Sanity Check:
    assert(tree != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // General case: Move the biggest element to the root
    splay_right(tree);

    // And return a pointer to its data:
    return tree->root->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x14f55
jmp 0x14f74
leaq 0x1316(%rip), %rdi      # 0x16272
leaq 0x1299(%rip), %rsi      # 0x161fc
movl $0x1334, %edx           # imm = 0x1334
leaq 0x1d22(%rip), %rcx      # 0x16c91
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x14f88
movq $0x0, -0x8(%rbp)
jmp 0x14f9f
movq -0x10(%rbp), %rdi
callq 0x14d20
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_prev
void *sp_tree_prev(sp_tree *tree, const void *data) {

    sp_node *old_root;
    int      comp;

    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // Trivial case: empty tree
    if (tree->root == NULL) { return NULL; }

    // Trivial case: null data == return maximum
    if (data == NULL) {
        splay_right(tree);
        return tree->root->data;
    }

    // General case: Splay data to the root
    splay(tree, data);

    // Take a look at the current root:
    comp = (tree->comp)(tree->root->data, data);

    // If its bigger or equal we must find the predecessor in the left subtree:    
    if (comp >= 0) {
        if (tree->root->left == NULL) { return NULL; }
        else {
            old_root   = tree->root;
            tree->root = tree->root->left;
            old_root->left = NULL;
            splay_right(tree);
            tree->root->right = old_root;
        }
    }

    // Predecessor is at root now:
    return tree->root->data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x14fc9
jmp 0x14fe8
leaq 0x12a2(%rip), %rdi      # 0x16272
leaq 0x1225(%rip), %rsi      # 0x161fc
movl $0x134b, %edx           # imm = 0x134B
leaq 0x1ccb(%rip), %rcx      # 0x16cae
callq 0x1060
cmpq $0x0, -0x18(%rbp)
je 0x14ff1
jmp 0x15010
leaq 0x12f9(%rip), %rdi      # 0x162f1
leaq 0x11fd(%rip), %rsi      # 0x161fc
movl $0x134c, %edx           # imm = 0x134C
leaq 0x1ca3(%rip), %rcx      # 0x16cae
callq 0x1060
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x15027
movq $0x0, -0x8(%rbp)
jmp 0x150e1
cmpq $0x0, -0x18(%rbp)
jne 0x1504a
movq -0x10(%rbp), %rdi
callq 0x14d20
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x150e1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x14890
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x150d3
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x15090
movq $0x0, -0x8(%rbp)
jmp 0x150e1
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0x14d20
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x10(%rax)
jmp 0x150d3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_remove
void *sp_tree_remove(sp_tree *tree, const void *data) {

    sp_node *old_root;
    void    *old_data = NULL;

    // Sanity Checks:
    assert(tree != NULL);
    assert(data != NULL);

    // Avoid trivial case: empty tree
    if (tree->root != NULL) {

        // Splay the data to the root:
        splay(tree, data);

        // If it is here: remove it!
        if ((tree->comp)(tree->root->data, data) == 0) {
            old_root = tree->root;
            old_data = tree->root->data;
            if (tree->root->right == NULL) { tree->root = tree->root->left; }
            else {
                tree->root = tree->root->right;
                splay_left(tree);
                tree->root->left = old_root->left;
            }
            free(old_root);
        }
    }

    // Return
    return old_data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x15111
jmp 0x15130
leaq 0x115a(%rip), %rdi      # 0x16272
leaq 0x10dd(%rip), %rsi      # 0x161fc
movl $0x13a8, %edx           # imm = 0x13A8
leaq 0x1bdb(%rip), %rcx      # 0x16d06
callq 0x1060
cmpq $0x0, -0x10(%rbp)
je 0x15139
jmp 0x15158
leaq 0x11b1(%rip), %rdi      # 0x162f1
leaq 0x10b5(%rip), %rsi      # 0x161fc
movl $0x13a9, %edx           # imm = 0x13A9
leaq 0x1bb3(%rip), %rcx      # 0x16d06
callq 0x1060
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x15204
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x14890
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdi
movq -0x10(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
jne 0x15202
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x151cb
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x151f9
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
callq 0x14c20
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rdi
callq 0x10e0
jmp 0x15204
movq -0x20(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_remove_min
void *sp_tree_remove_min(sp_tree *tree) {

    sp_node *old_root;
    void    *old_data;

    // Sanity check:
    assert(tree != NULL);

    // Avoid trivial case: empty tree
    old_data = NULL;
    if (tree->root != NULL) {

        // Splay the smallest node to the root:
        splay_left(tree);

        // Remove it!
        old_root   = tree->root;
        old_data   = tree->root->data;
        tree->root = tree->root->right;
        free(old_root);
    }

    // Return
    return old_data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x15225
jmp 0x15244
leaq 0x1046(%rip), %rdi      # 0x16272
leaq 0xfc9(%rip), %rsi       # 0x161fc
movl $0x13cc, %edx           # imm = 0x13CC
leaq 0x1af5(%rip), %rcx      # 0x16d34
callq 0x1060
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x15293
movq -0x8(%rbp), %rdi
callq 0x14c20
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x10e0
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_remove_max
void *sp_tree_remove_max(sp_tree *tree) {

    sp_node *old_root;
    void    *old_data;

    // Sanity check:
    assert(tree != NULL);

    // Avoid trivial case: empty tree
    old_data = NULL;
    if (tree->root != NULL) {

        // Splay the biggest node to the root:
        splay_right(tree);

        // Remove it!
        old_root   = tree->root;
        old_data   = tree->root->data;
        tree->root = tree->root->left;
        free(old_root);
    }

    // Return
    return old_data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x152b5
jmp 0x152d4
leaq 0xfb6(%rip), %rdi       # 0x16272
leaq 0xf39(%rip), %rsi       # 0x161fc
movl $0x13e9, %edx           # imm = 0x13E9
leaq 0x1a89(%rip), %rcx      # 0x16d58
callq 0x1060
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x15323
movq -0x8(%rbp), %rdi
callq 0x14d20
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x10e0
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: sp_tree_remove_all
void sp_tree_remove_all(sp_tree *tree, void (* free_data) (void *)) {

    sp_node *root;
    sp_node *left;
    sp_node *right;

    // Sanity check:
    assert(tree != NULL);

    // Initialize:
    root = tree->root;
    tree->root = NULL;

    // While the tree is not empty:
    while (root != NULL) {

        // Unravel the tree: Rotate right "root" & "left"
        if (root->left != NULL) {
            left        = root->left;
            right       = left->right;
            left->right = root;
            root->left  = right;
            root        = left;

        // Erase the current "root" node:
        } else {
            right = root->right;
            if (free_data != NULL) { free_data(root->data); }
            free(root);
            root = right;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x15349
jmp 0x15368
leaq 0xf22(%rip), %rdi       # 0x16272
leaq 0xea5(%rip), %rsi       # 0x161fc
movl $0x1417, %edx           # imm = 0x1417
leaq 0x1a19(%rip), %rcx      # 0x16d7c
callq 0x1060
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x153fd
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x153ca
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x153fb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x153ea
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdi
callq *%rax
movq -0x18(%rbp), %rdi
callq 0x10e0
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x1537e
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)