// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: Preorder_Merge(unsigned int, haplotype_evdience_alloc*, int)
void Preorder_Merge(uint32_t snpID, haplotype_evdience_alloc* hap, int is_merge) 
{ 
    int vectorID = hap->snp_stat.a[snpID].id;
    int8_t* vector = Get_SNP_Vector((*hap), vectorID);
    hap->dp.visit[snpID] = 1;
    

    if(is_merge)
    {
        if(hap->snp_stat.a[snpID].is_homopolymer)
        {
            hap->result_stat.homopolymer_num++;
        }
        else
        {
            hap->result_stat.non_homopolymer_num++;
        }
        
        hap->result_stat.score++;
        int flag;
        if((flag = debug_add_to_result_snp_vector(hap, vector, Get_SNP_Vector_Length((*hap))))!= -1)
        {
            fprintf(stderr, "incompatible snp vector....\n");
            exit(0);
        }
    }

    uint32_t* column;
    int j;

    if(hap->dp.backtrack_length[snpID] != 0)
    {
        column = Get_DP_Backtrack_Column(hap->dp, snpID);
        
        if(is_merge)
        {
            int add_ID = 0;
            for (j = 0; j < (int)hap->dp.backtrack_length[snpID]; j++)
            {
                if(hap->snp_stat.a[column[j]].is_homopolymer == 0)
                {
                    add_ID = j;
                }
            }

            for (j = 0; j < (int)hap->dp.backtrack_length[snpID]; j++)
            {
                if(j == add_ID)
                {
                    Preorder_Merge(column[j], hap, 1); 
                }
                else
                {
                    Preorder_Merge(column[j], hap, 0); 
                }
            }
        }
        else
        {
            for (j = 0; j < (int)hap->dp.backtrack_length[snpID]; j++)
            {
                Preorder_Merge(column[j], hap, 0); 
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movl %edi, %r14d
movq 0x218(%rsi), %rcx
movl %edi, %r15d
imulq $0x28, %r15, %rax
movl (%rcx,%rax), %edx
movq 0x1d0(%rsi), %rsi
movl 0x1c8(%rbx), %ecx
movq 0x258(%rbx), %rdi
movb $0x1, (%rdi,%r15)
testl %ebp, %ebp
je 0x22396
imull %edx, %ecx
addq %rcx, %rsi
movq 0x218(%rbx), %rcx
xorl %edx, %edx
cmpb $0x0, 0x24(%rcx,%rax)
sete %dl
incl 0x200(%rbx,%rdx,4)
incl 0x208(%rbx)
movl 0x1c8(%rbx), %edx
movq %rbx, %rdi
callq 0x22080
cmpl $-0x1, %eax
jne 0x22458
movq 0x278(%rbx), %rax
movl (%rax,%r15,4), %eax
testl %eax, %eax
je 0x22449
imull 0x250(%rbx), %r14d
shlq $0x2, %r14
addq 0x280(%rbx), %r14
testl %ebp, %ebp
je 0x22421
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
xorl %esi, %esi
cmpq %rcx, %rdx
je 0x223f0
movq 0x218(%rbx), %rdi
movl (%r14,%rcx,4), %r8d
imulq $0x28, %r8, %r8
cmpb $0x0, 0x24(%rdi,%r8)
cmovel %ecx, %esi
incq %rcx
jmp 0x223ce
movl %esi, %r12d
xorl %r13d, %r13d
cltq
cmpq %rax, %r13
jge 0x22449
xorl %edx, %edx
cmpq %r13, %r12
sete %dl
movl (%r14,%r13,4), %edi
movq %rbx, %rsi
callq 0x2231a
incq %r13
movq 0x278(%rbx), %rax
movl (%rax,%r15,4), %eax
jmp 0x223f6
xorl %r12d, %r12d
cltq
cmpq %rax, %r12
jge 0x22449
movl (%r14,%r12,4), %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2231a
incq %r12
movq 0x278(%rbx), %rax
movl (%rax,%r15,4), %eax
jmp 0x22424
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x230b81(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x1c16d1(%rip), %rdi    # 0x1e3b3a
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
xorl %edi, %edi
callq 0x2250