// File: micahcc[P]polygon_skeleton/voronoi.cpp
// Function: BeachCompare::operator()(Intersection const&, Intersection const&) const
bool operator()(const Intersection& lhs, const Intersection& rhs) const
    {
        // Compares the x index of thwo intersections. In the case where a point
        // is missing (nullptr), there is no intersection (or intersection is at
        // positive or negative infinity, if right or left point is nullptr,
        // respectively)
        std::cerr << "<<<Comparing: ("
            << lhs.pt_left << ", " << lhs.pt_right << ", " << ") to ("
            << rhs.pt_left << ", " << rhs.pt_right << ", " << ")" << std::endl;
        if(lhs.pt_left)
            std::cerr << "<<<Left Point 0: " << *lhs.pt_left << std::endl;
        if(lhs.pt_right)
            std::cerr << "<<<Left Point 1: " << *lhs.pt_right << std::endl;
        if(rhs.pt_left)
            std::cerr << "<<<Right Point 0: " << *rhs.pt_left << std::endl;
        if(rhs.pt_right)
            std::cerr << "<<<Right Point 1: " << *rhs.pt_right << std::endl;
        std::cerr << "<<<Using sweep = " << *sweep_y << std::endl;
        bool lhs_n_infinite = lhs.pt_left == nullptr;
        bool lhs_p_infinite = lhs.pt_right == nullptr;
        bool rhs_n_infinite = rhs.pt_left == nullptr;
        bool rhs_p_infinite = rhs.pt_right == nullptr;

        bool result;
        if((lhs_p_infinite && rhs_n_infinite) ||
                (lhs_p_infinite && rhs_p_infinite) ||
                (lhs_n_infinite && rhs_n_infinite)) {
            // Obviously +infinity !< -infinity and
            // if both inputs have an infinite side in the same direction, then
            // both intersections are dummy boundaries and therefore one can't
            // be less than the other
            result = false;
        } else if(lhs_n_infinite || rhs_p_infinite) {
            // -infinity < rhs => true
            result = true;
        } else if(lhs_p_infinite || rhs_n_infinite) {
            // lhs < -infinity => false
            result = false;
        } else if(lhs.pt_left == rhs.pt_left && lhs.pt_right == rhs.pt_right) {
            // intersection of the exact same to parabolas, by definition this
            // equal and therefore not less
            result = false;
        } else if(lhs.pt_right == rhs.pt_left && lhs.pt_left == rhs.pt_right) {
            // the order of the parabolas determines the sign. So the same two
            // parabolas does not mean the same intersection.
            result = getSign(lhs) < getSign(rhs);
        } else if(lhs.pt_left == lhs.pt_right) {
            // Special case, intersection of two identical points is assumed to
            // be just the x value of the double-point intersection
            assert(rhs.pt_left != rhs.pt_right);
            assert(!(lhs_n_infinite || lhs_p_infinite || rhs_n_infinite ||
                        rhs_p_infinite));
            Point right = getIntersection(*sweep_y, rhs);
            result = lhs.pt_left->x < right.x;
        } else if(rhs.pt_left == rhs.pt_right) {
            // Special case, intersection of two identical points is assumed to
            // be just the x value of the double-point intersection
            assert(lhs.pt_left != lhs.pt_right);
            assert(!(lhs_n_infinite || lhs_p_infinite || rhs_n_infinite ||
                        rhs_p_infinite));
            Point left  = getIntersection(*sweep_y, lhs);
            result = left.x < rhs.pt_left->x;
        } else {
            // get intersection of left two parabolas, and compare x with
            // intersection of right two
            assert(!(lhs_n_infinite || lhs_p_infinite || rhs_n_infinite || rhs_p_infinite));
            std::cerr << "<<<Computing intersections" << std::endl;
            Point left  = getIntersection(*sweep_y, lhs);
            Point right = getIntersection(*sweep_y, rhs);
            std::cerr << "<<<" << (left.x < right.x) << std::endl;
            result = left.x < right.x;
        }

        std::cerr << "<<<" << result << std::endl;
        return result;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x22c5d(%rip), %rdi     # 0x32ff0
leaq 0x1374d(%rip), %rsi     # 0x23ae7
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x12cbf(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x12ca0(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, %rdi
leaq 0x13711(%rip), %rsi     # 0x23af7
callq 0x3250
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x12c73(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x12c54(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, %rdi
leaq 0x13587(%rip), %rsi     # 0x239b9
callq 0x3250
movq %rax, %rdi
movq 0x22b7f(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x10481
movq 0x22b99(%rip), %rdi     # 0x32ff0
leaq 0x136a0(%rip), %rsi     # 0x23afe
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xa320
movq %rax, %rdi
movq 0x22b44(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x104be
movq 0x22b5d(%rip), %rdi     # 0x32ff0
leaq 0x13676(%rip), %rsi     # 0x23b10
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0xa320
movq %rax, %rdi
movq 0x22b07(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x104f9
movq 0x22b21(%rip), %rdi     # 0x32ff0
leaq 0x1364c(%rip), %rsi     # 0x23b22
callq 0x3250
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0xa320
movq %rax, %rdi
movq 0x22acc(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x10536
movq 0x22ae5(%rip), %rdi     # 0x32ff0
leaq 0x13623(%rip), %rsi     # 0x23b35
callq 0x3250
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0xa320
movq %rax, %rdi
movq 0x22a8f(%rip), %rsi     # 0x32fc0
callq 0x3290
movq 0x22ab3(%rip), %rdi     # 0x32ff0
leaq 0x13604(%rip), %rsi     # 0x23b48
callq 0x3250
movq %rax, %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rax
movss (%rax), %xmm0
callq 0x31b0
movq %rax, %rdi
movq 0x22a5a(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
sete %al
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
sete %al
andb $0x1, %al
movb %al, -0x1a(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
sete %al
andb $0x1, %al
movb %al, -0x1b(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
sete %al
andb $0x1, %al
movb %al, -0x1c(%rbp)
testb $0x1, -0x1a(%rbp)
je 0x105b9
testb $0x1, -0x1b(%rbp)
jne 0x105d1
testb $0x1, -0x1a(%rbp)
je 0x105c5
testb $0x1, -0x1c(%rbp)
jne 0x105d1
testb $0x1, -0x19(%rbp)
je 0x105da
testb $0x1, -0x1b(%rbp)
je 0x105da
movb $0x0, -0x1d(%rbp)
jmp 0x1092b
testb $0x1, -0x19(%rbp)
jne 0x105e6
testb $0x1, -0x1c(%rbp)
je 0x105ef
movb $0x1, -0x1d(%rbp)
jmp 0x10929
testb $0x1, -0x1a(%rbp)
jne 0x105fb
testb $0x1, -0x1b(%rbp)
je 0x10604
movb $0x0, -0x1d(%rbp)
jmp 0x10927
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x1062f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1062f
movb $0x0, -0x1d(%rbp)
jmp 0x10925
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x1067d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1067d
movq -0x10(%rbp), %rdi
callq 0x9710
movss %xmm0, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x9710
movss -0x4c(%rbp), %xmm1
ucomiss %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x10923
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x10750
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x106a5
jmp 0x106c4
leaq 0x134ae(%rip), %rdi     # 0x23b5a
leaq 0x12c1b(%rip), %rsi     # 0x232ce
movl $0x90, %edx
leaq 0x134b7(%rip), %rcx     # 0x23b76
callq 0x3170
movb $0x1, %al
testb $0x1, -0x19(%rbp)
movb %al, -0x4d(%rbp)
jne 0x106eb
movb $0x1, %al
testb $0x1, -0x1a(%rbp)
movb %al, -0x4d(%rbp)
jne 0x106eb
movb $0x1, %al
testb $0x1, -0x1b(%rbp)
movb %al, -0x4d(%rbp)
jne 0x106eb
movb -0x1c(%rbp), %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x106f6
jmp 0x106f8
jmp 0x10717
leaq 0x134c7(%rip), %rdi     # 0x23bc6
leaq 0x12bc8(%rip), %rsi     # 0x232ce
movl $0x92, %edx
leaq 0x13464(%rip), %rcx     # 0x23b76
callq 0x3170
movq -0x48(%rbp), %rax
movq (%rax), %rax
movss (%rax), %xmm0
movq -0x18(%rbp), %rdi
callq 0x97c0
movlpd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movss (%rax), %xmm1
movss -0x28(%rbp), %xmm0
ucomiss %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x10921
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x10823
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x10778
jmp 0x10797
leaq 0x1348f(%rip), %rdi     # 0x23c0e
leaq 0x12b48(%rip), %rsi     # 0x232ce
movl $0x98, %edx
leaq 0x133e4(%rip), %rcx     # 0x23b76
callq 0x3170
movb $0x1, %al
testb $0x1, -0x19(%rbp)
movb %al, -0x4e(%rbp)
jne 0x107be
movb $0x1, %al
testb $0x1, -0x1a(%rbp)
movb %al, -0x4e(%rbp)
jne 0x107be
movb $0x1, %al
testb $0x1, -0x1b(%rbp)
movb %al, -0x4e(%rbp)
jne 0x107be
movb -0x1c(%rbp), %al
movb %al, -0x4e(%rbp)
movb -0x4e(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x107c9
jmp 0x107cb
jmp 0x107ea
leaq 0x133f4(%rip), %rdi     # 0x23bc6
leaq 0x12af5(%rip), %rsi     # 0x232ce
movl $0x9a, %edx
leaq 0x13391(%rip), %rcx     # 0x23b76
callq 0x3170
movq -0x48(%rbp), %rax
movq (%rax), %rax
movss (%rax), %xmm0
movq -0x10(%rbp), %rdi
callq 0x97c0
movlpd %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm1
movq -0x18(%rbp), %rax
movq (%rax), %rax
movss (%rax), %xmm0
ucomiss %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x1091f
movb $0x1, %al
testb $0x1, -0x19(%rbp)
movb %al, -0x4f(%rbp)
jne 0x1084a
movb $0x1, %al
testb $0x1, -0x1a(%rbp)
movb %al, -0x4f(%rbp)
jne 0x1084a
movb $0x1, %al
testb $0x1, -0x1b(%rbp)
movb %al, -0x4f(%rbp)
jne 0x1084a
movb -0x1c(%rbp), %al
movb %al, -0x4f(%rbp)
movb -0x4f(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x10855
jmp 0x10857
jmp 0x10876
leaq 0x13368(%rip), %rdi     # 0x23bc6
leaq 0x12a69(%rip), %rsi     # 0x232ce
movl $0xa0, %edx
leaq 0x13305(%rip), %rcx     # 0x23b76
callq 0x3170
movq 0x22773(%rip), %rdi     # 0x32ff0
leaq 0x133a6(%rip), %rsi     # 0x23c2a
callq 0x3250
movq %rax, %rdi
movq 0x2272d(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x48(%rbp), %rax
movq (%rax), %rax
movss (%rax), %xmm0
movq -0x10(%rbp), %rdi
callq 0x97c0
movq -0x48(%rbp), %rax
movlpd %xmm0, -0x38(%rbp)
movq (%rax), %rax
movss (%rax), %xmm0
movq -0x18(%rbp), %rdi
callq 0x97c0
movlpd %xmm0, -0x40(%rbp)
movq 0x2271f(%rip), %rdi     # 0x32ff0
leaq 0x12aa2(%rip), %rsi     # 0x2337a
callq 0x3250
movq %rax, %rdi
movss -0x38(%rbp), %xmm1
movss -0x40(%rbp), %xmm0
ucomiss %xmm1, %xmm0
seta %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x3420
movq %rax, %rdi
movq 0x226bb(%rip), %rsi     # 0x32fc0
callq 0x3290
movss -0x38(%rbp), %xmm1
movss -0x40(%rbp), %xmm0
ucomiss %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x10921
jmp 0x10923
jmp 0x10925
jmp 0x10927
jmp 0x10929
jmp 0x1092b
movq 0x226be(%rip), %rdi     # 0x32ff0
leaq 0x12a41(%rip), %rsi     # 0x2337a
callq 0x3250
movq %rax, %rdi
movb -0x1d(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x3420
movq %rax, %rdi
movq 0x22668(%rip), %rsi     # 0x32fc0
callq 0x3290
movb -0x1d(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)