// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/./Correct.h
// Function: count_nearby_snps(haplotype_evdience_alloc*, unsigned int*, int, int*, int*)
inline void count_nearby_snps(haplotype_evdience_alloc* hap, uint32_t* SNPs, int SNPsLen, int* nearsnp, int* non_nearsnps)
{
    long long i, current_id, large_id, small_id;
    long long distance = 10;

    

    if(SNPsLen == 1)
    {
        (*non_nearsnps) = 1;
        (*nearsnp) = 0;
        return;
    }

    if(SNPsLen == 0)
    {
        (*nearsnp) = 0;
        (*non_nearsnps) = 0;
        return;
    }

    (*nearsnp) = 0;
    (*non_nearsnps) = 0;

    for (i = 0; i < SNPsLen; i++)
    {
        if(i > 0 && i < SNPsLen - 1)
        {
            current_id= SNPs[i];

            ///since SNPs[i - 1].site is larger than SNPs[i]
            large_id = SNPs[i - 1];
            small_id = SNPs[i + 1];
            

            if(hap->snp_stat.a[large_id].site - hap->snp_stat.a[current_id].site < distance
              ||
              hap->snp_stat.a[current_id].site - hap->snp_stat.a[small_id].site < distance)
            {
                (*nearsnp)++;
            }
            else
            {
                (*non_nearsnps)++;
            }

            if(hap->snp_stat.a[current_id].site > hap->snp_stat.a[large_id].site || 
               hap->snp_stat.a[current_id].site < hap->snp_stat.a[small_id].site)
            {
                fprintf(stderr, "error\n");
            }
        }
        else if(i == 0)
        {
            current_id= SNPs[i];
            small_id = SNPs[i + 1];
            if(hap->snp_stat.a[current_id].site - hap->snp_stat.a[small_id].site < distance)
            {
                (*nearsnp)++;
            }
            else
            {
                (*non_nearsnps)++;
            }

            if(hap->snp_stat.a[current_id].site < hap->snp_stat.a[small_id].site)
            {
                fprintf(stderr, "error\n");
            }
        }
        else
        {
            large_id = SNPs[i - 1];
            current_id= SNPs[i];
            if(hap->snp_stat.a[large_id].site - hap->snp_stat.a[current_id].site < distance)
            {
                (*nearsnp)++;
            }
            else
            {
                (*non_nearsnps)++;
            }

            if(hap->snp_stat.a[current_id].site > hap->snp_stat.a[large_id].site)
            {
                fprintf(stderr, "error\n");
            }
            
        }
        
    }

    if((*nearsnp) + (*non_nearsnps) != SNPsLen)
    {
        fprintf(stderr, "(*nearsnp): %d, (*non_nearsnps): %d, SNPsLen: %d\n", (*nearsnp), (*non_nearsnps), SNPsLen);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
testl %edx, %edx
je 0x876db
movl %edx, %r10d
cmpl $0x1, %edx
jne 0x876e8
movl $0x1, (%r8)
movl $0x0, (%r15)
jmp 0x87835
xorl %eax, %eax
movl %eax, (%r15)
movl %eax, (%r8)
jmp 0x87835
xorl %eax, %eax
movl %eax, (%r15)
movl %eax, (%r8)
testl %r10d, %r10d
jle 0x87827
movq %rsi, %r12
movq %rdi, %r13
movslq %r10d, %rbp
leal -0x1(%r10), %eax
movslq %eax, %rbx
xorl %r14d, %r14d
movq %r10, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
testq %r14, %r14
je 0x87794
cmpq %rbx, %r14
jge 0x877d9
movl -0x4(%r12,%r14,4), %edx
movl (%r12,%r14,4), %edi
movl 0x4(%r12,%r14,4), %eax
movq 0x218(%r13), %rcx
leaq (%rdx,%rdx,4), %rsi
movl 0x20(%rcx,%rsi,8), %r9d
leaq (%rdi,%rdi,4), %rdx
movl 0x20(%rcx,%rdx,8), %r11d
subl %r11d, %r9d
movq %r15, %rdi
cmpl $0xa, %r9d
jb 0x8776c
leaq (%rax,%rax,4), %rdi
subl 0x20(%rcx,%rdi,8), %r11d
movq %r15, %rdi
cmpl $0xa, %r11d
jb 0x8776c
movq %r8, %rdi
leaq (%rcx,%rsi,8), %rsi
addq $0x20, %rsi
incl (%rdi)
leaq (%rcx,%rdx,8), %rdx
addq $0x20, %rdx
movl (%rdx), %edx
cmpl (%rsi), %edx
ja 0x87810
leaq (%rax,%rax,4), %rax
cmpl 0x20(%rcx,%rax,8), %edx
jae 0x877cb
jmp 0x87810
movl (%r12), %ecx
movl 0x4(%r12), %edx
movq 0x218(%r13), %rax
leaq (%rcx,%rcx,4), %rcx
movl 0x20(%rax,%rcx,8), %edi
leaq (%rdx,%rdx,4), %rdx
subl 0x20(%rax,%rdx,8), %edi
movq %r15, %rsi
cmpl $0xa, %edi
jb 0x877bf
movq %r8, %rsi
incl (%rsi)
movl 0x20(%rax,%rcx,8), %ecx
cmpl 0x20(%rax,%rdx,8), %ecx
jb 0x87810
incq %r14
cmpq %r14, %rbp
jne 0x87716
jmp 0x87827
movl -0x4(%r12,%r14,4), %ecx
movl (%r12,%r14,4), %edx
movq 0x218(%r13), %rax
leaq (%rcx,%rcx,4), %rcx
movl 0x20(%rax,%rcx,8), %edi
leaq (%rdx,%rdx,4), %rdx
subl 0x20(%rax,%rdx,8), %edi
movq %r15, %rsi
cmpl $0xa, %edi
jb 0x87804
movq %r8, %rsi
incl (%rsi)
movl 0x20(%rax,%rdx,8), %edx
cmpl 0x20(%rax,%rcx,8), %edx
jbe 0x877cb
movq %r8, %rbx
callq 0x5aad
movq %rbx, %r8
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r10
jmp 0x877cb
movl (%r15), %edx
movl (%r8), %ecx
leal (%rcx,%rdx), %eax
cmpl %r10d, %eax
jne 0x87844
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x202795(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x1a1f3c(%rip), %rsi    # 0x229791
movl %r10d, %r8d
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0