// File: realuptime[P]PolyDetector/PolyDetector.cpp
// Function: PolyDetector::rmLines(RmLinesType)
bool PolyDetector::rmLines(RmLinesType type)
{
    if (verbose)
        logoutf("rmLines type:%s", RmLinesTypeStr(type));
    
    if (type == RmLinesType::Collinear)
    {
        // rm collinear lines
        uint32_t nCollinearRemoved = 0;
        for (uint32_t i = 0; i < lines.size(); ++i)
        {
            auto &l = lines[i];
            if (!l.ignore)
            {
                if (dissolveCollinearLine(l))
                {
                    nCollinearRemoved++;
                    i = 0; // again
                }
            }
        }
        if (verbose)
            logoutf("Collinear removed lines:%u", nCollinearRemoved);
        return true;
    }
    
    if (type == RmLinesType::PointConsumed)
    {
        rmEarPoints();
        return true;
    }

    // else pass type to canBeRemoved
    for (uint32_t i = 0; i < lines.size(); ++i)
    {
        auto &l = lines[i];
        if (!l.ignore && l.canBeRemoved(*this, type))
        {
            if (verbose)
                logoutf("remove line %s (type %d)", l.toString(*this).c_str(), type);
            l.setIgnore(*this, (std::string("rmLines.") + RmLinesTypeStr(type)).c_str());
            
            // reprocess same position
            if (i > 0) i--;
            //i = 0;
        }
    }
    
    return true;
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xd8(%rsp)
movl %esi, 0xd4(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x60(%rax)
je 0xcb66
movl 0xd4(%rsp), %edi
callq 0x23e0
movq %rax, %rsi
leaq 0x1a3cb(%rip), %rdi     # 0x26f2a
movb $0x0, %al
callq 0x2050
cmpl $0x1, 0xd4(%rsp)
jne 0xcc59
movl $0x0, 0xd0(%rsp)
movl $0x0, 0xcc(%rsp)
movq 0x30(%rsp), %rdi
movl 0xcc(%rsp), %eax
movq %rax, 0x28(%rsp)
addq $0x30, %rdi
callq 0x12b40
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0xcc2c
movq 0x30(%rsp), %rdi
addq $0x30, %rdi
movl 0xcc(%rsp), %eax
movl %eax, %esi
callq 0x12cf0
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
testb $0x1, 0x74(%rax)
jne 0xcc14
movq 0x30(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0xc870
testb $0x1, %al
jne 0xcbf6
jmp 0xcc12
movl 0xd0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd0(%rsp)
movl $0x0, 0xcc(%rsp)
jmp 0xcc14
jmp 0xcc16
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0xcb8a
movq 0x30(%rsp), %rax
cmpl $0x0, 0x60(%rax)
je 0xcc4c
movl 0xd0(%rsp), %esi
leaq 0x1a2f6(%rip), %rdi     # 0x26f3b
movb $0x0, %al
callq 0x2050
movb $0x1, 0xe7(%rsp)
jmp 0xceb5
cmpl $0x3, 0xd4(%rsp)
jne 0xcc7a
movq 0x30(%rsp), %rdi
callq 0xd280
movb $0x1, 0xe7(%rsp)
jmp 0xceb5
movl $0x0, 0xbc(%rsp)
movq 0x30(%rsp), %rdi
movl 0xbc(%rsp), %eax
movq %rax, 0x20(%rsp)
addq $0x30, %rdi
callq 0x12b40
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0xcead
movq 0x30(%rsp), %rdi
addq $0x30, %rdi
movl 0xbc(%rsp), %eax
movl %eax, %esi
callq 0x12cf0
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
testb $0x1, 0x74(%rax)
jne 0xce95
movq 0x30(%rsp), %rsi
movq 0xb0(%rsp), %rdi
movl 0xd4(%rsp), %edx
callq 0x7520
cmpl $0x0, %eax
je 0xce95
movq 0x30(%rsp), %rax
cmpl $0x0, 0x60(%rax)
je 0xcd86
movq 0x30(%rsp), %rdx
movq 0xb0(%rsp), %rsi
leaq 0x90(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x65a0
movq 0x18(%rsp), %rdi
callq 0x20b0
movq %rax, %rsi
movl 0xd4(%rsp), %edx
leaq 0x1a20f(%rip), %rdi     # 0x26f57
xorl %eax, %eax
callq 0x2050
jmp 0xcd51
leaq 0x90(%rsp), %rdi
callq 0x2100
jmp 0xcd86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x2100
jmp 0xcec6
movq 0xb0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x3f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x2290
movq 0x10(%rsp), %rdx
leaq 0x1a1c3(%rip), %rsi     # 0x26f71
leaq 0x40(%rsp), %rdi
callq 0x2210
jmp 0xcdba
movl 0xd4(%rsp), %edi
callq 0x23e0
movq %rax, %rdx
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x13270
jmp 0xcdda
leaq 0x60(%rsp), %rdi
callq 0x20b0
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rax, %rdx
callq 0xc7b0
jmp 0xcdf8
leaq 0x60(%rsp), %rdi
callq 0x2100
leaq 0x40(%rsp), %rdi
callq 0x2100
leaq 0x3f(%rsp), %rdi
callq 0x21c0
cmpl $0x0, 0xbc(%rsp)
jbe 0xce93
movl 0xbc(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0xce93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0xce87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0xce7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x2100
leaq 0x40(%rsp), %rdi
callq 0x2100
leaq 0x3f(%rsp), %rdi
callq 0x21c0
jmp 0xcec6
jmp 0xce95
jmp 0xce97
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0xcc85
movb $0x1, 0xe7(%rsp)
movb 0xe7(%rsp), %al
andb $0x1, %al
addq $0xe8, %rsp
retq
movq 0x88(%rsp), %rdi
callq 0x2280
nopw %cs:(%rax,%rax)