// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/align.c
// Function: mm_align1_inv
static int mm_align1_inv(void *km, const mm_mapopt_t *opt, const mm_idx_t *mi, int qlen, uint8_t *qseq0[2], const mm_reg1_t *r1, const mm_reg1_t *r2, mm_reg1_t *r_inv, ksw_extz_t *ez)
{ // NB: this doesn't work with the qstrand mode
	int tl, ql, score, ret = 0, q_off, t_off;
	uint8_t *tseq, *qseq;
	int8_t mat[25];
	void *qp;

	memset(r_inv, 0, sizeof(mm_reg1_t));
	if (!(r1->split&1) || !(r2->split&2)) return 0;
	if (r1->id != r1->parent && r1->parent != MM_PARENT_TMP_PRI) return 0;
	if (r2->id != r2->parent && r2->parent != MM_PARENT_TMP_PRI) return 0;
	if (r1->rid != r2->rid || r1->rev != r2->rev) return 0;
	ql = r1->rev? r1->qs - r2->qe : r2->qs - r1->qe;
	tl = r2->rs - r1->re;
	if (ql < opt->min_chain_score || ql > opt->max_gap) return 0;
	if (tl < opt->min_chain_score || tl > opt->max_gap) return 0;

	ksw_gen_ts_mat(5, mat, opt->a, opt->b, opt->transition, opt->sc_ambi);
	tseq = (uint8_t*)kmalloc(km, tl);
	mm_idx_getseq(mi, r1->rid, r1->re, r2->rs, tseq);
	qseq = r1->rev? &qseq0[0][r2->qe] : &qseq0[1][qlen - r2->qs];

	mm_seq_rev(ql, qseq);
	mm_seq_rev(tl, tseq);
	qp = ksw_ll_qinit(km, 2, ql, qseq, 5, mat);
	score = ksw_ll_i16(qp, tl, tseq, opt->q, opt->e, &q_off, &t_off);
	kfree(km, qp);
	mm_seq_rev(ql, qseq);
	mm_seq_rev(tl, tseq);
	if (score < opt->min_dp_max) goto end_align1_inv;
	q_off = ql - (q_off + 1), t_off = tl - (t_off + 1);
	mm_align_pair(km, opt, ql - q_off, qseq + q_off, tl - t_off, tseq + t_off, 0, mat, (int)(opt->bw * 1.5), -1, opt->zdrop, KSW_EZ_EXTZ_ONLY, ez);
	if (ez->n_cigar == 0) goto end_align1_inv; // should never be here
	mm_append_cigar(r_inv, ez->n_cigar, ez->cigar);
	r_inv->p->dp_score = ez->max;
	r_inv->id = -1;
	r_inv->parent = MM_PARENT_UNSET;
	r_inv->inv = 1;
	r_inv->rev = !r1->rev;
	r_inv->rid = r1->rid;
	r_inv->div = -1.0f;
	if (r_inv->rev == 0) {
		r_inv->qs = r2->qe + q_off;
		r_inv->qe = r_inv->qs + ez->max_q + 1;
	} else {
		r_inv->qe = r2->qs - q_off;
		r_inv->qs = r_inv->qe - (ez->max_q + 1);
	}
	r_inv->rs = r1->re + t_off;
	r_inv->re = r_inv->rs + ez->max_t + 1;
	mm_update_extra(r_inv, &qseq[q_off], &tseq[t_off], mat, opt->q, opt->e, opt->flag & MM_F_EQX, !(opt->flag & (MM_F_SR|MM_F_SR_RNA)));
	ret = 1;
end_align1_inv:
	kfree(km, tseq);
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movl %ecx, -0x34(%rbp)
movq %r8, -0x40(%rbp)
movq %r9, -0x48(%rbp)
movl $0x0, -0x58(%rbp)
movq 0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x21b0
movq -0x48(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x8, %eax
andl $0x3, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x25b32
movq 0x10(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x8, %eax
andl $0x3, %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x25b3e
movl $0x0, -0x14(%rbp)
jmp 0x26067
movq -0x48(%rbp), %rax
movl (%rax), %eax
movq -0x48(%rbp), %rcx
cmpl 0x20(%rcx), %eax
je 0x25b63
movq -0x48(%rbp), %rax
cmpl $-0x2, 0x20(%rax)
je 0x25b63
movl $0x0, -0x14(%rbp)
jmp 0x26067
movq 0x10(%rbp), %rax
movl (%rax), %eax
movq 0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
je 0x25b88
movq 0x10(%rbp), %rax
cmpl $-0x2, 0x20(%rax)
je 0x25b88
movl $0x0, -0x14(%rbp)
jmp 0x26067
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
movq 0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x25bb6
movq -0x48(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
movq 0x10(%rbp), %rcx
movl 0x3c(%rcx), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
cmpl %ecx, %eax
je 0x25bc2
movl $0x0, -0x14(%rbp)
jmp 0x26067
movq -0x48(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x25bea
movq -0x48(%rbp), %rax
movl 0x10(%rax), %eax
movq 0x10(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0x9c(%rbp)
jmp 0x25bfe
movq 0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x48(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x48(%rbp), %rcx
subl 0x1c(%rcx), %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jl 0x25c30
movl -0x50(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jle 0x25c3c
movl $0x0, -0x14(%rbp)
jmp 0x26067
movl -0x4c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jl 0x25c54
movl -0x4c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jle 0x25c60
movl $0x0, -0x14(%rbp)
jmp 0x26067
leaq -0x90(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x64(%rax), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movl 0x68(%rax), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movl 0x7c(%rax), %eax
movb %al, %r8b
movq -0x28(%rbp), %rax
movl 0x80(%rax), %eax
movl $0x5, %edi
movsbl %dl, %edx
movsbl %cl, %ecx
movsbl %r8b, %r8d
movsbl %al, %r9d
callq 0x26110
movq -0x20(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x1aae0
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %edx
movq 0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x68(%rbp), %r8
callq 0x8ac0
movq -0x48(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x25d05
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
jmp 0x25d24
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x34(%rbp), %ecx
movq 0x10(%rbp), %rdx
subl 0x10(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x50(%rbp), %edi
movq -0x70(%rbp), %rsi
callq 0x272d0
movl -0x4c(%rbp), %edi
movq -0x68(%rbp), %rsi
callq 0x272d0
movq -0x20(%rbp), %rdi
movl -0x50(%rbp), %edx
movq -0x70(%rbp), %rcx
leaq -0x90(%rbp), %r9
movl $0x2, %esi
movl $0x5, %r8d
callq 0x2e8f0
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x68(%rbp), %rdx
movq -0x28(%rbp), %rax
movl 0x6c(%rax), %ecx
movq -0x28(%rbp), %rax
movl 0x70(%rax), %r8d
leaq -0x5c(%rbp), %r9
leaq -0x60(%rbp), %rax
movq %rax, (%rsp)
callq 0x2eca0
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x1a8c0
movl -0x50(%rbp), %edi
movq -0x70(%rbp), %rsi
callq 0x272d0
movl -0x4c(%rbp), %edi
movq -0x68(%rbp), %rsi
callq 0x272d0
movl -0x54(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x9c(%rcx), %eax
jge 0x25ddd
jmp 0x26054
movl -0x50(%rbp), %eax
movl -0x5c(%rbp), %ecx
addl $0x1, %ecx
subl %ecx, %eax
movl %eax, -0x5c(%rbp)
movl -0x4c(%rbp), %eax
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
subl %ecx, %eax
movl %eax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x50(%rbp), %edx
subl -0x5c(%rbp), %edx
movq -0x70(%rbp), %rcx
movslq -0x5c(%rbp), %rax
addq %rax, %rcx
movl -0x4c(%rbp), %r8d
subl -0x60(%rbp), %r8d
movq -0x68(%rbp), %r9
movslq -0x60(%rbp), %rax
addq %rax, %r9
leaq -0x90(%rbp), %rbx
movq -0x28(%rbp), %rax
cvtsi2sdl 0x14(%rax), %xmm0
movsd 0x32353(%rip), %xmm1    # 0x58190
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r11d
movq -0x28(%rbp), %rax
movl 0x90(%rax), %r10d
movq 0x20(%rbp), %rax
xorl %r14d, %r14d
movq $0x0, (%rsp)
movq %rbx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movl %r10d, 0x20(%rsp)
movl $0x40, 0x28(%rsp)
movq %rax, 0x30(%rsp)
callq 0x27340
movq 0x20(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x25e98
jmp 0x26054
movq 0x18(%rbp), %rdi
movq 0x20(%rbp), %rax
movl 0x24(%rax), %esi
movq 0x20(%rbp), %rax
movq 0x30(%rax), %rdx
callq 0x27880
movq 0x20(%rbp), %rax
movl (%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, 0x4(%rax)
movq 0x18(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x18(%rbp), %rax
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movq 0x18(%rbp), %rax
movl 0x3c(%rax), %ecx
andl $0xfffff7ff, %ecx       # imm = 0xFFFFF7FF
orl $0x800, %ecx            # imm = 0x800
movl %ecx, 0x3c(%rax)
movq -0x48(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movq 0x18(%rbp), %rax
movl 0x3c(%rax), %ecx
andl $0x1, %edx
shll $0xa, %edx
andl $0xfffffbff, %ecx       # imm = 0xFFFFFBFF
orl %edx, %ecx
movl %ecx, 0x3c(%rax)
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
movss 0x31c5a(%rip), %xmm0    # 0x57b98
movss %xmm0, 0x44(%rax)
movq 0x18(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x25f80
movq 0x10(%rbp), %rax
movl 0x14(%rax), %ecx
addl -0x5c(%rbp), %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq 0x18(%rbp), %rax
movl 0x10(%rax), %ecx
movq 0x20(%rbp), %rax
addl 0x4(%rax), %ecx
addl $0x1, %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x25fab
movq 0x10(%rbp), %rax
movl 0x10(%rax), %ecx
subl -0x5c(%rbp), %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x14(%rax)
movq 0x18(%rbp), %rax
movl 0x14(%rax), %ecx
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
subl %eax, %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
addl -0x60(%rbp), %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq 0x18(%rbp), %rax
movl 0x18(%rax), %ecx
movq 0x20(%rbp), %rax
addl 0x8(%rax), %ecx
addl $0x1, %ecx
movq 0x18(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq 0x18(%rbp), %rdi
movq -0x70(%rbp), %rsi
movslq -0x5c(%rbp), %rax
addq %rax, %rsi
movq -0x68(%rbp), %rdx
movslq -0x60(%rbp), %rax
addq %rax, %rdx
leaq -0x90(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x6c(%rax), %eax
movb %al, %r8b
movq -0x28(%rbp), %rax
movl 0x70(%rax), %eax
movb %al, %r9b
movq -0x28(%rbp), %rax
movq (%rax), %rax
andq $0x4000000, %rax        # imm = 0x4000000
movl %eax, %r10d
movq -0x28(%rbp), %r11
movabsq $0x8000001000, %rax     # imm = 0x8000001000
andq (%r11), %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movsbl %r8b, %r8d
movsbl %r9b, %r9d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x28380
movl $0x1, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1a8c0
movl -0x58(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)