// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1019e
cmpq $0x0, 0x12e42(%rip)     # 0x22e90
jne 0x1007d
movl $0x38, %edi
callq 0x11110
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1007b
leaq 0xaf94(%rip), %rdi      # 0x1b000
callq 0x31a0
movl $0x1, %edi
callq 0x31e0
jmp 0x1009a
movq 0x12e0c(%rip), %rax     # 0x22e90
movq %rax, -0x40(%rbp)
movq 0x12e01(%rip), %rax     # 0x22e90
movq 0x10(%rax), %rax
movq %rax, 0x12df6(%rip)     # 0x22e90
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x30(%rax)
cmpq $0x0, -0x30(%rbp)
je 0x10120
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x10106
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x10186
cmpq $0x0, -0x28(%rbp)
je 0x1016c
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x10152
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x10184
movq -0x40(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x28(%rax)
jmp 0x10186
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x10319
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rdi
movq -0x10(%rbp), %rsi
callq *%rax
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jle 0x101df
movq -0x40(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %r9
xorl %eax, %eax
movl %eax, %r8d
callq 0x10010
movq %rax, -0x60(%rbp)
jmp 0x10205
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
callq 0x10010
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x10219
movl $0x0, -0x34(%rbp)
jmp 0x10227
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x1023b
movl $0x0, -0x38(%rbp)
jmp 0x10249
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x102a5
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rdi
callq 0x10cf0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x10301
movl -0x38(%rbp), %eax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x102ff
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rdi
callq 0x10cf0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x10301
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x10cf0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x30(%rax)
movq -0x60(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)