// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/format.c
// Function: write_MD_core
static void write_MD_core(kstring_t *s, const uint8_t *tseq, const uint8_t *qseq, const mm_reg1_t *r, char *tmp, int write_tag)
{
	int i, q_off, t_off, l_MD = 0;
	if (write_tag) mm_sprintf_lite(s, "\tMD:Z:");
	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) {
			for (j = 0; j < len; ++j) {
				if (qseq[q_off + j] != tseq[t_off + j]) {
					mm_sprintf_lite(s, "%d%c", l_MD, "ACGTN"[tseq[t_off + j]]);
					l_MD = 0;
				} else ++l_MD;
			}
			q_off += len, t_off += len;
		} else if (op == MM_CIGAR_INS) {
			q_off += len;
		} else if (op == MM_CIGAR_DEL) {
			for (j = 0, tmp[len] = 0; j < len; ++j)
				tmp[j] = "ACGTN"[tseq[t_off + j]];
			mm_sprintf_lite(s, "%d^%s", l_MD, tmp);
			l_MD = 0;
			t_off += len;
		} else if (op == MM_CIGAR_N_SKIP) {
			t_off += len;
		}
	}
	if (l_MD > 0) mm_sprintf_lite(s, "%d", l_MD);
	assert(t_off == r->re - r->rs && q_off == r->qe - r->qs);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
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)
cmpl $0x0, -0x2c(%rbp)
je 0x1738f
movq -0x8(%rbp), %rdi
leaq 0x404de(%rip), %rsi     # 0x57866
movb $0x0, %al
callq 0x144f0
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 0x17589
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)
jl 0x173f0
cmpl $0x3, -0x44(%rbp)
jle 0x173fc
cmpl $0x7, -0x44(%rbp)
je 0x173fc
cmpl $0x8, -0x44(%rbp)
jne 0x173fe
jmp 0x1741d
leaq 0x40468(%rip), %rdi     # 0x5786d
leaq 0x40200(%rip), %rsi     # 0x5760c
movl $0x134, %edx            # imm = 0x134
leaq 0x404bd(%rip), %rcx     # 0x578d5
callq 0x21a0
cmpl $0x0, -0x44(%rbp)
je 0x17433
cmpl $0x7, -0x44(%rbp)
je 0x17433
cmpl $0x8, -0x44(%rbp)
jne 0x174d1
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x174ba
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x40(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x38(%rbp), %edx
addl -0x40(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x174a4
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %edx
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x40(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x404ae(%rip), %rax     # 0x57937
movsbl (%rax,%rcx), %ecx
leaq 0x4023c(%rip), %rsi     # 0x576d0
movb $0x0, %al
callq 0x144f0
movl $0x0, -0x3c(%rbp)
jmp 0x174ad
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x174af
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1743a
movl -0x48(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x48(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x17579
cmpl $0x1, -0x44(%rbp)
jne 0x174e5
movl -0x48(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x17577
cmpl $0x2, -0x44(%rbp)
jne 0x17564
movl $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x17539
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x40(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x40417(%rip), %rax     # 0x57937
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x174fe
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq 0x403f2(%rip), %rsi     # 0x5793d
movb $0x0, %al
callq 0x144f0
movl $0x0, -0x3c(%rbp)
movl -0x48(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x17575
cmpl $0x3, -0x44(%rbp)
jne 0x17573
movl -0x48(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x17575
jmp 0x17577
jmp 0x17579
jmp 0x1757b
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x173a4
cmpl $0x0, -0x3c(%rbp)
jle 0x175a4
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %edx
leaq 0x40129(%rip), %rsi     # 0x576c6
movb $0x0, %al
callq 0x144f0
movl -0x38(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x1c(%rcx), %ecx
movq -0x20(%rbp), %rdx
subl 0x18(%rdx), %ecx
cmpl %ecx, %eax
jne 0x175d0
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %ecx
movq -0x20(%rbp), %rdx
subl 0x10(%rdx), %ecx
cmpl %ecx, %eax
jne 0x175d0
jmp 0x175ef
leaq 0x4036c(%rip), %rdi     # 0x57943
leaq 0x4002e(%rip), %rsi     # 0x5760c
movl $0x14a, %edx            # imm = 0x14A
leaq 0x402eb(%rip), %rcx     # 0x578d5
callq 0x21a0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)