// File: /workspace/github_c_makefile_star2_O2/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 0xedb4
movq %r8, %r14
testb $0x4, 0x3d(%r8)
jne 0xedd3
movl 0x10(%r14), %r15d
movl %ecx, %ebp
subl 0x14(%r14), %ebp
jmp 0xedde
leaq 0x19d8f(%rip), %rsi     # 0x28b4a
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xce8e
movl %ecx, %r15d
subl 0x14(%r14), %r15d
movl 0x10(%r14), %ebp
testl %edx, %edx
je 0xee9a
btl $0xb, %esi
pushq $0x4
popq %r12
jb 0xee03
btl $0x8, %esi
setae %al
btq $0x24, %r9
setae %cl
orb %al, %cl
jne 0xee0c
btl $0x13, %r9d
sbbl $-0x1, %r12d
leaq 0x1a0c8(%rip), %rsi     # 0x28edb
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
testl %r15d, %r15d
je 0xee3d
shll $0x4, %r15d
orl %r12d, %r15d
leaq 0x1a0b3(%rip), %rsi     # 0x28ee3
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xce8e
leaq 0x1a09f(%rip), %r15     # 0x28ee3
xorl %r13d, %r13d
movq 0x48(%r14), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %r13
jae 0xee6a
movl 0x1c(%rax,%r13,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0xce8e
incq %r13
jmp 0xee47
testl %ebp, %ebp
je 0xef5f
shll $0x4, %ebp
orl %ebp, %r12d
leaq 0x1a064(%rip), %rsi     # 0x28ee3
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 0xce8e
btl $0xb, %esi
pushq $0x53
popq %r12
jb 0xeeb7
btl $0x8, %esi
setae %al
btq $0x24, %r9
setae %dl
orb %al, %dl
jne 0xeec3
btl $0x13, %r9d
pushq $0x48
popq %rax
cmovael %eax, %r12d
cmpl %ecx, %r15d
jae 0xef6e
cmpl %ecx, %ebp
jae 0xef6e
testl %r15d, %r15d
je 0xeef0
leaq 0x19c08(%rip), %rsi     # 0x28ae8
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xce8e
movl %r12d, 0x4(%rsp)
leaq 0x19bf1(%rip), %r13     # 0x28aed
leaq 0x19be5(%rip), %r15     # 0x28ae8
xorl %r12d, %r12d
movq 0x48(%r14), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %r12
jae 0xef36
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 0xce8e
incq %r12
jmp 0xef06
testl %ebp, %ebp
je 0xef5f
leaq 0x19ba7(%rip), %rsi     # 0x28ae8
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 0xce8e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19f72(%rip), %rdi     # 0x28ee7
leaq 0x19aa8(%rip), %rsi     # 0x28a24
leaq 0x19f8d(%rip), %rcx     # 0x28f10
movl $0x1f7, %edx            # imm = 0x1F7
callq 0x21a0