// File: /workspace/github_cpp_makefile_star2_O2/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 0x537b5
cmpl $0x1, %edx
jne 0x537c2
movl $0x1, (%r8)
andl $0x0, (%r15)
jmp 0x5391f
andl $0x0, (%r15)
andl $0x0, (%r8)
jmp 0x5391f
movq %rsi, %r12
movq %rdi, %r13
andl $0x0, (%r15)
andl $0x0, (%r8)
leal -0x1(%rdx), %eax
movslq %eax, %rbp
xorl %ebx, %ebx
testl %edx, %edx
movl $0x0, %r14d
movq %rdx, 0x8(%rsp)
cmovgl %edx, %r14d
movq %r8, 0x10(%rsp)
cmpq %rbx, %r14
je 0x5390c
testq %rbx, %rbx
je 0x53873
cmpq %rbp, %rbx
jge 0x538b2
movl -0x4(%r12,%rbx,4), %edx
movl (%r12,%rbx,4), %edi
movl 0x4(%r12,%rbx,4), %eax
movq 0x218(%r13), %rcx
imulq $0x28, %rdx, %rsi
movl 0x20(%rcx,%rsi), %r9d
imulq $0x28, %rdi, %rdx
movl 0x20(%rcx,%rdx), %r10d
subl %r10d, %r9d
movq %r15, %rdi
cmpl $0xa, %r9d
jb 0x5384d
imulq $0x28, %rax, %rdi
subl 0x20(%rcx,%rdi), %r10d
movq %r15, %rdi
cmpl $0xa, %r10d
jb 0x5384d
movq %r8, %rdi
addq %rcx, %rsi
addq $0x20, %rsi
incl (%rdi)
addq %rcx, %rdx
addq $0x20, %rdx
movl (%rdx), %edx
cmpl (%rsi), %edx
ja 0x538e9
imulq $0x28, %rax, %rax
cmpl 0x20(%rcx,%rax), %edx
jae 0x538aa
jmp 0x538e9
movl (%r12), %ecx
movl 0x4(%r12), %edx
movq 0x218(%r13), %rax
imulq $0x28, %rcx, %rcx
movl 0x20(%rax,%rcx), %edi
imulq $0x28, %rdx, %rdx
subl 0x20(%rax,%rdx), %edi
movq %r15, %rsi
cmpl $0xa, %edi
jb 0x5389e
movq %r8, %rsi
incl (%rsi)
movl 0x20(%rax,%rcx), %ecx
cmpl 0x20(%rax,%rdx), %ecx
jb 0x538e9
incq %rbx
jmp 0x537ee
movl -0x4(%r12,%rbx,4), %ecx
movl (%r12,%rbx,4), %edx
movq 0x218(%r13), %rax
imulq $0x28, %rcx, %rcx
movl 0x20(%rax,%rcx), %edi
imulq $0x28, %rdx, %rdx
subl 0x20(%rax,%rdx), %edi
movq %r15, %rsi
cmpl $0xa, %edi
jb 0x538dd
movq %r8, %rsi
incl (%rsi)
movl 0x20(%rax,%rdx), %edx
cmpl 0x20(%rax,%rcx), %edx
jbe 0x538aa
movq 0x1ff6f0(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x190073(%rip), %rdi    # 0x1e396d
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq 0x10(%rsp), %r8
jmp 0x538aa
movl (%r15), %edx
movl (%r8), %ecx
leal (%rcx,%rdx), %eax
movq 0x8(%rsp), %r8
cmpl %r8d, %eax
jne 0x5392e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1ff6ab(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x193eb2(%rip), %rsi    # 0x1e77f1
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0