// File: realuptime[P]PolyDetector/PolyDetector.cpp
// Function: PolyCycle::convex(PolyDetector&) const
bool PolyCycle::convex(PolyDetector &pd) const
{
    for (auto it1 = idx.begin(); it1 != idx.end(); ++it1)
    {
        auto l1 = pd.findLine(*it1, false);
        if (!l1) continue;
        
        auto it2 = it1;
        ++it2;
        
        for (; it2 != idx.end(); ++it2)
        {
            auto l2 = pd.findLine(*it2, false);
            if (!l2) continue;
            
            PolyLine ls(l1->center, l2->center);
            for (auto it3 = idx.begin(); it3 != idx.end(); ++it3)
            {
                if (it3 != it1 && it3 != it2
                    //&& !pd.CollinearIdx(*it3, *it1) && !pd.CollinearIdx(*it3, *it2)
                )
                {
                    auto l3 = pd.findLine(*it3);
                    
                    if (l3 && doIntersect(ls.a, ls.b, l3->a, l3->b))
                    //if (l2 && !Collinear(ls, *l2) && ls.PolyIntersects(*l2))
                    {
                        logoutf("convex(%s): l1:%u intersects l2:%u l3:%u", toString().c_str(), l1->id, l2->id, l3->id);
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x148(%rsp)
movq %rsi, 0x140(%rsp)
movq 0x148(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x13140
movq %rax, 0x138(%rsp)
movq 0x28(%rsp), %rdi
callq 0x13190
movq %rax, 0x130(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x13170
testb $0x1, %al
jne 0xb771
jmp 0xba46
movq 0x140(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x131c0
movq 0x20(%rsp), %rdi
movl (%rax), %esi
xorl %edx, %edx
callq 0x7240
movq %rax, 0x128(%rsp)
cmpq $0x0, 0x128(%rsp)
jne 0xb7b1
jmp 0xba34
movq 0x138(%rsp), %rax
movq %rax, 0x120(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x13240
movq 0x28(%rsp), %rdi
callq 0x13190
movq %rax, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x13170
testb $0x1, %al
jne 0xb7fe
jmp 0xba32
movq 0x140(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x131c0
movq 0x18(%rsp), %rdi
movl (%rax), %esi
xorl %edx, %edx
callq 0x7240
movq %rax, 0x110(%rsp)
cmpq $0x0, 0x110(%rsp)
jne 0xb83e
jmp 0xba11
movq 0x128(%rsp), %rsi
addq $0x58, %rsi
movq 0x110(%rsp), %rdx
addq $0x58, %rdx
leaq 0x80(%rsp), %rdi
callq 0x15130
movq 0x28(%rsp), %rdi
callq 0x13140
movq %rax, 0x78(%rsp)
movq 0x28(%rsp), %rdi
callq 0x13190
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x13170
testb $0x1, %al
jne 0xb899
jmp 0xb9ee
leaq 0x78(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x13170
testb $0x1, %al
jne 0xb8b4
jmp 0xb9dd
leaq 0x78(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x13170
testb $0x1, %al
jne 0xb8cf
jmp 0xb9dd
movq 0x140(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x131c0
movq 0x8(%rsp), %rdi
movl (%rax), %esi
movl $0x1, %edx
callq 0x7240
movq %rax, 0x10(%rsp)
jmp 0xb8fe
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0xb9db
leaq 0x88(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq %rdx, %rcx
addq $0x8, %rcx
leaq 0x80(%rsp), %rdi
callq 0x2680
movb %al, 0x7(%rsp)
jmp 0xb93b
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0xb948
jmp 0xb9db
movq 0x28(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x14b30
jmp 0xb959
leaq 0x38(%rsp), %rdi
callq 0x20b0
movq %rax, %rsi
movq 0x128(%rsp), %rax
movl 0x60(%rax), %edx
movq 0x110(%rsp), %rax
movl 0x60(%rax), %ecx
movq 0x68(%rsp), %rax
movl 0x60(%rax), %r8d
leaq 0x1b5ee(%rip), %rdi     # 0x26f7a
xorl %eax, %eax
callq 0x2050
jmp 0xb995
leaq 0x38(%rsp), %rdi
callq 0x2100
movb $0x0, 0x157(%rsp)
movl $0x1, 0x34(%rsp)
jmp 0xb9f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0xba23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x2100
jmp 0xba23
jmp 0xb9dd
jmp 0xb9df
leaq 0x78(%rsp), %rdi
callq 0x13240
jmp 0xb872
movl $0x0, 0x34(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x12a40
movl 0x34(%rsp), %eax
testl %eax, %eax
je 0xba0f
jmp 0xba0d
jmp 0xba4e
jmp 0xba11
leaq 0x120(%rsp), %rdi
callq 0x13240
jmp 0xb7ce
leaq 0x80(%rsp), %rdi
callq 0x12a40
jmp 0xba5f
jmp 0xba34
leaq 0x138(%rsp), %rdi
callq 0x13240
jmp 0xb741
movb $0x1, 0x157(%rsp)
movb 0x157(%rsp), %al
andb $0x1, %al
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x60(%rsp), %rdi
callq 0x2280
nopl (%rax)