// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/map-algo.c
// Function: mm_filter_bad_seeds
static void mm_filter_bad_seeds(void *km, int as1, int cnt1, mg128_t *a, int min_gap, int diff_thres, int max_ext_len, int max_ext_cnt)
{
	int max_st, max_en, n, i, k, max, *K;
	K = collect_long_gaps(km, as1, cnt1, a, min_gap, &n);
	if (K == 0) return;
	max = 0, max_st = max_en = -1;
	for (k = 0;; ++k) { // traverse long gaps
		int gap, l, n_ins = 0, n_del = 0, qs, rs, max_diff = 0, max_diff_l = -1;
		if (k == n || k >= max_en) {
			if (max_en > 0)
				for (i = K[max_st]; i < K[max_en]; ++i)
					a[as1 + i].y |= MG_SEED_IGNORE;
			max = 0, max_st = max_en = -1;
			if (k == n) break;
		}
		i = K[k];
		gap = ((int32_t)a[as1 + i].y - (int32_t)a[as1 + i - 1].y) - (int32_t)(a[as1 + i].x - a[as1 + i - 1].x);
		if (gap > 0) n_ins += gap;
		else n_del += -gap;
		qs = (int32_t)a[as1 + i - 1].y;
		rs = (int32_t)a[as1 + i - 1].x;
		for (l = k + 1; l < n && l <= k + max_ext_cnt; ++l) {
			int j = K[l], diff;
			if ((int32_t)a[as1 + j].y - qs > max_ext_len || (int32_t)a[as1 + j].x - rs > max_ext_len) break;
			gap = ((int32_t)a[as1 + j].y - (int32_t)a[as1 + j - 1].y) - (int32_t)(a[as1 + j].x - a[as1 + j - 1].x);
			if (gap > 0) n_ins += gap;
			else n_del += -gap;
			diff = n_ins + n_del - abs(n_ins - n_del);
			if (max_diff < diff)
				max_diff = diff, max_diff_l = l;
		}
		if (max_diff > diff_thres && max_diff > max)
			max = max_diff, max_st = k, max_en = max_diff_l;
	}
	kfree(km, K);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
leaq -0x2c(%rbp), %r9
callq 0x2f570
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2eb5f
jmp 0x2ee79
movl $0x0, -0x38(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x34(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0xffffffff, -0x60(%rbp) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0x2eba7
movl -0x34(%rbp), %eax
cmpl -0x28(%rbp), %eax
jl 0x2ec22
cmpl $0x0, -0x28(%rbp)
jle 0x2ebfe
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x28(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x2ebfc
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movabsq $0x20000000000, %rcx    # imm = 0x20000000000
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2ebbb
jmp 0x2ebfe
movl $0x0, -0x38(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x2ec20
jmp 0x2ee6c
jmp 0x2ec22
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0xc(%rbp), %edx
addl -0x30(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subl %ecx, %eax
movq -0x18(%rbp), %rcx
movl -0xc(%rbp), %edx
addl -0x30(%rbp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movq -0x18(%rbp), %rdx
movl -0xc(%rbp), %esi
addl -0x30(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
subq (%rdx), %rcx
subl %ecx, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jle 0x2ecac
movl -0x44(%rbp), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x2ecb7
xorl %eax, %eax
subl -0x44(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x58(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %ecx
xorl %eax, %eax
cmpl -0x2c(%rbp), %ecx
movb %al, -0x69(%rbp)
jge 0x2ed19
movl -0x48(%rbp), %eax
movl -0x34(%rbp), %ecx
addl 0x18(%rbp), %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x2ed25
jmp 0x2ee3a
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x64(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
subl -0x54(%rbp), %eax
cmpl 0x10(%rbp), %eax
jg 0x2ed72
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x64(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
subl -0x58(%rbp), %eax
cmpl 0x10(%rbp), %eax
jle 0x2ed77
jmp 0x2ee3a
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x64(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0xc(%rbp), %edx
addl -0x64(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subl %ecx, %eax
movq -0x18(%rbp), %rcx
movl -0xc(%rbp), %edx
addl -0x64(%rbp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movq -0x18(%rbp), %rdx
movl -0xc(%rbp), %esi
addl -0x64(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
subq (%rdx), %rcx
subl %ecx, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jle 0x2edf3
movl -0x44(%rbp), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x2edfe
xorl %eax, %eax
subl -0x44(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
addl -0x50(%rbp), %eax
movl -0x4c(%rbp), %ecx
subl -0x50(%rbp), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
subl %ecx, %eax
movl %eax, -0x68(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0x2ee2a
movl -0x68(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x2ee2c
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x2ecfb
movl -0x5c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x2ee5c
movl -0x5c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x2ee5c
movl -0x5c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x2ee5e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2eb7b
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2670
addq $0x70, %rsp
popq %rbp
retq
nop