// File: /workspace/github_c_makefile_star2_O3/theovosse[P]llgen/avl3.c
// Function: RemoveNode
static TREE RemoveNode(TREE node, void *key, int (*keyCmp)(void *, void *), void (*freeProc)(void *, void *))
{
	short int lDepth;
	short int rDepth;
	int rescmp;

	if (node == NULL)
	{
		return (NULL);
	}
	if ((rescmp = (*keyCmp)(node->key, key)) == 0)
	{
		TREE sNode = NULL;

		if (node->previous != NULL)
		{
			node->previous->next = node->next;
		}
		if (node->next != NULL)
		{
			node->next->previous = node->previous;
		}
		if (node->left == NULL && node->right == NULL)
		{
			if (freeProc != NULL) (*freeProc)(node->key, node->info);
			node->left = oldNodes; oldNodes = node;
			return (NULL);
		}
		lDepth = (node->left == 0? 0: node->left->depth);
		rDepth = (node->right == 0? 0: node->right->depth);
		if (lDepth > rDepth)
		{
			node->left = delmax(node->left, &sNode);
		}
		else
		{
			node->right = delmin(node->right, &sNode);
		}
		sNode->left = node->left;
		sNode->right = node->right;
		sNode->depth = NDepth(sNode);
		if (freeProc != NULL) (*freeProc)(node->key, node->info);
		node->left = oldNodes; oldNodes = node;
		return (Reorder(sNode));
	}
	else
	{
		if (rescmp > 0)
		{
			node->left = RemoveNode(node->left, key, keyCmp, freeProc);
		}
		else
		{
			node->right = RemoveNode(node->right, key, keyCmp, freeProc);
		}
		return (Reorder(node));
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0xbf7b
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdi), %rdi
callq *%rdx
testl %eax, %eax
je 0xbe83
setle %al
movzbl %al, %r13d
movq 0x10(%rbx,%r13,8), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xbe24
movq %rax, 0x10(%rbx,%r13,8)
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xc0f0
movq $0x0, 0x8(%rsp)
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
testq %rcx, %rcx
je 0xbe9d
movq %rax, 0x20(%rcx)
testq %rax, %rax
je 0xbea6
movq %rcx, 0x28(%rax)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0xbec2
movswl 0x30(%rdi), %ecx
movq 0x18(%rbx), %rax
testq %rax, %rax
jne 0xbed1
xorl %eax, %eax
xorl %edx, %edx
jmp 0xbed5
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0xbf5a
xorl %ecx, %ecx
movswl 0x30(%rax), %edx
leaq 0x8(%rsp), %rsi
cmpl %edx, %ecx
jle 0xbef0
callq 0xc0a6
movq %rax, %rcx
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rax
jmp 0xbf00
movq %rax, %rdi
callq 0xc0cb
movq %rax, 0x18(%rbx)
movq 0x10(%rbx), %rcx
movq 0x8(%rsp), %r15
movq %rcx, 0x10(%r15)
movq %rax, 0x18(%r15)
xorl %edx, %edx
movl $0x0, %esi
testq %rcx, %rcx
je 0xbf1c
movl 0x30(%rcx), %esi
testq %rax, %rax
je 0xbf24
movl 0x30(%rax), %edx
cmpl %edx, %esi
cmovgl %esi, %edx
incl %edx
movl %edx, 0x30(%r15)
testq %r14, %r14
je 0xbf3e
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq *%r14
movq 0xfceb(%rip), %rax      # 0x1bc30
movq %rax, 0x10(%rbx)
movq %rbx, 0xfce0(%rip)      # 0x1bc30
movq %r15, %rdi
callq 0xc0f0
jmp 0xbf7d
testq %r14, %r14
je 0xbf69
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq *%r14
movq 0xfcc0(%rip), %rax      # 0x1bc30
movq %rax, 0x10(%rbx)
movq %rbx, 0xfcb5(%rip)      # 0x1bc30
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq