// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/format.c
// Function: write_cs_ds_core
static void write_cs_ds_core(kstring_t *s, const uint8_t *tseq, const uint8_t *qseq, const mm_reg1_t *r, char *tmp, int no_iden, int is_ds, int write_tag)
{
	int i, q_off, t_off, q_len = 0, t_len = 0;
	if (write_tag) mm_sprintf_lite(s, "\t%cs:Z:", is_ds? 'd' : 'c');
	for (i = 0; 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)
			q_len += len, t_len += len;
		else if (op == MM_CIGAR_INS)
			q_len += len;
		else if (op == MM_CIGAR_DEL || op == MM_CIGAR_N_SKIP)
			t_len += len;
	}
	for (i = q_off = t_off = 0; i < (int)r->p->n_cigar; ++i) {
		int j, op = r->p->cigar[i]&0xf, len = r->p->cigar[i]>>4;
		assert((op >= MM_CIGAR_MATCH && op <= MM_CIGAR_N_SKIP) || op == MM_CIGAR_EQ_MATCH || op == MM_CIGAR_X_MISMATCH);
		if (op == MM_CIGAR_MATCH || op == MM_CIGAR_EQ_MATCH || op == MM_CIGAR_X_MISMATCH) {
			int l_tmp = 0;
			for (j = 0; j < len; ++j) {
				if (qseq[q_off + j] != tseq[t_off + j]) {
					if (l_tmp > 0) {
						if (!no_iden) {
							tmp[l_tmp] = 0;
							mm_sprintf_lite(s, "=%s", tmp);
						} else mm_sprintf_lite(s, ":%d", l_tmp);
						l_tmp = 0;
					}
					mm_sprintf_lite(s, "*%c%c", "acgtn"[tseq[t_off + j]], "acgtn"[qseq[q_off + j]]);
				} else tmp[l_tmp++] = "ACGTN"[qseq[q_off + j]];
			}
			if (l_tmp > 0) {
				if (!no_iden) {
					tmp[l_tmp] = 0;
					mm_sprintf_lite(s, "=%s", tmp);
				} else mm_sprintf_lite(s, ":%d", l_tmp);
			}
			q_off += len, t_off += len;
		} else if (op == MM_CIGAR_INS) {
			if (is_ds) {
				int z, ll, lr, y = q_off;
				for (z = 1; z <= len; ++z)
					if (y - z < 0 || qseq[y + len - z] != qseq[y - z])
						break;
				lr = z - 1;
				for (z = 0; z < len; ++z)
					if (y + len + z >= q_len || qseq[y + len + z] != qseq[y + z])
						break;
				ll = z;
				mm_sprintf_lite(s, "+");
				write_indel_ds(s, len, &qseq[y], ll, lr);
			} else {
				for (j = 0, tmp[len] = 0; j < len; ++j)
					tmp[j] = "acgtn"[qseq[q_off + j]];
				mm_sprintf_lite(s, "+%s", tmp);
			}
			q_off += len;
		} else if (op == MM_CIGAR_DEL) {
			if (is_ds) {
				int z, ll, lr, x = t_off;
				for (z = 1; z <= len; ++z)
					if (x - z < 0 || tseq[x + len - z] != tseq[x - z])
						break;
				lr = z - 1;
				for (z = 0; z < len; ++z)
					if (x + len + z >= t_len || tseq[x + z] != tseq[x + len + z])
						break;
				ll = z;
				mm_sprintf_lite(s, "-");
				write_indel_ds(s, len, &tseq[x], ll, lr);
			} else {
				for (j = 0, tmp[len] = 0; j < len; ++j)
					tmp[j] = "acgtn"[tseq[t_off + j]];
				mm_sprintf_lite(s, "-%s", tmp);
			}
			t_off += len;
		} else { // intron
			assert(len >= 2);
			mm_sprintf_lite(s, "~%c%c%d%c%c", "acgtn"[tseq[t_off]], "acgtn"[tseq[t_off+1]],
				len, "acgtn"[tseq[t_off+len-2]], "acgtn"[tseq[t_off+len-1]]);
			t_off += len;
		}
	}
	assert(t_off == r->re - r->rs && q_off == r->qe - r->qs);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x0, 0x18(%rbp)
je 0x17662
movq -0x8(%rbp), %rdi
movl 0x10(%rbp), %ecx
movl $0x63, %edx
movl $0x64, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
leaq 0x40319(%rip), %rsi     # 0x57974
movb $0x0, %al
callq 0x144f0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x17709
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x30(%rbp), %rcx
movl 0x1c(%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x30(%rbp), %rcx
movl 0x1c(%rax,%rcx,4), %eax
shrl $0x4, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x176bb
cmpl $0x7, -0x44(%rbp)
je 0x176bb
cmpl $0x8, -0x44(%rbp)
jne 0x176cf
movl -0x48(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x48(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x176f9
cmpl $0x1, -0x44(%rbp)
jne 0x176e0
movl -0x48(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x176f7
cmpl $0x2, -0x44(%rbp)
je 0x176ec
cmpl $0x3, -0x44(%rbp)
jne 0x176f5
movl -0x48(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x176f7
jmp 0x176f9
jmp 0x176fb
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x17669
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x17cf0
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x30(%rbp), %rcx
movl 0x1c(%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x30(%rbp), %rcx
movl 0x1c(%rax,%rcx,4), %eax
shrl $0x4, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x50(%rbp)
jl 0x1776a
cmpl $0x3, -0x50(%rbp)
jle 0x17776
cmpl $0x7, -0x50(%rbp)
je 0x17776
cmpl $0x8, -0x50(%rbp)
jne 0x17778
jmp 0x17797
leaq 0x400ee(%rip), %rdi     # 0x5786d
leaq 0x3fe86(%rip), %rsi     # 0x5760c
movl $0xba, %edx
leaq 0x401ea(%rip), %rcx     # 0x5797c
callq 0x21a0
cmpl $0x0, -0x50(%rbp)
je 0x177ad
cmpl $0x7, -0x50(%rbp)
je 0x177ad
cmpl $0x8, -0x50(%rbp)
jne 0x1792d
movl $0x0, -0x58(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x178cf
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x38(%rbp), %edx
addl -0x4c(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x1788d
cmpl $0x0, -0x58(%rbp)
jle 0x1783d
cmpl $0x0, -0x2c(%rbp)
jne 0x17821
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x401d3(%rip), %rsi     # 0x579eb
movb $0x0, %al
callq 0x144f0
jmp 0x17836
movq -0x8(%rbp), %rdi
movl -0x58(%rbp), %edx
leaq 0x4022a(%rip), %rsi     # 0x57a59
movb $0x0, %al
callq 0x144f0
movl $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x4019a(%rip), %rax     # 0x579f5
movsbl (%rax,%rcx), %edx
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x4017c(%rip), %rax     # 0x579f5
movsbl (%rax,%rcx), %ecx
leaq 0x4016b(%rip), %rsi     # 0x579ef
movb $0x0, %al
callq 0x144f0
jmp 0x178bf
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x40090(%rip), %rax     # 0x57937
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x58(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x178c1
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x177bb
cmpl $0x0, -0x58(%rbp)
jle 0x17916
cmpl $0x0, -0x2c(%rbp)
jne 0x178ff
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x400f5(%rip), %rsi     # 0x579eb
movb $0x0, %al
callq 0x144f0
jmp 0x17914
movq -0x8(%rbp), %rdi
movl -0x58(%rbp), %edx
leaq 0x4014c(%rip), %rsi     # 0x57a59
movb $0x0, %al
callq 0x144f0
jmp 0x17916
movl -0x54(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x54(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x17ce0
cmpl $0x1, -0x50(%rbp)
jne 0x17aa3
cmpl $0x0, 0x10(%rbp)
je 0x17a31
movl -0x34(%rbp), %eax
movl %eax, -0x68(%rbp)
movl $0x1, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jg 0x17999
movl -0x68(%rbp), %eax
subl -0x5c(%rbp), %eax
cmpl $0x0, %eax
jl 0x1798a
movq -0x18(%rbp), %rax
movl -0x68(%rbp), %ecx
addl -0x54(%rbp), %ecx
subl -0x5c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x68(%rbp), %edx
subl -0x5c(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x1798c
jmp 0x17999
jmp 0x1798e
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1794e
movl -0x5c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x179f7
movl -0x68(%rbp), %eax
addl -0x54(%rbp), %eax
addl -0x5c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x179e8
movq -0x18(%rbp), %rax
movl -0x68(%rbp), %ecx
addl -0x54(%rbp), %ecx
addl -0x5c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x68(%rbp), %edx
addl -0x5c(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x179ea
jmp 0x179f7
jmp 0x179ec
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x179a9
movl -0x5c(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3fff3(%rip), %rsi     # 0x579fb
movb $0x0, %al
callq 0x144f0
movq -0x8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
movq -0x18(%rbp), %rdx
movslq -0x68(%rbp), %rax
addq %rax, %rdx
movslq -0x60(%rbp), %rcx
movslq -0x64(%rbp), %r8
callq 0x17d50
jmp 0x17a95
movl $0x0, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x4c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x17a7f
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x3ff8f(%rip), %rax     # 0x579f5
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x17a44
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x3ff6f(%rip), %rsi     # 0x579fd
movb $0x0, %al
callq 0x144f0
movl -0x54(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x17cde
cmpl $0x2, -0x50(%rbp)
jne 0x17c19
cmpl $0x0, 0x10(%rbp)
je 0x17ba7
movl -0x38(%rbp), %eax
movl %eax, -0x78(%rbp)
movl $0x1, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jg 0x17b0f
movl -0x78(%rbp), %eax
subl -0x6c(%rbp), %eax
cmpl $0x0, %eax
jl 0x17b00
movq -0x10(%rbp), %rax
movl -0x78(%rbp), %ecx
addl -0x54(%rbp), %ecx
subl -0x6c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x78(%rbp), %edx
subl -0x6c(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x17b02
jmp 0x17b0f
jmp 0x17b04
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x17ac4
movl -0x6c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x17b6d
movl -0x78(%rbp), %eax
addl -0x54(%rbp), %eax
addl -0x6c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x17b5e
movq -0x10(%rbp), %rax
movl -0x78(%rbp), %ecx
addl -0x6c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x78(%rbp), %edx
addl -0x54(%rbp), %edx
addl -0x6c(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x17b60
jmp 0x17b6d
jmp 0x17b62
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x17b1f
movl -0x6c(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3f814(%rip), %rsi     # 0x57392
movb $0x0, %al
callq 0x144f0
movq -0x8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
movq -0x10(%rbp), %rdx
movslq -0x78(%rbp), %rax
addq %rax, %rdx
movslq -0x70(%rbp), %rcx
movslq -0x74(%rbp), %r8
callq 0x17d50
jmp 0x17c0b
movl $0x0, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x4c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x17bf5
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x3fe19(%rip), %rax     # 0x579f5
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x17bba
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x3fdfd(%rip), %rsi     # 0x57a01
movb $0x0, %al
callq 0x144f0
movl -0x54(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x17cdc
cmpl $0x2, -0x54(%rbp)
jl 0x17c21
jmp 0x17c40
leaq 0x3f9db(%rip), %rdi     # 0x57603
leaq 0x3f9dd(%rip), %rsi     # 0x5760c
movl $0xf7, %edx
leaq 0x3fd41(%rip), %rcx     # 0x5797c
callq 0x21a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x3fd9c(%rip), %rax     # 0x579f5
movsbl (%rax,%rcx), %edx
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x3fd7e(%rip), %rax     # 0x579f5
movsbl (%rax,%rcx), %ecx
movl -0x54(%rbp), %r8d
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %esi
addl -0x54(%rbp), %esi
subl $0x2, %esi
movslq %esi, %rsi
movzbl (%rax,%rsi), %eax
movl %eax, %esi
leaq 0x3fd59(%rip), %rax     # 0x579f5
movsbl (%rax,%rsi), %r9d
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %esi
addl -0x54(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
movzbl (%rax,%rsi), %eax
movl %eax, %esi
leaq 0x3fd37(%rip), %rax     # 0x579f5
movsbl (%rax,%rsi), %eax
leaq 0x3fd3c(%rip), %rsi     # 0x57a05
movl %eax, (%rsp)
movb $0x0, %al
callq 0x144f0
movl -0x54(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x17cde
jmp 0x17ce0
jmp 0x17ce2
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1771e
movl -0x38(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x1c(%rcx), %ecx
movq -0x20(%rbp), %rdx
subl 0x18(%rdx), %ecx
cmpl %ecx, %eax
jne 0x17d1c
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %ecx
movq -0x20(%rbp), %rdx
subl 0x10(%rdx), %ecx
cmpl %ecx, %eax
jne 0x17d1c
jmp 0x17d3b
leaq 0x3fc20(%rip), %rdi     # 0x57943
leaq 0x3f8e2(%rip), %rsi     # 0x5760c
movl $0xfd, %edx
leaq 0x3fc46(%rip), %rcx     # 0x5797c
callq 0x21a0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)