// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/map-algo.c
// Function: mm_fix_bad_ends_alt
static void mm_fix_bad_ends_alt(const mg128_t *a, int32_t score, int bw, int min_match, int32_t *as, int32_t *cnt)
{
	int32_t i, l, m, as0 = *as, cnt0 = *cnt;
	if (cnt0 < 3) return;
	m = l = a[as0].y >> 32 & 0xff;
	for (i = as0 + 1; i < as0 + cnt0 - 1; ++i) {
		int32_t lq, lr, min, max;
		int32_t q_span = a[i].y >> 32 & 0xff;
		lr = (int32_t)a[i].x - (int32_t)a[i-1].x;
		lq = (int32_t)a[i].y - (int32_t)a[i-1].y;
		min = lr < lq? lr : lq;
		max = lr > lq? lr : lq;
		if (max - min > l >> 1) *as = i;
		l += min;
		m += min < q_span? min : q_span;
		if (l >= bw << 1 || (m >= min_match && m >= bw) || m >= score>>1) break;
	}
	*cnt = as0 + cnt0 - *as;
	m = l = a[as0 + cnt0 - 1].y >> 32 & 0xff;
	for (i = as0 + cnt0 - 2; i > *as; --i) {
		int32_t lq, lr, min, max;
		int32_t q_span = a[i+1].y >> 32 & 0xff;
		lr = (int32_t)a[i+1].x - (int32_t)a[i].x;
		lq = (int32_t)a[i+1].y - (int32_t)a[i].y;
		min = lr < lq? lr : lq;
		max = lr > lq? lr : lq;
		if (max - min > l >> 1) *cnt = i + 1 - *as;
		l += min;
		m += min < q_span? min : q_span;
		if (l >= bw << 1 || (m >= min_match && m >= bw) || m >= score>>1) break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x3, -0x3c(%rbp)
jge 0x2e806
jmp 0x2eb0c
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2e976
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
subl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x2e8d4
movl -0x44(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x2e8da
movl -0x40(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0x2e8f0
movl -0x44(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x2e8f6
movl -0x40(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
subl -0x48(%rbp), %eax
movl -0x30(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jle 0x2e914
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x48(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x2e92d
movl -0x48(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x2e933
movl -0x50(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movl -0x10(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x2e964
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x2e958
movl -0x34(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x2e964
movl -0x34(%rbp), %eax
movl -0xc(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jl 0x2e966
jmp 0x2e976
jmp 0x2e968
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2e832
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movq -0x20(%rbp), %rax
subl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
addl -0x3c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x2eb0c
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
subl %ecx, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x2ea61
movl -0x58(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x2ea67
movl -0x54(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jle 0x2ea7d
movl -0x58(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x2ea83
movl -0x54(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
subl -0x5c(%rbp), %eax
movl -0x30(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jle 0x2eaaa
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
subl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x5c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x2eac3
movl -0x5c(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x2eac9
movl -0x64(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movl -0x10(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x2eafa
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x2eaee
movl -0x34(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x2eafa
movl -0x34(%rbp), %eax
movl -0xc(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jl 0x2eafc
jmp 0x2eb0c
jmp 0x2eafe
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2e9bf
popq %rbp
retq
nop