// File: /workspace/github_cpp_makefile_star2_O3/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 0x5842
testq %rax, %rax
je 0x77e4
movq %rax, %r12
leaq 0x68(%r14), %rdi
leaq 0xc(%rsp), %rsi
movq %rdi, 0xb8(%rsp)
callq 0xb536
movq 0x8(%rax), %rcx
subq (%rax), %rcx
cmpq $0x5, %rcx
jae 0x77f8
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 0x7a7f
leaq 0xa0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x925f(%rip), %rsi      # 0x10a75
leaq 0x925e(%rip), %rdx      # 0x10a7b
leaq 0x90(%rsp), %rdi
callq 0xe45a
movl 0xc(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x787c
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x7875
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x787a
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x787c
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x7844
addl $-0x3, %eax
jmp 0x787c
addl $-0x2, %eax
jmp 0x787c
decl %eax
movl %eax, %esi
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x2190
movq 0x30(%rsp), %rdi
movl 0x38(%rsp), %esi
movl %ebp, %edx
callq 0xbfed
movq 0x90(%rsp), %rcx
movq 0x98(%rsp), %r8
movq 0x38(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r13, %rcx
je 0x78ce
movq 0xa0(%rsp), %rdi
movq 0x30(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x78ec
movl $0xf, %edi
cmpq %r15, %rsi
je 0x78e7
movq 0x40(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x78fb
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x7909
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
leaq 0x20(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x792d
movq %rsi, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x7933
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x80(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x8e18(%rip), %rsi      # 0x1077b
leaq 0x8e12(%rip), %rdx      # 0x1077c
leaq 0x70(%rsp), %rdi
callq 0xe45a
leaq 0x20(%rsp), %r15
movq -0x10(%r15), %rcx
movq -0x8(%r15), %r8
movq 0x78(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r15, %rcx
je 0x7999
movq 0x20(%rsp), %rdi
movq 0x70(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x79ba
movl $0xf, %edi
cmpq %rbp, %rsi
je 0x79b5
movq 0x80(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x79c6
leaq 0x10(%rsp), %rdi
callq 0x2060
jmp 0x79d4
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 0x79f8
movq %rsi, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x79fe
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 0xb79c
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7a3b
callq 0x2140
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x7a4a
callq 0x2140
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a59
callq 0x2140
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7a6d
callq 0x2140
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x7a7f
callq 0x2140
cmpq $0x3, 0x28(%rbx)
jb 0x7ad3
movl 0xc(%rsp), %eax
cmpl %eax, 0x30(%rbx)
jne 0x7ad3
movb $0x1, 0x38(%rbx)
cmpl $0x3, 0x60(%r14)
jb 0x7aa9
leaq 0x8fdb(%rip), %rsi      # 0x10a7c
movq %rbx, %rdi
callq 0xb79c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x707e
testb %al, %al
je 0x7eb1
cmpl $0x2, 0x60(%r14)
jbe 0x77e4
leaq 0x8fc4(%rip), %rsi      # 0x10a92
jmp 0x7ed9
movl 0x60(%r12), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7176
testb %al, %al
je 0x77e4
leaq 0xc(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0xb536
movq (%rax), %r12
movq 0x8(%rax), %rbp
cmpq %rbp, %r12
je 0x77e4
leaq 0x30(%rbx), %rax
movq %rax, 0xc0(%rsp)
leaq 0x8(%rbx), %r15
movq %r14, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
movq %r12, %rsi
callq 0xb536
movq 0x8(%rax), %rcx
subq (%rax), %rcx
cmpq $0x5, %rcx
jb 0x7e9f
movl (%r12), %r13d
cmpq $0x3, 0x28(%rbx)
jb 0x7be2
cmpl %r13d, 0x30(%rbx)
jne 0x7be2
cmpl $0x3, 0x60(%r14)
jb 0x7e45
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x8f19(%rip), %rsi      # 0x10aa2
leaq 0x8f19(%rip), %rdx      # 0x10aa9
callq 0xe45a
movl (%r12), %r13d
movl $0x1, %eax
cmpl $0xa, %r13d
jb 0x7c14
movl $0x4, %eax
movl %r13d, %ecx
movl $0xd1b71759, %esi       # imm = 0xD1B71759
cmpl $0x63, %ecx
jbe 0x7c0d
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x7c12
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x7c14
movl %ecx, %edx
imulq %rsi, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x7bb1
addl $-0x3, %eax
jmp 0x7c14
movq 0x18(%rbx), %rax
cmpq %r15, %rax
je 0x7b5f
cmpl %r13d, 0x20(%rax)
je 0x7bff
movq %rax, %rdi
callq 0x2180
jmp 0x7be6
cmpq %r15, %rax
jne 0x7e9f
jmp 0x7b5f
addl $-0x2, %eax
jmp 0x7c14
decl %eax
movl %eax, %esi
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x2190
movq 0x30(%rsp), %rdi
movl 0x38(%rsp), %esi
movl %r13d, %edx
callq 0xbfed
movq 0x90(%rsp), %rcx
movl $0xf, %edi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rcx
je 0x7c5f
movq 0xa0(%rsp), %rdi
movq 0x98(%rsp), %r8
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
leaq 0x20(%rsp), %r13
jbe 0x7c98
movl $0xf, %edi
leaq 0x40(%rsp), %r9
cmpq %r9, %rsi
je 0x7c93
movq 0x40(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x7ca7
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x7cb5
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r13, 0x10(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x7cd5
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x7cdd
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x8a68(%rip), %rsi      # 0x1077b
leaq 0x8a62(%rip), %rdx      # 0x1077c
callq 0xe45a
movq 0x10(%rsp), %rcx
movl $0xf, %edi
cmpq %r13, %rcx
je 0x7d33
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x7d6a
movl $0xf, %edi
leaq 0x80(%rsp), %r9
cmpq %r9, %rsi
je 0x7d65
movq 0x80(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x7d76
leaq 0x10(%rsp), %rdi
callq 0x2060
jmp 0x7d84
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 0x7da9
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x7daf
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 0xb79c
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x7ded
callq 0x2140
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x7e04
callq 0x2140
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x7e13
callq 0x2140
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7e27
callq 0x2140
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x7e41
callq 0x2140
movl (%r12), %r13d
movq %rbp, %r14
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xc0a4
movq 0xc0(%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 %rbp, %rdx
callq 0x7794
movq %rbp, %rdi
callq 0xc2b6
movq %r14, %rbp
movq 0xb0(%rsp), %r14
addq $0x4, %r12
cmpq %rbp, %r12
jne 0x7b25
jmp 0x77e4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x771a
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb7f2
cmpl $0x2, 0x60(%r14)
jbe 0x77e4
leaq 0x8bad(%rip), %rsi      # 0x10a86
movq %rbx, %rdi
callq 0xb79c
jmp 0x77e4
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7f01
callq 0x2140
jmp 0x7f01
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x7f15
callq 0x2140
jmp 0x7f15
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7f2d
callq 0x2140
jmp 0x7f2d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7f46
callq 0x2140
jmp 0x7f46
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
jne 0x7fe5
jmp 0x7ffc
jmp 0x7f68
movq %rax, %rbx
jmp 0x7fbc
movq %rax, %rbx
jmp 0x7fd0
movq %rax, %rbx
jmp 0x7ffc
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x7f8c
callq 0x2140
jmp 0x7f8c
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x7fa8
callq 0x2140
jmp 0x7fa8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7fbc
callq 0x2140
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7fd0
callq 0x2140
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x7ffc
callq 0x2140
jmp 0x7ffc
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xc2b6
movq %rbx, %rdi
callq 0x2200