// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: Merge_Out_Nodes(Graph*, Node*)
void Merge_Out_Nodes(Graph* DAGCon, Node* currentNode)
{
    ///if this node does not have any output, directly return
    if(Real_Length(Output_Edges((*currentNode))) == 0)
    {
        return;
    }

    RSet buf, out_buf;
    char Bases[4] = {'A', 'C', 'G', 'T'};
    char base;
    long long base_i, weight;
    int flag = 0;
    Node* get_node_1 = NULL;
    Node* out_node_of_get_node_1 = NULL;
    Node* consensus_node_1 = NULL;
    Edge* e_forward_1 = NULL;
    Edge* e_backward_1 = NULL;

    ///merge all base for each base
    for (base_i = 0; base_i < 4; base_i++)
    {
        base = Bases[base_i];

        clear_RSet(&buf);
        flag = 0;
        weight = 0;
        ///should use getOutputEdges, instead of getOutputNodes
        ///check all out-nodes of currentNode
        while(getOutputNodes(&buf, DAGCon, currentNode, &get_node_1))
        {
            ///check the corresponding node, this node must only have one in-node
            ///note this is the Real_Length, instead of the Input_Edges.length
            if((*get_node_1).base == base && Real_Length(Input_Edges(*get_node_1)) == 1)
            {
                if(flag == 0)
                {
                    flag = 1;
                    ///add a new node to merge all out-node
                    consensus_node_1 = get_node_1;
                    ///link consensus_node to currentNode
                    ///set the new edge to be visited
                    if(get_bi_Edge(DAGCon, currentNode, consensus_node_1, &e_forward_1, &e_backward_1))
                    {
                        Visit(*e_forward_1) = 1;
                        Visit(*e_backward_1) = 1;
                    }
                    else
                    {
                        fprintf(stderr, "error\n");
                    }

                    weight = (*e_forward_1).weight;
                }
                else
                {
                    flag++;
                    ///add the weight of get_node->currentNode
                    if(get_bi_Edge(DAGCon, currentNode, get_node_1, &e_forward_1, &e_backward_1))
                    {
                        weight = weight + (*e_forward_1).weight;
                    }
                    else
                    {
                        fprintf(stderr, "error\n");
                    }

                    ///process the out-nodes of get_node
                    clear_RSet(&out_buf);
                    while(getOutputNodes(&out_buf, DAGCon, get_node_1, &out_node_of_get_node_1))
                    {
                        ///link consensus_node to the out-nodes of get_node
                        if(get_bi_Edge(DAGCon, consensus_node_1, out_node_of_get_node_1, &e_forward_1, &e_backward_1))
                        {
                            Visit(*e_forward_1) = 1;
                            Visit(*e_backward_1) = 1;
                            (*e_forward_1).weight += get_Edge_Weight(DAGCon, get_node_1, out_node_of_get_node_1);
                            (*e_backward_1).weight = (*e_forward_1).weight;
                        }
                        else
                        {
                            add_bi_direction_edge(DAGCon, consensus_node_1, out_node_of_get_node_1, 
                            get_Edge_Weight(DAGCon, get_node_1, out_node_of_get_node_1), 1);
                        }
                    }

                    delete_Node_DAGCon(DAGCon, get_node_1);
                }
            }
        }

        if(flag > 1)
        {
            get_bi_Edge(DAGCon, currentNode, consensus_node_1, &e_forward_1, &e_backward_1);
            (*e_forward_1).weight = weight;
            (*e_backward_1).weight = (*e_forward_1).weight;
        }

        if(flag > 0)
        {
            Merge_Out_Nodes(DAGCon, consensus_node_1);   
        }
    }
}

