// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: idx_check_rate(unsigned long*, unsigned long, unsigned long, unsigned long, float)
uint32_t idx_check_rate(uint64_t *a, uint64_t a_n, uint64_t tot, uint64_t winlen, float match_rate)
{
    if(a_n == 0) return 0;
    if(tot < winlen) winlen = tot;
    uint64_t k, mm = a[0]>>32, ks, s, e; int64_t p;
    s = 0; e = winlen;
    for (k = ks = 0; k < a_n; k++) {
        assert(a[k] != (uint64_t)-1);
        // if(mm != (a[k]>>32)) {
        //     fprintf(stderr, "***[M::%s::] mm::%lu, (a[%lu]>>32)::%lu\n", 
        //     __func__, mm, k, (a[k]>>32));
        // }
        assert(mm == (a[k]>>32));
        if(((uint32_t)a[k]) >= s && ((uint32_t)a[k]) < e) continue;
        break;
    }
    p = k;
    if(p > 0 && p >= (int64_t)(winlen*match_rate)) return 1;

    for (; k < a_n; k++) {
        assert(a[k] != (uint64_t)-1);
        assert(mm == (a[k]>>32));
        e = ((uint32_t)a[k]) + 1; p++;
        for (; ks < k; ks++) {
            if(e - ((uint32_t)a[ks]) <= winlen) break;
            p--;
        }
        assert(p >= 0);
        if(p > 0 && p >= (int64_t)(winlen*match_rate)) return 1;
    }
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x206fef
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
movl 0x4(%rdi), %edx
xorl %r8d, %r8d
movq (%rdi,%r8,8), %rax
cmpq $-0x1, %rax
je 0x207000
movq %rax, %r9
shrq $0x20, %r9
cmpl %r9d, %edx
jne 0x20701f
movl %eax, %eax
cmpq %rcx, %rax
jae 0x206f0e
incq %r8
cmpq %r8, %rsi
jne 0x206ede
movq %rsi, %r8
testq %r8, %r8
jle 0x206f4f
testq %rcx, %rcx
js 0x206f1f
cvtsi2ss %rcx, %xmm1
jmp 0x206f38
movq %rcx, %rax
shrq %rax
movl %ecx, %r9d
andl $0x1, %r9d
orq %rax, %r9
cvtsi2ss %r9, %xmm1
addss %xmm1, %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %r9
movl $0x1, %eax
cmpq %r9, %r8
jge 0x206ff1
cmpq %rsi, %r8
jae 0x206fef
testq %rcx, %rcx
js 0x206f67
xorps %xmm1, %xmm1
cvtsi2ss %rcx, %xmm1
jmp 0x206f83
movq %rcx, %rax
shrq %rax
movl %ecx, %r9d
andl $0x1, %r9d
orq %rax, %r9
xorps %xmm1, %xmm1
cvtsi2ss %r9, %xmm1
addss %xmm1, %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %rax
xorl %r9d, %r9d
movq %r8, %r10
movq (%rdi,%r10,8), %r11
cmpq $-0x1, %r11
je 0x20705d
movq %r11, %rbx
shrq $0x20, %rbx
cmpl %ebx, %edx
jne 0x20703e
incq %r8
cmpq %r10, %r9
jae 0x206fd7
incl %r11d
movl (%rdi,%r9,8), %ebx
movq %r11, %r14
subq %rbx, %r14
cmpq %rcx, %r14
jbe 0x206fd7
decq %r8
incq %r9
cmpq %r10, %r9
jb 0x206fba
movq %r10, %r9
testq %r8, %r8
js 0x20707c
je 0x206fe7
cmpq %rax, %r8
jge 0x206ff9
incq %r10
cmpq %rsi, %r10
jne 0x206f92
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x1, %eax
jmp 0x206ff1
leaq 0x350ca(%rip), %rdi     # 0x23c0d1
leaq 0x32317(%rip), %rsi     # 0x239325
leaq 0x350d1(%rip), %rcx     # 0x23c0e6
movl $0x27ed, %edx           # imm = 0x27ED
callq 0x2110
leaq 0x35109(%rip), %rdi     # 0x23c12f
leaq 0x322f8(%rip), %rsi     # 0x239325
leaq 0x350b2(%rip), %rcx     # 0x23c0e6
movl $0x27f2, %edx           # imm = 0x27F2
callq 0x2110
leaq 0x350ea(%rip), %rdi     # 0x23c12f
leaq 0x322d9(%rip), %rsi     # 0x239325
leaq 0x35093(%rip), %rcx     # 0x23c0e6
movl $0x27fb, %edx           # imm = 0x27FB
callq 0x2110
leaq 0x3506d(%rip), %rdi     # 0x23c0d1
leaq 0x322ba(%rip), %rsi     # 0x239325
leaq 0x35074(%rip), %rcx     # 0x23c0e6
movl $0x27fa, %edx           # imm = 0x27FA
callq 0x2110
leaq 0x350bd(%rip), %rdi     # 0x23c140
leaq 0x3229b(%rip), %rsi     # 0x239325
leaq 0x35055(%rip), %rcx     # 0x23c0e6
movl $0x2801, %edx           # imm = 0x2801
callq 0x2110