// File: /workspace/github_c_makefile_star2_O1/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 0xc24e
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdi), %rdi
callq *%rdx
testl %eax, %eax
je 0xc14d
setle %al
movzbl %al, %r13d
movq 0x10(%rbx,%r13,8), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xc0ee
movq %rax, 0x10(%rbx,%r13,8)
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xc396
movq $0x0, 0x8(%rsp)
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0xc167
movq 0x20(%rbx), %rcx
movq %rcx, 0x20(%rax)
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0xc174
movq %rax, 0x28(%rcx)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0xc190
movswl 0x30(%rdi), %ecx
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0xc1a4
movswl 0x30(%rax), %edx
jmp 0xc1a6
cmpq $0x0, 0x18(%rbx)
je 0xc22d
testq %rdi, %rdi
jne 0xc17d
xorl %ecx, %ecx
jmp 0xc181
xorl %edx, %edx
leaq 0x8(%rsp), %rsi
cmpl %edx, %ecx
jle 0xc1ba
callq 0xc34c
movq %rax, 0x10(%rbx)
jmp 0xc1c6
movq %rax, %rdi
callq 0xc371
movq %rax, 0x18(%rbx)
movq 0x10(%rbx), %rsi
movq 0x8(%rsp), %r15
movq %rsi, 0x10(%r15)
movq 0x18(%rbx), %rcx
movq %rcx, 0x18(%r15)
xorl %eax, %eax
testq %r15, %r15
je 0xc1fe
movl $0x0, %edx
testq %rsi, %rsi
je 0xc1ef
movl 0x30(%rsi), %edx
testq %rcx, %rcx
je 0xc1f7
movl 0x30(%rcx), %eax
cmpl %eax, %edx
cmovgl %edx, %eax
incl %eax
movl %eax, 0x30(%r15)
testq %r14, %r14
je 0xc211
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq *%r14
movq 0xfa18(%rip), %rax      # 0x1bc30
movq %rax, 0x10(%rbx)
movq %rbx, 0xfa0d(%rip)      # 0x1bc30
movq %r15, %rdi
callq 0xc396
jmp 0xc250
testq %r14, %r14
je 0xc23c
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq *%r14
movq 0xf9ed(%rip), %rax      # 0x1bc30
movq %rax, 0x10(%rbx)
movq %rbx, 0xf9e2(%rip)      # 0x1bc30
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq