// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
andq $0x0, (%rdi)
movq %rsi, 0x10(%rsp)
testb $0x8, 0x3f(%rcx)
je 0xd3db
movq %rcx, %rbx
movq 0x48(%rcx), %rax
testq %rax, %rax
je 0xd3db
movl 0x14(%rax), %ecx
shrl $0x1e, %ecx
decl %ecx
cmpl $0x1, %ecx
ja 0xd3db
movq %rdx, 0x20(%rsp)
movl 0x18(%rbx), %ebp
xorl %r14d, %r14d
xorl %r8d, %r8d
movq %rbx, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movslq 0x18(%rax), %rcx
cmpq %rcx, %r14
jge 0xd3d6
movl 0x1c(%rax,%r14,4), %ecx
movl %ecx, %edx
shrl $0x4, %edx
testb $0x7, %cl
je 0xd1cb
movl %ecx, %esi
andl $0xf, %esi
cmpl $0x7, %esi
je 0xd1cb
cmpl $0x3, %esi
je 0xd1d8
cmpl $0x2, %esi
jne 0xd259
addl %ebp, %edx
movl %edx, %r13d
incq %r14
movl %r13d, %ebp
jmp 0xd197
cmpl $0x1f, %ecx
jbe 0xd3ea
movl %r8d, 0x8(%rsp)
movl 0x14(%rax), %eax
movl $0xc0000000, %ecx       # imm = 0xC0000000
andl %ecx, %eax
xorl %edi, %edi
negl %eax
seto %dil
movl 0x8(%rbx), %esi
movl 0x3c(%rbx), %r12d
shrl $0xa, %r12d
andl $0x1, %r12d
leal 0x2(%rbp), %ecx
leal (%rdx,%rbp), %r13d
leal (%rdx,%rbp), %eax
addl $-0x2, %eax
movl %eax, 0xc(%rsp)
movl %edi, 0x1c(%rsp)
cmpl %edi, %r12d
jne 0xd261
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %edx
leaq 0x6(%rsp), %r8
callq 0x612e
movl 0x8(%rbx), %esi
movq %r15, %rdi
movl 0xc(%rsp), %edx
movl %r13d, %ecx
leaq 0x4(%rsp), %r8
callq 0x612e
movb 0x6(%rsp), %al
movb 0x7(%rsp), %cl
jmp 0xd2f0
movl %ebp, %r13d
jmp 0xd1d0
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %edx
leaq 0x4(%rsp), %r8
callq 0x612e
movl 0x8(%rbx), %esi
movq %r15, %rdi
movl 0xc(%rsp), %edx
movl %r13d, %ecx
leaq 0x6(%rsp), %r8
callq 0x612e
movb 0x6(%rsp), %cl
movb 0x7(%rsp), %al
movb $0x3, %dl
subb %al, %dl
cmpb $0x4, %al
movzbl %dl, %eax
pushq $0x4
popq %r8
cmovael %r8d, %eax
movb $0x3, %dl
subb %cl, %dl
cmpb $0x4, %cl
movzbl %dl, %ecx
cmovael %r8d, %ecx
movb %cl, 0x7(%rsp)
movb %al, 0x6(%rsp)
movb 0x4(%rsp), %dl
movb 0x5(%rsp), %sil
movb $0x3, %dil
subb %sil, %dil
cmpb $0x4, %sil
movzbl %dil, %esi
cmovael %r8d, %esi
movb $0x3, %dil
subb %dl, %dil
cmpb $0x4, %dl
movzbl %dil, %edx
cmovael %r8d, %edx
movb %dl, 0x5(%rsp)
movb %sil, 0x4(%rsp)
cmpb $0x2, %al
movl 0x8(%rsp), %edi
jne 0xd301
pushq $0x3
popq %r8
cmpb $0x3, %cl
je 0xd31a
cmpb $0x2, %al
jne 0xd30e
pushq $0x2
popq %r8
cmpb $0x1, %cl
je 0xd31a
xorb $0x3, %cl
xorl %r8d, %r8d
orb %cl, %al
sete %r8b
movb 0x4(%rsp), %al
testb %al, %al
sete %cl
movb 0x5(%rsp), %dl
cmpb $0x1, %dl
sete %sil
andb %cl, %sil
cmpb $0x2, %dl
movzbl %sil, %ecx
movl %ecx, %ebx
pushq $0x3
popq %rdx
cmovel %edx, %ebx
testb %al, %al
cmovnel %ecx, %ebx
testl %edi, %edi
movq 0x28(%rsp), %r15
je 0xd36f
movq %r15, %rdi
leaq 0x19053(%rip), %rsi     # 0x263ab
xorl %eax, %eax
movl %r12d, 0x8(%rsp)
movl %r8d, %r12d
callq 0xce8e
movl %r12d, %r8d
movl 0x8(%rsp), %r12d
xorl 0x1c(%rsp), %r12d
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x30(%rsp), %r11
movslq 0x8(%r11), %rcx
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %rdx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %r9
addl %r8d, %ebx
movl %r12d, %eax
leaq 0x1b405(%rip), %rcx     # 0x287a9
movsbl (%rax,%rcx), %r10d
movq %r15, %rdi
leaq 0x1b6d3(%rip), %rsi     # 0x28a86
movl %ebp, %ecx
movl %r13d, %r8d
xorl %eax, %eax
pushq %r10
pushq %rbx
movq %r11, %rbx
callq 0xce8e
addq $0x10, %rsp
movq 0x48(%rbx), %rax
pushq $0x1
popq %r8
jmp 0xd1d0
cmpl 0x1c(%rbx), %ebp
jne 0xd409
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b62a(%rip), %rdi     # 0x28a1b
leaq 0x1b62c(%rip), %rsi     # 0x28a24
leaq 0x1b62e(%rip), %rcx     # 0x28a2d
movl $0x114, %edx            # imm = 0x114
callq 0x21a0
leaq 0x1b688(%rip), %rdi     # 0x28a98
leaq 0x1b60d(%rip), %rsi     # 0x28a24
leaq 0x1b60f(%rip), %rcx     # 0x28a2d
movl $0x12b, %edx            # imm = 0x12B
callq 0x21a0