// File: /workspace/github_c_makefile_star2_O2/theovosse[P]llgen/avl3.c
// Function: InsertNodeDupl2
static TREE InsertNodeDupl2(TREE *root, void *key, void *info, int (*keyCmp)(void *, void *), TREE previous, TREE next)
{
	int lDepth;
	int rDepth;
	TREE n0 = *root;
	TREE n1;
	TREE n2;
	int res;
	TREE ret;
	
	if (n0 == NULL)
	{
		if (oldNodes == NULL)
		{
			n0 = (TREE) mmalloc(sizeof(struct tree));
			if (n0 == NULL)
			{
				perror("AVL Insert");
				exit(1);
			}
		}
		else
		{
			n0 = oldNodes;
			oldNodes = oldNodes->left;
		}
		n0->key = key;
		n0->info = info;
		n0->left = n0->right = NULL;
		n0->depth = 1;
		if (next != NULL)
		{
			n0->previous = next->previous;
			if (next->previous != NULL)
			{
				next->previous->next = n0;
			}
			next->previous = n0;
			n0->next = next;
		}
		else if (previous != NULL)
		{
			n0->next = previous->next;
			if (previous->next != NULL)
			{
				previous->next->previous = n0;
			}
			previous->next = n0;
			n0->previous = previous;
		}
		else
		{
			n0->next = NULL;
			n0->previous = NULL;
		}
		*root = n0;
		ret = n0;
	}
	else
	{
		if ((res = (*keyCmp)(n0->key, key)) > 0)
		{
			ret = InsertNodeDupl2(&(n0->left), key, info, keyCmp, NULL, n0);
		}
		else
		{
			ret = InsertNodeDupl2(&(n0->right), key, info, keyCmp, n0, NULL);
		}
		if (n0->left == NULL)
		{
			lDepth = 0;
		}
		else
		{
			lDepth = n0->left->depth;
		}
		if (n0->right == NULL)
		{
			rDepth = 0;
		}
		else
		{
			rDepth = n0->right->depth;
		}
		if (lDepth > rDepth + 1)
		{
			n1 = n0->left;
			n2 = n1->right;
			n0->left = n2;
			n1->right = n0;
			n0->depth = NDepth(n0);
			*root = n1;
		}
		else if (rDepth > lDepth + 1)
		{
			n1 = n0->right;
			n2 = n1->left;
			n0->right = n2;
			n1->left = n0;
			n0->depth = NDepth(n0);
			*root = n1;
		}
		(*root)->depth = NDepth(*root);
	}
	return (ret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %rbp
movq (%rdi), %r15
testq %r15, %r15
je 0xb0da
movq %rcx, %r14
movq %rdi, %r13
movq (%r15), %rdi
movq %rbp, %rsi
callq *%rcx
testl %eax, %eax
jle 0xb100
leaq 0x10(%r15), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movq %r15, %r9
jmp 0xb113
movq %r9, %rbx
movq %r8, %r13
movq 0xfb49(%rip), %r14      # 0x1ac30
testq %r14, %r14
je 0xb19b
movq 0x10(%r14), %rax
movq %rax, 0xfb35(%rip)      # 0x1ac30
jmp 0xb1b1
leaq 0x18(%r15), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %r15, %r8
xorl %r9d, %r9d
callq 0xb09a
movq %rax, %r14
movq 0x10(%r15), %rbx
xorl %eax, %eax
movl $0x0, %ecx
testq %rbx, %rbx
je 0xb12e
movl 0x30(%rbx), %ecx
movq 0x18(%r15), %r12
testq %r12, %r12
je 0xb13c
movl 0x30(%r12), %eax
leal 0x1(%rax), %edx
cmpl %edx, %ecx
jle 0xb161
movq 0x18(%rbx), %rax
movq %rax, 0x10(%r15)
movq %r15, 0x18(%rbx)
movq %r15, %rdi
callq 0xb6bd
movl %eax, 0x30(%r15)
movq %rbx, (%r13)
jmp 0xb18e
incl %ecx
cmpl %ecx, %eax
jle 0xb18a
movq 0x10(%r12), %rax
movq %rax, 0x18(%r15)
movq %r15, 0x10(%r12)
movq %r15, %rdi
callq 0xb6bd
movl %eax, 0x30(%r15)
movq %r12, (%r13)
movq %r12, %rbx
jmp 0xb18e
movq (%r13), %rbx
movq %rbx, %rdi
callq 0xb6bd
movl %eax, 0x30(%rbx)
jmp 0xb210
movq %rdi, %r14
pushq $0x38
popq %rdi
callq 0xb85c
movq %r14, %rdi
movq %rax, %r14
testq %rax, %rax
je 0xb222
movq %rbp, (%r14)
movq %r12, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movl $0x1, 0x30(%r14)
testq %rbx, %rbx
je 0xb1e8
movq 0x28(%rbx), %rax
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0xb1de
movq %r14, 0x20(%rax)
movq %r14, 0x28(%rbx)
movq %rbx, 0x20(%r14)
jmp 0xb20d
testq %r13, %r13
je 0xb208
movq 0x20(%r13), %rax
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0xb1fe
movq %r14, 0x28(%rax)
movq %r14, 0x20(%r13)
movq %r13, 0x28(%r14)
jmp 0xb20d
movups %xmm0, 0x20(%r14)
movq %r14, (%rdi)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6c38(%rip), %rdi      # 0x11e61
callq 0x31c0
pushq $0x1
popq %rdi
callq 0x3200