// File: /workspace/github_c_makefile_star2_O0/theovosse[P]llgen/avl3.c
// Function: InsertNodeSingle2
static TREE InsertNodeSingle2(TREE *tree, void *key, void *info, int (*keyCmp)(void *, void *), TREE previous, TREE next)
{
	int lDepth;
	int rDepth;
	TREE n0 = *tree;
	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;
		}
		*tree = n0;
		ret = n0;
	}
	else
	{
		if ((res = (*keyCmp)(n0->key, key)) > 0)
		{
			ret = InsertNodeSingle2(&(n0->left), key, info, keyCmp, NULL, n0);
		}
		else if (res < 0)
		{
			ret = InsertNodeSingle2(&(n0->right), key, info, keyCmp, n0, NULL);
		}
		else
		{
			ret = n0;
		}
		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);
			*tree = n1;
		}
		else if (rDepth > lDepth + 1)
		{
			n1 = n0->right;
			n2 = n1->left;
			n0->right = n2;
			n1->left = n0;
			n0->depth = NDepth(n0);
			*tree = n1;
		}
		(*tree)->depth = NDepth(*tree);
	}
	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 0xfe2e
cmpq $0x0, 0x131b2(%rip)     # 0x22e90
jne 0xfd0d
movl $0x38, %edi
callq 0x11110
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xfd0b
leaq 0xb304(%rip), %rdi      # 0x1b000
callq 0x31a0
movl $0x1, %edi
callq 0x31e0
jmp 0xfd2a
movq 0x1317c(%rip), %rax     # 0x22e90
movq %rax, -0x40(%rbp)
movq 0x13171(%rip), %rax     # 0x22e90
movq 0x10(%rax), %rax
movq %rax, 0x13166(%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 0xfdb0
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 0xfd96
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 0xfe16
cmpq $0x0, -0x28(%rbp)
je 0xfdfc
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 0xfde2
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 0xfe14
movq -0x40(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x28(%rax)
jmp 0xfe16
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0xffbb
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 0xfe6f
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 0xfca0
movq %rax, -0x60(%rbp)
jmp 0xfea7
cmpl $0x0, -0x54(%rbp)
jge 0xfe9d
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 0xfca0
movq %rax, -0x60(%rbp)
jmp 0xfea5
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0xfea7
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xfebb
movl $0x0, -0x34(%rbp)
jmp 0xfec9
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 0xfedd
movl $0x0, -0x38(%rbp)
jmp 0xfeeb
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 0xff47
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 0xffa3
movl -0x38(%rbp), %eax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0xffa1
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 0xffa3
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)