// File: /workspace/github_c_makefile_star2_O2/chbarts[P]aa-tree/aa-tree.c
// Function: delete
static struct node *delete(struct node *t, void *data, ftype dup,
                           ftype comp, void (*del) (void *), jmp_buf env)
{
    void *l;

    if (t == NULL) {
        return NULL;
    } else if (comp(data, t->data) == -1) {
        t->left = delete(t->left, data, dup, comp, del, env);
    } else if (comp(data, t->data) == 1) {
        t->right = delete(t->right, data, dup, comp, del, env);
    } else if (dup != NULL) {
        if (dup(t->data, data) == 0) {
            return t;
        } else {
            longjmp(env, 4);
        }

    } else {
        if ((t->left == NULL) && (t->right == NULL)) {
            if (del)
                del(t->data);

            free(t);
            return NULL;
        } else if (t->left == NULL) {
            l = successor(t);
            t->right = delete(t->right, l, dup, comp, del, env);
            if (del)
                del(t->data);

            t->data = l;
        } else {
            l = predecessor(t);
            t->left = delete(t->left, l, dup, comp, del, env);
            if (del)
                del(t->data);

            t->data = l;
        }
    }

    t = decrease_level(t);
    t = skew(t);
    t->right = skew(t->right);
    t->right->right = skew(t->right->right);
    t = split(t);
    t->right = split(t->right);
    return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x1709
movq %r9, %r15
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x8(%rdi), %rsi
movq %rbp, %rdi
callq *%rcx
cmpl $-0x1, %eax
je 0x15d4
movq 0x8(%rbx), %rsi
movq %rbp, %rdi
callq *%r12
cmpl $0x1, %eax
jne 0x15f5
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x1570
movq %rax, 0x18(%rbx)
jmp 0x1693
movq 0x10(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x1570
movq %rax, 0x10(%rbx)
jmp 0x1693
testq %r13, %r13
je 0x1617
movq 0x8(%rbx), %rdi
movq %rbp, %rsi
callq *%r13
testl %eax, %eax
je 0x170b
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x1150
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x164c
movq %rdi, %rax
movq %rax, %rcx
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0x1623
movq 0x8(%rcx), %r13
movq %r13, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x1570
movq %rax, 0x10(%rbx)
jmp 0x1683
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x16f5
movq %rdi, %rax
movq %rax, %rcx
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x165c
movq 0x8(%rcx), %r13
movq %r13, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x1570
movq %rax, 0x18(%rbx)
testq %r14, %r14
je 0x168f
movq 0x8(%rbx), %rdi
callq *%r14
movq %r13, 0x8(%rbx)
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rax
movl (%rcx), %edx
movl (%rax), %ecx
cmpl %ecx, %edx
cmovll %edx, %ecx
incl %ecx
cmpl (%rbx), %ecx
jge 0x16b2
movl %ecx, (%rbx)
cmpl (%rax), %ecx
jge 0x16b2
movl %ecx, (%rax)
movq %rbx, %rdi
callq 0x1b42
movq %rax, %rbx
movq 0x18(%rax), %rdi
callq 0x1b42
movq %rax, 0x18(%rbx)
movq 0x18(%rax), %rdi
callq 0x1b42
movq 0x18(%rbx), %rcx
movq %rax, 0x18(%rcx)
movq %rbx, %rdi
callq 0x1b6a
movq %rax, %rbx
movq 0x18(%rax), %rdi
callq 0x1b6a
movq %rax, 0x18(%rbx)
jmp 0x170b
testq %r14, %r14
je 0x1701
movq 0x8(%rbx), %rdi
callq *%r14
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq