// File: /workspace/github_c_makefile_star2_O2/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, 0x14(%rsp)
cmpq $0x0, 0x48(%r8)
je 0xd5df
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x18(%rsp)
movl 0xc8(%rsp), %ebp
movl 0xc0(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0xb8(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0xb0(%rsp), %eax
movl %eax, 0x20(%rsp)
movslq 0x14(%r8), %rsi
movslq 0x10(%r8), %rax
subq %rax, %rsi
movq %r8, %r13
movq %rdi, %r15
callq 0x10afc
movq %rax, 0x28(%rsp)
movslq 0x1c(%r13), %rsi
movslq 0x18(%r13), %rax
subq %rax, %rsi
movq %r15, %rdi
callq 0x10afc
movq %rax, %r12
movl 0x1c(%r13), %eax
subl 0x18(%r13), %eax
movl 0x14(%r13), %ecx
subl 0x10(%r13), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
incl %ecx
movslq %ecx, %rsi
movq %r15, 0x70(%rsp)
movq %r15, %rdi
callq 0x10afc
movq %rax, 0x48(%rsp)
testl %ebp, %ebp
je 0xd5ee
movl 0x3c(%r13), %esi
shrl $0xa, %esi
andl $0x1, %esi
movl 0x8(%r13), %edx
movl 0x18(%r13), %ecx
movl 0x1c(%r13), %r8d
movq %r14, %rdi
movq %r12, %r9
callq 0x6237
movslq 0x10(%r13), %rax
leaq 0x2526d(%rip), %rcx     # 0x32810
movq 0x28(%rsp), %r14
movq %r12, %r15
movq %r13, %r12
movq 0x48(%rsp), %r13
movslq 0x14(%r12), %rdx
cmpq %rdx, %rax
jge 0xd6a6
movq 0x10(%rbx), %rdx
movzbl (%rdx,%rax), %edx
movb (%rcx,%rdx), %dl
movslq 0x10(%r12), %rsi
movq %r14, %rdi
subq %rsi, %rdi
movb %dl, (%rdi,%rax)
incq %rax
jmp 0xd5b3
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%r13), %esi
movl 0x18(%r13), %edx
movl 0x1c(%r13), %ecx
movq %r14, %rdi
movq %r12, %r8
callq 0x612e
testb $0x4, 0x3d(%r13)
movslq 0x10(%r13), %rax
movq %r13, %rdi
movq %r12, %r15
jne 0xd652
leaq 0x251f3(%rip), %rcx     # 0x32810
movq 0x28(%rsp), %r14
movq 0x48(%rsp), %r13
movq %rdi, %r12
movslq 0x14(%r12), %rdx
cmpq %rdx, %rax
jge 0xd6a6
movq 0x10(%rbx), %rdx
movzbl (%rdx,%rax), %edx
movb (%rcx,%rdx), %dl
movslq 0x10(%r12), %rsi
movq %r14, %rdi
subq %rsi, %rdi
movb %dl, (%rdi,%rax)
incq %rax
jmp 0xd62a
movl %eax, %ecx
notl %ecx
leaq 0x251b3(%rip), %rdx     # 0x32810
pushq $0x4
popq %rsi
movq 0x28(%rsp), %r14
movq 0x48(%rsp), %r13
movq %rdi, %r12
movslq 0x14(%r12), %rdi
cmpq %rdi, %rax
jge 0xd6a6
movq 0x10(%rbx), %r8
movzbl (%r8,%rax), %r8d
movb (%rdx,%r8), %r8b
movb $0x3, %r9b
subb %r8b, %r9b
cmpb $0x4, %r8b
movzbl %r9b, %r8d
cmovael %esi, %r8d
addl %ecx, %edi
movslq %edi, %rdi
movb %r8b, (%r14,%rdi)
incq %rax
decl %ecx
jmp 0xd66d
cmpl $0x0, 0x20(%rsp)
movq %r15, 0x20(%rsp)
movq %r12, 0x38(%rsp)
je 0xd87c
cmpl $0x0, 0x8(%rsp)
je 0xd6d5
leaq 0x1b5b1(%rip), %rsi     # 0x28c7a
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xce8e
xorl %r15d, %r15d
leaq 0x1b66c(%rip), %r14     # 0x28d4b
xorl %ebp, %ebp
xorl %edx, %edx
movl $0x0, 0x8(%rsp)
movq 0x48(%r12), %rax
movslq 0x18(%rax), %rcx
cmpq %rcx, %r15
jge 0xd81a
movl 0x1c(%rax,%r15,4), %ecx
movl %ecx, %eax
andl $0xf, %eax
cmpl $0x8, %eax
ja 0xde3a
movl $0x18f, %esi            # imm = 0x18F
btl %eax, %esi
jae 0xde3a
movq %r12, %rbx
movl %ecx, %r12d
shrl $0x4, %r12d
cmpl $0x7, %eax
setne %sil
testb $0x7, %cl
setne %cl
movl %ebp, 0x14(%rsp)
movslq %ebp, %rbp
testb %sil, %cl
jne 0xd786
movslq 0x8(%rsp), %r13
addq 0x28(%rsp), %r13
addq 0x20(%rsp), %rbp
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0xd7a8
movzbl (%rbp,%rbx), %eax
cmpb %al, (%r13,%rbx)
jne 0xd767
incl %edx
jmp 0xd781
movsbl (%rax,%r14), %ecx
movq 0x18(%rsp), %rdi
leaq 0x1b370(%rip), %rsi     # 0x28ae8
xorl %eax, %eax
callq 0xce8e
xorl %edx, %edx
incq %rbx
jmp 0xd752
cmpl $0x3, %eax
je 0xd807
cmpl $0x2, %eax
je 0xd7c0
cmpl $0x1, %eax
jne 0xd79f
addl 0x8(%rsp), %r12d
movl %r12d, 0x8(%rsp)
movq %rbx, %r12
movl 0x14(%rsp), %ebp
jmp 0xd812
addl %r12d, 0x8(%rsp)
movl 0x14(%rsp), %ebp
addl %r12d, %ebp
movq 0x38(%rsp), %r12
movq 0x48(%rsp), %r13
jmp 0xd812
movb $0x0, (%r13,%r12)
addq 0x20(%rsp), %rbp
xorl %eax, %eax
cmpq %rax, %r12
je 0xd7e5
movzbl (%rbp,%rax), %ecx
movb (%rcx,%r14), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xd7cd
movq 0x18(%rsp), %rdi
leaq 0x1b560(%rip), %rsi     # 0x28d51
movq %r13, %rcx
xorl %eax, %eax
callq 0xce8e
addl 0x14(%rsp), %r12d
movl %r12d, %ebp
xorl %edx, %edx
jmp 0xd80f
addl 0x14(%rsp), %r12d
movl %r12d, %ebp
movq %rbx, %r12
incq %r15
jmp 0xd6eb
testl %edx, %edx
jle 0xd831
leaq 0x1b2b9(%rip), %rsi     # 0x28ade
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xce8e
movl 0x1c(%r12), %eax
subl 0x18(%r12), %eax
cmpl %eax, %ebp
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r15
jne 0xd85d
movl 0x14(%r12), %eax
subl 0x10(%r12), %eax
cmpl %eax, 0x8(%rsp)
je 0xde06
leaq 0x1b4f3(%rip), %rdi     # 0x28d57
leaq 0x1b1b9(%rip), %rsi     # 0x28a24
leaq 0x1b477(%rip), %rcx     # 0x28ce9
movl $0x14a, %edx            # imm = 0x14A
callq 0x21a0
cmpl $0x0, 0x8(%rsp)
je 0xd8a1
cmpl $0x1, 0x44(%rsp)
pushq $0x64
popq %rdx
sbbl $0x0, %edx
leaq 0x1b4f3(%rip), %rsi     # 0x28d88
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xce8e
movq 0x48(%r12), %rax
movl 0x18(%rax), %ecx
xorl %edx, %edx
testl %ecx, %ecx
movl $0x0, %esi
cmovgl %ecx, %esi
xorl %r9d, %r9d
xorl %edi, %edi
xorl %r8d, %r8d
cmpq %r9, %rsi
je 0xd910
movl 0x1c(%rax,%r9,4), %r11d
movl %r11d, %ebx
andl $0xf, %ebx
movl %r11d, %r10d
shrl $0x4, %r10d
cmpl $0x7, %ebx
setne %bpl
testb $0x7, %r11b
setne %r14b
testb %bpl, %r14b
jne 0xd8ed
addl %r10d, %r8d
jmp 0xd903
cmpl $0x1, %ebx
jne 0xd8f7
addl %r10d, %r8d
jmp 0xd906
andl $0xe, %r11d
cmpl $0x2, %r11d
cmovnel %edx, %r10d
addl %r10d, %edi
movq 0x28(%rsp), %r14
incq %r9
jmp 0xd8bd
movslq %edi, %rdx
movq %rdx, 0x68(%rsp)
movslq %r8d, %rdx
movq %rdx, 0x60(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
movslq %ecx, %rcx
cmpq %rcx, %rbp
jge 0xddde
movl 0x1c(%rax,%rbp,4), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x8, %ecx
ja 0xde78
movl $0x18f, %edx            # imm = 0x18F
btl %ecx, %edx
jae 0xde78
movl %eax, %r15d
shrl $0x4, %r15d
cmpl $0x7, %ecx
setne %dl
testb $0x7, %al
setne %sil
movslq 0x30(%rsp), %rbx
movslq 0x8(%rsp), %r12
testb %dl, %sil
jne 0xda51
movq %rbp, 0x50(%rsp)
addq %r14, %r12
addq 0x20(%rsp), %rbx
xorl %ebp, %ebp
xorl %r14d, %r14d
movl %r14d, %eax
cmpq %rbp, %r15
je 0xdad8
movzbl (%r12,%rbp), %ecx
cmpb (%rbx,%rbp), %cl
jne 0xd9c8
leaq 0x1b396(%rip), %rax     # 0x28d4b
movb (%rcx,%rax), %al
movslq %r14d, %rcx
incl %r14d
movb %al, (%r13,%rcx)
jmp 0xda49
testl %r14d, %r14d
jle 0xd9f2
cmpl $0x0, 0x14(%rsp)
je 0xd9f9
movq 0x18(%rsp), %r13
movq %r13, %rdi
leaq 0x1b48a(%rip), %rsi     # 0x28e6d
movl %r14d, %edx
xorl %eax, %eax
callq 0xce8e
xorl %r14d, %r14d
jmp 0xda1b
movq 0x18(%rsp), %r13
jmp 0xda1b
movb $0x0, (%r13,%rax)
xorl %r14d, %r14d
movq %r13, %rdx
movq 0x18(%rsp), %r13
movq %r13, %rdi
leaq 0x1b3eb(%rip), %rsi     # 0x28dff
xorl %eax, %eax
callq 0xce8e
movzbl (%rbx,%rbp), %eax
leaq 0x1b3e3(%rip), %rcx     # 0x28e09
movsbl (%rax,%rcx), %edx
movzbl (%r12,%rbp), %eax
movsbl (%rax,%rcx), %ecx
movq %r13, %rdi
leaq 0x1b3c6(%rip), %rsi     # 0x28e03
xorl %eax, %eax
callq 0xce8e
movq 0x48(%rsp), %r13
incq %rbp
jmp 0xd998
movl %r15d, %edx
cmpl $0x2, %ecx
je 0xdb11
cmpl $0x1, %ecx
jne 0xdb82
cmpl $0x0, 0x44(%rsp)
je 0xdc2f
movq %rdx, 0x58(%rsp)
movq %rbp, 0x50(%rsp)
movq 0x8(%rsp), %r13
leal (%r15,%r13), %ebx
leal 0x1(%r15), %ecx
leaq -0x1(%r12), %rdx
shrl $0x4, %eax
decl %r13d
movq %rax, %r8
pushq $0x1
popq %rsi
movq %rax, %rdi
movq 0x60(%rsp), %r11
subq $0x1, %rdi
jb 0xdcdb
movl %esi, %ebp
testq %rdx, %rdx
js 0xdcdd
addl %r13d, %r8d
movslq %r8d, %r8
movb (%r14,%r8), %r9b
incq %rsi
leaq -0x1(%rdx), %r10
movq %rdi, %r8
cmpb (%r14,%rdx), %r9b
movq %r10, %rdx
je 0xdaa1
jmp 0xdcdd
testl %r14d, %r14d
movq 0x38(%rsp), %r12
movq 0x50(%rsp), %rbp
jle 0xdc0e
cmpl $0x0, 0x14(%rsp)
je 0xdbf2
movq 0x18(%rsp), %rdi
leaq 0x1b36b(%rip), %rsi     # 0x28e6d
movl %r14d, %edx
xorl %eax, %eax
callq 0xce8e
jmp 0xdc0e
cmpl $0x0, 0x44(%rsp)
je 0xdc80
movq %rdx, 0x58(%rsp)
movq %rbp, 0x50(%rsp)
movq 0x30(%rsp), %r12
leal (%r15,%r12), %r14d
leal 0x1(%r15), %ecx
leaq -0x1(%rbx), %rdx
shrl $0x4, %eax
decl %r12d
movq %rax, %r8
pushq $0x1
popq %rsi
movq %rax, %rdi
subq $0x1, %rdi
jb 0xdd3e
movl %esi, %ebp
testq %rdx, %rdx
js 0xdd40
addl %r12d, %r8d
movslq %r8d, %r8
movq 0x20(%rsp), %r11
movb (%r11,%r8), %r9b
incq %rsi
leaq -0x1(%rdx), %r10
movq %rdi, %r8
cmpb (%r11,%rdx), %r9b
movq %r10, %rdx
je 0xdb46
jmp 0xdd40
cmpl $0x1f, %eax
jbe 0xde59
movq 0x20(%rsp), %rdi
movzbl (%rdi,%rbx), %eax
leaq 0x1b26e(%rip), %r8      # 0x28e09
movsbl (%rax,%r8), %edx
movzbl 0x1(%rdi,%rbx), %eax
movsbl (%rax,%r8), %ecx
movq 0x30(%rsp), %rax
addl %r15d, %eax
movq %rax, 0x30(%rsp)
cltq
movzbl -0x2(%rdi,%rax), %esi
movsbl (%rsi,%r8), %r9d
movzbl -0x1(%rdi,%rax), %eax
movsbl (%rax,%r8), %eax
movl %eax, (%rsp)
movq 0x18(%rsp), %rdi
leaq 0x1b23d(%rip), %rsi     # 0x28e19
movl %r15d, %r8d
xorl %eax, %eax
callq 0xce8e
movq 0x8(%rsp), %rax
movl %eax, %ebx
jmp 0xdc76
movb $0x0, (%r13,%rax)
movq 0x18(%rsp), %rdi
leaq 0x1b1fb(%rip), %rsi     # 0x28dff
movq %r13, %rdx
xorl %eax, %eax
callq 0xce8e
movq 0x8(%rsp), %rcx
addl %r15d, %ecx
movq 0x30(%rsp), %rax
addl %r15d, %eax
movq %rax, 0x30(%rsp)
movl %ecx, %ebx
movq 0x28(%rsp), %r14
jmp 0xddc2
movb $0x0, (%r13,%r15)
addq %r14, %r12
xorl %eax, %eax
cmpq %rax, %r15
je 0xdc58
movzbl (%r12,%rax), %ecx
leaq 0x1b1be(%rip), %rdx     # 0x28e09
movb (%rcx,%rdx), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xdc3a
movq 0x18(%rsp), %rdi
leaq 0x1b1ad(%rip), %rsi     # 0x28e11
movq %r13, %rdx
xorl %eax, %eax
callq 0xce8e
addl 0x8(%rsp), %r15d
movl %r15d, %ebx
movq 0x38(%rsp), %r12
jmp 0xddc2
movb $0x0, (%r13,%r15)
addq 0x20(%rsp), %rbx
xorl %eax, %eax
movq 0x38(%rsp), %r12
cmpq %rax, %r15
je 0xdcaf
movzbl (%rbx,%rax), %ecx
leaq 0x1b167(%rip), %rdx     # 0x28e09
movb (%rcx,%rdx), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xdc92
movq 0x18(%rsp), %rdi
leaq 0x1b15a(%rip), %rsi     # 0x28e15
movq %r13, %rdx
xorl %eax, %eax
callq 0xce8e
addl 0x30(%rsp), %r15d
movq %r15, 0x30(%rsp)
movq 0x8(%rsp), %rax
movl %eax, %ebx
jmp 0xddc2
movl %ecx, %ebp
decl %ebp
movslq %ebx, %rcx
addq %r14, %r12
leaq (%r14,%rcx), %rsi
xorl %edx, %edx
cmpq %rdx, %rax
je 0xdd0b
leaq (%rcx,%rdx), %rdi
cmpq %r11, %rdi
jge 0xdd08
movb (%rsi,%rdx), %dil
cmpb (%r12,%rdx), %dil
jne 0xdd08
incq %rdx
jmp 0xdceb
movl %edx, %r15d
movq 0x18(%rsp), %r13
movq %r13, %rdi
leaq 0x1b0f5(%rip), %rsi     # 0x28e0f
xorl %eax, %eax
callq 0xce8e
movl %r15d, %ecx
movslq %ebp, %r8
movq %r13, %rdi
movq 0x58(%rsp), %rsi
movq %r12, %rdx
callq 0xf12e
movq 0x48(%rsp), %r13
jmp 0xddb8
movl %ecx, %ebp
decl %ebp
movslq %r14d, %rcx
movq 0x20(%rsp), %rdx
addq %rdx, %rbx
leaq (%rdx,%rcx), %rsi
xorl %edx, %edx
movq 0x68(%rsp), %r8
cmpq %rdx, %rax
je 0xdd78
leaq (%rcx,%rdx), %rdi
cmpq %r8, %rdi
jge 0xdd75
movb (%rbx,%rdx), %dil
cmpb (%rsi,%rdx), %dil
jne 0xdd75
incq %rdx
jmp 0xdd58
movl %edx, %r15d
movq 0x18(%rsp), %r12
movq %r12, %rdi
leaq 0x1aa23(%rip), %rsi     # 0x287aa
xorl %eax, %eax
callq 0xce8e
movl %r15d, %ecx
movslq %ebp, %r8
movq %r12, %rdi
movq 0x58(%rsp), %rsi
movq %rbx, %rdx
callq 0xf12e
movl %r14d, %eax
movq %rax, 0x30(%rsp)
movq 0x8(%rsp), %rax
movl %eax, %ebx
movq 0x28(%rsp), %r14
movq 0x38(%rsp), %r12
movq 0x50(%rsp), %rbp
incq %rbp
movq 0x48(%r12), %rax
movl 0x18(%rax), %ecx
movl %ebx, %edx
movq %rdx, 0x8(%rsp)
movq 0x20(%rsp), %r15
jmp 0xd934
movl 0x1c(%r12), %eax
subl 0x18(%r12), %eax
cmpl %eax, 0x30(%rsp)
jne 0xde97
movl 0x14(%r12), %eax
subl 0x10(%r12), %eax
cmpl %eax, 0x8(%rsp)
jne 0xde97
movq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10a07
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10a07
movq %rbx, %rdi
movq %r13, %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a07
leaq 0x1ae40(%rip), %rdi     # 0x28c81
leaq 0x1abdc(%rip), %rsi     # 0x28a24
leaq 0x1ae9a(%rip), %rcx     # 0x28ce9
movl $0x134, %edx            # imm = 0x134
callq 0x21a0
leaq 0x1abbb(%rip), %rdi     # 0x28a1b
leaq 0x1abbd(%rip), %rsi     # 0x28a24
leaq 0x1af22(%rip), %rcx     # 0x28d90
movl $0xf7, %edx
callq 0x21a0
leaq 0x1ae02(%rip), %rdi     # 0x28c81
leaq 0x1ab9e(%rip), %rsi     # 0x28a24
leaq 0x1af03(%rip), %rcx     # 0x28d90
movl $0xba, %edx
callq 0x21a0
leaq 0x1aeb9(%rip), %rdi     # 0x28d57
leaq 0x1ab7f(%rip), %rsi     # 0x28a24
leaq 0x1aee4(%rip), %rcx     # 0x28d90
movl $0xfd, %edx
callq 0x21a0