// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x0, 0x60(%rdi)
je 0x8cea
cmpl $0x3, %ebp
ja 0x8cd5
movl %ebp, %eax
leaq 0xd0d9(%rip), %rcx      # 0x15da8
movq (%rcx,%rax,8), %rsi
jmp 0x8cdc
leaq 0x73e4(%rip), %rsi      # 0x100c0
leaq 0x81c0(%rip), %rdi      # 0x10ea3
xorl %eax, %eax
callq 0x2030
cmpl $0x3, %ebp
je 0x8d5c
cmpl $0x1, %ebp
jne 0x8d69
movq 0x30(%rbx), %rsi
cmpq %rsi, 0x38(%rbx)
je 0x8ede
xorl %r15d, %r15d
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
xorl %ebp, %ebp
leaq (%r15,%r15,8), %rax
shlq $0x4, %rax
cmpb $0x0, 0x74(%rsi,%rax)
jne 0x8d3c
addq %rax, %rsi
movq %rbx, %rdi
callq 0x8b68
xorl %ecx, %ecx
testb %al, %al
jne 0x8d34
movl %r15d, %ecx
movzbl %al, %eax
addl %eax, %ebp
movl %ecx, %r15d
incl %r15d
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rax
subq %rsi, %rax
sarq $0x4, %rax
imulq %r14, %rax
cmpq %r15, %rax
ja 0x8d11
jmp 0x8ee0
movq %rbx, %rdi
callq 0x90f6
jmp 0x8ef6
movq 0x30(%rbx), %r13
cmpq %r13, 0x38(%rbx)
je 0x8ef6
leaq 0x10(%rsp), %r15
movl %ebp, %eax
movq %rax, 0x20(%rsp)
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
xorl %eax, %eax
xorl %r12d, %r12d
leaq (%rax,%rax,8), %rax
shlq $0x4, %rax
cmpb $0x0, 0x74(%r13,%rax)
jne 0x8eba
addq %rax, %r13
movq %r13, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x586e
testl %eax, %eax
je 0x8eba
cmpl $0x0, 0x60(%rbx)
je 0x8df4
movq %rsp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4d08
movq (%rsp), %rsi
leaq 0x80f3(%rip), %rdi      # 0x10ed0
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x8df4
callq 0x2140
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x80e0(%rip), %rsi      # 0x10eea
leaq 0x80e1(%rip), %rdx      # 0x10ef2
callq 0xe1f8
leaq 0x72a3(%rip), %rsi      # 0x100c0
cmpl $0x3, %ebp
ja 0x8e32
movq 0x20(%rsp), %rax
leaq 0xcf7a(%rip), %rcx      # 0x15da8
movq (%rcx,%rax,8), %rsi
leaq 0x28(%rsp), %rdi
callq 0x2230
movq %r15, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8e5d
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x8e64
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rdx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8b08
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x8e99
callq 0x2140
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x8ead
callq 0x2140
subl $0x1, %r12d
movl $0x0, %eax
cmovbl %eax, %r12d
incl %r12d
movq 0x30(%rbx), %r13
movq 0x38(%rbx), %rcx
subq %r13, %rcx
sarq $0x4, %rcx
imulq %r14, %rcx
movq %r12, %rax
cmpq %r12, %rcx
ja 0x8d92
jmp 0x8ef6
xorl %ebp, %ebp
cmpl $0x0, 0x60(%rbx)
je 0x8ef6
leaq 0x7fc7(%rip), %rdi      # 0x10eb4
movl %ebp, %esi
xorl %eax, %eax
callq 0x2030
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x8f1d
callq 0x2140
jmp 0x8f1d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x8f31
callq 0x2140
movq %rbx, %rdi
callq 0x2200
nop