// File: /workspace/github_cpp_makefile_star2_O1/meghanamreddy[P]Range-trees-and-Interval-Trees/binaryRangeTree.cpp
// Function: BinaryRangeTree::insert(int, int, BinaryRangeNode*, Line*)
BinaryRangeNode* BinaryRangeTree::insert(int x, int y, BinaryRangeNode *t, Line *line)
{	
     if (t == NULL) 
         t = new BinaryRangeNode(x,y, line);
     else if (x < t->data)
     {
         t->left = insert(x, y, t->left, line);
         if (height(t->left) - height(t->right) == 2)
             if (x < t->left->data)
                 t = rotateWithLeftChild(t);
             else
                 t = doubleWithLeftChild(t);
     }
     else if (x > t->data)
     {
         t->right = insert(x, y, t->right, line);
         if (height(t->right) - height(t->left) == 2)
             if (x > t->right->data)
                 t = rotateWithRightChild(t);
             else
                 t = doubleWithRightChild(t);
     }
	else if (x == t->data) {
		t->data2.push_back(y);
		t->lines.push_back(line);			
	}
     t->height = max(height(t->left), height(t->right)) + 1;
     return t;
 }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %r8, %r12
movl %edx, %r15d
movl %esi, %r14d
movl %edx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
testq %rcx, %rcx
je 0x285e
movq %rcx, %rbx
movl 0x4(%rcx), %eax
cmpl %r14d, %eax
jle 0x2881
movq 0x20(%rbx), %rcx
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %r8
callq 0x27d6
movq %rax, 0x20(%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x282c
movl (%rax), %edx
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x2837
movl (%rsi), %ecx
subl %ecx, %edx
cmpl $0x2, %edx
jne 0x2926
cmpl %r14d, 0x4(%rax)
jg 0x2854
movq %rax, %rsi
callq 0x2a0e
movq %rax, 0x20(%rbx)
movq %rbx, %rsi
callq 0x2994
jmp 0x28d6
movl $0x50, %edi
callq 0x10f0
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %rcx
callq 0x3b8e
jmp 0x2926
jge 0x28db
movq 0x28(%rbx), %rcx
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %r8
callq 0x27d6
movq %rax, 0x28(%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x28aa
movl (%rax), %edx
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x28b5
movl (%rsi), %ecx
subl %ecx, %edx
cmpl $0x2, %edx
jne 0x2926
cmpl %r14d, 0x4(%rax)
jl 0x28ce
movq %rax, %rsi
callq 0x2994
movq %rax, 0x28(%rbx)
movq %rbx, %rsi
callq 0x2a0e
movq %rax, %rbx
jmp 0x2926
jne 0x2926
movq 0x10(%rbx), %rsi
cmpq 0x18(%rbx), %rsi
je 0x28f4
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x10(%rbx)
jmp 0x2901
leaq 0x8(%rbx), %rdi
leaq -0x24(%rbp), %rdx
callq 0x2056
movq 0x40(%rbx), %rsi
cmpq 0x48(%rbx), %rsi
je 0x2919
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x40(%rbx)
jmp 0x2926
leaq 0x38(%rbx), %rdi
leaq -0x30(%rbp), %rdx
callq 0x218e
movq 0x20(%rbx), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rdx, %rdx
je 0x293b
movl (%rdx), %ecx
movq 0x28(%rbx), %rdx
testq %rdx, %rdx
je 0x2946
movl (%rdx), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
incl %eax
movl %eax, (%rbx)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x10d0
movq %r14, %rdi
callq 0x1170