// File: /workspace/github_cpp_makefile_star2_O3/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 0x8da2
cmpl $0x3, %ebp
ja 0x8d8d
movl %ebp, %eax
leaq 0xd021(%rip), %rcx      # 0x15da8
movq (%rcx,%rax,8), %rsi
jmp 0x8d94
leaq 0x733c(%rip), %rsi      # 0x100d0
leaq 0x8118(%rip), %rdi      # 0x10eb3
xorl %eax, %eax
callq 0x2030
cmpl $0x3, %ebp
je 0x8e1a
cmpl $0x1, %ebp
jne 0x8e27
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rax
cmpq %rsi, %rax
je 0x8f9c
xorl %r15d, %r15d
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
xorl %ebp, %ebp
leaq (%r15,%r15,8), %rcx
shlq $0x4, %rcx
cmpb $0x0, 0x74(%rsi,%rcx)
jne 0x8dff
addq %rcx, %rsi
movq %rbx, %rdi
callq 0x8c34
xorl %ecx, %ecx
testb %al, %al
jne 0x8def
movl %r15d, %ecx
movzbl %al, %eax
addl %eax, %ebp
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rax
movl %ecx, %r15d
incl %r15d
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x4, %rcx
imulq %r14, %rcx
cmpq %r15, %rcx
ja 0x8dcc
jmp 0x8f9e
movq %rbx, %rdi
callq 0x91a6
jmp 0x8fb4
movq 0x30(%rbx), %r13
cmpq %r13, 0x38(%rbx)
je 0x8fb4
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 0x8f78
addq %rax, %r13
movq %r13, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x5954
testl %eax, %eax
je 0x8f78
cmpl $0x0, 0x60(%rbx)
je 0x8eb2
movq %rsp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4e48
movq (%rsp), %rsi
leaq 0x8045(%rip), %rdi      # 0x10ee0
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x8eb2
callq 0x2140
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x8032(%rip), %rsi      # 0x10efa
leaq 0x8033(%rip), %rdx      # 0x10f02
callq 0xe45a
leaq 0x71f5(%rip), %rsi      # 0x100d0
cmpl $0x3, %ebp
ja 0x8ef0
movq 0x20(%rsp), %rax
leaq 0xcebc(%rip), %rcx      # 0x15da8
movq (%rcx,%rax,8), %rsi
leaq 0x28(%rsp), %rdi
callq 0x2220
movq %r15, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8f1b
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x8f22
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 0x8bd4
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x8f57
callq 0x2140
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x8f6b
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 0x8e50
jmp 0x8fb4
xorl %ebp, %ebp
cmpl $0x0, 0x60(%rbx)
je 0x8fb4
leaq 0x7f19(%rip), %rdi      # 0x10ec4
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 0x8fdb
callq 0x2140
jmp 0x8fdb
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x8fef
callq 0x2140
movq %rbx, %rdi
callq 0x2200
nop