// File: chhylp123[P]hifiasm/Hash_Table.cpp
// Function: filter_bad_seed_dp(k_mer_hit*, k_mer_hit*, k_mer_hit*, long, long, double, long)
int64_t filter_bad_seed_dp(k_mer_hit *sk, k_mer_hit *ek, k_mer_hit* a, int64_t a_n, int64_t max_lgap, double small_bw_rate, int64_t min_small_bw)
{
    int64_t k = 0; k_mer_hit *z; double bw_r; int64_t bw, mmgap, occ = 0;
    bw_r = small_bw_rate; bw = min_small_bw; mmgap = max_lgap;
    if(sk) {
        for (k = 0; k < a_n; k++) {
            z = &(a[k]); 
            if(z->cnt < z->readID) continue;
            mmgap = max_lgap;
            if(z->cnt <= 1) mmgap = -1;
            if((sk && (!hit_long_gap(sk, z, mmgap, bw_r, bw))) || 
                                (ek && (!hit_long_gap(z, ek, mmgap, bw_r, bw)))) {
                z->offset = z->self_offset = (uint32_t)-1; occ++;
            } else {
                break;
            }
        }
    }

    if(ek && k < a_n) {
        for (k = a_n-1; k >= 0; k--) {
            z = &(a[k]); 
            if(z->cnt < z->readID) continue;
            mmgap = max_lgap;
            if(z->cnt <= 1) mmgap = -1;
            if((sk && (!hit_long_gap(sk, z, mmgap, bw_r, bw))) || 
                                (ek && (!hit_long_gap(z, ek, mmgap, bw_r, bw)))) {
                z->offset = z->self_offset = (uint32_t)-1; occ++;
            } else {
                break;
            }
        }
    }

    return occ;    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x68(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2ae22
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x2ae20
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x48(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x2ad7f
jmp 0x2ae0f
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x1, 0xc(%rax)
ja 0x2ad99
movq $-0x1, -0x60(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2adc0
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x60(%rbp), %rdx
movsd -0x50(%rbp), %xmm0
movq -0x58(%rbp), %rcx
callq 0x2b7c0
cmpq $0x0, %rax
je 0x2ade7
cmpq $0x0, -0x10(%rbp)
je 0x2ae0b
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
movsd -0x50(%rbp), %xmm0
movq -0x58(%rbp), %rcx
callq 0x2b7c0
cmpq $0x0, %rax
jne 0x2ae0b
movq -0x48(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2ae0d
jmp 0x2ae20
jmp 0x2ae0f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2ad42
jmp 0x2ae22
cmpq $0x0, -0x10(%rbp)
je 0x2af24
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x2af24
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jl 0x2af22
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x48(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x2ae81
jmp 0x2af11
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x1, 0xc(%rax)
ja 0x2ae9b
movq $-0x1, -0x60(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2aec2
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x60(%rbp), %rdx
movsd -0x50(%rbp), %xmm0
movq -0x58(%rbp), %rcx
callq 0x2b7c0
cmpq $0x0, %rax
je 0x2aee9
cmpq $0x0, -0x10(%rbp)
je 0x2af0d
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
movsd -0x50(%rbp), %xmm0
movq -0x58(%rbp), %rcx
callq 0x2b7c0
cmpq $0x0, %rax
jne 0x2af0d
movq -0x48(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2af0f
jmp 0x2af22
jmp 0x2af11
movq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2ae47
jmp 0x2af24
movq -0x68(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nop