// File: /workspace/github_cpp_makefile_star2_O2/meghanamreddy[P]Range-trees-and-Interval-Trees/interval_tree.cpp
// Function: IntervalTree::constructX(std::vector<Line*, std::allocator<Line*>>, IntervalNode*)
IntervalNode* IntervalTree::constructX(vector<Line*> lines, IntervalNode *node) {
	if (node == NULL)
                 node = new IntervalNode();
	int j;
	vector<int> endpoints = getSortedEndPointsX(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]->x2 < x_mid)
			I_left.push_back(lines[i]);
		else if (lines[i]->x1 > x_mid)
			I_right.push_back(lines[i]);
		else
			I_mid.push_back(lines[i]);
	}

	if (I_left.size() > 0)
		node->left = constructX(I_left, node->left);
	if (I_right.size() > 0)
		node->right = constructX(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 0x15b9
pushq $0x38
popq %rdi
callq 0x1100
movq %rax, %rbx
andl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
movq %r14, -0x90(%rbp)
leaq -0x108(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1c74
leaq -0xa8(%rbp), %rdi
movq %r12, %rdx
callq 0x1318
leaq -0x108(%rbp), %rdi
callq 0x1dbc
movq -0xa8(%rbp), %rax
movq -0xa0(%rbp), %rcx
subq %rax, %rcx
sarq %rcx
andq $-0x4, %rcx
movl -0x4(%rax,%rcx), %r12d
xorps %xmm0, %xmm0
leaq -0x80(%rbp), %r13
movaps %xmm0, (%r13)
andq $0x0, 0x10(%r13)
leaq -0x60(%rbp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq -0x40(%rbp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rbx, -0x88(%rbp)
movl %r12d, (%rbx)
xorl %ebx, %ebx
xorl %r14d, %r14d
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
sarq $0x3, %rax
cmpq %r14, %rax
jbe 0x1680
movq (%rsi,%rbx), %rax
movq %r13, %rdi
cmpl %r12d, 0x4(%rax)
jl 0x166f
leaq -0x60(%rbp), %rdi
cmpl %r12d, (%rax)
jg 0x166f
leaq -0x40(%rbp), %rdi
addq %rbx, %rsi
callq 0x1ccc
incq %r14
addq $0x8, %rbx
jmp 0x1642
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
movq -0x88(%rbp), %rbx
movq -0x90(%rbp), %r14
je 0x16cb
leaq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1c74
movq 0x20(%rbx), %rdx
leaq -0xf0(%rbp), %rsi
movq %r14, %rdi
callq 0x157a
movq %rax, 0x20(%rbx)
leaq -0xf0(%rbp), %rdi
callq 0x1dbc
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x1708
leaq -0xd8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1c74
movq 0x28(%rbx), %rdx
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x157a
movq %rax, 0x28(%rbx)
leaq -0xd8(%rbp), %rdi
callq 0x1dbc
leaq 0x8(%rbx), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cf0
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x1760
pushq $0x8
popq %rdi
callq 0x1100
movq %rax, %r14
andq $0x0, (%rax)
leaq -0xc0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1c74
leaq -0xc0(%rbp), %rdx
movq %r14, %rdi
movq %r14, %rsi
callq 0x36e2
movq %rax, 0x30(%rbx)
leaq -0xc0(%rbp), %rdi
callq 0x1dbc
leaq -0x40(%rbp), %rdi
callq 0x1dbc
leaq -0x60(%rbp), %rdi
callq 0x1dbc
leaq -0x80(%rbp), %rdi
callq 0x1dbc
leaq -0xa8(%rbp), %rdi
callq 0x1dd0
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x17be
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
jmp 0x17be
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x1dbc
jmp 0x17dd
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x1dbc
jmp 0x1804
jmp 0x17da
jmp 0x17da
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x1dbc
leaq -0x60(%rbp), %rdi
callq 0x1dbc
leaq -0x80(%rbp), %rdi
callq 0x1dbc
leaq -0xa8(%rbp), %rdi
callq 0x1dd0
movq %rbx, %rdi
callq 0x1160