// File: /workspace/github_c_makefile_star2_O0/CarlosLunaMota[P]BinaryTrees/BinaryTrees.c
// Function: is_rb_subtree
static int is_rb_subtree(const rb_tree *tree, const rb_node *node,
                         const void *min, const void *max) {

    int left_height  = 0;
    int right_height = 0;

    // 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 rb_tree\n");
        return -1;
    }
    if (max != NULL && (tree->comp)(node->data, max) >= 0) {
        fprintf(stderr, "ERROR: Symmetric order not satisfied in rb_tree\n");
        return -1;
    }

    // Check for RED violations:
    if (node->color == RED) {
        if (node->left  != NULL && node->left->color  == RED) {
            fprintf(stderr, "ERROR: Two RED nodes in a row in rb_tree\n");
            return -1;
        }
        if (node->right != NULL && node->right->color == RED) {
            fprintf(stderr, "ERROR: Two RED nodes in a row in rb_tree\n");
            return -1;
        }
    }

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

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

    // Check for BLACK violations:
    if (left_height != right_height) {
        fprintf(stderr, "ERROR: Different BLACK height in rb_tree\n");
        return -1;
    }
    
    // Return Black-Height of "node":
    if (node->color == RED){ return left_height; }
    return left_height+1;
}

// 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)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x13cab
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 0x13cab
movq 0x636a(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x32da(%rip), %rsi      # 0x16f72
movb $0x0, %al
callq 0x1080
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
cmpq $0x0, -0x28(%rbp)
je 0x13cf0
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 0x13cf0
movq 0x6325(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x3295(%rip), %rsi      # 0x16f72
movb $0x0, %al
callq 0x1080
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
movq -0x18(%rbp), %rax
movsbl 0x18(%rax), %eax
cmpl $0x1, %eax
jne 0x13d83
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x13d41
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x18(%rax), %eax
cmpl $0x1, %eax
jne 0x13d41
movq 0x62d4(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x3275(%rip), %rsi      # 0x16fa3
movb $0x0, %al
callq 0x1080
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x13d81
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movsbl 0x18(%rax), %eax
cmpl $0x1, %eax
jne 0x13d81
movq 0x6294(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x3235(%rip), %rsi      # 0x16fa3
movb $0x0, %al
callq 0x1080
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
jmp 0x13d83
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x13dc1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
callq 0x13c40
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
jne 0x13dbf
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
jmp 0x13dc1
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x13dfc
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
callq 0x13c40
movl %eax, -0x30(%rbp)
cmpl $-0x1, -0x30(%rbp)
jne 0x13dfa
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
jmp 0x13dfc
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x13e25
movq 0x61ed(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x31b8(%rip), %rsi      # 0x16fcd
movb $0x0, %al
callq 0x1080
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e43
movq -0x18(%rbp), %rax
movsbl 0x18(%rax), %eax
cmpl $0x1, %eax
jne 0x13e3a
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13e43
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)