// File: /workspace/github_cpp_makefile_star2_O3/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 0x1786
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 0x1398
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x17b8
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 0x18db
movq %r14, -0x88(%rbp)
movq %rbx, -0x90(%rbp)
xorl %r14d, %r14d
leaq -0x80(%rbp), %rbx
xorl %r13d, %r13d
movq (%rdx,%r14), %rax
cmpl %r12d, 0x4(%rax)
jge 0x183e
movq -0x78(%rbp), %rsi
movq %rbx, %rdi
leaq -0x78(%rbp), %rcx
cmpq -0x70(%rbp), %rsi
je 0x1869
movq %rax, (%rsi)
addq $0x8, (%rcx)
jmp 0x1871
cmpl %r12d, (%rax)
jle 0x1857
movq -0x58(%rbp), %rsi
leaq -0x60(%rbp), %rdi
leaq -0x58(%rbp), %rcx
cmpq -0x50(%rbp), %rsi
jne 0x1835
jmp 0x1869
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdi
leaq -0x38(%rbp), %rcx
cmpq -0x30(%rbp), %rsi
jne 0x1835
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 0x181a
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
movq -0x90(%rbp), %rbx
movq -0x88(%rbp), %r14
je 0x18db
leaq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1f1e
movq 0x20(%rbx), %rdx
leaq -0xf0(%rbp), %rsi
movq %r14, %rdi
callq 0x1742
movq %rax, 0x20(%rbx)
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x18db
callq 0x10d0
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x191d
leaq -0xd8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1f1e
movq 0x28(%rbx), %rdx
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x1742
movq %rax, 0x28(%rbx)
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x191d
callq 0x10d0
leaq 0x8(%rbx), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1f9e
movq -0x40(%rbp), %rdi
cmpq %rdi, -0x38(%rbp)
je 0x1983
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 0x197f
callq 0x10d0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x198d
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x199b
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x19a9
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x19ba
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 0x19f1
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
jmp 0x19f1
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x1a10
callq 0x10d0
jmp 0x1a10
movq %rax, %rbx
movq -0x108(%rbp), %rdi
jmp 0x1a41
jmp 0x1a0d
jmp 0x1a0d
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1a1e
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1a2c
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1a3a
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1a4b
callq 0x10d0
movq %rbx, %rdi
callq 0x1170
nop