// File: /workspace/github_c_makefile_star2_O3/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
movq 0x48(%r8), %rax
testq %rax, %rax
je 0x1080f
movq %r8, %r14
testb $0x4, 0x3d(%r8)
jne 0x1082e
movl 0x10(%r14), %r15d
movl %ecx, %ebp
subl 0x14(%r14), %ebp
jmp 0x10839
leaq 0x1d334(%rip), %rsi     # 0x2db4a
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe575
movl %ecx, %r15d
subl 0x14(%r14), %r15d
movl 0x10(%r14), %ebp
testl %edx, %edx
je 0x10905
btl $0xb, %esi
jb 0x10860
btl $0x8, %esi
setae %al
btq $0x24, %r9
setae %cl
orb %al, %cl
movl $0x4, %r12d
jne 0x1086f
btl $0x13, %r9d
movl $0x4, %r12d
sbbl $-0x1, %r12d
leaq 0x1d665(%rip), %rsi     # 0x2dedb
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe575
testl %r15d, %r15d
je 0x108a0
shll $0x4, %r15d
orl %r12d, %r15d
leaq 0x1d650(%rip), %rsi     # 0x2dee3
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe575
movq 0x48(%r14), %rax
cmpl $0x0, 0x18(%rax)
je 0x108d5
leaq 0x1d632(%rip), %r15     # 0x2dee3
xorl %r13d, %r13d
movl 0x1c(%rax,%r13,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0xe575
incq %r13
movq 0x48(%r14), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %r13
jb 0x108b4
testl %ebp, %ebp
je 0x109de
shll $0x4, %ebp
orl %ebp, %r12d
leaq 0x1d5f9(%rip), %rsi     # 0x2dee3
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 0xe575
btl $0xb, %esi
jb 0x10926
btl $0x8, %esi
setae %dl
btq $0x24, %r9
setae %sil
orb %dl, %sil
movl $0x53, %r12d
jne 0x1093a
btl $0x13, %r9d
movl $0x48, %edx
movl $0x53, %r12d
cmovael %edx, %r12d
cmpl %ecx, %r15d
jae 0x109ed
cmpl %ecx, %ebp
jae 0x109ed
testl %r15d, %r15d
je 0x1096b
leaq 0x1d191(%rip), %rsi     # 0x2dae8
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe575
movq 0x48(%r14), %rax
movl %r12d, 0x4(%rsp)
cmpl $0x0, 0x18(%rax)
je 0x109b5
leaq 0x1d170(%rip), %r13     # 0x2daed
leaq 0x1d164(%rip), %r15     # 0x2dae8
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 0xe575
incq %r12
movq 0x48(%r14), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %r12
jb 0x10987
testl %ebp, %ebp
je 0x109de
leaq 0x1d128(%rip), %rsi     # 0x2dae8
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 0xe575
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d4f3(%rip), %rdi     # 0x2dee7
leaq 0x1d029(%rip), %rsi     # 0x2da24
leaq 0x1d50e(%rip), %rcx     # 0x2df10
movl $0x1f7, %edx            # imm = 0x1F7
callq 0x21a0