// File: /workspace/github_c_makefile_star2_O3/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 0x188a
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 0x1706
movq 0x8(%rbx), %rsi
movq %rbp, %rdi
callq *%r12
cmpl $0x1, %eax
jne 0x1727
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x16a2
movq %rax, 0x18(%rbx)
jmp 0x17c7
movq 0x10(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x16a2
movq %rax, 0x10(%rbx)
jmp 0x17c7
testq %r13, %r13
je 0x174b
movq 0x8(%rbx), %rdi
movq %rbp, %rsi
callq *%r13
testl %eax, %eax
je 0x188c
movq %r15, %rdi
movl $0x4, %esi
callq 0x1150
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1780
movq %rdi, %rax
movq %rax, %rcx
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0x1757
movq 0x8(%rcx), %r13
movq %r13, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x16a2
movq %rax, 0x10(%rbx)
jmp 0x17b7
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x1876
movq %rdi, %rax
movq %rax, %rcx
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x1790
movq 0x8(%rcx), %r13
movq %r13, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
callq 0x16a2
movq %rax, 0x18(%rbx)
testq %r14, %r14
je 0x17c3
movq 0x8(%rbx), %rdi
callq *%r14
movq %r13, 0x8(%rbx)
movq 0x10(%rbx), %rdi
movl (%rdi), %edx
movq 0x18(%rbx), %rcx
movl (%rcx), %eax
cmpl %eax, %edx
cmovll %edx, %eax
incl %eax
movl (%rbx), %edx
cmpl %edx, %eax
jge 0x17ee
movl %eax, (%rbx)
cmpl (%rcx), %eax
jge 0x17ec
movl %eax, (%rcx)
movl (%rbx), %edx
jmp 0x17ee
movl %eax, %edx
cmpl %edx, (%rdi)
jne 0x1803
movq 0x18(%rdi), %rax
movq %rax, 0x10(%rbx)
movq %rbx, 0x18(%rdi)
movq %rbx, %rcx
jmp 0x1806
movq %rbx, %rdi
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0x1823
movl (%rax), %edx
cmpl (%rcx), %edx
jne 0x1823
movq 0x18(%rax), %rdx
movq %rdx, 0x10(%rcx)
movq %rcx, 0x18(%rax)
jmp 0x1826
movq %rcx, %rax
movq %rax, 0x18(%rdi)
movq 0x18(%rax), %rdx
testq %rdx, %rdx
je 0x1859
movq 0x10(%rdx), %rcx
testq %rcx, %rcx
je 0x1854
movl (%rcx), %esi
cmpl (%rdx), %esi
jne 0x1854
movq 0x18(%rcx), %rax
movq %rax, 0x10(%rdx)
movq %rdx, 0x18(%rcx)
movq 0x18(%rdi), %rax
jmp 0x185b
movq %rdx, %rcx
jmp 0x185b
xorl %ecx, %ecx
movq %rcx, 0x18(%rax)
callq 0x1cdb
movq %rax, %rbx
movq 0x18(%rax), %rdi
callq 0x1cdb
movq %rax, 0x18(%rbx)
jmp 0x188c
testq %r14, %r14
je 0x1882
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