// File: realuptime[P]PolyDetector/PolyDetector.cpp
// Function: PolyDetector::dissolveCollinearLine(PolyLine&)
bool PolyDetector::dissolveCollinearLine(PolyLine &l)
{
    for (auto id : {l.aIdx, l.bIdx})
    {
        uint32_t nValid = 0;
        PolyLine *l1 = nullptr;
        for (auto &n : pointToLines[id])
        {
            if (n != l.id)
            {
                auto lPtr = findLine(n);
                if (lPtr)
                {
                    if (lPtr->took < 2)
                    //if (lPtr->took == 0)
                    //if (lPtr->numNeigh(*this) < 2)
                    {
                        l1 = lPtr;
                        nValid++;
                    }
                }
            }
        }
        //if (nValid == 1)
        //if (nValid > 0)
        //{
        //    logoutf("CollinearIdx[P%u](%s, %s)) = %d. nValid:%u", id, l.toString(*this).c_str(), l1->toString(*this).c_str(), CollinearIdx(l, *l1), nValid);
        //}
        if (nValid == 1 && CollinearIdx(l, *l1))
        {
            if (verbose)
                logoutf("line %s -> P%u has 2 intersections. otherLine:%u", l.toString(*this).c_str(), id, l1->id);
            return dissolveCollinear(l, *l1);
        }
    }
    return false;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xb0(%rsp), %rax
movl 0x80(%rax), %eax
movl %eax, 0x90(%rsp)
movq 0xb0(%rsp), %rax
movl 0x84(%rax), %eax
movl %eax, 0x94(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x98(%rsp)
movq $0x2, 0xa0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x13b00
movq %rax, 0x88(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x13b10
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rax
cmpq 0x80(%rsp), %rax
je 0xcaf0
movq 0x10(%rsp), %rdi
movq 0x88(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x7c(%rsp)
movl $0x0, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
addq $0xe0, %rdi
leaq 0x7c(%rsp), %rsi
callq 0x12dd0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x128b0
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rdi
callq 0x128e0
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x134e0
testb $0x1, %al
jne 0xc997
jmp 0xca12
leaq 0x60(%rsp), %rdi
callq 0x13520
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movl (%rax), %eax
movq 0xb0(%rsp), %rcx
cmpl 0x60(%rcx), %eax
je 0xca01
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rax
movl (%rax), %esi
movl $0x1, %edx
callq 0x7240
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0xc9ff
movq 0x48(%rsp), %rax
cmpl $0x2, 0x78(%rax)
jae 0xc9fd
movq 0x48(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0xc9ff
jmp 0xca01
jmp 0xca03
leaq 0x60(%rsp), %rdi
callq 0x13530
jmp 0xc982
cmpl $0x1, 0x78(%rsp)
jne 0xcad5
movq 0x10(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0xa9a0
testb $0x1, %al
jne 0xca3d
jmp 0xcad5
movq 0x10(%rsp), %rax
cmpl $0x0, 0x60(%rax)
je 0xcab3
movq 0x10(%rsp), %rdx
movq 0xb0(%rsp), %rsi
leaq 0x28(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x65a0
movq 0x8(%rsp), %rdi
callq 0x20b0
movq %rax, %rsi
movl 0x7c(%rsp), %edx
movq 0x70(%rsp), %rax
movl 0x60(%rax), %ecx
leaq 0x1a328(%rip), %rdi     # 0x26dac
xorl %eax, %eax
callq 0x2050
jmp 0xca8d
leaq 0x28(%rsp), %rdi
callq 0x2100
jmp 0xcab3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x2100
jmp 0xcb09
movq 0x10(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0xbd30
andb $0x1, %al
movb %al, 0xc7(%rsp)
jmp 0xcaf8
jmp 0xcad7
movq 0x88(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x88(%rsp)
jmp 0xc914
movb $0x0, 0xc7(%rsp)
movb 0xc7(%rsp), %al
andb $0x1, %al
addq $0xc8, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x2280
nopw %cs:(%rax,%rax)