// File: /workspace/github_c_makefile_star2_O1/lh3[P]minimap2/format.c
// Function: mm_write_paf4
void mm_write_paf4(kstring_t *s, const mm_idx_t *mi, const mm_bseq1_t *t, const mm_reg1_t *r, void *km, int64_t opt_flag, int rep_len, int n_seg, int seg_idx)
{
	s->l = 0;
	mm_sprintf_lite(s, "%s", t->name);
	if ((opt_flag & MM_F_FRAG_MODE) && n_seg >= 2 && seg_idx >= 0)
		mm_sprintf_lite(s, "/%d", seg_idx + 1);
	if (r == 0) {
		mm_sprintf_lite(s, "\t%d\t0\t0\t*\t*\t0\t0\t0\t0\t0\t0", t->l_seq);
		if (rep_len >= 0) mm_sprintf_lite(s, "\trl:i:%d", rep_len);
		return;
	}
	mm_sprintf_lite(s, "\t%d\t%d\t%d\t%c\t", t->l_seq, r->qs, r->qe, "+-"[r->rev]);
	if (mi->seq[r->rid].name) mm_sprintf_lite(s, "%s", mi->seq[r->rid].name);
	else mm_sprintf_lite(s, "%d", r->rid);
	mm_sprintf_lite(s, "\t%d", mi->seq[r->rid].len);
	if ((opt_flag & MM_F_QSTRAND) && r->rev)
		mm_sprintf_lite(s, "\t%d\t%d", mi->seq[r->rid].len - r->re, mi->seq[r->rid].len - r->rs);
	else
		mm_sprintf_lite(s, "\t%d\t%d", r->rs, r->re);
	mm_sprintf_lite(s, "\t%d\t%d", r->mlen, r->blen);
	mm_sprintf_lite(s, "\t%d", r->mapq);
	write_tags(s, r);
	if (rep_len >= 0) mm_sprintf_lite(s, "\trl:i:%d", rep_len);
	if (r->p && (opt_flag & MM_F_OUT_CG)) {
		uint32_t k;
		mm_sprintf_lite(s, "\tcg:Z:");
		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 (r->p && (opt_flag & (MM_F_OUT_CS|MM_F_OUT_DS|MM_F_OUT_MD)))
		write_cs_ds_or_MD(km, s, mi, t, r, !(opt_flag&MM_F_OUT_CS_LONG), !!(opt_flag&MM_F_OUT_MD), !!(opt_flag&MM_F_OUT_DS), 1, !!(opt_flag&MM_F_QSTRAND));
	if ((opt_flag & MM_F_COPY_COMMENT) && t->comment)
		mm_sprintf_lite(s, "\t%s", t->comment);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r15
movq %r8, 0x20(%rsp)
movq %rcx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, %rbx
movl 0x70(%rsp), %ebp
movl 0x60(%rsp), %r13d
movl 0x68(%rsp), %r14d
movq $0x0, (%rdi)
movq %rdx, 0x8(%rsp)
movq 0x8(%rdx), %rdx
leaq 0x1d0cd(%rip), %rsi     # 0x2cad9
xorl %eax, %eax
callq 0xe671
btl $0xd, %r15d
setae %al
cmpl $0x2, %r14d
setl %cl
testl %ebp, %ebp
sets %dl
orb %cl, %dl
orb %al, %dl
jne 0xfa42
incl %ebp
leaq 0x1d051(%rip), %rsi     # 0x2ca87
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe671
movq 0x8(%rsp), %rax
movl (%rax), %edx
testq %r12, %r12
je 0xfab0
movl 0x10(%r12), %ecx
movl 0x14(%r12), %r8d
btl $0xa, 0x3c(%r12)
leaq 0x1cd23(%rip), %rax     # 0x2c789
adcq $0x0, %rax
movsbl (%rax), %r9d
leaq 0x1d037(%rip), %rsi     # 0x2caac
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movq 0x10(%rsp), %r14
movq 0x20(%r14), %rax
movslq 0x8(%r12), %rdx
leaq (%rdx,%rdx,2), %rcx
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0xfaec
leaq 0x1d038(%rip), %rsi     # 0x2cad9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe671
jmp 0xfafd
leaq 0x1cfd4(%rip), %rsi     # 0x2ca8b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
testl %r13d, %r13d
js 0xfccc
leaq 0x1cfd2(%rip), %rsi     # 0x2caa3
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe671
leaq 0x1cfcb(%rip), %rsi     # 0x2cabe
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movq 0x20(%r14), %rax
movslq 0x8(%r12), %rcx
leaq (%rcx,%rcx,2), %rcx
movl 0x10(%rax,%rcx,8), %edx
leaq 0x1cfa8(%rip), %rsi     # 0x2cabd
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movabsq $0x100000000, %rax      # imm = 0x100000000
andq %r15, %rax
movq %rax, 0x18(%rsp)
je 0xfb3b
testb $0x4, 0x3d(%r12)
jne 0xfb47
movl 0x18(%r12), %edx
movl 0x1c(%r12), %ecx
jmp 0xfb64
movq 0x20(%r14), %rax
movslq 0x8(%r12), %rcx
leaq (%rcx,%rcx,2), %rcx
movl 0x10(%rax,%rcx,8), %ecx
movl %ecx, %edx
subl 0x1c(%r12), %edx
subl 0x18(%r12), %ecx
leaq 0x1cf4f(%rip), %rsi     # 0x2caba
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movl 0x2c(%r12), %edx
movl 0x30(%r12), %ecx
leaq 0x1cf34(%rip), %rsi     # 0x2caba
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movzbl 0x3c(%r12), %edx
leaq 0x1cf20(%rip), %rsi     # 0x2cabd
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movq %rbx, %rdi
movq %r12, %rsi
callq 0xfcdb
testl %r13d, %r13d
js 0xfbcb
leaq 0x1cee5(%rip), %rsi     # 0x2caa3
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe671
testb $0x20, %r15b
je 0xfc33
cmpq $0x0, 0x48(%r12)
je 0xfc33
leaq 0x1cee1(%rip), %rsi     # 0x2cac1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe671
movq 0x48(%r12), %rax
cmpl $0x0, 0x18(%rax)
je 0xfc33
leaq 0x1ced1(%rip), %r14     # 0x2cacd
leaq 0x1cec5(%rip), %r13     # 0x2cac8
xorl %ebp, %ebp
movl 0x1c(%rax,%rbp,4), %eax
movl %eax, %edx
shrl $0x4, %edx
andl $0xf, %eax
movsbl (%rax,%r14), %ecx
movq %rbx, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0xe671
incq %rbp
movq 0x48(%r12), %rax
movl 0x18(%rax), %ecx
cmpq %rcx, %rbp
jb 0xfc05
movabsq $0x2001000040, %rax     # imm = 0x2001000040
testq %rax, %r15
je 0xfc98
cmpq $0x0, 0x48(%r12)
je 0xfc98
xorl %r9d, %r9d
btl $0xb, %r15d
setae %r9b
movl %r15d, %eax
shrl $0x18, %eax
andl $0x1, %eax
movq %r15, %r10
shrq $0x25, %r10
andl $0x1, %r10d
movq 0x18(%rsp), %r11
shrq $0x20, %r11
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq %r12, %r8
pushq %r11
pushq $0x1
pushq %r10
pushq %rax
callq 0xef18
addq $0x20, %rsp
btl $0x19, %r15d
jae 0xfccc
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rdx
testq %rdx, %rdx
je 0xfccc
leaq 0x1ce24(%rip), %rsi     # 0x2cad8
movq %rbx, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe671
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq