// File: Davidc2525[P]Leaf/compiler/feactures/class/class_handler.cpp
// Function: LEAF::FEACTURE::CLASS::ClassHandler::cyclic(LEAF::HELPER::GRAPH::Node*, LEAF::HELPER::GRAPH::Node*)
bool ClassHandler::cyclic(Node *a, Node *b)
{

    bool p = false;
    vector<Edge *>::iterator x = edges->begin();
    for (; x != edges->end(); x++)
    {
        if ((0 == strcmp((*x)->nodea->name->c_str(), a->name->c_str())) && (0 == strcmp((*x)->nodeb->name->c_str(), b->name->c_str())))
        {
            p = true;
            cout << "cyclic" << endl;
        }
        if (0 == strcmp((*x)->nodea->name->c_str(), b->name->c_str()) && 0 == strcmp((*x)->nodeb->name->c_str(), a->name->c_str()))
        {
            p = true;
            cout << *(*x)->nodeb->name << " no puede hererdar " << *(*x)->nodea->name << ", ya se hereda una a la otra" << endl;
        }
    }

    if (!p)
    {
        vector<Edge *> *result;
        vector<Edge *> *list = new vector<Edge *>;
        this->path_from(a, list);
        vector<Edge *> *path_from_na = this->filter_path_from_by_nodea(a, list);

        vector<Edge *>::iterator pfa_i = path_from_na->begin();

        for (; pfa_i != path_from_na->end(); pfa_i++)
        {
            result = new vector<Edge *>;
            Edge *edge = (*pfa_i);
            if (p)
                return p;

            this->path_from(edge->nodeb, result);
            vector<Edge *>::iterator result_i = result->begin();

            for (; result_i != result->end(); result_i++)
            {
                if (0 == strcmp((*result_i)->nodeb->name->c_str(), b->name->c_str()))
                {
                    p = true;
                }
            }
        }
    }

    cout << "hay camino de " << *a->name << " a " << *b->name << " ? " << (p ? "si" : "no") << endl;

    return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movb $0x0, -0x21(%rbp)
movq (%rax), %rdi
callq 0x32bc0
movq %rax, -0x30(%rbp)
movq -0x98(%rbp), %rax
movq (%rax), %rdi
callq 0x32c30
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x32bf0
testb $0x1, %al
jne 0x327bb
jmp 0x32976
leaq -0x30(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x6120
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x6120
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x6440
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x32864
leaq -0x30(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
callq 0x6120
movq %rax, -0xa8(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x6120
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x6440
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x32864
movb $0x1, -0x21(%rbp)
movq 0x17787(%rip), %rdi     # 0x49fd0
leaq 0x3b20(%rip), %rsi      # 0x36370
callq 0x62c0
movq %rax, %rdi
movq 0x17751(%rip), %rsi     # 0x49fb0
callq 0x6320
leaq -0x30(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x6120
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x6120
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x6440
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x32960
leaq -0x30(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
callq 0x6120
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x6120
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x6440
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x32960
movb $0x1, -0x21(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq 0x176c7(%rip), %rdi     # 0x49fd0
callq 0x6280
movq %rax, %rdi
leaq 0x3a5f(%rip), %rsi      # 0x36377
callq 0x62c0
movq %rax, -0xc0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x32c60
movq -0xc0(%rbp), %rdi
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rsi
callq 0x6280
movq %rax, %rdi
leaq 0x3a3f(%rip), %rsi      # 0x3638b
callq 0x62c0
movq %rax, %rdi
movq 0x17655(%rip), %rsi     # 0x49fb0
callq 0x6320
jmp 0x32962
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x32c80
movq %rax, -0x40(%rbp)
jmp 0x32792
testb $0x1, -0x21(%rbp)
jne 0x32b03
movl $0x18, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, -0xc8(%rbp)
callq 0x32cc0
movq -0xc8(%rbp), %rax
movq -0x98(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x32f30
movq -0x98(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x32e20
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x32bc0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x32c30
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x32bf0
testb $0x1, %al
jne 0x32a00
jmp 0x32b01
movl $0x18, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, -0xd0(%rbp)
callq 0x32cc0
movq -0xd0(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq %rax, -0x70(%rbp)
testb $0x1, -0x21(%rbp)
je 0x32a47
movb -0x21(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x32ba9
movq -0x98(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x48(%rbp), %rdx
callq 0x32f30
movq -0x48(%rbp), %rdi
callq 0x32bc0
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rdi
callq 0x32c30
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x32bf0
testb $0x1, %al
jne 0x32a8c
jmp 0x32ae8
leaq -0x78(%rbp), %rdi
callq 0x32c60
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
callq 0x6120
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x6120
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
callq 0x6440
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x32ad2
movb $0x1, -0x21(%rbp)
jmp 0x32ad4
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
callq 0x32c80
movq %rax, -0x88(%rbp)
jmp 0x32a6c
jmp 0x32aea
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x32c80
movq %rax, -0x90(%rbp)
jmp 0x329dd
jmp 0x32b03
movq 0x174c6(%rip), %rdi     # 0x49fd0
leaq 0x3897(%rip), %rsi      # 0x363a8
callq 0x62c0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x6280
movq %rax, %rdi
leaq 0x3888(%rip), %rsi      # 0x363b7
callq 0x62c0
movq %rax, %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
callq 0x6280
movq %rax, %rdi
leaq 0x386e(%rip), %rsi      # 0x363bb
callq 0x62c0
movq %rax, -0xe0(%rbp)
testb $0x1, -0x21(%rbp)
je 0x32b6f
leaq 0x33a2(%rip), %rax      # 0x35f08
movq %rax, -0xe8(%rbp)
jmp 0x32b7f
leaq 0x3849(%rip), %rax      # 0x363bf
movq %rax, -0xe8(%rbp)
jmp 0x32b7f
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x62c0
movq %rax, %rdi
movq 0x17414(%rip), %rsi     # 0x49fb0
callq 0x6320
movb -0x21(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)