// File: /workspace/github_cpp_makefile_star2_O1/realuptime[P]PolyDetector/PolyDetector.cpp
// Function: PolyDetector::BuildCycle(unsigned int, PolyCycle)
bool PolyDetector::BuildCycle(uint32_t id, PolyCycle cycle) // as value!
{
    //if (cycle.startIdx != id && cycle.idx.size() > 2)
    //    return true;
    
    //if (cycle.idx.size() >= 7)
    //    return true;
    
    auto l = findLine(id);
    if (!l)
        return true;
    
    if (_neighbors[id].size() < 2)
    {
        return true;
    }
    
    if (verbose > 2)
        cycle.print((std::string("[PROC:") + std::to_string(id) + std::string("]")).c_str());
    
    if (cycle.canBeClosed(*this, id))
    {
        cycle.isClosed = true;
        
        if (verbose > 2)
            cycle.print("[CLOSED] ");
        
        if (!similarCycle(_cycles, cycle))
        {
            if (cycle.accepted(*this))
            {
                _cycles.push_back(cycle);
                if (verbose > 2)
                    cycle.print("[ACCEPTED] ");
                //logoutf("nCycles:%u", uint32_t(_cycles.size()));
                //return false;
            }
            else
            {
                if (verbose > 2)
                    cycle.print("[NOT ACCEPTED] ");
            }
        }
        else
        {
            if (verbose > 2)
                cycle.print("[CYCLE_EXISTS] ");
        }
        
        return true;
    }
    
    if (!cycle.AddLineId(*this, l->id))
    {
        return true;
    }
    
#if 0 // disable entire process checking
#if 0
    if (l->processed + 1 == cycle.startIdx)
    {
        if (verbose > 2)
        {
            logoutf("line %s can't be added to cycle %s! processed: %u!", l->toString(*this).c_str(), cycle.toString().c_str(), l->processed - 1);
        }
        //printf("procHit for %u!\n", l->id);
        return true;
    }
#else
    if (cycleProcessed(cycle))
    {
        if (verbose > 2)
            cycle.print("[PROCESSED!] ");
        return true;
    }
    processed.push_back(cycle.idx);
#endif
#endif

    for (auto &nid : _neighbors[id])
    {
        if (_neighbors[nid].size() < 2) continue;
        if (cycle.canBeClosed(*this, nid) || !cycle.contains(nid))
        {
            if (verbose > 2)
                cycle.print((std::string("[NEIGN:") + std::to_string(nid) + std::string("]")).c_str());
            if (!BuildCycle(nid, cycle))
            {
                return false;
                //break;
            }
        }
    }
    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, %rbx
movq %rdi, %r14
movl %esi, 0xc(%rsp)
movl $0x1, %edx
callq 0x5706
testq %rax, %rax
je 0x770b
movq %rax, %r12
leaq 0x68(%r14), %r15
leaq 0xc(%rsp), %rsi
movq %r15, %rdi
callq 0xb3c8
movq 0x8(%rax), %rcx
subq (%rax), %rcx
cmpq $0x5, %rcx
jae 0x771f
movb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, 0x60(%r14)
jb 0x79b7
leaq 0xa0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x9328(%rip), %rsi      # 0x10a65
leaq 0x9327(%rip), %rdx      # 0x10a6b
leaq 0x90(%rsp), %rdi
callq 0xe1f8
movl 0xc(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x77a3
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x779c
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x77a1
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x77a3
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x776b
addl $-0x3, %eax
jmp 0x77a3
addl $-0x2, %eax
jmp 0x77a3
decl %eax
movl %eax, %esi
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x2190
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %esi
movl %ebp, %edx
callq 0xbea5
movq 0x90(%rsp), %rcx
movq 0x98(%rsp), %r8
movq 0x18(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x77f5
movq 0xa0(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x7815
movl $0xf, %esi
leaq 0x20(%rsp), %rdi
cmpq %rdi, 0x10(%rsp)
je 0x7810
movq 0x20(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x7829
movq 0x10(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x7837
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
leaq 0x40(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x785b
movq %rsi, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x7861
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x80(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x8eda(%rip), %rsi      # 0x1076b
leaq 0x8ed4(%rip), %rdx      # 0x1076c
leaq 0x70(%rsp), %rdi
callq 0xe1f8
leaq 0x40(%rsp), %r13
movq -0x10(%r13), %rcx
movq -0x8(%r13), %r8
movq 0x78(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x78c7
movq 0x40(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x78e5
movl $0xf, %esi
cmpq %rbp, 0x70(%rsp)
je 0x78e0
movq 0x80(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x78f6
movq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x2060
jmp 0x7904
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
leaq 0x60(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x7928
movq %rsi, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x792e
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0xb62c
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x796b
callq 0x2140
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x797a
callq 0x2140
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x7989
callq 0x2140
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
leaq 0xa0(%rsp), %r13
je 0x79a5
callq 0x2140
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x79b7
callq 0x2140
cmpq $0x3, 0x28(%rbx)
jb 0x7a0b
movl 0xc(%rsp), %eax
cmpl %eax, 0x30(%rbx)
jne 0x7a0b
movb $0x1, 0x38(%rbx)
cmpl $0x3, 0x60(%r14)
jb 0x79e1
leaq 0x9093(%rip), %rsi      # 0x10a6c
movq %rbx, %rdi
callq 0xb62c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6fad
testb %al, %al
je 0x7df5
cmpl $0x2, 0x60(%r14)
jbe 0x770b
leaq 0x907c(%rip), %rsi      # 0x10a82
jmp 0x7e1d
movl 0x60(%r12), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x70c2
testb %al, %al
je 0x770b
leaq 0xc(%rsp), %rsi
movq %r15, %rdi
callq 0xb3c8
movq (%rax), %r12
movq 0x8(%rax), %rax
movq %rax, 0xc0(%rsp)
cmpq %rax, %r12
je 0x770b
leaq 0x30(%rbx), %rax
movq %rax, 0xb8(%rsp)
leaq 0x8(%rbx), %rbp
movq %r14, 0xb0(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xb3c8
movq 0x8(%rax), %rdx
subq (%rax), %rdx
movl $0x3, %ecx
cmpq $0x5, %rdx
jb 0x7dd1
movl (%r12), %r13d
cmpq $0x3, 0x28(%rbx)
jb 0x7a92
cmpl %r13d, 0x30(%rbx)
je 0x7ab6
movq 0x18(%rbx), %rax
cmpq %rbp, %rax
je 0x7aab
cmpl %r13d, 0x20(%rax)
je 0x7aab
movq %rax, %rdi
callq 0x2180
jmp 0x7a96
xorl %ecx, %ecx
cmpq %rbp, %rax
jne 0x7dd1
cmpl $0x3, 0x60(%r14)
jb 0x7d71
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x8fb2(%rip), %rsi      # 0x10a92
leaq 0x8fb2(%rip), %rdx      # 0x10a99
callq 0xe1f8
movl (%r12), %r13d
movl $0x1, %eax
cmpl $0xa, %r13d
jb 0x7b40
movl $0x4, %eax
movl %r13d, %ecx
movl $0xd1b71759, %esi       # imm = 0xD1B71759
cmpl $0x63, %ecx
jbe 0x7b39
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x7b3e
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x7b40
movl %ecx, %edx
imulq %rsi, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x7b08
addl $-0x3, %eax
jmp 0x7b40
addl $-0x2, %eax
jmp 0x7b40
decl %eax
movl %eax, %esi
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x2190
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %esi
movl %r13d, %edx
callq 0xbea5
movq 0x90(%rsp), %rcx
movl $0xf, %esi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rcx
je 0x7b8b
movq 0xa0(%rsp), %rsi
movq 0x98(%rsp), %r8
movq 0x18(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq 0x40(%rsp), %r13
jbe 0x7bc1
movl $0xf, %esi
leaq 0x20(%rsp), %rdi
cmpq %rdi, 0x10(%rsp)
je 0x7bbc
movq 0x20(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x7bd5
movq 0x10(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x7be3
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r13, 0x30(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x7c03
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x7c0b
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x8b2a(%rip), %rsi      # 0x1076b
leaq 0x8b24(%rip), %rdx      # 0x1076c
callq 0xe1f8
movq 0x30(%rsp), %rcx
movl $0xf, %esi
cmpq %r13, %rcx
je 0x7c61
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %r8
movq 0x78(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x7c95
movl $0xf, %esi
leaq 0x80(%rsp), %rdi
cmpq %rdi, 0x70(%rsp)
je 0x7c90
movq 0x80(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x7ca6
movq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x2060
jmp 0x7cb4
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
leaq 0x60(%rsp), %rsi
movq %rsi, 0x50(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x7cd9
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x7cdf
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0xb62c
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x7d1d
callq 0x2140
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x7d34
callq 0x2140
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x7d43
callq 0x2140
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7d57
callq 0x2140
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x7d71
callq 0x2140
movq %rbx, %rsi
movq %r15, %r14
movl (%r12), %r13d
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0xbf5c
movq 0xb8(%rsp), %rcx
movzwl 0x8(%rcx), %eax
leaq 0xf8(%rsp), %rdx
movw %ax, 0x8(%rdx)
movq (%rcx), %rax
movq %rax, (%rdx)
movq 0xb0(%rsp), %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x76c0
movq %r15, %rdi
callq 0xc16e
xorl %ecx, %ecx
movq %r14, %r15
movq 0xb0(%rsp), %r14
cmpl $0x3, %ecx
je 0x7dde
testl %ecx, %ecx
jne 0x770b
addq $0x4, %r12
cmpq 0xc0(%rsp), %r12
jne 0x7a60
jmp 0x770b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7646
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb682
cmpl $0x2, 0x60(%r14)
jbe 0x770b
leaq 0x8c59(%rip), %rsi      # 0x10a76
movq %rbx, %rdi
callq 0xb62c
jmp 0x770b
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7e45
callq 0x2140
jmp 0x7e45
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x7e59
callq 0x2140
jmp 0x7e59
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x7eaf
jmp 0x7ebb
jmp 0x7ed4
jmp 0x7ef3
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x7e89
callq 0x2140
jmp 0x7e89
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x7ea5
callq 0x2140
jmp 0x7ea5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7ebe
callq 0x2140
jmp 0x7ebe
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7ed7
callq 0x2140
jmp 0x7ed7
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x7f08
callq 0x2140
jmp 0x7f08
movq %rax, %rbx
jmp 0x7f08
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xc16e
movq %rbx, %rdi
callq 0x2200