// File: /workspace/github_cpp_makefile_star2_O3/thierry7100[P]CutOptim/src/ConvexHull.cpp
// Function: makeConvexHullPresorted(std::vector<Point, std::allocator<Point>> const&)
vector<Point> makeConvexHullPresorted(const vector<Point> &points) {
	if (points.size() <= 1)
		return vector<Point>(points);

	// Andrew's monotone chain algorithm. Positive y coordinates correspond to "up"
	// as per the mathematical convention, instead of "down" as per the computer
	// graphics convention. This doesn't affect the correctness of the result.

	vector<Point> upperHull;
	for (const Point &p : points) {
		while (upperHull.size() >= 2) {
			const Point &q = *(upperHull.cend() - 1);  // Same as .back()
			const Point &r = *(upperHull.cend() - 2);
			if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x))
				upperHull.pop_back();
			else
				break;
		}
		upperHull.push_back(p);
	}
	upperHull.pop_back();

	vector<Point> lowerHull;
	for (vector<Point>::const_reverse_iterator it = points.crbegin(); it != points.crend(); ++it) {
		const Point &p = *it;
		while (lowerHull.size() >= 2) {
			const Point &q = *(lowerHull.cend() - 1);  // Same as .back()
			const Point &r = *(lowerHull.cend() - 2);
			if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x))
				lowerHull.pop_back();
			else
				break;
		}
		lowerHull.push_back(p);
	}
	lowerHull.pop_back();

	if (!(upperHull.size() == 1 && upperHull == lowerHull))
		upperHull.insert(upperHull.end(), lowerHull.cbegin(), lowerHull.cend());
	return upperHull;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %r15
movq 0x8(%rsi), %r12
movq %r12, %rax
subq %r15, %rax
cmpq $0x10, %rax
ja 0x254d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x259ac
jmp 0x256eb
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
cmpq %r12, %r15
je 0x25645
movq 0x8(%rbx), %rsi
movq %rsi, %rax
subq (%rbx), %rax
cmpq $0x11, %rax
jb 0x2554c
movupd (%r15), %xmm0
addq $-0x10, %rsi
movupd -0x10(%rsi), %xmm1
movupd (%rsi), %xmm2
subpd %xmm1, %xmm2
movapd %xmm0, %xmm3
subpd %xmm1, %xmm3
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
mulpd %xmm2, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
ucomisd %xmm1, %xmm3
jb 0x25548
movq %rsi, 0x8(%rbx)
addq $-0x10, %rsi
addq $-0x10, %rax
cmpq $0x10, %rax
ja 0x2550a
addq $0x10, %rsi
cmpq 0x10(%rbx), %rsi
je 0x25562
movupd (%r15), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rbx)
jmp 0x2556d
movq %rbx, %rdi
movq %r15, %rdx
callq 0x25a40
addq $0x10, %r15
cmpq %r12, %r15
jne 0x254f1
movq 0x8(%rbx), %rax
movq 0x8(%r14), %r15
addq $-0x10, %rax
cmpq (%r14), %r15
movq %rax, 0x8(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
je 0x25662
movq %rsp, %r12
addq $-0x10, %r15
movq 0x8(%rsp), %rsi
movq %rsi, %rax
subq (%rsp), %rax
cmpq $0x11, %rax
jb 0x2560a
movupd (%r15), %xmm0
addq $-0x10, %rsi
movupd -0x10(%rsi), %xmm1
movupd (%rsi), %xmm2
subpd %xmm1, %xmm2
movapd %xmm0, %xmm3
subpd %xmm1, %xmm3
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
mulpd %xmm2, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
ucomisd %xmm1, %xmm3
jb 0x25606
movq %rsi, 0x8(%rsp)
addq $-0x10, %rsi
addq $-0x10, %rax
cmpq $0x10, %rax
ja 0x255c7
addq $0x10, %rsi
cmpq 0x10(%rsp), %rsi
je 0x25622
movupd (%r15), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rsp)
jmp 0x2562d
movq %r12, %rdi
movq %r15, %rdx
callq 0x25a40
cmpq (%r14), %r15
jne 0x255a8
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x8(%rbx), %rax
jmp 0x25666
movq $-0x10, 0x8(%rbx)
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq $-0x10, %rax
xorl %edx, %edx
xorl %ecx, %ecx
addq $-0x10, %rcx
movq %rcx, 0x8(%rsp)
movq (%rbx), %rsi
movq %rax, %rdi
subq %rsi, %rdi
cmpq $0x10, %rdi
jne 0x256c7
movq %rcx, %r8
subq %rdx, %r8
cmpq $0x10, %r8
jne 0x256c7
cmpq %rax, %rsi
je 0x256d6
xorl %r8d, %r8d
movsd (%rsi,%r8), %xmm0
ucomisd (%rdx,%r8), %xmm0
jne 0x256c7
jp 0x256c7
movsd 0x8(%rsi,%r8), %xmm0
ucomisd 0x8(%rdx,%r8), %xmm0
jne 0x256c7
jp 0x256c7
leaq (%rsi,%r8), %r9
addq $0x10, %r8
addq $0x10, %r9
cmpq %rax, %r9
jne 0x25692
jmp 0x256d6
addq %rdi, %rsi
movq %rbx, %rdi
callq 0x25b64
movq (%rsp), %rdx
testq %rdx, %rdx
je 0x256eb
movq 0x10(%rsp), %rsi
subq %rdx, %rsi
movq %rdx, %rdi
callq 0x7450
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x256fc
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2571a
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x7450
jmp 0x2571a
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2572e
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x7450
movq %r14, %rdi
callq 0x7740