// File: /workspace/github_c_makefile_star2_O3/lh3[P]minimap2/format.c
// Function: write_cs_ds_or_MD
static void write_cs_ds_or_MD(void *km, kstring_t *s, const mm_idx_t *mi, const mm_bseq1_t *t, const mm_reg1_t *r, int no_iden, int is_MD, int is_ds, int write_tag, int is_qstrand)
{
	extern unsigned char seq_nt4_table[256];
	int i;
	uint8_t *qseq, *tseq;
	char *tmp;
	if (r->p == 0) return;
	qseq = (uint8_t*)kmalloc(km, r->qe - r->qs);
	tseq = (uint8_t*)kmalloc(km, r->re - r->rs);
	tmp = (char*)kmalloc(km, r->re - r->rs > r->qe - r->qs? r->re - r->rs + 1 : r->qe - r->qs + 1);
	if (is_qstrand) {
		mm_idx_getseq2(mi, r->rev, r->rid, r->rs, r->re, tseq);
		for (i = r->qs; i < r->qe; ++i)
			qseq[i - r->qs] = seq_nt4_table[(uint8_t)t->seq[i]];
	} else {
		mm_idx_getseq(mi, r->rid, r->rs, r->re, tseq);
		if (!r->rev) {
			for (i = r->qs; i < r->qe; ++i)
				qseq[i - r->qs] = seq_nt4_table[(uint8_t)t->seq[i]];
		} else {
			for (i = r->qs; i < r->qe; ++i) {
				uint8_t c = seq_nt4_table[(uint8_t)t->seq[i]];
				qseq[r->qe - i - 1] = c >= 4? 4 : 3 - c;
			}
		}
	}
	if (is_MD) write_MD_core(s, tseq, qseq, r, tmp, write_tag);
	else write_cs_ds_core(s, tseq, qseq, r, tmp, no_iden, is_ds, write_tag);
	kfree(km, qseq); kfree(km, tseq); kfree(km, tmp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0x3c(%rsp)
cmpq $0x0, 0x48(%r8)
je 0xef5c
movq %r8, %rbp
movq %rcx, %rbx
movq %rdx, %r12
movq %rdi, %r13
movq %rsi, 0x20(%rsp)
movl 0xc8(%rsp), %r15d
movl 0xc0(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0xb8(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0xb0(%rsp), %eax
movl %eax, 0x10(%rsp)
movslq 0x14(%r8), %rsi
movslq 0x10(%r8), %rax
subq %rax, %rsi
callq 0x1264d
movq %rax, 0x48(%rsp)
movslq 0x1c(%rbp), %rsi
movslq 0x18(%rbp), %rax
subq %rax, %rsi
movq %r13, %rdi
callq 0x1264d
movq %rax, %r14
movl 0x1c(%rbp), %eax
subl 0x18(%rbp), %eax
movl 0x14(%rbp), %ecx
subl 0x10(%rbp), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
incl %ecx
movslq %ecx, %rsi
movq %r13, 0x68(%rsp)
movq %r13, %rdi
callq 0x1264d
movq %rax, %r13
testl %r15d, %r15d
movq %r14, 0x40(%rsp)
je 0xef6b
movl 0x3c(%rbp), %esi
shrl $0xa, %esi
andl $0x1, %esi
movl 0x8(%rbp), %edx
movl 0x18(%rbp), %ecx
movl 0x1c(%rbp), %r8d
movq %r12, %rdi
movq %r14, %r9
callq 0x72e4
movslq 0x10(%rbp), %rax
cmpl 0x14(%rbp), %eax
movq %rbp, %r12
movq 0x48(%rsp), %r15
movl 0x30(%rsp), %r10d
movl 0x10(%rsp), %r11d
jge 0xf02f
leaq 0x278df(%rip), %rcx     # 0x36810
movq 0x10(%rbx), %rdx
movzbl (%rdx,%rax), %edx
movb (%rcx,%rdx), %dl
movslq 0x10(%r12), %rsi
movq %r15, %rdi
subq %rsi, %rdi
movb %dl, (%rdi,%rax)
incq %rax
movslq 0x14(%r12), %rdx
cmpq %rdx, %rax
jl 0xef31
jmp 0xf02f
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rbp), %esi
movl 0x18(%rbp), %edx
movl 0x1c(%rbp), %ecx
movq %r12, %rdi
movq %r14, %r8
callq 0x71d0
testb $0x4, 0x3d(%rbp)
movslq 0x10(%rbp), %rax
movl 0x14(%rbp), %ecx
movq %rbp, %r12
jne 0xefd5
cmpl %ecx, %eax
movq 0x48(%rsp), %r15
movl 0x30(%rsp), %r10d
movl 0x10(%rsp), %r11d
jge 0xf02f
leaq 0x27863(%rip), %rcx     # 0x36810
movq 0x10(%rbx), %rdx
movzbl (%rdx,%rax), %edx
movb (%rcx,%rdx), %dl
movslq 0x10(%r12), %rsi
movq %r15, %rdi
subq %rsi, %rdi
movb %dl, (%rdi,%rax)
incq %rax
movslq 0x14(%r12), %rdx
cmpq %rdx, %rax
jl 0xefad
jmp 0xf02f
cmpl %ecx, %eax
movq 0x48(%rsp), %r15
movl 0x30(%rsp), %r10d
movl 0x10(%rsp), %r11d
jge 0xf02f
movl %eax, %edx
notl %edx
leaq 0x2781d(%rip), %rsi     # 0x36810
movl $0x4, %edi
movq 0x10(%rbx), %r8
movzbl (%r8,%rax), %r8d
movb (%rsi,%r8), %r8b
movb $0x3, %r9b
subb %r8b, %r9b
cmpb $0x4, %r8b
movzbl %r9b, %r8d
cmovael %edi, %r8d
addl %edx, %ecx
movslq %ecx, %rcx
movb %r8b, (%r15,%rcx)
incq %rax
movslq 0x14(%r12), %rcx
decl %edx
cmpq %rcx, %rax
jl 0xeff8
testl %r11d, %r11d
je 0xf1e9
testl %r10d, %r10d
je 0xf050
leaq 0x1ec36(%rip), %rsi     # 0x2dc7a
movq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0xe575
movq 0x48(%r12), %rax
cmpl $0x0, 0x18(%rax)
jle 0xf770
xorl %r15d, %r15d
leaq 0x1ece2(%rip), %rbx     # 0x2dd4b
movl $0x0, 0x10(%rsp)
xorl %edx, %edx
xorl %r14d, %r14d
movl 0x1c(%rax,%r15,4), %esi
movl %esi, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
jb 0xf091
leal -0x7(%rcx), %edi
cmpl $0x2, %edi
jae 0xf817
movl %esi, %ebp
shrl $0x4, %ebp
testb $0x7, %sil
je 0xf132
cmpl $0x7, %ecx
je 0xf132
cmpl $0x2, %ecx
jne 0xf113
movb $0x0, (%r13,%rbp)
cmpl $0x10, %esi
jb 0xf0d8
movslq %r14d, %rax
addq 0x40(%rsp), %rax
xorl %ecx, %ecx
movzbl (%rax,%rcx), %esi
movb (%rsi,%rbx), %sil
movb %sil, (%r13,%rcx)
incq %rcx
cmpq %rcx, %rbp
jne 0xf0c3
movq 0x20(%rsp), %rdi
leaq 0x1ec6d(%rip), %rsi     # 0x2dd51
movq %r13, %rcx
xorl %eax, %eax
callq 0xe575
addl %r14d, %ebp
incq %r15
movq 0x48(%r12), %rax
movslq 0x18(%rax), %rcx
movl $0x0, %edx
movl %ebp, %r14d
cmpq %rcx, %r15
jl 0xf076
jmp 0xf762
cmpl $0x3, %ecx
je 0xf1ae
cmpl $0x1, %ecx
jne 0xf1b4
addl 0x10(%rsp), %ebp
movl %ebp, 0x10(%rsp)
jmp 0xf1b4
cmpl $0x10, %esi
jb 0xf1a5
movq %r12, 0x58(%rsp)
movslq 0x10(%rsp), %rcx
movslq %r14d, %rsi
addq 0x48(%rsp), %rcx
addq 0x40(%rsp), %rsi
xorl %r12d, %r12d
movq %rcx, 0x30(%rsp)
movl %r14d, 0x3c(%rsp)
movzbl (%rsi,%r12), %eax
cmpb %al, (%rcx,%r12)
jne 0xf16a
incl %edx
jmp 0xf193
movsbl (%rax,%rbx), %ecx
movq 0x20(%rsp), %rdi
movq %rsi, %r14
leaq 0x1e96b(%rip), %rsi     # 0x2dae8
xorl %eax, %eax
callq 0xe575
movq %r14, %rsi
movl 0x3c(%rsp), %r14d
movq 0x30(%rsp), %rcx
xorl %edx, %edx
incq %r12
cmpq %r12, %rbp
jne 0xf15b
movq 0x58(%rsp), %r12
movq 0x48(%r12), %rax
addl %ebp, 0x10(%rsp)
addl %ebp, %r14d
jmp 0xf1b4
addl %r14d, %ebp
movl %ebp, %r14d
incq %r15
movslq 0x18(%rax), %rcx
cmpq %rcx, %r15
jl 0xf076
testl %edx, %edx
movq 0x48(%rsp), %r15
jle 0xf76a
leaq 0x1e906(%rip), %rsi     # 0x2dade
movq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0xe575
jmp 0xf76a
testl %r10d, %r10d
je 0xf20e
cmpl $0x1, 0x50(%rsp)
movl $0x64, %edx
sbbl $0x0, %edx
leaq 0x1eb86(%rip), %rsi     # 0x2dd88
movq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0xe575
movq 0x48(%r12), %rax
movslq 0x18(%rax), %rcx
testq %rcx, %rcx
movq %r12, 0x58(%rsp)
jle 0xf7b1
xorl %edx, %edx
xorl %esi, %esi
xorl %ebp, %ebp
movl $0x0, 0x54(%rsp)
movl 0x1c(%rax,%rsi,4), %r8d
movl %r8d, %r9d
andl $0xf, %r9d
movl %r8d, %edi
shrl $0x4, %edi
cmpl $0x7, %r9d
setne %r10b
testb $0x7, %r8b
setne %r11b
testb %r10b, %r11b
jne 0xf25e
addl %edi, %ebp
jmp 0xf273
cmpl $0x1, %r9d
jne 0xf268
addl %edi, %ebp
jmp 0xf277
andl $0xe, %r8d
cmpl $0x2, %r8d
cmovnel %edx, %edi
addl %edi, 0x54(%rsp)
incq %rsi
cmpq %rsi, %rcx
jne 0xf233
xorl %edx, %edx
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq %r13, 0x30(%rsp)
movq %rdx, 0x70(%rsp)
movl 0x1c(%rax,%rdx,4), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
jb 0xf2b7
leal -0x7(%rcx), %edx
cmpl $0x2, %edx
jae 0xf855
movl %eax, %ebx
shrl $0x4, %ebx
cmpl $0x7, %ecx
setne %dl
testb $0x7, %al
setne %sil
testb %dl, %sil
jne 0xf3e9
cmpl $0x10, %eax
jb 0xf592
movl %ebp, 0x2c(%rsp)
movq %r15, %rax
movslq 0x10(%rsp), %r15
movslq 0x18(%rsp), %rbp
addq %rax, %r15
addq 0x40(%rsp), %rbp
xorl %r14d, %r14d
xorl %r12d, %r12d
movzbl (%r15,%r14), %eax
cmpb (%rbp,%r14), %al
jne 0xf31f
leaq 0x1ea3f(%rip), %rcx     # 0x2dd4b
movb (%rax,%rcx), %al
movslq %r12d, %rcx
incl %r12d
movb %al, (%r13,%rcx)
jmp 0xf3a5
testl %r12d, %r12d
jle 0xf349
cmpl $0x0, 0x3c(%rsp)
je 0xf350
movq 0x20(%rsp), %r13
movq %r13, %rdi
leaq 0x1eb33(%rip), %rsi     # 0x2de6d
movl %r12d, %edx
xorl %eax, %eax
callq 0xe575
xorl %r12d, %r12d
jmp 0xf375
movq 0x20(%rsp), %r13
jmp 0xf375
movl %r12d, %eax
movb $0x0, (%r13,%rax)
xorl %r12d, %r12d
movq %r13, %rdx
movq 0x20(%rsp), %r13
movq %r13, %rdi
leaq 0x1ea91(%rip), %rsi     # 0x2ddff
xorl %eax, %eax
callq 0xe575
movzbl (%rbp,%r14), %eax
leaq 0x1ea87(%rip), %rcx     # 0x2de09
movsbl (%rax,%rcx), %edx
movzbl (%r15,%r14), %eax
movsbl (%rax,%rcx), %ecx
movq %r13, %rdi
leaq 0x1ea6a(%rip), %rsi     # 0x2de03
xorl %eax, %eax
callq 0xe575
movq 0x30(%rsp), %r13
incq %r14
cmpq %r14, %rbx
jne 0xf2f9
testl %r12d, %r12d
movq 0x48(%rsp), %r15
movl 0x2c(%rsp), %ebp
jle 0xf592
cmpl $0x0, 0x3c(%rsp)
je 0xf573
movq 0x20(%rsp), %rdi
leaq 0x1ea93(%rip), %rsi     # 0x2de6d
movl %r12d, %edx
xorl %eax, %eax
callq 0xe575
jmp 0xf592
cmpl $0x2, %ecx
je 0xf42f
cmpl $0x1, %ecx
leaq 0x1ea11(%rip), %rdi     # 0x2de09
jne 0xf46e
cmpl $0x0, 0x50(%rsp)
je 0xf4d4
movl %ebp, 0x2c(%rsp)
movq 0x10(%rsp), %rcx
leal (%rbx,%rcx), %r12d
movl %ebx, %edx
movq %rdx, 0x60(%rsp)
movslq %ecx, %rbp
cmpl $0x10, %eax
jae 0xf5d3
xorl %r14d, %r14d
xorl %ebx, %ebx
jmp 0xf6cd
cmpl $0x0, 0x50(%rsp)
leaq 0x1e9ce(%rip), %rsi     # 0x2de09
je 0xf51f
movq 0x18(%rsp), %rcx
leal (%rbx,%rcx), %r10d
cmpl $0x10, %eax
movl %r10d, 0x2c(%rsp)
jae 0xf64c
movl %ebx, %ebx
movslq %ecx, %r14
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
jmp 0xf716
cmpl $0x1f, %eax
jbe 0xf836
movq 0x18(%rsp), %rsi
movslq %esi, %rax
movq 0x40(%rsp), %r8
movzbl (%r8,%rax), %ecx
movsbl (%rcx,%rdi), %edx
movzbl 0x1(%r8,%rax), %eax
movsbl (%rax,%rdi), %ecx
addl %ebx, %esi
movq %rsi, 0x18(%rsp)
movslq %esi, %rax
movzbl -0x2(%r8,%rax), %esi
movsbl (%rsi,%rdi), %r9d
movzbl -0x1(%r8,%rax), %eax
movsbl (%rax,%rdi), %eax
movl %eax, (%rsp)
movq 0x20(%rsp), %rdi
leaq 0x1e954(%rip), %rsi     # 0x2de19
movl %ebx, %r8d
xorl %eax, %eax
callq 0xe575
jmp 0xf569
movb $0x0, (%r13,%rbx)
cmpl $0x10, %eax
jb 0xf4fd
movslq 0x10(%rsp), %rax
addq %r15, %rax
xorl %ecx, %ecx
movzbl (%rax,%rcx), %edx
movb (%rdx,%rdi), %dl
movb %dl, (%r13,%rcx)
incq %rcx
cmpq %rcx, %rbx
jne 0xf4e9
movq 0x20(%rsp), %rdi
leaq 0x1e908(%rip), %rsi     # 0x2de11
movq %r13, %rdx
xorl %eax, %eax
callq 0xe575
addl 0x10(%rsp), %ebx
movl %ebx, %r12d
jmp 0xf5a8
movb $0x0, (%r13,%rbx)
cmpl $0x10, %eax
jb 0xf54a
movslq 0x18(%rsp), %rax
addq 0x40(%rsp), %rax
xorl %ecx, %ecx
movzbl (%rax,%rcx), %edx
movb (%rdx,%rsi), %dl
movb %dl, (%r13,%rcx)
incq %rcx
cmpq %rcx, %rbx
jne 0xf536
movq 0x20(%rsp), %rdi
leaq 0x1e8bf(%rip), %rsi     # 0x2de15
movq %r13, %rdx
xorl %eax, %eax
callq 0xe575
addl 0x18(%rsp), %ebx
movq %rbx, 0x18(%rsp)
movq 0x10(%rsp), %rax
movl %eax, %r12d
jmp 0xf5a8
movl %r12d, %eax
movb $0x0, (%r13,%rax)
movq 0x20(%rsp), %rdi
leaq 0x1e877(%rip), %rsi     # 0x2ddff
movq %r13, %rdx
xorl %eax, %eax
callq 0xe575
movq 0x10(%rsp), %rcx
addl %ebx, %ecx
movq 0x18(%rsp), %rax
addl %ebx, %eax
movq %rax, 0x18(%rsp)
movl %ecx, %r12d
movq 0x70(%rsp), %rdx
incq %rdx
movq 0x58(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x18(%rax), %rcx
movl %r12d, %esi
movq %rsi, 0x10(%rsp)
cmpq %rcx, %rdx
jl 0xf298
jmp 0xf7bd
leal 0x1(%rbx), %edx
shrl $0x4, %eax
leal -0x1(%rbp), %esi
leaq -0x1(%rbp), %rdi
movl $0x1, %ecx
movq %rax, %r8
testq %rdi, %rdi
js 0xf60b
leal (%rsi,%r8), %r9d
movslq %r9d, %r9
movb (%r15,%r9), %r9b
cmpb (%r15,%rdi), %r9b
jne 0xf60b
incq %rcx
decq %rdi
decq %r8
jne 0xf5e8
movl %edx, %ecx
decl %ecx
movslq %ecx, %r14
movslq %r12d, %rdx
movl 0x2c(%rsp), %esi
cmpl %edx, %esi
movl %edx, %ecx
cmovgl %esi, %ecx
subl %edx, %ecx
addq %r15, %rdx
leaq (%r15,%rbp), %rdi
xorl %esi, %esi
cmpq %rsi, %rcx
je 0xf6cb
movb (%rdx,%rsi), %r8b
cmpb (%rdi,%rsi), %r8b
jne 0xf6c9
incq %rsi
cmpq %rsi, %rax
jne 0xf629
movl %ebx, %ecx
jmp 0xf6cb
movslq %ecx, %r14
leal 0x1(%rbx), %edx
shrl $0x4, %eax
leal -0x1(%r14), %esi
leaq -0x1(%r14), %rdi
movl $0x1, %ecx
movq %rax, %r8
movq 0x40(%rsp), %r11
testq %rdi, %rdi
js 0xf68d
leal (%rsi,%r8), %r9d
movslq %r9d, %r9
movb (%r11,%r9), %r9b
cmpb (%r11,%rdi), %r9b
jne 0xf68d
incq %rcx
decq %rdi
decq %r8
jne 0xf66a
movl %edx, %ecx
decl %ecx
movslq %ecx, %r12
movslq %r10d, %rdx
movl 0x54(%rsp), %esi
cmpl %edx, %esi
movl %edx, %ecx
cmovgl %esi, %ecx
subl %edx, %ecx
movl %ebx, %r9d
leaq (%r11,%r14), %rsi
addq %r11, %rdx
xorl %edi, %edi
cmpq %rdi, %rcx
je 0xf70c
movb (%rsi,%rdi), %r8b
cmpb (%rdx,%rdi), %r8b
jne 0xf70a
incq %rdi
cmpq %rdi, %rax
jne 0xf6ae
movl %ebx, %ecx
jmp 0xf70c
movl %esi, %ecx
movl %ecx, %ebx
movq 0x20(%rsp), %r13
movq %r13, %rdi
leaq 0x1e733(%rip), %rsi     # 0x2de0f
xorl %eax, %eax
callq 0xe575
addq %r15, %rbp
movq %r13, %rdi
movq 0x60(%rsp), %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0x10bd2
movq 0x30(%rsp), %r13
movl 0x2c(%rsp), %ebp
jmp 0xf5a8
movl %edi, %ecx
movl %ecx, %eax
movq %rax, 0x18(%rsp)
movq %r9, %rbx
movq 0x20(%rsp), %r13
movq %r13, %rdi
leaq 0x1e085(%rip), %rsi     # 0x2d7aa
xorl %eax, %eax
callq 0xe575
addq 0x40(%rsp), %r14
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq 0x18(%rsp), %rcx
movq %r12, %r8
callq 0x10bd2
movl 0x2c(%rsp), %eax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rax
movl %eax, %r12d
movq 0x30(%rsp), %r13
jmp 0xf5a8
movl %ebp, %r14d
movq 0x48(%rsp), %r15
movl 0x10(%rsp), %ecx
jmp 0xf775
xorl %ecx, %ecx
xorl %r14d, %r14d
movl 0x1c(%r12), %eax
subl 0x18(%r12), %eax
cmpl %eax, %r14d
jne 0xf792
movl 0x14(%r12), %eax
subl 0x10(%r12), %eax
cmpl %eax, %ecx
je 0xf7e1
leaq 0x1e5be(%rip), %rdi     # 0x2dd57
leaq 0x1e284(%rip), %rsi     # 0x2da24
leaq 0x1e542(%rip), %rcx     # 0x2dce9
movl $0x14a, %edx            # imm = 0x14A
callq 0x21a0
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
movq 0x58(%rsp), %rcx
movl 0x1c(%rcx), %eax
subl 0x18(%rcx), %eax
cmpl %eax, 0x18(%rsp)
jne 0xf874
movl 0x14(%rcx), %eax
subl 0x10(%rcx), %eax
cmpl %eax, %r12d
jne 0xf874
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x12587
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x12587
movq %rbx, %rdi
movq %r13, %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12587
leaq 0x1e463(%rip), %rdi     # 0x2dc81
leaq 0x1e1ff(%rip), %rsi     # 0x2da24
leaq 0x1e4bd(%rip), %rcx     # 0x2dce9
movl $0x134, %edx            # imm = 0x134
callq 0x21a0
leaq 0x1e1de(%rip), %rdi     # 0x2da1b
leaq 0x1e1e0(%rip), %rsi     # 0x2da24
leaq 0x1e545(%rip), %rcx     # 0x2dd90
movl $0xf7, %edx
callq 0x21a0
leaq 0x1e425(%rip), %rdi     # 0x2dc81
leaq 0x1e1c1(%rip), %rsi     # 0x2da24
leaq 0x1e526(%rip), %rcx     # 0x2dd90
movl $0xba, %edx
callq 0x21a0
leaq 0x1e4dc(%rip), %rdi     # 0x2dd57
leaq 0x1e1a2(%rip), %rsi     # 0x2da24
leaq 0x1e507(%rip), %rcx     # 0x2dd90
movl $0xfd, %edx
callq 0x21a0