// File: /workspace/github_c_makefile_star2_O1/lh3[P]minimap2/format.c
// Function: write_sam_cigar
static void write_sam_cigar(kstring_t *s, int sam_flag, int in_tag, int qlen, const mm_reg1_t *r, int64_t opt_flag)
{
	if (r->p == 0) {
		mm_sprintf_lite(s, "*");
	} else {
		uint32_t k, clip_len[2];
		clip_len[0] = r->rev? qlen - r->qe : r->qs;
		clip_len[1] = r->rev? r->qs : qlen - r->qe;
		if (in_tag) {
			int clip_char = (((sam_flag&0x800) || ((sam_flag&0x100) && (opt_flag&MM_F_SECONDARY_SEQ))) &&
							 !(opt_flag&MM_F_SOFTCLIP)) ? 5 : 4;
			mm_sprintf_lite(s, "\tCG:B:I");
			if (clip_len[0]) mm_sprintf_lite(s, ",%u", clip_len[0]<<4|clip_char);
			for (k = 0; k < r->p->n_cigar; ++k)
				mm_sprintf_lite(s, ",%u", r->p->cigar[k]);
			if (clip_len[1]) mm_sprintf_lite(s, ",%u", clip_len[1]<<4|clip_char);
		} else {
			int clip_char = (((sam_flag&0x800) || ((sam_flag&0x100) && (opt_flag&MM_F_SECONDARY_SEQ))) &&
							 !(opt_flag&MM_F_SOFTCLIP)) ? 'H' : 'S';
			assert(clip_len[0] < qlen && clip_len[1] < qlen);
			if (clip_len[0]) mm_sprintf_lite(s, "%d%c", clip_len[0], clip_char);
			for (k = 0; k < r->p->n_cigar; ++k)
				mm_sprintf_lite(s, "%d%c", r->p->cigar[k]>>4, MM_CIGAR_STR[r->p->cigar[k]&0xf]);
			if (clip_len[1]) mm_sprintf_lite(s, "%d%c", clip_len[1], clip_char);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x48(%r8)
je 0x108ef
movq %r8, %r14
movl 0x3c(%r8), %eax
btl $0xa, %eax
jb 0x1090e
movl 0x10(%r14), %r15d
jmp 0x10915
leaq 0x1c234(%rip), %rsi     # 0x2cb2a
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe671
movl %ecx, %r15d
subl 0x14(%r14), %r15d
btl $0xa, %eax
jb 0x10923
movl %ecx, %ebp
subl 0x14(%r14), %ebp
jmp 0x10927
movl 0x10(%r14), %ebp
testl %edx, %edx
je 0x109f3
btl $0xb, %esi
jb 0x1094e
btl $0x8, %esi
setae %al
btq $0x24, %r9
setae %cl
orb %al, %cl
movl $0x4, %r12d
jne 0x1095d
btl $0x13, %r9d
movl $0x4, %r12d
sbbl $-0x1, %r12d
leaq 0x1c55b(%rip), %rsi     # 0x2cebf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
testl %r15d, %r15d
je 0x1098e
shll $0x4, %r15d
orl %r12d, %r15d
leaq 0x1c546(%rip), %rsi     # 0x2cec7
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe671
movq 0x48(%r14), %rax
cmpl $0x0, 0x18(%rax)
je 0x109c3
leaq 0x1c528(%rip), %r15     # 0x2cec7
xorl %r13d, %r13d
movl 0x1c(%rax,%r13,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0xe671
incq %r13
movq 0x48(%r14), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %r13
jb 0x109a2
testl %ebp, %ebp
je 0x10aca
shll $0x4, %ebp
orl %ebp, %r12d
leaq 0x1c4ef(%rip), %rsi     # 0x2cec7
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe671
btl $0xb, %esi
jb 0x10a12
btl $0x8, %esi
setae %al
btq $0x24, %r9
setae %dl
orb %al, %dl
movl $0x53, %r12d
jne 0x10a26
btl $0x13, %r9d
movl $0x48, %eax
movl $0x53, %r12d
cmovael %eax, %r12d
cmpl %ecx, %r15d
jae 0x10ad9
cmpl %ecx, %ebp
jae 0x10ad9
testl %r15d, %r15d
je 0x10a53
leaq 0x1c085(%rip), %rsi     # 0x2cac8
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe671
movl %r12d, 0x4(%rsp)
movq 0x48(%r14), %rax
cmpl $0x0, 0x18(%rax)
je 0x10aa1
leaq 0x1c064(%rip), %r13     # 0x2cacd
leaq 0x1c058(%rip), %r15     # 0x2cac8
xorl %r12d, %r12d
movl 0x1c(%rax,%r12,4), %eax
movl %eax, %edx
shrl $0x4, %edx
andl $0xf, %eax
movsbl (%rax,%r13), %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0xe671
incq %r12
movq 0x48(%r14), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %r12
jb 0x10a73
testl %ebp, %ebp
je 0x10aca
leaq 0x1c01c(%rip), %rsi     # 0x2cac8
movq %rbx, %rdi
movl %ebp, %edx
movl 0x4(%rsp), %ecx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe671
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c3eb(%rip), %rdi     # 0x2cecb
leaq 0x1bf1d(%rip), %rsi     # 0x2ca04
leaq 0x1c406(%rip), %rcx     # 0x2cef4
movl $0x1f7, %edx            # imm = 0x1F7
callq 0x21a0