// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/format.c
// Function: mm_write_junc
void mm_write_junc(kstring_t *s, const mm_idx_t *mi, const mm_bseq1_t *t, const mm_reg1_t *r)
{
	int32_t i, t_off, swritten = 0;
	s->l = 0;
	if (!r->is_spliced || r->p == 0) return; // no junctions
	if (r->p->trans_strand != 1 && r->p->trans_strand != 2) return; // no preferred strand
	for (i = 0, t_off = r->rs; i < (int)r->p->n_cigar; ++i) {
		int op = r->p->cigar[i]&0xf, len = r->p->cigar[i]>>4;
		if (op == MM_CIGAR_MATCH || op == MM_CIGAR_EQ_MATCH || op == MM_CIGAR_X_MISMATCH || op == MM_CIGAR_DEL) {
			t_off += len;
		} else if (op == MM_CIGAR_N_SKIP) { // intron
			uint8_t donor[2], acceptor[2];
			int32_t score1 = 0, score2 = 0, rev;
			assert(len >= 2);
			rev = (r->p->trans_strand == 2) ^ r->rev;
			if (!rev) {
				mm_idx_getseq(mi, r->rid, t_off, t_off + 2, donor);
				mm_idx_getseq(mi, r->rid, t_off + len - 2, t_off + len, acceptor);
			} else {
				mm_idx_getseq(mi, r->rid, t_off, t_off + 2, acceptor);
				mm_idx_getseq(mi, r->rid, t_off + len - 2, t_off + len, donor);
				revcomp_splice(donor);
				revcomp_splice(acceptor);
			}
			//fprintf(stderr, "%c%c-%c%c\n", "ACGTN"[donor[0]], "ACGTN"[donor[1]], "ACGTN"[acceptor[0]], "ACGTN"[acceptor[1]]);
			if (donor[0] == 2 && donor[1] == 3) score1 = 3;
			else if (donor[0] == 2 && donor[1] == 1) score1 = 2;
			else if (donor[0] == 0 && donor[1] == 3) score1 = 1;
			if (acceptor[0] == 0 && acceptor[1] == 2) score2 = 3;
			else if (acceptor[0] == 0 && acceptor[1] == 1) score2 = 1;
			if (swritten) mm_sprintf_lite(s, "\n");
			else swritten = 1;
			mm_sprintf_lite(s, "%s\t%d\t%d\t%s\t%d\t%c", mi->seq[r->rid].name, t_off, t_off + len, t->name, score1 + score2, "+-"[rev]);
			t_off += len;
		}
	}
	assert(t_off == r->re);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x1b, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x14c97
movq -0x20(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x14c9c
jmp 0x14f92
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x14(%rax), %eax
shrl $0x1e, %eax
cmpl $0x1, %eax
je 0x14cc7
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x14(%rax), %eax
shrl $0x1e, %eax
cmpl $0x2, %eax
je 0x14cc7
jmp 0x14f92
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x14f65
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x24(%rbp), %rcx
movl 0x1c(%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x24(%rbp), %rcx
movl 0x1c(%rax,%rcx,4), %eax
shrl $0x4, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x14d30
cmpl $0x7, -0x30(%rbp)
je 0x14d30
cmpl $0x8, -0x30(%rbp)
je 0x14d30
cmpl $0x2, -0x30(%rbp)
jne 0x14d3e
movl -0x34(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x14f55
cmpl $0x3, -0x30(%rbp)
jne 0x14f53
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x2, -0x34(%rbp)
jl 0x14d5e
jmp 0x14d7d
leaq 0x4289e(%rip), %rdi     # 0x57603
leaq 0x428a0(%rip), %rsi     # 0x5760c
movl $0x114, %edx            # imm = 0x114
leaq 0x4289d(%rip), %rcx     # 0x57615
callq 0x21a0
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x14(%rax), %eax
shrl $0x1e, %eax
cmpl $0x2, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movq -0x20(%rbp), %rcx
movl 0x3c(%rcx), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
xorl %ecx, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x14df0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x28(%rbp), %edx
movl -0x28(%rbp), %ecx
addl $0x2, %ecx
leaq -0x36(%rbp), %r8
callq 0x8ac0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x28(%rbp), %edx
addl -0x34(%rbp), %edx
subl $0x2, %edx
movl -0x28(%rbp), %ecx
addl -0x34(%rbp), %ecx
leaq -0x38(%rbp), %r8
callq 0x8ac0
jmp 0x14e42
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x28(%rbp), %edx
movl -0x28(%rbp), %ecx
addl $0x2, %ecx
leaq -0x38(%rbp), %r8
callq 0x8ac0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x28(%rbp), %edx
addl -0x34(%rbp), %edx
subl $0x2, %edx
movl -0x28(%rbp), %ecx
addl -0x34(%rbp), %ecx
leaq -0x36(%rbp), %r8
callq 0x8ac0
leaq -0x36(%rbp), %rdi
callq 0x14fa0
leaq -0x38(%rbp), %rdi
callq 0x14fa0
movzbl -0x36(%rbp), %eax
cmpl $0x2, %eax
jne 0x14e5d
movzbl -0x35(%rbp), %eax
cmpl $0x3, %eax
jne 0x14e5d
movl $0x3, -0x3c(%rbp)
jmp 0x14e95
movzbl -0x36(%rbp), %eax
cmpl $0x2, %eax
jne 0x14e78
movzbl -0x35(%rbp), %eax
cmpl $0x1, %eax
jne 0x14e78
movl $0x2, -0x3c(%rbp)
jmp 0x14e93
movzbl -0x36(%rbp), %eax
cmpl $0x0, %eax
jne 0x14e91
movzbl -0x35(%rbp), %eax
cmpl $0x3, %eax
jne 0x14e91
movl $0x1, -0x3c(%rbp)
jmp 0x14e93
jmp 0x14e95
movzbl -0x38(%rbp), %eax
cmpl $0x0, %eax
jne 0x14eb0
movzbl -0x37(%rbp), %eax
cmpl $0x2, %eax
jne 0x14eb0
movl $0x3, -0x40(%rbp)
jmp 0x14ecb
movzbl -0x38(%rbp), %eax
cmpl $0x0, %eax
jne 0x14ec9
movzbl -0x37(%rbp), %eax
cmpl $0x1, %eax
jne 0x14ec9
movl $0x1, -0x40(%rbp)
jmp 0x14ecb
cmpl $0x0, -0x2c(%rbp)
je 0x14ee5
movq -0x8(%rbp), %rdi
leaq 0x4020b(%rip), %rsi     # 0x550e7
movb $0x0, %al
callq 0x144f0
jmp 0x14eec
movl $0x1, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movl -0x28(%rbp), %ecx
movl -0x28(%rbp), %r8d
addl -0x34(%rbp), %r8d
movq -0x18(%rbp), %rax
movq 0x8(%rax), %r9
movl -0x3c(%rbp), %r10d
addl -0x40(%rbp), %r10d
movslq -0x44(%rbp), %rsi
leaq 0x42461(%rip), %rax     # 0x57391
movsbl (%rax,%rsi), %eax
leaq 0x42733(%rip), %rsi     # 0x5766e
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x144f0
movl -0x34(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x14f55
jmp 0x14f57
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x14cd8
movl -0x28(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0x14f73
jmp 0x14f92
leaq 0x42706(%rip), %rdi     # 0x57680
leaq 0x4268b(%rip), %rsi     # 0x5760c
movl $0x12b, %edx            # imm = 0x12B
leaq 0x42688(%rip), %rcx     # 0x57615
callq 0x21a0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)