// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: splay
static inline void splay(sp_tree *tree, const void *data) {

    sp_node  root;
    sp_node *left;
    sp_node *right;
    sp_node *node;
    sp_node *temp;
    int      comp;

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

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

    for (;;) {

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

        // If "data" is smaller:
        if (comp < 0) {                         
            if (node->left == NULL) { break; }

            // Rotate right if needed:
            if ((tree->comp)(data, node->left->data) < 0) {
                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;

        // If "data" is bigger:
        } else if (comp > 0) {
            if (node->right == NULL) { break; }

            // Rotate left if needed:
            if ((tree->comp)(data, node->right->data) > 0) {
                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;

        // If we have found "data":
        } else { break; }
    }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x148a9
jmp 0x148c8
leaq 0x19c2(%rip), %rdi      # 0x16272
leaq 0x1945(%rip), %rsi      # 0x161fc
movl $0x116d, %edx           # imm = 0x116D
leaq 0x279d(%rip), %rcx      # 0x17060
callq 0x1060
cmpq $0x0, -0x10(%rbp)
je 0x148d1
jmp 0x148f0
leaq 0x1a19(%rip), %rdi      # 0x162f1
leaq 0x191d(%rip), %rsi      # 0x161fc
movl $0x116e, %edx           # imm = 0x116E
leaq 0x2775(%rip), %rcx      # 0x17060
callq 0x1060
movq $0x0, -0x20(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x14927
jmp 0x14ac5
jmp 0x14929
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x149e0
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x1495b
jmp 0x14a82
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx), %rsi
callq *%rax
cmpl $0x0, %eax
jge 0x149bb
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x149b9
jmp 0x14a82
jmp 0x149bb
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x14a7d
cmpl $0x0, -0x4c(%rbp)
jle 0x14a79
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x149fa
jmp 0x14a82
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx), %rsi
callq *%rax
cmpl $0x0, %eax
jle 0x14a57
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x14a55
jmp 0x14a82
jmp 0x14a57
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x14a7b
jmp 0x14a82
jmp 0x14a7d
jmp 0x14929
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)