// File: /workspace/github_c_makefile_star2_O1/theovosse[P]llgen/avl3.c
// Function: Reorder
static TREE Reorder(TREE node)
{
	short int lDepth = (node->left == 0? 0: node->left->depth);
	short int rDepth = (node->right == 0? 0: node->right->depth);
	TREE n1;
	TREE n2;

	if (lDepth > rDepth + 1)
	{
		n1 = node->left;
		n2 = n1->right;
		if (n2 == 0 || n2->depth < n1->depth - 1)
		{
			node->left = n2;
			n1->right = node;
			node->depth = NDepth(node);
			n1->depth = NDepth(n1);
			return (n1);
		}
		else
		{
			node->left = n2->right;
			n1->right = n2->left;
			n2->right = node;
			n2->left = n1;
			node->depth = NDepth(node);
			n1->depth = NDepth(n1);
			n2->depth = NDepth(n2);
			return (n2);
		}
	}
	else if (rDepth > lDepth + 1)
	{
		n1 = node->right;
		n2 = n1->left;
		if (n2 == 0 || n2->depth < n1->depth - 1)
		{
			node->right = n2;
			n1->left = node;
			node->depth = NDepth(node);
			n1->depth = NDepth(n1);
			return (n1);
		}
		else
		{
			node->right = n2->left;
			n1->left = n2->right;
			n2->left = node;
			n2->right = n1;
			node->depth = NDepth(node);
			n1->depth = NDepth(n1);
			n2->depth = NDepth(n2);
			return (n2);
		}
	}
	node->depth = (lDepth > rDepth? lDepth: rDepth) + 1;
	return (node);
}

// Assembly:
movq 0x10(%rdi), %rax
xorl %edx, %edx
movl $0x0, %esi
testq %rax, %rax
je 0xc3aa
movswl 0x30(%rax), %esi
movq 0x18(%rdi), %rcx
testq %rcx, %rcx
je 0xc3b7
movswl 0x30(%rcx), %edx
leal 0x1(%rdx), %r8d
cmpl %r8d, %esi
jle 0xc432
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0xc3d7
movl 0x30(%rax), %edx
decl %edx
cmpl %edx, 0x30(%rcx)
jge 0xc4b9
movq %rcx, 0x10(%rdi)
movq %rdi, 0x18(%rax)
xorl %esi, %esi
movl $0x0, %edx
testq %rdi, %rdi
je 0xc411
xorl %edx, %edx
movl $0x0, %r8d
testq %rcx, %rcx
je 0xc3fc
movl 0x30(%rcx), %r8d
movq 0x18(%rdi), %rcx
testq %rcx, %rcx
je 0xc408
movl 0x30(%rcx), %edx
cmpl %edx, %r8d
cmovgl %r8d, %edx
incl %edx
movl %edx, 0x30(%rdi)
testq %rax, %rax
je 0xc557
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0xc54c
movl 0x30(%rcx), %ecx
jmp 0xc54e
leal 0x1(%rsi), %eax
cmpl %eax, %edx
jle 0xc4ab
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0xc450
movl 0x30(%rcx), %edx
decl %edx
cmpl %edx, 0x30(%rax)
jge 0xc55b
movq %rax, 0x18(%rdi)
movq %rdi, 0x10(%rcx)
xorl %edx, %edx
movl $0x0, %esi
testq %rdi, %rdi
je 0xc48a
movq 0x10(%rdi), %r9
xorl %esi, %esi
movl $0x0, %r8d
testq %r9, %r9
je 0xc479
movl 0x30(%r9), %r8d
testq %rax, %rax
je 0xc481
movl 0x30(%rax), %esi
cmpl %esi, %r8d
cmovgl %r8d, %esi
incl %esi
movl %esi, 0x30(%rdi)
testq %rcx, %rcx
je 0xc5fe
movq 0x18(%rcx), %rax
testq %rax, %rax
je 0xc5f5
movl 0x30(%rax), %edx
jmp 0xc5f7
cmpl %edx, %esi
cmovgl %esi, %edx
incl %edx
movl %edx, 0x30(%rdi)
movq %rdi, %rax
retq
movq 0x18(%rcx), %rdx
movq %rdx, 0x10(%rdi)
movq 0x10(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq %rdi, 0x18(%rcx)
movq %rax, 0x10(%rcx)
xorl %edx, %edx
movl $0x0, %esi
testq %rdi, %rdi
je 0xc508
movq 0x10(%rdi), %r9
xorl %esi, %esi
movl $0x0, %r8d
testq %r9, %r9
je 0xc4f2
movl 0x30(%r9), %r8d
movq 0x18(%rdi), %r9
testq %r9, %r9
je 0xc4ff
movl 0x30(%r9), %esi
cmpl %esi, %r8d
cmovgl %r8d, %esi
incl %esi
movl %esi, 0x30(%rdi)
testq %rax, %rax
je 0xc538
movq 0x10(%rax), %r8
xorl %edx, %edx
movl $0x0, %esi
testq %r8, %r8
je 0xc524
movl 0x30(%r8), %esi
movq 0x18(%rax), %r8
testq %r8, %r8
je 0xc531
movl 0x30(%r8), %edx
cmpl %edx, %esi
cmovgl %esi, %edx
incl %edx
movl %edx, 0x30(%rax)
testq %rdi, %rdi
je 0xc5e7
movl 0x30(%rdi), %eax
jmp 0xc5e9
xorl %ecx, %ecx
cmpl %edx, %ecx
cmovgl %ecx, %edx
incl %edx
movl %edx, %esi
movl %esi, 0x30(%rax)
retq
movq 0x10(%rax), %rdx
movq %rdx, 0x18(%rdi)
movq 0x18(%rax), %rdx
movq %rdx, 0x10(%rcx)
movq %rdi, 0x10(%rax)
movq %rcx, 0x18(%rax)
xorl %edx, %edx
movl $0x0, %esi
testq %rdi, %rdi
je 0xc5aa
movq 0x10(%rdi), %r9
xorl %esi, %esi
movl $0x0, %r8d
testq %r9, %r9
je 0xc594
movl 0x30(%r9), %r8d
movq 0x18(%rdi), %r9
testq %r9, %r9
je 0xc5a1
movl 0x30(%r9), %esi
cmpl %esi, %r8d
cmovgl %r8d, %esi
incl %esi
movl %esi, 0x30(%rdi)
testq %rcx, %rcx
je 0xc5da
movq 0x10(%rcx), %r8
xorl %edx, %edx
movl $0x0, %esi
testq %r8, %r8
je 0xc5c6
movl 0x30(%r8), %esi
movq 0x18(%rcx), %r8
testq %r8, %r8
je 0xc5d3
movl 0x30(%r8), %edx
cmpl %edx, %esi
cmovgl %esi, %edx
incl %edx
movl %edx, 0x30(%rcx)
testq %rdi, %rdi
je 0xc605
movl 0x30(%rdi), %ecx
jmp 0xc607
xorl %eax, %eax
cmpl %eax, %edx
cmovgl %edx, %eax
incl %eax
movl %eax, 0x30(%rcx)
jmp 0xc601
xorl %edx, %edx
cmpl %edx, %esi
cmovgl %esi, %edx
incl %edx
movl %edx, 0x30(%rcx)
movq %rcx, %rax
retq
xorl %ecx, %ecx
cmpl %edx, %ecx
cmovgl %ecx, %edx
incl %edx
movl %edx, 0x30(%rax)
retq
nop