// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/align.c
// Function: mm_align_sr_rna
static int mm_align_sr_rna(void *km, const mm_mapopt_t *opt, int qlen, const uint8_t *qseq, int tlen, const uint8_t *tseq, const uint8_t *junc, uint8_t *tseq2, uint8_t *junc2,
							const int8_t *mat, int w, int end_bonus, int zdrop, int ksw_flag, ksw_extz_t *ez)
{
	int32_t ilen = opt->q2 * 2, tlen2 = qlen * 2 + ilen;
	int32_t i, ll = 0, lr = 0, nn = 0, n_ins = 0;
	if (!(opt->flag & MM_F_SPLICE)) return 0; // only for spliced alignment
	if (qlen > MM_MAX_QLEN_FLANK || qlen * 2 + ilen > tlen) return 0; // the query sequence can't be too long and the target sequence must be long enough
	for (i = 0; i < qlen; ++i) // exact match length from the left
		if (qseq[i] == tseq[i] && qseq[i] < 4)
			++ll;
	for (i = 0; i < qlen; ++i) // exact match length from the right
		if (qseq[qlen - 1 - i] == tseq[tlen - 1 - i] && qseq[qlen - 1 - i] < 4)
			++lr;
	if (qlen - (ll + lr) > 9) return 0; // qlen may be smaller than ll+lr
	memcpy(tseq2, tseq, qlen);
	memset(&tseq2[qlen], 4, ilen);
	memcpy(&tseq2[qlen + ilen], &tseq[tlen - qlen], qlen);
	if (junc) {
		memcpy(junc2, junc, qlen);
		memset(&junc2[qlen], 0, ilen);
		memcpy(&junc2[qlen + ilen], &junc[tlen - qlen], qlen);
	}
	if (!(opt->flag & MM_F_SPLICE_OLD)) ksw_flag |= KSW_EZ_SPLICE_CMPLX;
	ksw_exts2_sse(km, qlen, qseq, tlen2, tseq2, 5, mat, opt->q, opt->e, opt->q2, opt->noncan, zdrop, end_bonus, opt->junc_bonus, opt->junc_pen, ksw_flag, junc2, ez);
	if (ez->zdropped) return 0;
	if ((ez->cigar[0]&0xf) != KSW_CIGAR_MATCH || (ez->cigar[ez->n_cigar-1]&0xf) != KSW_CIGAR_MATCH) return 0;
	for (i = 0; i < ez->n_cigar; ++i) { // count the number of introns in the alignment
		if ((ez->cigar[i]&0xf) == KSW_CIGAR_N_SKIP)
			++nn;
		else if ((ez->cigar[i]&0xf) == KSW_CIGAR_INS)
			++n_ins;
	}
	if (nn != 1 || n_ins > 0) return 0; // the heuristic only works when there is exactly one intron
	for (i = 0; i < ez->n_cigar; ++i)
		if ((ez->cigar[i]&0xf) == KSW_CIGAR_N_SKIP)
			ez->cigar[i] += (tlen - tlen2) << 4;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq 0x50(%rbp), %rax
movl 0x48(%rbp), %eax
movl 0x40(%rbp), %eax
movl 0x38(%rbp), %eax
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movl %edx, -0x44(%rbp)
movq %rcx, -0x50(%rbp)
movl %r8d, -0x54(%rbp)
movq %r9, -0x60(%rbp)
movq -0x40(%rbp), %rax
movl 0x74(%rax), %eax
shll %eax
movl %eax, -0x64(%rbp)
movl -0x44(%rbp), %eax
shll %eax
addl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
andq $0x80, %rax
cmpq $0x0, %rax
jne 0x27bad
movl $0x0, -0x2c(%rbp)
jmp 0x27f8d
cmpl $0x64, -0x44(%rbp)
jg 0x27bc0
movl -0x44(%rbp), %eax
shll %eax
addl -0x64(%rbp), %eax
cmpl -0x54(%rbp), %eax
jle 0x27bcc
movl $0x0, -0x2c(%rbp)
jmp 0x27f8d
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x27c1e
movq -0x50(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x60(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x27c11
movq -0x50(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x27c11
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x27c13
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x27bd3
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x27c88
movq -0x50(%rbp), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
subl -0x6c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x60(%rbp), %rcx
movl -0x54(%rbp), %edx
subl $0x1, %edx
subl -0x6c(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x27c7b
movq -0x50(%rbp), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
subl -0x6c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x27c7b
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x27c7d
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x27c25
movl -0x44(%rbp), %eax
movl -0x70(%rbp), %ecx
addl -0x74(%rbp), %ecx
subl %ecx, %eax
cmpl $0x9, %eax
jle 0x27ca4
movl $0x0, -0x2c(%rbp)
jmp 0x27f8d
movq 0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
movslq -0x44(%rbp), %rdx
callq 0x2290
movq 0x18(%rbp), %rdi
movslq -0x44(%rbp), %rax
addq %rax, %rdi
movslq -0x64(%rbp), %rdx
movl $0x4, %esi
callq 0x21b0
movq 0x18(%rbp), %rdi
movl -0x44(%rbp), %eax
addl -0x64(%rbp), %eax
cltq
addq %rax, %rdi
movq -0x60(%rbp), %rsi
movl -0x54(%rbp), %eax
subl -0x44(%rbp), %eax
cltq
addq %rax, %rsi
movslq -0x44(%rbp), %rdx
callq 0x2290
cmpq $0x0, 0x10(%rbp)
je 0x27d4a
movq 0x20(%rbp), %rdi
movq 0x10(%rbp), %rsi
movslq -0x44(%rbp), %rdx
callq 0x2290
movq 0x20(%rbp), %rdi
movslq -0x44(%rbp), %rax
addq %rax, %rdi
movslq -0x64(%rbp), %rdx
xorl %esi, %esi
callq 0x21b0
movq 0x20(%rbp), %rdi
movl -0x44(%rbp), %eax
addl -0x64(%rbp), %eax
cltq
addq %rax, %rdi
movq 0x10(%rbp), %rsi
movl -0x54(%rbp), %eax
subl -0x44(%rbp), %eax
cltq
addq %rax, %rsi
movslq -0x44(%rbp), %rdx
callq 0x2290
movq -0x40(%rbp), %rcx
movabsq $0x800000000, %rax      # imm = 0x800000000
andq (%rcx), %rax
cmpq $0x0, %rax
jne 0x27d6c
movl 0x48(%rbp), %eax
orl $0x800, %eax            # imm = 0x800
movl %eax, 0x48(%rbp)
movq -0x38(%rbp), %rdi
movl -0x44(%rbp), %esi
movq -0x50(%rbp), %rdx
movl -0x68(%rbp), %ecx
movq 0x18(%rbp), %r8
movq 0x28(%rbp), %rax
movq -0x40(%rbp), %r9
movl 0x6c(%r9), %r9d
movb %r9b, -0x8b(%rbp)
movq -0x40(%rbp), %r9
movl 0x70(%r9), %r9d
movb %r9b, -0x8a(%rbp)
movq -0x40(%rbp), %r9
movl 0x74(%r9), %r9d
movb %r9b, -0x89(%rbp)
movq -0x40(%rbp), %r9
movl 0x84(%r9), %r9d
movb %r9b, %r13b
movl 0x40(%rbp), %r12d
movl 0x38(%rbp), %r15d
movq -0x40(%rbp), %r9
movl 0x88(%r9), %r9d
movb %r9b, %r14b
movq -0x40(%rbp), %r9
movl 0x8c(%r9), %r9d
movb %r9b, %bl
movl 0x48(%rbp), %r11d
movq 0x20(%rbp), %r10
movq 0x50(%rbp), %r9
movq %r9, -0x88(%rbp)
movl $0x5, %r9d
movq %rax, (%rsp)
movb -0x8b(%rbp), %al
movsbl %al, %eax
movl %eax, 0x8(%rsp)
movb -0x8a(%rbp), %al
movsbl %al, %eax
movl %eax, 0x10(%rsp)
movb -0x89(%rbp), %al
movsbl %al, %eax
movl %eax, 0x18(%rsp)
movq -0x88(%rbp), %rax
movsbl %r13b, %r13d
movl %r13d, 0x20(%rsp)
movl %r12d, 0x28(%rsp)
movl %r15d, 0x30(%rsp)
movsbl %r14b, %r14d
movl %r14d, 0x38(%rsp)
movsbl %bl, %ebx
movl %ebx, 0x40(%rsp)
movl %r11d, 0x48(%rsp)
movq %r10, 0x50(%rsp)
movq %rax, 0x58(%rsp)
callq 0x2fbf0
movq 0x50(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x27e7d
movl $0x0, -0x2c(%rbp)
jmp 0x27f8d
movq 0x50(%rbp), %rax
movq 0x30(%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x0, %eax
jne 0x27eaf
movq 0x50(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x50(%rbp), %rcx
movl 0x24(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x27ebb
movl $0x0, -0x2c(%rbp)
jmp 0x27f8d
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq 0x50(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x27f1f
movq 0x50(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x6c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x3, %eax
jne 0x27ef0
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x27f12
movq 0x50(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x6c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x1, %eax
jne 0x27f10
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x27f12
jmp 0x27f14
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x27ec2
cmpl $0x1, -0x78(%rbp)
jne 0x27f2b
cmpl $0x0, -0x7c(%rbp)
jle 0x27f34
movl $0x0, -0x2c(%rbp)
jmp 0x27f8d
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq 0x50(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x27f86
movq 0x50(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x6c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
cmpl $0x3, %eax
jne 0x27f79
movl -0x54(%rbp), %edx
subl -0x68(%rbp), %edx
shll $0x4, %edx
movq 0x50(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x6c(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x27f7b
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x27f3b
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)