// File: /workspace/github_cpp_makefile_star2_O3/meghanamreddy[P]Range-trees-and-Interval-Trees/interval_tree.cpp
// Function: IntervalTree::constructY(std::vector<Line*, std::allocator<Line*>>, IntervalNode*)
IntervalNode* IntervalTree::constructY(vector<Line*> lines, IntervalNode *node) {
	if (node == NULL)
                 node = new IntervalNode();
	int j;
	
	vector<int> endpoints = getSortedEndPointsY(lines);
	int x_mid = endpoints[(endpoints.size()/2)-1];
	vector<Line*> I_left;
	vector<Line*> I_right;
	vector<Line*> I_mid;
	node->x_mid = x_mid;
	int i;
	for (i=0; i<lines.size(); i++) {
		if (lines[i]->y2 < x_mid)
			I_left.push_back(lines[i]);
		else if (lines[i]->y1 > x_mid)
			I_right.push_back(lines[i]);
		else
			I_mid.push_back(lines[i]);
	}
	
	if (I_left.size() > 0)
		node->left = constructY(I_left, node->left);
	if (I_right.size() > 0)
		node->right = constructY(I_right, node->right);
	node->I_mid = I_mid;
	if (I_mid.size() > 0) {
		BinaryRangeTree *sbbst = new BinaryRangeTree();
		node->rangetree = sbbst->buildRangeTree2(sbbst, I_mid);
	}
	return node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %rdx, %rdx
jne 0x1af4
movl $0x38, %edi
callq 0x10f0
movq %rax, %rbx
movl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
leaq -0x108(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1f1e
leaq -0xa8(%rbp), %rdi
movq %r12, %rdx
callq 0x14a0
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x1b26
callq 0x10d0
movq -0xa8(%rbp), %rax
movq -0xa0(%rbp), %rcx
subq %rax, %rcx
sarq %rcx
andq $-0x4, %rcx
movl -0x4(%rax,%rcx), %r12d
xorl %eax, %eax
movq %rax, -0x70(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq %rax, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq %rax, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movl %r12d, (%rbx)
movq (%r15), %rdx
cmpq %rdx, 0x8(%r15)
je 0x1c4a
movq %r14, -0x88(%rbp)
movq %rbx, -0x90(%rbp)
xorl %r14d, %r14d
leaq -0x80(%rbp), %rbx
xorl %r13d, %r13d
movq (%rdx,%r14), %rax
cmpl %r12d, 0xc(%rax)
jge 0x1bac
movq -0x78(%rbp), %rsi
movq %rbx, %rdi
leaq -0x78(%rbp), %rcx
cmpq -0x70(%rbp), %rsi
je 0x1bd8
movq %rax, (%rsi)
addq $0x8, (%rcx)
jmp 0x1be0
cmpl %r12d, 0x8(%rax)
jle 0x1bc6
movq -0x58(%rbp), %rsi
leaq -0x60(%rbp), %rdi
leaq -0x58(%rbp), %rcx
cmpq -0x50(%rbp), %rsi
jne 0x1ba3
jmp 0x1bd8
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdi
leaq -0x38(%rbp), %rcx
cmpq -0x30(%rbp), %rsi
jne 0x1ba3
addq %r14, %rdx
callq 0x21bc
incq %r13
movq (%r15), %rdx
movq 0x8(%r15), %rax
subq %rdx, %rax
sarq $0x3, %rax
addq $0x8, %r14
cmpq %r13, %rax
ja 0x1b88
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
movq -0x90(%rbp), %rbx
movq -0x88(%rbp), %r14
je 0x1c4a
leaq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1f1e
movq 0x20(%rbx), %rdx
leaq -0xf0(%rbp), %rsi
movq %r14, %rdi
callq 0x1ab0
movq %rax, 0x20(%rbx)
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x1c4a
callq 0x10d0
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x1c8c
leaq -0xd8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1f1e
movq 0x28(%rbx), %rdx
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x1ab0
movq %rax, 0x28(%rbx)
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x1c8c
callq 0x10d0
leaq 0x8(%rbx), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1f9e
movq -0x40(%rbp), %rdi
cmpq %rdi, -0x38(%rbp)
je 0x1cf2
movl $0x8, %edi
callq 0x10f0
movq %rax, %r14
movq $0x0, (%rax)
leaq -0xc0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1f1e
leaq -0xc0(%rbp), %rdx
movq %r14, %rdi
movq %r14, %rsi
callq 0x3b1a
movq %rax, 0x30(%rbx)
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x1cee
callq 0x10d0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1cfc
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1d0a
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1d18
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1d29
callq 0x10d0
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
jmp 0x1d60
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
jmp 0x1d60
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x1d7f
callq 0x10d0
jmp 0x1d7f
movq %rax, %rbx
movq -0x108(%rbp), %rdi
jmp 0x1db0
jmp 0x1d7c
jmp 0x1d7c
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1d8d
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1d9b
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1da9
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1dba
callq 0x10d0
movq %rbx, %rdi
callq 0x1170