// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1089c
movq $0x0, -0x8(%rbp)
jmp 0x10ac0
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
jne 0x10a63
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x108e0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x108ff
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x10958
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x10958
cmpq $0x0, -0x28(%rbp)
je 0x10931
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rsi
callq *%rax
movq 0x12558(%rip), %rcx     # 0x22e90
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq %rax, 0x12545(%rip)     # 0x22e90
movq $0x0, -0x8(%rbp)
jmp 0x10ac0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x1096a
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x10978
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x2a(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x10991
xorl %eax, %eax
movl %eax, -0x40(%rbp)
jmp 0x1099f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movw %ax, -0x2c(%rbp)
movswl -0x2a(%rbp), %eax
movswl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jle 0x109d0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x10d80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x109ec
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x10df0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rdi
callq 0x10cf0
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x30(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x10a3a
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rsi
callq *%rax
movq 0x1244f(%rip), %rcx     # 0x22e90
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq %rax, 0x1243c(%rip)     # 0x22e90
movq -0x38(%rbp), %rdi
callq 0x10e60
movq %rax, -0x8(%rbp)
jmp 0x10ac0
cmpl $0x0, -0x30(%rbp)
jle 0x10a8f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x10870
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x10ab3
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x10870
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x10e60
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)