// File: 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 %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x110(%rbp)
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5add0
cmpq $0x1, %rax
ja 0x5a3e8
movq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5adf0
jmp 0x5a835
movq -0x110(%rbp), %rdi
movb $0x0, -0x11(%rbp)
callq 0x5aee0
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5af00
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5af30
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5af60
testb $0x1, %al
jne 0x5a430
jmp 0x5a54b
leaq -0x28(%rbp), %rdi
callq 0x5afa0
movq %rax, -0x38(%rbp)
movq -0x110(%rbp), %rdi
callq 0x5add0
cmpq $0x2, %rax
jb 0x5a518
movq -0x110(%rbp), %rdi
callq 0x5afc0
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x5aff0
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5afa0
movq -0x110(%rbp), %rdi
movq %rax, -0x40(%rbp)
callq 0x5afc0
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x2, %esi
callq 0x5aff0
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5afa0
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movsd (%rax), %xmm0
movq -0x58(%rbp), %rax
subsd (%rax), %xmm0
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm1
movq -0x58(%rbp), %rax
subsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
movsd 0x8(%rax), %xmm1
movq -0x58(%rbp), %rax
subsd 0x8(%rax), %xmm1
movq -0x38(%rbp), %rax
movsd (%rax), %xmm2
movq -0x58(%rbp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x5a511
movq -0x110(%rbp), %rdi
callq 0x5b030
jmp 0x5a513
jmp 0x5a518
jmp 0x5a43d
movq -0x110(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5b060
jmp 0x5a52a
jmp 0x5a52c
leaq -0x28(%rbp), %rdi
callq 0x5b0d0
jmp 0x5a41a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x5a827
movq -0x110(%rbp), %rdi
callq 0x5b030
leaq -0x90(%rbp), %rdi
callq 0x5aee0
movq -0x10(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x5b0f0
movq -0x10(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x5b170
movq -0x120(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x5b140
movb %al, -0x111(%rbp)
jmp 0x5a5a5
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x5a5b4
jmp 0x5a72f
leaq -0x98(%rbp), %rdi
callq 0x5b1c0
movq %rax, -0x128(%rbp)
jmp 0x5a5c9
movq -0x128(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5add0
cmpq $0x2, %rax
jb 0x5a705
leaq -0x90(%rbp), %rdi
callq 0x5afc0
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rdi
movl $0x1, %esi
callq 0x5aff0
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x5afa0
movq %rax, -0xb0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5afc0
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rdi
movl $0x2, %esi
callq 0x5aff0
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5afa0
movq %rax, -0xc8(%rbp)
movq -0xb0(%rbp), %rax
movsd (%rax), %xmm0
movq -0xc8(%rbp), %rax
subsd (%rax), %xmm0
movq -0xa8(%rbp), %rax
movsd 0x8(%rax), %xmm1
movq -0xc8(%rbp), %rax
subsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
movq -0xb0(%rbp), %rax
movsd 0x8(%rax), %xmm1
movq -0xc8(%rbp), %rax
subsd 0x8(%rax), %xmm1
movq -0xa8(%rbp), %rax
movsd (%rax), %xmm2
movq -0xc8(%rbp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x5a6fe
leaq -0x90(%rbp), %rdi
callq 0x5b030
jmp 0x5a700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5b3f0
jmp 0x5a827
jmp 0x5a705
jmp 0x5a5d7
movq -0xa8(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x5b060
jmp 0x5a71a
jmp 0x5a71c
leaq -0x98(%rbp), %rdi
callq 0x5b1f0
jmp 0x5a72a
jmp 0x5a573
leaq -0x90(%rbp), %rdi
callq 0x5b030
movq -0x110(%rbp), %rdi
callq 0x5add0
cmpq $0x1, %rax
jne 0x5a778
movq -0x110(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x5b220
movb %al, -0x129(%rbp)
jmp 0x5a768
movb -0x129(%rbp), %al
testb $0x1, %al
jne 0x5a803
jmp 0x5a778
movq -0x110(%rbp), %rdi
callq 0x5b350
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x5b380
leaq -0x90(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x5b3c0
movq -0x140(%rbp), %rdi
movq %rax, -0xf0(%rbp)
callq 0x5afc0
movq -0x110(%rbp), %rdi
movq %rax, -0xf8(%rbp)
movq -0xe0(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq -0xf8(%rbp), %rcx
callq 0x5b2a0
movq %rax, -0x138(%rbp)
jmp 0x5a7f5
movq -0x138(%rbp), %rax
movq %rax, -0x100(%rbp)
movb $0x1, -0x11(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5b3f0
testb $0x1, -0x11(%rbp)
jne 0x5a825
movq -0x110(%rbp), %rdi
callq 0x5b3f0
jmp 0x5a835
movq -0x110(%rbp), %rdi
callq 0x5b3f0
jmp 0x5a845
movq -0x108(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x9960
nop