// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: generate_seq_from_node(Graph*, Node*, int)
inline void generate_seq_from_node(Graph* DAGCon, Node* node, int direction)
{
    clear_Queue(&(DAGCon->node_q));
    RSet iter;
    uint64_t max;
    Node* max_node = NULL;
    Node* getNodes = NULL;
    

    if(direction == 0)
    {
        while (node->ID != DAGCon->s_end_nodeID)
        {
            push_to_Queue(&(DAGCon->node_q), node->base);
            clear_RSet(&iter);
            max = 0;
            while(getOutputNodes(&iter, DAGCon, node, &getNodes))
            {
                if(getNodes->weight > max)
                {
                    max = getNodes->weight;
                    max_node = getNodes;
                }
            }
            node = max_node;
        }
    }
    else
    {
        while (node->ID != DAGCon->s_start_nodeID)
        {
            push_to_Queue(&(DAGCon->node_q), node->base);
            clear_RSet(&iter);
            max = 0;
            while(getInputNodes(&iter, DAGCon, node, &getNodes))
            {
                if(getNodes->weight > max)
                {
                    max = getNodes->weight;
                    max_node = getNodes;
                }
            }
            node = max_node;
        }

        long long i, k;
        long long length = (DAGCon->node_q.end - DAGCon->node_q.beg);
        long long length_ex = length/2;
        long long* array = DAGCon->node_q.buffer + DAGCon->node_q.beg;
        for (i = 0; i < length_ex; i++)
        {
            k = array[i];
            array[i] = array[length - i - 1];
            array[length - i - 1] = k;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x70(%rdi), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rdi)
andq $0x0, 0x80(%rdi)
andq $0x0, (%rsp)
xorl %ebp, %ebp
leaq 0x8(%rsp), %r12
movq %rsp, %r13
testl %edx, %edx
je 0x52cfd
movq (%r15), %rax
cmpq 0xa8(%rbx), %rax
je 0x52d18
movsbq 0x18(%r15), %rsi
movq 0x10(%rsp), %rdi
callq 0x63770
andq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x529e9
testl %eax, %eax
je 0x52cb3
movq (%rsp), %rax
movq 0x8(%rax), %rcx
cmpq %r14, %rcx
cmovaq %rax, %rbp
cmovaq %rcx, %r14
jmp 0x52c89
movq %rbp, %r15
jmp 0x52c61
movsbq 0x18(%r15), %rsi
movq 0x10(%rsp), %rdi
callq 0x63770
andq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x5288b
testl %eax, %eax
je 0x52cfa
movq (%rsp), %rax
movq 0x8(%rax), %rcx
cmpq %r14, %rcx
cmovaq %rax, %rbp
cmovaq %rcx, %r14
jmp 0x52cd0
movq %rbp, %r15
movq (%r15), %rax
cmpq 0xb0(%rbx), %rax
jne 0x52cb8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x70(%rbx), %rcx
movq 0x78(%rbx), %rsi
movq %rsi, %rax
subq %rcx, %rax
pushq $0x2
popq %rdi
cqto
idivq %rdi
movq 0x90(%rbx), %rdi
leaq (%rdi,%rcx,8), %rcx
xorl %edx, %edx
testq %rax, %rax
cmovleq %rdx, %rax
leaq (%rdi,%rsi,8), %rsi
addq $-0x8, %rsi
cmpq %rdx, %rax
je 0x52d09
movq (%rcx,%rdx,8), %rdi
movq (%rsi), %r8
movq %r8, (%rcx,%rdx,8)
movq %rdi, (%rsi)
incq %rdx
addq $-0x8, %rsi
jmp 0x52d4a