// File: chhylp123[P]hifiasm/./Correct.h
// Function: InsertSNPVector(haplotype_evdience_alloc*, haplotype_evdience*, long long, char, UC_Read*)
inline void InsertSNPVector(haplotype_evdience_alloc* h, haplotype_evdience* sub_list, long long sub_length, char misBase, 
UC_Read* g_read)
{
    if(sub_length <= 0)
        return;
    long long i = 0; SnpStats *p = NULL;
    kv_pushp(SnpStats, h->snp_stat, &p);
    
    // h->snp_stat[h->available_snp].id = h->available_snp;
    // h->snp_stat[h->available_snp].occ_0 = 0;
    // h->snp_stat[h->available_snp].occ_1 = 0;
    // h->snp_stat[h->available_snp].occ_2 = 0;
    // h->snp_stat[h->available_snp].overlap_num = 0;
    // h->snp_stat[h->available_snp].site = sub_list[0].site;
    // h->snp_stat[h->available_snp].is_homopolymer = 
    // if_is_homopolymer_strict(h->snp_stat[h->available_snp].site, g_read->seq, g_read->length);
    // int8_t* vector = Get_SNP_Vector((*h), h->available_snp);

    p->id = h->snp_stat.n-1;
    p->occ_0 = 0;
    p->occ_1 = 0;
    p->occ_2 = 0;
    p->overlap_num = 0;
    p->site = sub_list[0].site;
    p->is_homopolymer = if_is_homopolymer_strict(p->site, g_read->seq, g_read->length);
    int8_t* vector = Get_SNP_Vector((*h), p->id);
    for (i = 0; i < sub_length; i++)
    {
        if(sub_list[i].type == 0)
        {
            vector[sub_list[i].overlapID] = 0;
            // h->snp_stat[h->available_snp].occ_0++;
            h->snp_stat.a[p->id].occ_0++;
        }
        else if(sub_list[i].type == 1 && sub_list[i].misBase == misBase)
        {
            vector[sub_list[i].overlapID] = 1;
            // h->snp_stat[h->available_snp].occ_1++;
            h->snp_stat.a[p->id].occ_1++;
        }
        else
        {
            vector[sub_list[i].overlapID] = 2;
            // h->snp_stat[h->available_snp].occ_2++;
            h->snp_stat.a[p->id].occ_2++;
        }
        // h->snp_stat[h->available_snp].overlap_num++;
        h->snp_stat.a[p->id].overlap_num++;
    }


    // int new_occ_0 = h->snp_stat[h->available_snp].occ_0 + 1;
    // int new_occ_1 = h->snp_stat[h->available_snp].occ_1;
    int new_occ_0 = h->snp_stat.a[p->id].occ_0 + 1;
    int new_occ_1 = h->snp_stat.a[p->id].occ_1;

    if(filter_snp(new_occ_0, new_occ_1, new_occ_0 + new_occ_1) == 0) ///Fix-attention:definitely wrong
    {
        // h->snp_stat[h->available_snp].score = -1;
        h->snp_stat.a[p->id].score = -1;
    }
    else
    {
        h->core_snp++;


        double consensus = new_occ_0 + new_occ_1 - abs(new_occ_0 - new_occ_1);

        consensus = consensus /((double)(new_occ_0 + new_occ_1));

        ///50% vs 50%///Fix-attention:definitely wrong
        if(new_occ_0 == new_occ_1)
        {
            consensus = consensus + 0.25;
        }
        else if(consensus >= 0.8)
        {
            consensus = consensus + 0.2;
        }
        else if(consensus >= 0.6)
        {
            consensus = consensus + 0.15;
        }
        else if(consensus >= 0.4)
        {
            consensus = consensus + 0.1;
        }
        else if(consensus >= 0.2)
        {
            consensus = consensus + 0.05;
        }
        

        consensus= consensus*((double)(new_occ_0 + new_occ_1));

        // h->snp_stat[h->available_snp].score = consensus;
        h->snp_stat.a[p->id].score = consensus;
    }


    
    // h->available_snp++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jg 0xa1049
jmp 0xa1497
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x220(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x228(%rcx), %rax
jne 0xa10d7
movq -0x8(%rbp), %rax
cmpq $0x0, 0x228(%rax)
je 0xa1093
movq -0x8(%rbp), %rax
movq 0x228(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0xa109e
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0xa109e
movq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x228(%rax)
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rdi
movq -0x8(%rbp), %rax
imulq $0x28, 0x228(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x218(%rax)
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x8(%rbp), %rdx
movq 0x220(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x220(%rdx)
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x220(%rax), %rax
subq $0x1, %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, %edi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0xa0650
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x24(%rax)
movq -0x8(%rbp), %rax
movq 0x1d0(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x1c8(%rcx), %ecx
movq -0x38(%rbp), %rdx
imull (%rdx), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0xa12dc
movq -0x10(%rbp), %rax
imulq $0x18, -0x30(%rbp), %rcx
addq %rcx, %rax
movzbl 0xc(%rax), %eax
cmpl $0x0, %eax
jne 0xa1209
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
imulq $0x18, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0xa12aa
movq -0x10(%rbp), %rax
imulq $0x18, -0x30(%rbp), %rcx
addq %rcx, %rax
movzbl 0xc(%rax), %eax
cmpl $0x1, %eax
jne 0xa1270
movq -0x10(%rbp), %rax
imulq $0x18, -0x30(%rbp), %rcx
addq %rcx, %rax
movsbl 0x14(%rax), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jne 0xa1270
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
imulq $0x18, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
movb $0x1, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0xa12a8
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
imulq $0x18, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
movb $0x2, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0xa12aa
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xa11a9
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %edi
movl -0x48(%rbp), %esi
movl -0x44(%rbp), %edx
addl -0x48(%rbp), %edx
callq 0xc3500
cmpl $0x0, %eax
jne 0xa1355
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
jmp 0xa1497
movq -0x8(%rbp), %rax
movl 0x1c4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c4(%rax)
movl -0x44(%rbp), %eax
addl -0x48(%rbp), %eax
movl -0x44(%rbp), %ecx
subl -0x48(%rbp), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movl -0x44(%rbp), %eax
addl -0x48(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jne 0xa13bd
movsd 0x2e0ea2(%rip), %xmm0   # 0x382250
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xa145f
movsd -0x50(%rbp), %xmm0
movsd 0x2e0e66(%rip), %xmm1   # 0x382230
ucomisd %xmm1, %xmm0
jb 0xa13e4
movsd 0x2ddc38(%rip), %xmm0   # 0x37f010
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xa145d
movsd -0x50(%rbp), %xmm0
movsd 0x2e0e1f(%rip), %xmm1   # 0x382210
ucomisd %xmm1, %xmm0
jb 0xa140b
movsd 0x2e0e49(%rip), %xmm0   # 0x382248
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xa145b
movsd -0x50(%rbp), %xmm0
movsd 0x2e0e20(%rip), %xmm1   # 0x382238
ucomisd %xmm1, %xmm0
jb 0xa1432
movsd 0x2ddbf2(%rip), %xmm0   # 0x37f018
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xa1459
movsd -0x50(%rbp), %xmm0
movsd 0x2ddbd1(%rip), %xmm1   # 0x37f010
ucomisd %xmm1, %xmm0
jb 0xa1457
movsd 0x2e0df3(%rip), %xmm0   # 0x382240
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xa1459
jmp 0xa145b
jmp 0xa145d
jmp 0xa145f
movsd -0x50(%rbp), %xmm0
movl -0x44(%rbp), %eax
addl -0x48(%rbp), %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
cvttsd2si -0x50(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq -0x38(%rbp), %rdx
movl (%rdx), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x1c(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)