// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/hit.c
// Function: mp_cal_max_ext
uint64_t *mp_cal_max_ext(void *km, const mp_ntdb_t *nt, int32_t n_reg, mp_reg1_t *reg, const uint64_t *a, int32_t min_ext, int32_t max_ext)
{
	mp128_t *b;
	uint64_t *ext;
	int32_t i;
	if (n_reg <= 0) return 0;
	b = Kmalloc(km, mp128_t, n_reg);
	for (i = 0; i < n_reg; ++i) {
		mp_reg1_t *r = &reg[i];
		b[i].x = nt? r->vs + nt->ctg[r->vid>>1].off + (r->vid&1? nt->ctg[r->vid>>1].len : 0) : a[r->off] >> 32;
		b[i].y = i;
	}
	radix_sort_mp128x(b, b + n_reg);
	ext = Kmalloc(km, uint64_t, n_reg);
	for (i = 0; i < n_reg; ++i) {
		int32_t left = max_ext, right = max_ext, j = b[i].y;
		mp_reg1_t *r = &reg[j];
		if (i > 0) {
			mp_reg1_t *q = &reg[b[i-1].y];
			if (q->vid == r->vid && q->qe >= r->qs) {
				left = r->vs - q->ve < max_ext? r->vs - q->ve : max_ext;
				left = left > min_ext? left : min_ext;
			}
		}
		if (i < n_reg - 1) {
			mp_reg1_t *q = &reg[b[i+1].y];
			if (q->vid == r->vid && r->qe >= q->qs) {
				right = q->vs - r->ve < max_ext? q->vs - r->ve : max_ext;
				right = right > min_ext? right : min_ext;
			}
		}
		ext[j] = (uint64_t)left<<32 | right;
	}
	kfree(km, b);
	return ext;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpl $0x0, -0x1c(%rbp)
jg 0x1b918
movq $0x0, -0x8(%rbp)
jmp 0x1bc6f
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
shlq $0x4, %rsi
callq 0xaeb0
movq %rax, -0x40(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1ba3d
movq -0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1b9e5
movq -0x58(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x58(%rbp), %rdx
movl 0x30(%rdx), %edx
shrl %edx
movl %edx, %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
addq (%rcx), %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1b9c0
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movl 0x30(%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x1b9cb
xorl %eax, %eax
movq %rax, -0x90(%rbp)
jmp 0x1b9cb
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
jmp 0x1b9ff
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rcx
movq -0x40(%rbp), %rax
movslq -0x4c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movslq -0x4c(%rbp), %rcx
movq -0x40(%rbp), %rax
movslq -0x4c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1b934
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x4bd0
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
shlq $0x3, %rsi
callq 0xaeb0
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1bc5a
movl 0x10(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, -0x64(%rbp)
movq -0x28(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
cmpl $0x0, -0x4c(%rbp)
jle 0x1bb6e
movq -0x28(%rbp), %rax
movq -0x40(%rbp), %rcx
movl -0x4c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
imulq $0x68, 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x70(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jne 0x1bb6c
movq -0x78(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x70(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jl 0x1bb6c
movq -0x70(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x78(%rbp), %rcx
subq 0x48(%rcx), %rax
movslq 0x10(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1bb32
movq -0x70(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x78(%rbp), %rcx
subq 0x48(%rcx), %rax
movq %rax, -0xa0(%rbp)
jmp 0x1bb3d
movslq 0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x1bb5a
movl -0x5c(%rbp), %eax
movl %eax, -0xa4(%rbp)
jmp 0x1bb63
movl -0x34(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x1bb6e
movl -0x4c(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1bc31
movq -0x28(%rbp), %rax
movq -0x40(%rbp), %rcx
movl -0x4c(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
imulq $0x68, 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x70(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jne 0x1bc2f
movq -0x70(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x80(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jl 0x1bc2f
movq -0x80(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x70(%rbp), %rcx
subq 0x48(%rcx), %rax
movslq 0x10(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1bbf5
movq -0x80(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x70(%rbp), %rcx
subq 0x48(%rcx), %rax
movq %rax, -0xb0(%rbp)
jmp 0x1bc00
movslq 0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x1bc1d
movl -0x60(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x1bc26
movl -0x34(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x1bc31
movslq -0x5c(%rbp), %rdx
shlq $0x20, %rdx
movslq -0x60(%rbp), %rax
orq %rax, %rdx
movq -0x48(%rbp), %rax
movslq -0x64(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1ba71
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xac90
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)