// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x70(%rdi), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rdi)
movq $0x0, 0x80(%rdi)
movq (%rsi), %rax
testl %edx, %edx
je 0x86389
cmpq 0xa8(%rbx), %rax
jne 0x864a4
movq 0x90(%rbx), %rax
xorl %edx, %edx
xorl %r12d, %r12d
jmp 0x865b2
cmpq 0xb0(%rbx), %rax
je 0x865f3
xorl %r13d, %r13d
xorl %r12d, %r12d
movsbq 0x18(%r14), %rbp
movq 0x88(%rbx), %rsi
cmpq %rsi, %r13
jl 0x86410
movq (%r15), %rax
testq %rax, %rax
je 0x863d7
subq %rax, %r13
leaq (,%r13,8), %rdx
movq 0x90(%rbx), %rdi
leaq (%rdi,%rax,8), %rsi
cmpq %rax, %r13
jle 0x863ff
callq 0x2360
jmp 0x86404
leaq (%rsi,%rsi), %rax
movq %rax, 0x88(%rbx)
movq 0x90(%rbx), %rdi
shlq $0x4, %rsi
callq 0x2370
movq %rax, 0x90(%rbx)
movq 0x78(%rbx), %r13
jmp 0x86410
callq 0x2160
movq $0x0, 0x70(%rbx)
movq %r13, 0x78(%rbx)
movq 0x90(%rbx), %rax
movq %rbp, (%rax,%r13,8)
movq 0x78(%rbx), %r13
incq %r13
movq %r13, 0x78(%rbx)
movq 0x50(%r14), %rax
testq %rax, %rax
jle 0x8648b
movq 0x40(%r14), %rcx
movq %rax, %rdx
negq %rdx
addq $0x8, %rcx
xorl %esi, %esi
xorl %edi, %edi
imulq $0x38, %rdi, %r8
incq %rdi
addq %rcx, %r8
movq (%r8), %r9
cmpq $-0x1, %r9
jne 0x8646a
leaq (%rdx,%rdi), %r9
incq %r9
incq %rdi
addq $0x38, %r8
cmpq $0x1, %r9
jne 0x8644b
jmp 0x8648b
movq 0x18(%rbx), %r8
shlq $0x7, %r9
leaq (%r8,%r9), %r10
movq 0x8(%r8,%r9), %r8
cmpq %rsi, %r8
cmovaq %r10, %r12
cmovaq %r8, %rsi
cmpq %rax, %rdi
jl 0x86441
movq (%r12), %rax
movq %r12, %r14
cmpq 0xb0(%rbx), %rax
jne 0x8639c
jmp 0x865f3
xorl %r12d, %r12d
xorl %r13d, %r13d
movsbq 0x18(%r14), %rbp
movq 0x88(%rbx), %rsi
cmpq %rsi, %r12
jl 0x8651e
movq (%r15), %rax
testq %rax, %rax
je 0x864e5
subq %rax, %r12
leaq (,%r12,8), %rdx
movq 0x90(%rbx), %rdi
leaq (%rdi,%rax,8), %rsi
cmpq %rax, %r12
jle 0x8650d
callq 0x2360
jmp 0x86512
leaq (%rsi,%rsi), %rax
movq %rax, 0x88(%rbx)
movq 0x90(%rbx), %rdi
shlq $0x4, %rsi
callq 0x2370
movq %rax, 0x90(%rbx)
movq 0x78(%rbx), %r12
jmp 0x8651e
callq 0x2160
movq $0x0, 0x70(%rbx)
movq %r12, 0x78(%rbx)
movq 0x90(%rbx), %rax
movq %rbp, (%rax,%r12,8)
movq 0x78(%rbx), %r12
incq %r12
movq %r12, 0x78(%rbx)
movq 0x70(%r14), %rcx
testq %rcx, %rcx
jle 0x8659b
movq 0x60(%r14), %rdx
addq $0x8, %rdx
movq %rcx, %rsi
negq %rsi
xorl %edi, %edi
xorl %r8d, %r8d
imulq $0x38, %r8, %r9
incq %r8
addq %rdx, %r9
cmpq $-0x1, (%r9)
jne 0x86576
addq $0x38, %r9
leaq (%rsi,%r8), %r10
incq %r10
incq %r8
cmpq $0x1, %r10
jne 0x8655a
jmp 0x8659b
movq 0x18(%rbx), %r10
movq -0x8(%r9), %r9
shlq $0x7, %r9
leaq (%r10,%r9), %r11
movq 0x8(%r10,%r9), %r9
cmpq %rdi, %r9
cmovaq %r11, %r13
cmovaq %r9, %rdi
cmpq %rcx, %r8
jl 0x86550
movq (%r13), %rcx
movq %r13, %r14
cmpq 0xa8(%rbx), %rcx
jne 0x864aa
movq (%r15), %rdx
movq %r12, %rsi
subq %rdx, %rsi
cmpq $0x2, %rsi
jl 0x865f3
movq %rsi, %rcx
shrq $0x3f, %rcx
addq %rsi, %rcx
sarq %rcx
leaq (%rax,%rdx,8), %rdx
leaq (%rax,%r12,8), %rax
addq $-0x8, %rax
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
movq (%rax), %r8
movq %r8, (%rdx,%rsi,8)
movq %rdi, (%rax)
incq %rsi
addq $-0x8, %rax
cmpq %rsi, %rcx
jne 0x865d9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq