// File: /workspace/github_cpp_makefile_star2_O1/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 0x2566c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x25bd8
jmp 0x2589b
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
cmpq %r12, %r15
je 0x2571d
movq 0x8(%rbx), %rax
movq %rax, %rcx
subq (%rbx), %rcx
cmpq $0x11, %rcx
jb 0x256ef
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
addq $-0x10, %rax
movsd (%rax), %xmm2
movsd -0x10(%rax), %xmm3
movsd -0x8(%rax), %xmm4
subsd %xmm3, %xmm2
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm2, %xmm5
movsd 0x8(%rax), %xmm2
subsd %xmm4, %xmm2
movapd %xmm0, %xmm4
subsd %xmm3, %xmm4
mulsd %xmm2, %xmm4
ucomisd %xmm4, %xmm5
jb 0x256ef
movq %rax, 0x8(%rbx)
addq $-0x10, %rax
addq $-0x10, %rcx
cmpq $0x10, %rcx
ja 0x256a4
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x25709
movupd (%r15), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rbx)
jmp 0x25714
movq %rbx, %rdi
movq %r15, %rdx
callq 0x25c6c
addq $0x10, %r15
jmp 0x2567c
addq $-0x10, 0x8(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x8(%r14), %r15
cmpq (%r14), %r15
je 0x257e7
movq %rsp, %r12
movq 0x8(%rsp), %rax
movq %rax, %rcx
subq (%rsp), %rcx
cmpq $0x11, %rcx
jb 0x257b2
movsd -0x10(%r15), %xmm0
movsd -0x8(%r15), %xmm1
addq $-0x10, %rax
movsd (%rax), %xmm2
movsd -0x10(%rax), %xmm3
movsd -0x8(%rax), %xmm4
subsd %xmm3, %xmm2
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm2, %xmm5
movsd 0x8(%rax), %xmm2
subsd %xmm4, %xmm2
movapd %xmm0, %xmm4
subsd %xmm3, %xmm4
mulsd %xmm2, %xmm4
ucomisd %xmm4, %xmm5
jb 0x257b2
movq %rax, 0x8(%rsp)
addq $-0x10, %rax
addq $-0x10, %rcx
cmpq $0x10, %rcx
ja 0x25766
addq $-0x10, %r15
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x257d3
movupd (%r15), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rsp)
jmp 0x257de
movq %r12, %rdi
movq %r15, %rdx
callq 0x25c6c
cmpq (%r14), %r15
jne 0x25744
movq 0x8(%rsp), %rcx
addq $-0x10, %rcx
movq %rcx, 0x8(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %rdx, %rax
subq %rsi, %rax
cmpq $0x10, %rax
jne 0x25876
movq (%rsp), %rdi
movq %rcx, %r8
subq %rdi, %r8
cmpq %r8, %rax
jne 0x25876
cmpq %rdx, %rsi
sete %r9b
je 0x25871
movsd (%rsi), %xmm0
ucomisd (%rdi), %xmm0
jne 0x25876
jp 0x25876
movsd 0x8(%rsi), %xmm0
ucomisd 0x8(%rdi), %xmm0
jne 0x25876
jp 0x25876
leaq 0x10(%rsi), %r8
addq $0x18, %rdi
cmpq %rdx, %r8
sete %r9b
je 0x25871
movsd (%r8), %xmm0
ucomisd -0x8(%rdi), %xmm0
jne 0x25876
jp 0x25876
movsd 0x8(%r8), %xmm0
addq $0x10, %r8
ucomisd (%rdi), %xmm0
leaq 0x10(%rdi), %rdi
jne 0x25876
jnp 0x25842
jmp 0x25876
testb %r9b, %r9b
jne 0x25885
movq (%rsp), %rdx
addq %rax, %rsi
movq %rbx, %rdi
callq 0x25d90
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2589b
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x7440
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x258ac
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x258ca
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x7440
jmp 0x258ca
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x258de
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x7440
movq %r14, %rdi
callq 0x7730