// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/jump.c
// Function: mm_jump_split_left
static void mm_jump_split_left(void *km, const mm_idx_t *mi, const mm_mapopt_t *opt, int32_t qlen, const uint8_t *qseq0, mm_reg1_t *r, int32_t ts_strand)
{
	uint8_t *tseq = 0, *qseq = 0;
	int32_t i, n, l, i0, m, mm0;
	int32_t i0_anno = -1, n_anno = 0, mm0_anno = 0, i0_misc = -1, n_misc = 0, mm0_misc = 0;
	int32_t ext = 1 + (opt->b + opt->a - 1) / opt->a + 1;
	int32_t clip = !r->rev? r->qs : qlen - r->qe;
	int32_t extt = clip < ext? clip : ext;
	const mm_idx_jjump1_t *a;

	if (mm_jump_check(km, mi, qlen, qseq0, r, ext + MM_MIN_EXON_LEN, 1) < 0) return;
	a = mm_idx_jump_get(mi, r->rid, r->rs - extt, r->rs + ext, &n);
	if (n == 0) return;

	for (i = 0; i < n; ++i) { // traverse possible jumps
		const mm_idx_jjump1_t *ai = &a[i];
		int32_t tlen, tl1, j, mm1, mm2;
		assert(ai->off >= r->rs - extt && ai->off <= r->rs + ext);
		if (ts_strand * ai->strand < 0) continue; // wrong strand
		if (ai->off2 >= ai->off) continue; // wrong direction
		if (ai->off - ai->off2 < 6) continue; // intron too small
		if (ai->off2 < clip + ext) continue; // not long enough
		if (tseq == 0) {
			tseq = Kcalloc(km, uint8_t, (clip + ext) * 2); // tseq and qseq are allocated together
			qseq = tseq + clip + ext;
			mm_jump_get_qseq_seq(km, qlen, qseq0, r, 1, clip + ext, qseq);
		}
		tl1 = clip + (ai->off - r->rs);
		tlen = mm_idx_getseq2(mi, 0, r->rid, ai->off, r->rs + ext, &tseq[tl1]);
		assert(tlen == r->rs + ext - ai->off);
		tlen = mm_idx_getseq2(mi, 0, r->rid, ai->off2 - tl1, ai->off2, tseq);
		assert(tlen == tl1);
		for (j = 0, mm1 = 0; j < tl1; ++j)
			if (qseq[j] != tseq[j] || qseq[j] > 3 || tseq[j] > 3)
				++mm1;
		for (mm2 = 0; j < clip + ext; ++j)
			if (qseq[j] != tseq[j] || qseq[j] > 3 || tseq[j] > 3)
				++mm2;
		if (mm1 == 0 && mm2 <= 1) {
			if (ai->flag & MM_JUNC_ANNO)
				i0_anno = i, mm0_anno = mm1 + mm2, ++n_anno; // i0 points to the rightmost i
			else
				i0_misc = i, mm0_misc = mm1 + mm2, ++n_misc;
		}
	}
	if (n_anno > 0) m = n_anno, i0 = i0_anno, mm0 = mm0_anno;
	else m = n_misc, i0 = i0_misc, mm0 = mm0_misc;
	kfree(km, tseq);

	l = m > 0? a[i0].off - r->rs : 0; // may be negative
	if (m == 1 && clip + l >= opt->jump_min_match) { // add one more exon
		mm_enlarge_cigar(r, 2);
		memmove(r->p->cigar + 2, r->p->cigar, r->p->n_cigar * 4);
		r->p->cigar[0] = (clip + l) << 4 | MM_CIGAR_MATCH;
		r->p->cigar[1] = (a[i0].off - a[i0].off2) << 4 | MM_CIGAR_N_SKIP;
		r->p->cigar[2] = ((r->p->cigar[2]>>4) - l) << 4 | MM_CIGAR_MATCH;
		r->p->n_cigar += 2;
		r->rs = a[i0].off2 - (clip + l);
		if (!r->rev) r->qs = 0;
		else r->qe = qlen;
		r->blen += clip, r->mlen += clip - mm0;
		r->p->dp_max0 += (clip - mm0) * opt->a - mm0 * opt->b;
		r->p->dp_max += (clip - mm0) * opt->a - mm0 * opt->b;
		if (!r->is_spliced) r->is_spliced = 1, r->p->dp_max += (opt->a + opt->b) + ((opt->a + opt->b) >> 1);
	} else if (m > 0 && a[i0].off > r->rs) { // trim by l; l is always positive
		r->p->cigar[0] -= l << 4 | MM_CIGAR_MATCH;
		r->rs += l;
		if (!r->rev) r->qs += l;
		else r->qe -= l;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0xffffffff, -0x68(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x18(%rbp), %rax
movl 0x68(%rax), %eax
movq -0x18(%rbp), %rcx
addl 0x64(%rcx), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
cltd
idivl 0x64(%rcx)
addl $0x1, %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2d5c2
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0xa8(%rbp)
jmp 0x2d5d2
movl -0x1c(%rbp), %eax
movq -0x30(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x2d5ee
movl -0x78(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0x2d5f7
movl -0x74(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movl -0x74(%rbp), %r9d
addl $0x14, %r9d
movl $0x1, (%rsp)
callq 0x2e5a0
cmpl $0x0, %eax
jge 0x2d631
jmp 0x2dd23
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x30(%rbp), %rax
movl 0x18(%rax), %edx
subl -0x7c(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x18(%rax), %ecx
addl -0x74(%rbp), %ecx
leaq -0x48(%rbp), %r8
callq 0xd320
movq %rax, -0x88(%rbp)
cmpl $0x0, -0x48(%rbp)
jne 0x2d66b
jmp 0x2dd23
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x2da38
movq -0x88(%rbp), %rax
movslq -0x44(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
movl 0x18(%rcx), %ecx
subl -0x7c(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2d6c7
movq -0x90(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
movl 0x18(%rcx), %ecx
addl -0x74(%rbp), %ecx
cmpl %ecx, %eax
jg 0x2d6c7
jmp 0x2d6e6
leaq 0x2b010(%rip), %rdi     # 0x586de
leaq 0x2af90(%rip), %rsi     # 0x58665
movl $0x43, %edx
leaq 0x2b02f(%rip), %rcx     # 0x58710
callq 0x21a0
movl 0x10(%rbp), %eax
movq -0x90(%rbp), %rcx
movswl 0xc(%rcx), %ecx
imull %ecx, %eax
cmpl $0x0, %eax
jge 0x2d701
jmp 0x2da2a
movq -0x90(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x90(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x2d71b
jmp 0x2da2a
movq -0x90(%rbp), %rax
movl (%rax), %eax
movq -0x90(%rbp), %rcx
subl 0x4(%rcx), %eax
cmpl $0x6, %eax
jge 0x2d738
jmp 0x2da2a
movq -0x90(%rbp), %rax
movl 0x4(%rax), %eax
movl -0x78(%rbp), %ecx
addl -0x74(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2d751
jmp 0x2da2a
cmpq $0x0, -0x38(%rbp)
jne 0x2d7b5
movq -0x8(%rbp), %rdi
movl -0x78(%rbp), %eax
addl -0x74(%rbp), %eax
shll %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x1a790
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movslq -0x78(%rbp), %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x78(%rbp), %r9d
addl -0x74(%rbp), %r9d
movq -0x40(%rbp), %rax
movl $0x1, %r8d
movq %rax, (%rsp)
callq 0x2e710
movl -0x78(%rbp), %eax
movq -0x90(%rbp), %rcx
movl (%rcx), %ecx
movq -0x30(%rbp), %rdx
subl 0x18(%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x90(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl 0x18(%rax), %r8d
addl -0x74(%rbp), %r8d
movq -0x38(%rbp), %r9
movslq -0x98(%rbp), %rax
addq %rax, %r9
xorl %esi, %esi
callq 0x8d20
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movq -0x30(%rbp), %rcx
movl 0x18(%rcx), %ecx
addl -0x74(%rbp), %ecx
movq -0x90(%rbp), %rdx
subl (%rdx), %ecx
cmpl %ecx, %eax
jne 0x2d82a
jmp 0x2d849
leaq 0x2af56(%rip), %rdi     # 0x58787
leaq 0x2ae2d(%rip), %rsi     # 0x58665
movl $0x4f, %edx
leaq 0x2aecc(%rip), %rcx     # 0x58710
callq 0x21a0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x90(%rbp), %rax
movl 0x4(%rax), %ecx
subl -0x98(%rbp), %ecx
movq -0x90(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x38(%rbp), %r9
xorl %esi, %esi
callq 0x8d20
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x98(%rbp), %eax
jne 0x2d890
jmp 0x2d8af
leaq 0x2af0e(%rip), %rdi     # 0x587a5
leaq 0x2adc7(%rip), %rsi     # 0x58665
movl $0x51, %edx
leaq 0x2ae66(%rip), %rcx     # 0x58710
callq 0x21a0
movl $0x0, -0x9c(%rbp)
movl $0x0, -0xa0(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x98(%rbp), %eax
jge 0x2d93d
movq -0x40(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x38(%rbp), %rcx
movslq -0x9c(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x2d91b
movq -0x40(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
jg 0x2d91b
movq -0x38(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
jle 0x2d92a
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x2d92c
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x2d8c3
movl $0x0, -0xa4(%rbp)
movl -0x9c(%rbp), %eax
movl -0x78(%rbp), %ecx
addl -0x74(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2d9c3
movq -0x40(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x38(%rbp), %rcx
movslq -0x9c(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x2d9a1
movq -0x40(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
jg 0x2d9a1
movq -0x38(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
jle 0x2d9b0
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2d9b2
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x2d947
cmpl $0x0, -0xa0(%rbp)
jne 0x2da28
cmpl $0x1, -0xa4(%rbp)
jg 0x2da28
movq -0x90(%rbp), %rax
movzwl 0xe(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2da08
movl -0x44(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0xa0(%rbp), %eax
addl -0xa4(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2da26
movl -0x44(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0xa0(%rbp), %eax
addl -0xa4(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2da28
jmp 0x2da2a
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x2d672
cmpl $0x0, -0x60(%rbp)
jle 0x2da52
movl -0x60(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x2da64
movl -0x6c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x1a8c0
cmpl $0x0, -0x54(%rbp)
jle 0x2da9a
movq -0x88(%rbp), %rax
movslq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, -0xb0(%rbp)
jmp 0x2daa4
xorl %eax, %eax
movl %eax, -0xb0(%rbp)
jmp 0x2daa4
movl -0xb0(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x1, -0x54(%rbp)
jne 0x2dca6
movl -0x78(%rbp), %eax
addl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc0(%rcx), %eax
jl 0x2dca6
movq -0x30(%rbp), %rdi
movl $0x2, %esi
callq 0x22560
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x1c, %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rsi
addq $0x1c, %rsi
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x18(%rax), %eax
shll $0x2, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x2330
movl -0x78(%rbp), %ecx
addl -0x4c(%rbp), %ecx
shll $0x4, %ecx
orl $0x0, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, 0x1c(%rax)
movq -0x88(%rbp), %rax
movslq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x88(%rbp), %rax
movslq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
subl 0x4(%rax), %ecx
shll $0x4, %ecx
orl $0x3, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x24(%rax), %ecx
shrl $0x4, %ecx
subl -0x4c(%rbp), %ecx
shll $0x4, %ecx
orl $0x0, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, 0x24(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x18(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x18(%rax)
movq -0x88(%rbp), %rax
movslq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movl -0x78(%rbp), %eax
addl -0x4c(%rbp), %eax
subl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2dbd5
movq -0x30(%rbp), %rax
movl $0x0, 0x10(%rax)
jmp 0x2dbdf
movl -0x1c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x78(%rbp), %ecx
movq -0x30(%rbp), %rax
addl 0x30(%rax), %ecx
movl %ecx, 0x30(%rax)
movl -0x78(%rbp), %ecx
subl -0x58(%rbp), %ecx
movq -0x30(%rbp), %rax
addl 0x2c(%rax), %ecx
movl %ecx, 0x2c(%rax)
movl -0x78(%rbp), %ecx
subl -0x58(%rbp), %ecx
movq -0x18(%rbp), %rax
imull 0x64(%rax), %ecx
movl -0x58(%rbp), %eax
movq -0x18(%rbp), %rdx
imull 0x68(%rdx), %eax
subl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movl -0x78(%rbp), %ecx
subl -0x58(%rbp), %ecx
movq -0x18(%rbp), %rax
imull 0x64(%rax), %ecx
movl -0x58(%rbp), %eax
movq -0x18(%rbp), %rdx
imull 0x68(%rdx), %eax
subl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x1b, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2dca4
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %ecx
andl $0xf7ffffff, %ecx       # imm = 0xF7FFFFFF
orl $0x8000000, %ecx        # imm = 0x8000000
movl %ecx, 0x3c(%rax)
movq -0x18(%rbp), %rax
movl 0x64(%rax), %ecx
movq -0x18(%rbp), %rax
addl 0x68(%rax), %ecx
movq -0x18(%rbp), %rax
movl 0x64(%rax), %eax
movq -0x18(%rbp), %rdx
addl 0x68(%rdx), %eax
sarl %eax
addl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
jmp 0x2dd23
cmpl $0x0, -0x54(%rbp)
jle 0x2dd21
movq -0x88(%rbp), %rax
movslq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jle 0x2dd21
movl -0x4c(%rbp), %edx
shll $0x4, %edx
orl $0x0, %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x1c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x1c(%rax)
movl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %rax
addl 0x18(%rax), %ecx
movl %ecx, 0x18(%rax)
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2dd10
movl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
jmp 0x2dd1f
movl -0x4c(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x14(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x14(%rax)
jmp 0x2dd21
jmp 0x2dd23
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)