// File: /workspace/github_cpp_makefile_star2_O3/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 0x2124e1
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
movl 0x4(%rdi), %edx
xorl %r8d, %r8d
movq (%rdi,%r8,8), %rax
cmpq $-0x1, %rax
je 0x2124f2
movq %rax, %r9
shrq $0x20, %r9
cmpl %r9d, %edx
jne 0x212511
movl %eax, %eax
cmpq %rcx, %rax
jae 0x212400
incq %r8
cmpq %r8, %rsi
jne 0x2123d0
movq %rsi, %r8
testq %r8, %r8
jle 0x212441
testq %rcx, %rcx
js 0x212411
cvtsi2ss %rcx, %xmm1
jmp 0x21242a
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 0x2124e3
cmpq %rsi, %r8
jae 0x2124e1
testq %rcx, %rcx
js 0x212459
xorps %xmm1, %xmm1
cvtsi2ss %rcx, %xmm1
jmp 0x212475
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 0x21254f
movq %r11, %rbx
shrq $0x20, %rbx
cmpl %ebx, %edx
jne 0x212530
incq %r8
cmpq %r10, %r9
jae 0x2124c9
incl %r11d
movl (%rdi,%r9,8), %ebx
movq %r11, %r14
subq %rbx, %r14
cmpq %rcx, %r14
jbe 0x2124c9
decq %r8
incq %r9
cmpq %r10, %r9
jb 0x2124ac
movq %r10, %r9
testq %r8, %r8
js 0x21256e
je 0x2124d9
cmpq %rax, %r8
jge 0x2124eb
incq %r10
cmpq %rsi, %r10
jne 0x212484
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x1, %eax
jmp 0x2124e3
leaq 0x35ebc(%rip), %rdi     # 0x2483b5
leaq 0x33109(%rip), %rsi     # 0x245609
leaq 0x35ec3(%rip), %rcx     # 0x2483ca
movl $0x27ed, %edx           # imm = 0x27ED
callq 0x2110
leaq 0x35efb(%rip), %rdi     # 0x248413
leaq 0x330ea(%rip), %rsi     # 0x245609
leaq 0x35ea4(%rip), %rcx     # 0x2483ca
movl $0x27f2, %edx           # imm = 0x27F2
callq 0x2110
leaq 0x35edc(%rip), %rdi     # 0x248413
leaq 0x330cb(%rip), %rsi     # 0x245609
leaq 0x35e85(%rip), %rcx     # 0x2483ca
movl $0x27fb, %edx           # imm = 0x27FB
callq 0x2110
leaq 0x35e5f(%rip), %rdi     # 0x2483b5
leaq 0x330ac(%rip), %rsi     # 0x245609
leaq 0x35e66(%rip), %rcx     # 0x2483ca
movl $0x27fa, %edx           # imm = 0x27FA
callq 0x2110
leaq 0x35eaf(%rip), %rdi     # 0x248424
leaq 0x3308d(%rip), %rsi     # 0x245609
leaq 0x35e47(%rip), %rcx     # 0x2483ca
movl $0x2801, %edx           # imm = 0x2801
callq 0x2110