// File: /workspace/github_cpp_makefile_star2_O1/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 0x1ad8
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 0x1496
movq %r14, -0x88(%rbp)
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x1b11
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 0x1bda
xorl %r14d, %r14d
leaq -0x80(%rbp), %rbx
xorl %r13d, %r13d
movq (%rdx,%r14), %rax
cmpl %r12d, 0xc(%rax)
jge 0x1b8c
movq -0x78(%rbp), %rsi
movq %rbx, %rdi
leaq -0x78(%rbp), %rcx
cmpq -0x70(%rbp), %rsi
je 0x1bb8
movq %rax, (%rsi)
addq $0x8, (%rcx)
jmp 0x1bc0
cmpl %r12d, 0x8(%rax)
jle 0x1ba6
movq -0x58(%rbp), %rsi
leaq -0x60(%rbp), %rdi
leaq -0x58(%rbp), %rcx
cmpq -0x50(%rbp), %rsi
jne 0x1b83
jmp 0x1bb8
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdi
leaq -0x38(%rbp), %rcx
cmpq -0x30(%rbp), %rsi
jne 0x1b83
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 0x1b68
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
movq -0x90(%rbp), %rbx
movq -0x88(%rbp), %r14
je 0x1c2a
leaq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1efe
movq 0x20(%rbx), %rdx
leaq -0xf0(%rbp), %rsi
movq %r14, %rdi
callq 0x1a94
movq %rax, 0x20(%rbx)
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x1c2a
callq 0x10d0
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x1c6c
leaq -0xd8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1efe
movq 0x28(%rbx), %rdx
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x1a94
movq %rax, 0x28(%rbx)
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x1c6c
callq 0x10d0
leaq 0x8(%rbx), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1f7e
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x1cce
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 0x1cce
callq 0x10d0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1cdc
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1cea
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1cf8
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1d09
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 0x1d40
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0x1d40
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x1d5f
callq 0x10d0
jmp 0x1d5f
movq %rax, %rbx
movq -0x108(%rbp), %rdi
jmp 0x1d90
jmp 0x1d5c
jmp 0x1d5c
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1d6d
callq 0x10d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1d7b
callq 0x10d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1d89
callq 0x10d0
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1d9a
callq 0x10d0
movq %rbx, %rdi
callq 0x1170