// Assembly:
movq 0x50(%rsi), %rax
cmpq 0x58(%rsi), %rax
je 0x4c617
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %r10d, %r10d
xorl %r11d, %r11d
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
movq %r13, 0x8(%rsp)
leaq 0x1ddca9(%rip), %rax    # 0x229b4d
movb (%r11,%rax), %r15b
xorl %r13d, %r13d
movq $0x0, 0x20(%rsp)
xorl %ebp, %ebp
movq 0x50(%rbx), %rcx
leaq -0x1(%rcx), %rdx
movq %r10, (%rsp)
movb $0x1, %al
cmpq %rcx, %r13
jge 0x4bf20
movq 0x40(%rbx), %rdi
imulq $0x38, %r13, %r8
movq 0x8(%rdi,%r8), %rsi
movb $0x1, %al
cmpq $-0x1, %rsi
je 0x4bee3
movb $0x1, %dil
jmp 0x4bf06
addq %r8, %rdi
addq $0x40, %rdi
cmpq %r13, %rdx
je 0x4bf1d
movq (%rdi), %rsi
addq $0x38, %rdi
incq %r13
cmpq $-0x1, %rsi
je 0x4beea
cmpq %rcx, %r13
setl %dil
testb %dil, %dil
je 0x4bf20
shlq $0x7, %rsi
addq 0x18(%r14), %rsi
incq %r13
xorl %eax, %eax
movq %rsi, %r12
jmp 0x4bf20
movq %rcx, %r13
testb %al, %al
jne 0x4c4cf
movb 0x18(%r12), %sil
cmpb %r15b, %sil
jne 0x4bec2
movq 0x70(%r12), %rax
movq %rax, %rdi
subq 0x78(%r12), %rdi
cmpq $0x1, %rdi
jne 0x4bec2
testl %ebp, %ebp
jne 0x4c08b
movb $0x1, %cl
cmpb $0x44, %sil
je 0x4c048
cmpb $0x44, 0x18(%rbx)
je 0x4c048
leaq -0x1(%rax), %rsi
xorl %edi, %edi
movb $0x1, %cl
cmpq %rax, %rdi
jge 0x4bf8d
movq 0x60(%r12), %r9
imulq $0x38, %rdi, %r10
movb $0x1, %r8b
cmpq $-0x1, 0x8(%r9,%r10)
je 0x4bf92
movb $0x1, %r10b
jmp 0x4bfb2
movb $0x1, %r8b
jmp 0x4bfd4
addq %r9, %r10
addq $0x40, %r10
cmpq %rdi, %rsi
je 0x4bfd1
incq %rdi
cmpq $-0x1, (%r10)
leaq 0x38(%r10), %r10
je 0x4bf99
cmpq %rax, %rdi
setl %r10b
testb %r10b, %r10b
je 0x4bfd4
imulq $0x38, %rdi, %r10
cmpq $-0x1, 0x8(%r9,%r10)
je 0x4bfd4
addq %r10, %r9
incq %rdi
xorl %r8d, %r8d
movq %r9, %rdx
jmp 0x4bfd4
movq %rax, %rdi
testb %r8b, %r8b
jne 0x4c048
movq (%rdx), %r8
cmpq (%rbx), %r8
jne 0x4bf6d
movq 0x8(%rdx), %rax
movq 0x28(%rdx), %rsi
movq 0x18(%r14), %rcx
movq %r8, %rdi
shlq $0x7, %rdi
addq %rcx, %rdi
addq $0x40, %rdi
cmpq 0x10(%rdi), %rsi
jae 0x4c027
movq (%rdi), %r10
imulq $0x38, %rsi, %r9
cmpq %r8, (%r10,%r9)
jne 0x4c027
addq %r9, %r10
cmpq %rax, 0x8(%r10)
jne 0x4c027
movq %r10, 0x8(%rsp)
imulq $0x38, 0x30(%rdx), %rdx
shlq $0x7, %rax
jmp 0x4c03c
imulq $0x38, 0x30(%rdx), %rdx
addq (%rdi), %rdx
movq %rdx, 0x8(%rsp)
shlq $0x7, %rax
imulq $0x38, %rsi, %rdx
addq 0x60(%rcx,%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %ecx, %ecx
testb %cl, %cl
jne 0x4c079
movl $0x1, %eax
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
movq 0x10(%rsp), %rdx
movq %rax, 0x20(%rdx)
movq 0x10(%rcx), %rax
movq %rax, 0x20(%rsp)
movl $0x1, %ebp
movq %r12, %r10
jmp 0x4beb6
movq %r11, %rbp
callq 0x56d4
movq %rbp, %r11
movq 0x8(%rsp), %rcx
jmp 0x4c063
movl %ebp, %edx
movb $0x1, %cl
cmpb $0x44, %sil
je 0x4c18e
cmpb $0x44, 0x18(%rbx)
je 0x4c18e
leaq -0x1(%rax), %rsi
xorl %edi, %edi
movb $0x1, %cl
cmpq %rax, %rdi
jge 0x4c0c9
movq 0x60(%r12), %r9
imulq $0x38, %rdi, %r10
movb $0x1, %r8b
cmpq $-0x1, 0x8(%r9,%r10)
je 0x4c0ce
movb $0x1, %r10b
jmp 0x4c0ee
movb $0x1, %r8b
jmp 0x4c114
addq %r9, %r10
addq $0x40, %r10
cmpq %rdi, %rsi
je 0x4c10d
incq %rdi
cmpq $-0x1, (%r10)
leaq 0x38(%r10), %r10
je 0x4c0d5
cmpq %rax, %rdi
setl %r10b
testb %r10b, %r10b
je 0x4c110
imulq $0x38, %rdi, %r10
cmpq $-0x1, 0x8(%r9,%r10)
je 0x4c110
addq %r10, %r9
incq %rdi
xorl %r8d, %r8d
movq %r9, %rdx
jmp 0x4c110
movq %rax, %rdi
movq (%rsp), %r10
testb %r8b, %r8b
jne 0x4c18c
movq (%rdx), %r8
cmpq (%rbx), %r8
jne 0x4c0a9
movq 0x8(%rdx), %rax
movq 0x28(%rdx), %rsi
movq 0x18(%r14), %rcx
movq %r8, %rdi
shlq $0x7, %rdi
addq %rcx, %rdi
addq $0x40, %rdi
cmpq 0x10(%rdi), %rsi
jae 0x4c167
movq (%rdi), %r10
imulq $0x38, %rsi, %r9
cmpq %r8, (%r10,%r9)
jne 0x4c167
addq %r9, %r10
cmpq %rax, 0x8(%r10)
jne 0x4c167
movq %r10, 0x8(%rsp)
imulq $0x38, 0x30(%rdx), %rdx
shlq $0x7, %rax
jmp 0x4c17c
imulq $0x38, 0x30(%rdx), %rdx
addq (%rdi), %rdx
movq %rdx, 0x8(%rsp)
shlq $0x7, %rax
imulq $0x38, %rsi, %rdx
addq 0x60(%rcx,%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %ecx, %ecx
movq (%rsp), %r10
movl %ebp, %edx
testb %cl, %cl
movq %r11, 0x30(%rsp)
jne 0x4c4ba
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rcx
addq 0x10(%rax), %rcx
movq %rcx, 0x20(%rsp)
incl %edx
movl %edx, 0x2c(%rsp)
xorl %ebp, %ebp
movq 0x50(%r12), %rdx
movb $0x1, %al
cmpq %rdx, %rbp
jge 0x4c21d
movq 0x40(%r12), %rsi
imulq $0x38, %rbp, %rdi
movq 0x8(%rsi,%rdi), %rcx
movb $0x1, %al
cmpq $-0x1, %rcx
je 0x4c1dc
movb $0x1, %dl
jmp 0x4c202
addq %rdi, %rsi
addq $0x40, %rsi
leaq -0x1(%rdx), %rdi
cmpq %rbp, %rdi
je 0x4c21a
movq (%rsi), %rcx
addq $0x38, %rsi
incq %rbp
cmpq $-0x1, %rcx
je 0x4c1e7
cmpq %rdx, %rbp
setl %dl
testb %dl, %dl
je 0x4c21d
shlq $0x7, %rcx
addq 0x18(%r14), %rcx
incq %rbp
xorl %eax, %eax
movq %rcx, 0x18(%rsp)
jmp 0x4c21d
movq %rdx, %rbp
testb %al, %al
jne 0x4c49c
movb $0x1, %al
cmpb $0x44, 0x18(%r10)
je 0x4c332
movq 0x18(%rsp), %rcx
cmpb $0x44, 0x18(%rcx)
je 0x4c332
movq 0x70(%rcx), %rdx
leaq -0x1(%rdx), %rsi
xorl %edi, %edi
movb $0x1, %al
cmpq %rdx, %rdi
jge 0x4c26f
movq 0x18(%rsp), %r8
movq 0x60(%r8), %r9
imulq $0x38, %rdi, %r10
movb $0x1, %r8b
cmpq $-0x1, 0x8(%r9,%r10)
je 0x4c274
movb $0x1, %r10b
jmp 0x4c294
movb $0x1, %r8b
jmp 0x4c2ba
addq %r9, %r10
addq $0x40, %r10
cmpq %rdi, %rsi
je 0x4c2b3
incq %rdi
cmpq $-0x1, (%r10)
leaq 0x38(%r10), %r10
je 0x4c27b
cmpq %rdx, %rdi
setl %r10b
testb %r10b, %r10b
je 0x4c2b6
imulq $0x38, %rdi, %r10
cmpq $-0x1, 0x8(%r9,%r10)
je 0x4c2b6
addq %r10, %r9
incq %rdi
xorl %r8d, %r8d
movq %r9, %rcx
jmp 0x4c2b6
movq %rdx, %rdi
movq (%rsp), %r10
testb %r8b, %r8b
jne 0x4c332
movq (%rcx), %r8
cmpq (%r10), %r8
jne 0x4c24b
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rsi
movq 0x18(%r14), %rdx
movq %r8, %rdi
shlq $0x7, %rdi
addq %rdx, %rdi
addq $0x40, %rdi
cmpq 0x10(%rdi), %rsi
jae 0x4c30d
movq (%rdi), %r10
imulq $0x38, %rsi, %r9
cmpq %r8, (%r10,%r9)
jne 0x4c30d
addq %r9, %r10
cmpq %rax, 0x8(%r10)
jne 0x4c30d
movq %r10, 0x8(%rsp)
imulq $0x38, 0x30(%rcx), %rcx
shlq $0x7, %rax
jmp 0x4c322
imulq $0x38, 0x30(%rcx), %rcx
addq (%rdi), %rcx
movq %rcx, 0x8(%rsp)
shlq $0x7, %rax
imulq $0x38, %rsi, %rcx
addq 0x60(%rdx,%rax), %rcx
movq %rcx, 0x10(%rsp)
xorl %eax, %eax
movq (%rsp), %r10
testb %al, %al
je 0x4c3e4
movq 0x18(%rsp), %rax
movq 0x60(%rax), %rax
movq (%r12), %rcx
leaq 0x40(%rax), %rdx
xorl %esi, %esi
imulq $0x38, %rsi, %rdi
cmpq $-0x1, 0x8(%rax,%rdi)
jne 0x4c369
addq %rdx, %rdi
incq %rsi
cmpq $-0x1, (%rdi)
leaq 0x38(%rdi), %rdi
je 0x4c35c
imulq $0x38, %rsi, %rdi
movq (%rax,%rdi), %r8
incq %rsi
cmpq %rcx, %r8
jne 0x4c34d
leaq (%rax,%rdi), %rcx
movq 0x28(%rcx), %r9
movq 0x18(%r14), %rdx
movq %r8, %rsi
shlq $0x7, %rsi
addq %rsi, %rdx
addq $0x40, %rdx
cmpq 0x10(%rdx), %r9
jae 0x4c3b4
movq (%rdx), %rsi
imulq $0x38, %r9, %r9
cmpq %r8, (%rsi,%r9)
jne 0x4c3b4
movq 0x8(%rax,%rdi), %rax
addq %r9, %rsi
cmpq %rax, 0x8(%rsi)
je 0x4c3bc
imulq $0x38, 0x30(%rcx), %rsi
addq (%rdx), %rsi
movq 0x10(%rsi), %rcx
movl $0x1, %r8d
movq %r14, %rdi
movq %r10, %rsi
movq 0x18(%rsp), %rdx
callq 0x44de5
movq (%rsp), %r10
movq 0x30(%rsp), %r11
jmp 0x4c1b6
movl $0x1, %eax
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
movq 0x10(%rsp), %rcx
movq %rax, 0x20(%rcx)
movq 0x18(%rsp), %rax
movq 0x60(%rax), %rax
movq (%r12), %rcx
leaq 0x40(%rax), %rdx
xorl %esi, %esi
imulq $0x38, %rsi, %rdi
cmpq $-0x1, 0x8(%rax,%rdi)
jne 0x4c42a
addq %rdx, %rdi
incq %rsi
cmpq $-0x1, (%rdi)
leaq 0x38(%rdi), %rdi
je 0x4c41d
imulq $0x38, %rsi, %rdi
movq (%rax,%rdi), %r8
incq %rsi
cmpq %rcx, %r8
jne 0x4c40e
leaq (%rax,%rdi), %rcx
movq 0x28(%rcx), %r9
movq 0x18(%r14), %rdx
movq %r8, %rsi
shlq $0x7, %rsi
addq %rsi, %rdx
addq $0x40, %rdx
cmpq 0x10(%rdx), %r9
jae 0x4c475
movq (%rdx), %rsi
imulq $0x38, %r9, %r9
cmpq %r8, (%rsi,%r9)
jne 0x4c475
movq 0x8(%rax,%rdi), %rax
addq %r9, %rsi
cmpq %rax, 0x8(%rsi)
je 0x4c47d
imulq $0x38, 0x30(%rcx), %rsi
addq (%rdx), %rsi
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rax
addq 0x10(%rsi), %rax
movq %rax, 0x10(%rcx)
movq 0x10(%rsp), %rcx
movq %rax, 0x10(%rcx)
jmp 0x4c1b6
movq %r14, %rdi
movq %r12, %rsi
movq %r11, %rbp
callq 0x868c0
movq (%rsp), %r10
movq %rbp, %r11
movl 0x2c(%rsp), %ebp
jmp 0x4beb6
callq 0x56b8
movl %ebp, %edx
movq (%rsp), %r10
movq 0x30(%rsp), %r11
jmp 0x4c1ae
movl %ebp, %ecx
cmpl $0x2, %ebp
jl 0x4c5ae
cmpb $0x44, 0x18(%rbx)
movq 0x8(%rsp), %r13
je 0x4c5d1
cmpb $0x44, 0x18(%r10)
je 0x4c5d1
movq 0x70(%r10), %rcx
leaq -0x1(%rcx), %rdx
xorl %esi, %esi
movb $0x1, %dil
cmpq %rcx, %rsi
jge 0x4c55f
movq 0x60(%r10), %r8
imulq $0x38, %rsi, %r9
movb $0x1, %dil
cmpq $-0x1, 0x8(%r8,%r9)
je 0x4c51e
movb $0x1, %r9b
jmp 0x4c53e
addq %r8, %r9
addq $0x40, %r9
cmpq %rsi, %rdx
je 0x4c55c
incq %rsi
cmpq $-0x1, (%r9)
leaq 0x38(%r9), %r9
je 0x4c525
cmpq %rcx, %rsi
setl %r9b
testb %r9b, %r9b
je 0x4c55f
imulq $0x38, %rsi, %r9
cmpq $-0x1, 0x8(%r8,%r9)
je 0x4c55f
addq %r9, %r8
incq %rsi
xorl %edi, %edi
movq %r8, %rax
jmp 0x4c55f
movq %rcx, %rsi
testb %dil, %dil
jne 0x4c5cf
movq (%rax), %rdi
cmpq (%rbx), %rdi
jne 0x4c4fe
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rsi
movq 0x18(%r14), %rdx
movq %rdi, %r8
shlq $0x7, %r8
addq %rdx, %r8
addq $0x40, %r8
cmpq 0x10(%r8), %rsi
jae 0x4c5b5
movq (%r8), %r13
imulq $0x38, %rsi, %r9
cmpq %rdi, (%r13,%r9)
jne 0x4c5b5
addq %r9, %r13
cmpq %rcx, 0x8(%r13)
jne 0x4c5b5
shlq $0x7, %rcx
imulq $0x38, 0x30(%rax), %rax
jmp 0x4c5c5
movq 0x8(%rsp), %r13
jmp 0x4c5e3
imulq $0x38, 0x30(%rax), %r13
addq (%r8), %r13
shlq $0x7, %rcx
imulq $0x38, %rsi, %rax
addq 0x60(%rdx,%rcx), %rax
movq %rax, 0x10(%rsp)
movl %ebp, %ecx
movq 0x20(%rsp), %rdx
movq %rdx, 0x10(%r13)
movq 0x10(%rsp), %rax
movq %rdx, 0x10(%rax)
testl %ecx, %ecx
jle 0x4c5fc
movq %r14, %rdi
movq %r10, %rsi
movq %r11, %r15
callq 0x4be58
movq (%rsp), %r10
movq %r15, %r11
incq %r11
cmpq $0x4, %r11
jne 0x4be98
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq