// File: realuptime[P]PolyDetector/PolyDetector.cpp
// Function: similarCycle(std::vector<PolyCycle, std::allocator<PolyCycle>> const&, PolyCycle const&)
bool similarCycle(const PolyCycles &cycles, const PolyCycle &cycle)
{
#if 1
    for (auto &c : cycles)
    {
        bool equal = true;

        // set already sorted
        for (auto itC = c.idx.cbegin(), itCycle = cycle.idx.cbegin(); itC != c.idx.cend();)
        {
            if (*itC != *itCycle)
            {
                equal = false;
                break;
            }
            bool cEnd = ++itC == c.idx.cend();
            bool cycleEnd = ++itCycle == cycle.idx.cend();
            if (cEnd || cycleEnd)
            {
                if (cEnd != cycleEnd) // contained!
                {
                    return true;
                }
                break;
            }
        }
        
        if (equal)
            return true;
    }
    return false;
#else
    if (cycle.idx.size() < 3) return true;
    
    for (auto &c : cycles)
    {
        assert(c.idx.size() >= 3);
        auto end1 = c.idx.cend();
        auto end2 = cycle.idx.cend();
        --end1;
        --end2;
        if (*c.idx.cbegin() == *cycle.idx.cbegin() && *end1 == *end2)
            return true;
        
        if (c.idx.size() > cycle.idx.size() && c.contains(*end2) && c.contains(*cycle.idx.cbegin()))
            return true;
        if (c.idx.size() < cycle.idx.size() && cycle.contains(*end1) && c.contains(*c.idx.cbegin()))
            return true;
    }
    return false;
#endif
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x141a0
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
callq 0x141d0
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x14200
testb $0x1, %al
jne 0x9e8a
jmp 0x9fd6
leaq 0x70(%rsp), %rdi
callq 0x14240
movq %rax, 0x60(%rsp)
movb $0x1, 0x5f(%rsp)
movq 0x60(%rsp), %rdi
callq 0x14250
movq %rax, 0x50(%rsp)
movq 0x80(%rsp), %rdi
callq 0x14250
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rdi
callq 0x14280
movq %rax, 0x40(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x13170
testb $0x1, %al
jne 0x9ee6
jmp 0x9fb4
leaq 0x50(%rsp), %rdi
callq 0x131c0
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x131c0
movq %rax, %rcx
movl 0x1c(%rsp), %eax
cmpl (%rcx), %eax
je 0x9f15
movb $0x0, 0x5f(%rsp)
jmp 0x9fb4
leaq 0x50(%rsp), %rdi
callq 0x13240
movq %rax, 0x8(%rsp)
movq 0x60(%rsp), %rdi
callq 0x14280
movq 0x8(%rsp), %rdi
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rsi
callq 0x142b0
andb $0x1, %al
movb %al, 0x3f(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x13240
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rdi
callq 0x14280
movq 0x10(%rsp), %rdi
movq %rax, 0x20(%rsp)
leaq 0x20(%rsp), %rsi
callq 0x142b0
andb $0x1, %al
movb %al, 0x2f(%rsp)
testb $0x1, 0x3f(%rsp)
jne 0x9f8c
testb $0x1, 0x2f(%rsp)
je 0x9faf
movb 0x3f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb 0x2f(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x9fad
movb $0x1, 0x97(%rsp)
jmp 0x9fde
jmp 0x9fb4
jmp 0x9ebf
testb $0x1, 0x5f(%rsp)
je 0x9fc5
movb $0x1, 0x97(%rsp)
jmp 0x9fde
jmp 0x9fc7
leaq 0x70(%rsp), %rdi
callq 0x142d0
jmp 0x9e72
movb $0x0, 0x97(%rsp)
movb 0x97(%rsp), %al
andb $0x1, %al
addq $0x98, %rsp
retq
nop