// File: /workspace/github_cpp_makefile_star2_O1/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 0x176e
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 0x1efe
leaq -0xa8(%rbp), %rdi
movq %r12, %rdx
callq 0x1398
movq %r14, -0x88(%rbp)
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x17a7
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)
movq %rbx, -0x90(%rbp)
movl %r12d, (%rbx)
movq (%r15), %rdx
cmpq %rdx, 0x8(%r15)
je 0x186f
xorl %r14d, %r14d
leaq -0x80(%rbp), %rbx
xorl %r13d, %r13d
movq (%rdx,%r14), %rax
cmpl %r12d, 0x4(%rax)
jge 0x1822
movq -0x78(%rbp), %rsi
movq %rbx, %rdi
leaq -0x78(%rbp), %rcx
cmpq -0x70(%rbp), %rsi
je 0x184d
movq %rax, (%rsi)
addq $0x8, (%rcx)
jmp 0x1855
cmpl %r12d, (%rax)
jle 0x183b
movq -0x58(%rbp), %rsi
leaq -0x60(%rbp), %rdi
leaq -0x58(%rbp), %rcx
cmpq -0x50(%rbp), %rsi
jne 0x1819
jmp 0x184d
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdi
leaq -0x38(%rbp), %rcx
cmpq -0x30(%rbp), %rsi
jne 0x1819
addq %r14, %rdx
callq 0x218e
incq %r13
movq (%r15), %rdx
movq 0x8(%r15), %rax
subq %rdx, %rax
sarq $0x3, %rax
addq $0x8, %r14
cmpq %r13, %rax
ja 0x17fe
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
movq -0x90(%rbp), %rbx
movq -0x88(%rbp), %r14
je 0x18bf
leaq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1efe
movq 0x20(%rbx), %rdx
leaq -0xf0(%rbp), %rsi
movq %r14, %rdi
callq 0x172a
movq %rax, 0x20(%rbx)
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x18bf
callq 0x10d0
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x1901
leaq -0xd8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1efe
movq 0x28(%rbx), %rdx
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x172a
movq %rax, 0x28(%rbx)
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x1901
callq 0x10d0
leaq 0x8(%rbx), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1f7e
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x1963
movl $0x8, %edi
callq 0x10f0
movq %rax, %r14
movq $0x0, (%rax)
leaq -0xc0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1efe
leaq -0xc0(%rbp), %rdx
movq %r14, %rdi
movq %r14, %rsi
callq 0x3b0c
movq %rax, 0x30(%rbx)
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x1963
callq 0x10d0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1971
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x197f
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x198d
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x199e
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 -0xc0(%rbp), %rdi
jmp 0x19d5
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0x19d5
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x19f4
callq 0x10d0
jmp 0x19f4
movq %rax, %rbx
movq -0x108(%rbp), %rdi
jmp 0x1a25
jmp 0x19f1
jmp 0x19f1
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1a02
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1a10
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1a1e
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1a2f
callq 0x10d0
movq %rbx, %rdi
callq 0x1170
nop