// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/align.c
// Function: mm_fix_bad_ends
static void mm_fix_bad_ends(const mm_reg1_t *r, const mm128_t *a, int bw, int min_match, int32_t *as, int32_t *cnt)
{
	int32_t i, l, m;
	*as = r->as, *cnt = r->cnt;
	if (r->cnt < 3) return;
	m = l = a[r->as].y >> 32 & 0xff;
	for (i = r->as + 1; i < r->as + r->cnt - 1; ++i) {
		int32_t lq, lr, min, max;
		int32_t q_span = a[i].y >> 32 & 0xff;
		if (a[i].y & MM_SEED_LONG_JOIN) break;
		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 >= r->mlen >> 1) break;
	}
	*cnt = r->as + r->cnt - *as;
	m = l = a[r->as + r->cnt - 1].y >> 32 & 0xff;
	for (i = r->as + r->cnt - 2; i > *as; --i) {
		int32_t lq, lr, min, max;
		int32_t q_span = a[i+1].y >> 32 & 0xff;
		if (a[i+1].y & MM_SEED_LONG_JOIN) break;
		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 >= r->mlen >> 1) break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x3, 0x4(%rax)
jge 0x26673
jmp 0x269fd
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq 0x28(%rcx), %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)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x28(%rcx), %ecx
movq -0x8(%rbp), %rdx
addl 0x4(%rdx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2681f
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
movabsq $0x10000000000, %rax    # imm = 0x10000000000
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
je 0x2670b
jmp 0x2681f
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x10(%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, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x10(%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, -0x38(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x26779
movl -0x3c(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x2677f
movl -0x38(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x26795
movl -0x3c(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x2679b
movl -0x38(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
subl -0x40(%rbp), %eax
movl -0x30(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jle 0x267b9
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x40(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x267d2
movl -0x40(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x267d8
movl -0x48(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x2680d
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x267fd
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2680d
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x2c(%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
jl 0x2680f
jmp 0x2681f
jmp 0x26811
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x266a7
movq -0x8(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x8(%rbp), %rax
addl 0x4(%rax), %ecx
movq -0x20(%rbp), %rax
subl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x28(%rcx), %ecx
movq -0x8(%rbp), %rdx
addl 0x4(%rdx), %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)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x4(%rcx), %eax
subl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x269fd
movq -0x10(%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, -0x5c(%rbp)
movq -0x10(%rbp), %rcx
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x4, %rax
addq %rax, %rcx
movabsq $0x10000000000, %rax    # imm = 0x10000000000
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
je 0x268e0
jmp 0x269fd
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
subl %ecx, %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x2694e
movl -0x50(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x26954
movl -0x4c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jle 0x2696a
movl -0x50(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x26970
movl -0x4c(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
subl -0x54(%rbp), %eax
movl -0x30(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jle 0x26997
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
subl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x54(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x269b0
movl -0x54(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x269b6
movl -0x5c(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x269eb
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x269db
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x269eb
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x2c(%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
jl 0x269ed
jmp 0x269fd
jmp 0x269ef
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x26880
popq %rbp
retq
nop