// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movl %edx, %r12d
movl %esi, %r14d
movl %edx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
testq %rcx, %rcx
je 0x2862
movq %rcx, %rbx
movl 0x4(%rcx), %eax
cmpl %r14d, %eax
jle 0x2885
movq 0x20(%rbx), %rcx
movl %r14d, %esi
movl %r12d, %edx
movq %r15, %r8
callq 0x27da
movq %rax, 0x20(%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2830
movl (%rax), %edx
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x283b
movl (%rsi), %ecx
subl %ecx, %edx
cmpl $0x2, %edx
jne 0x2926
cmpl %r14d, 0x4(%rax)
jg 0x2858
movq %rax, %rsi
callq 0x2a0e
movq %rax, 0x20(%rbx)
movq %rbx, %rsi
callq 0x2994
jmp 0x28da
movl $0x50, %edi
callq 0x10f0
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
movl %r12d, %edx
movq %r15, %rcx
callq 0x3b9e
jmp 0x2926
jge 0x28df
movq 0x28(%rbx), %rcx
movl %r14d, %esi
movl %r12d, %edx
movq %r15, %r8
callq 0x27da
movq %rax, 0x28(%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x28ae
movl (%rax), %edx
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x28b9
movl (%rsi), %ecx
subl %ecx, %edx
cmpl $0x2, %edx
jne 0x2926
cmpl %r14d, 0x4(%rax)
jl 0x28d2
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 0x28f8
movl %r12d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x10(%rbx)
jmp 0x2905
leaq 0x8(%rbx), %rdi
leaq -0x24(%rbp), %rdx
callq 0x2084
movq 0x40(%rbx), %rsi
cmpq 0x48(%rbx), %rsi
je 0x2919
movq %r15, (%rsi)
addq $0x8, 0x40(%rbx)
jmp 0x2926
leaq 0x38(%rbx), %rdi
leaq -0x30(%rbp), %rdx
callq 0x21bc
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