// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %r8, 0x28(%rsp)
movq %rcx, %r15
movq %rsi, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
xorl %r13d, %r13d
testq %rdi, %rdi
je 0x17b46
testq %r15, %r15
movl $0x0, %ebx
cmovgq %r15, %rbx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rdx, 0x30(%rsp)
movq %rdx, %r14
xorl %r12d, %r12d
cmpq %r13, %rbx
je 0x17bfb
movl 0xc(%r14), %eax
movl (%r14), %ecx
andl %esi, %ecx
cmpl %ecx, %eax
jb 0x17b3a
pushq $-0x1
popq %rbp
cmpl $0x2, %eax
jb 0x17ae4
movq 0x28(%rsp), %rbp
movq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rcx
callq 0x17fd5
testq %rax, %rax
je 0x17b2d
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x17bfb
movq %r14, %rdi
movq %rbp, %rdx
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rcx
callq 0x17fd5
testq %rax, %rax
jne 0x17b4b
orq $-0x1, 0x4(%r14)
incq %r12
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
incq %r13
addq $0x10, %r14
jmp 0x17ac1
xorl %r12d, %r12d
jmp 0x17b50
movq 0x30(%rsp), %rdx
cmpq $0x0, 0x18(%rsp)
sete %al
cmpq %r15, %r13
setge %cl
orb %al, %cl
jne 0x17bfb
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
pushq $-0x1
popq %rsi
movq %r15, %rax
shlq $0x4, %rax
movq %rdx, %r13
addq %rdx, %rax
testq %r15, %r15
jle 0x17bfb
decq %r15
leaq -0x10(%rax), %r14
movl -0x4(%rax), %ecx
movl -0x10(%rax), %edx
andl %ebx, %edx
movq %r14, %rax
cmpl %edx, %ecx
jb 0x17b7c
cmpl $0x2, %ecx
movq 0x28(%rsp), %rbp
cmovbq %rsi, %rbp
cmpq $0x0, 0x20(%rsp)
je 0x17bcb
movq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rcx
callq 0x17fd5
testq %rax, %rax
je 0x17beb
movq %r14, %rdi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rcx
callq 0x17fd5
testq %rax, %rax
jne 0x17bfb
orq $-0x1, 0x4(%r14)
incq %r12
movq %r13, %rdx
jmp 0x17b6c
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq