// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: generate_result_vector(haplotype_evdience_alloc*, int)
void generate_result_vector(haplotype_evdience_alloc* hap, int pathLen)
{
    if(pathLen != hap->dp.current_snp_num)
    {
        fprintf(stderr, "error\n");
    }


    int8_t* vector = Get_Result_SNP_Vector((*hap));
    memset(vector, -1, Get_SNP_Vector_Length((*hap)));
    hap->result_stat.occ_0 = 0;
    hap->result_stat.occ_1 = 0;
    hap->result_stat.occ_2 = 0;
    hap->result_stat.score = pathLen;
    hap->result_stat.homopolymer_num = 0;
    hap->result_stat.non_homopolymer_num = 0;

    long long snpID1;
    long long j = 0;
    int flag, vectorID;
    int current_score;
    for (j = 0; j < pathLen; j++)
    {
        snpID1 = hap->dp.buffer[j];
        vectorID = hap->snp_stat.a[snpID1].id;
        vector = Get_SNP_Vector((*hap), vectorID);
        if(hap->snp_stat.a[snpID1].is_homopolymer)
        {
            hap->result_stat.homopolymer_num++;
        }
        else
        {
            hap->result_stat.non_homopolymer_num++;
        }

        if((flag = debug_add_to_result_snp_vector(hap, vector, Get_SNP_Vector_Length((*hap))))!= -1)
        {
            fprintf(stderr, "incompatible snp vector....\n");
            exit(0);
        }
    }
    hap->result_stat.overlap_num = hap->result_stat.occ_0 + hap->result_stat.occ_1;
    

    

    ///check if this is a useful snp vector
    if(hap->result_stat.overlap_num !=0 && filter_one_snp_advance_nearby(hap, hap->result_stat.occ_0 + 1, 
    hap->result_stat.occ_1, hap->result_stat.overlap_num + 1,
    hap->result_stat.homopolymer_num, hap->result_stat.non_homopolymer_num,
    hap->dp.buffer, pathLen))
    {
        current_score = calculate_score(hap->result_stat.occ_0 + 1, hap->result_stat.occ_1);
        ///first useful snp vector
        if(hap->dp.max_snp_num < pathLen)
        {
            hap->dp.max_snp_num = pathLen;
            hap->dp.max_score = current_score;
            memcpy(hap->dp.max_buffer, hap->dp.buffer, sizeof(uint32_t) * pathLen);
        }///if we have multiple single best snp vector, select the vector with max score
        else if(hap->dp.max_snp_num == pathLen)
        {
            if(current_score > hap->dp.max_score)
            {
                hap->dp.max_score = current_score;
                memcpy(hap->dp.max_buffer, hap->dp.buffer, sizeof(uint32_t) * pathLen);
            }
        }
    }

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
cmpl %esi, 0x2a8(%rdi)
jne 0x2268a
movq 0x1e0(%rbx), %rdi
movl 0x1c8(%rbx), %edx
movl $0xff, %esi
callq 0x20e0
movl %r14d, 0x208(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x1f4(%rbx)
andl $0x0, 0x204(%rbx)
movslq %r14d, %r15
xorl %r12d, %r12d
testq %r15, %r15
movl $0x0, %r13d
cmovgq %r15, %r13
cmpq %r12, %r13
je 0x225ea
movq 0x290(%rbx), %rax
movl (%rax,%r12,4), %eax
movq 0x218(%rbx), %rcx
imulq $0x28, %rax, %rax
movl 0x1c8(%rbx), %edx
movl (%rcx,%rax), %esi
imull %edx, %esi
addq 0x1d0(%rbx), %rsi
xorl %edi, %edi
cmpb $0x0, 0x24(%rcx,%rax)
sete %dil
incl 0x200(%rbx,%rdi,4)
movq %rbx, %rdi
callq 0x22080
incq %r12
cmpl $-0x1, %eax
je 0x22577
movq 0x230a12(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x1c1562(%rip), %rdi    # 0x1e3b3a
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
xorl %edi, %edi
callq 0x2250
movl 0x1f4(%rbx), %esi
movl 0x1f8(%rbx), %edx
movl %edx, %ecx
addl %esi, %ecx
movl %ecx, 0x1f0(%rbx)
je 0x22680
incl %esi
incl %ecx
movl 0x200(%rbx), %r8d
movl 0x204(%rbx), %r9d
movq %rbx, %rdi
pushq %r14
pushq 0x290(%rbx)
callq 0x53694
popq %rcx
popq %rdx
testl %eax, %eax
je 0x22680
movl 0x1f4(%rbx), %edi
movl 0x1f8(%rbx), %esi
incl %edi
callq 0x536d7
cmpl %r14d, 0x2a0(%rbx)
jge 0x22676
movl %r14d, 0x2a0(%rbx)
movl %eax, 0x2a4(%rbx)
movq 0x290(%rbx), %rsi
movq 0x298(%rbx), %rdi
shlq $0x2, %r15
movq %r15, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2160
jne 0x22680
cmpl 0x2a4(%rbx), %eax
jg 0x2264d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x23094f(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x1c12d2(%rip), %rdi    # 0x1e396d
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
jmp 0x22535