// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0x1c4cd3
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
movl 0x4(%rdi), %edx
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x1c4c16
movq (%rdi,%r8,8), %rax
cmpq $-0x1, %rax
je 0x1c4cfd
movq %rax, %r9
shrq $0x20, %r9
cmpl %r9d, %edx
jne 0x1c4cde
movl %eax, %eax
cmpq %rcx, %rax
jae 0x1c4c19
incq %r8
jmp 0x1c4be7
movq %rsi, %r8
testq %r8, %r8
setle %r10b
testq %rcx, %rcx
js 0x1c4c2c
cvtsi2ss %rcx, %xmm1
jmp 0x1c4c45
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
cmpq %r9, %r8
setl %al
orb %al, %r10b
pushq $0x1
popq %rax
cmpb $0x1, %r10b
jne 0x1c4cd5
xorl %r10d, %r10d
movq %r8, %r11
cmpq %rsi, %r8
jae 0x1c4cd3
movq (%rdi,%r8,8), %rbx
cmpq $-0x1, %rbx
je 0x1c4d3b
movq %rbx, %r14
shrq $0x20, %r14
cmpl %r14d, %edx
jne 0x1c4d5a
incl %ebx
incq %r11
cmpq %r8, %r10
movq %r8, %r14
cmovaq %r10, %r14
cmpq %r8, %r10
jae 0x1c4cb4
movl (%rdi,%r10,8), %r15d
movq %rbx, %r12
subq %r15, %r12
cmpq %rcx, %r12
jbe 0x1c4cb7
decq %r11
incq %r10
jmp 0x1c4c98
movq %r14, %r10
testq %r11, %r11
js 0x1c4d1c
sete %bl
cmpq %r9, %r11
setl %bpl
orb %bl, %bpl
incq %r8
testb %bpl, %bpl
jne 0x1c4c66
jmp 0x1c4cd5
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x356ed(%rip), %rdi     # 0x1fa3d2
leaq 0x327ed(%rip), %rsi     # 0x1f74d9
leaq 0x35696(%rip), %rcx     # 0x1fa389
movl $0x27f2, %edx           # imm = 0x27F2
callq 0x2110
leaq 0x35670(%rip), %rdi     # 0x1fa374
leaq 0x327ce(%rip), %rsi     # 0x1f74d9
leaq 0x35677(%rip), %rcx     # 0x1fa389
movl $0x27ed, %edx           # imm = 0x27ED
callq 0x2110
leaq 0x356c0(%rip), %rdi     # 0x1fa3e3
leaq 0x327af(%rip), %rsi     # 0x1f74d9
leaq 0x35658(%rip), %rcx     # 0x1fa389
movl $0x2801, %edx           # imm = 0x2801
callq 0x2110
leaq 0x35632(%rip), %rdi     # 0x1fa374
leaq 0x32790(%rip), %rsi     # 0x1f74d9
leaq 0x35639(%rip), %rcx     # 0x1fa389
movl $0x27fa, %edx           # imm = 0x27FA
callq 0x2110
leaq 0x35671(%rip), %rdi     # 0x1fa3d2
leaq 0x32771(%rip), %rsi     # 0x1f74d9
leaq 0x3561a(%rip), %rcx     # 0x1fa389
movl $0x27fb, %edx           # imm = 0x27FB
callq 0x2110