// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap2/format.c
// Function: mm_write_sam3
void mm_write_sam3(kstring_t *s, const mm_idx_t *mi, const mm_bseq1_t *t, int seg_idx, int reg_idx, int n_seg, const int *n_regss, const mm_reg1_t *const* regss, void *km, int64_t opt_flag, int rep_len)
{
	const int max_bam_cigar_op = 65535;
	int flag, n_regs = n_regss[seg_idx], cigar_in_tag = 0;
	int this_rid = -1, this_pos = -1;
	const mm_reg1_t *regs = regss[seg_idx], *r_prev = NULL, *r_next;
	const mm_reg1_t *r = n_regs > 0 && reg_idx < n_regs && reg_idx >= 0? &regs[reg_idx] : NULL;

	// find the primary of the previous and the next segments, if they are mapped
	if (n_seg > 1) {
		int i, next_sid = (seg_idx + 1) % n_seg;
		r_next = get_sam_pri(n_regss[next_sid], regss[next_sid]);
		if (n_seg > 2) {
			for (i = 1; i <= n_seg - 1; ++i) {
				int prev_sid = (seg_idx + n_seg - i) % n_seg;
				if (n_regss[prev_sid] > 0) {
					r_prev = get_sam_pri(n_regss[prev_sid], regss[prev_sid]);
					break;
				}
			}
		} else r_prev = r_next;
	} else r_prev = r_next = NULL;

	// write QNAME
	s->l = 0;
	mm_sprintf_lite(s, "%s", t->name);
	if (n_seg > 1) s->l = mm_qname_len(t->name); // trim the suffix like /1 or /2

	// write flag
	flag = n_seg > 1? 0x1 : 0x0;
	if (r == 0) {
		flag |= 0x4;
	} else {
		if (r->rev) flag |= 0x10;
		if (r->parent != r->id) flag |= 0x100;
		else if (!r->sam_pri) flag |= 0x800;
	}
	if (n_seg > 1) {
		if (r && r->proper_frag) flag |= 0x2; // TODO: this doesn't work when there are more than 2 segments
		if (seg_idx == 0) flag |= 0x40;
		else if (seg_idx == n_seg - 1) flag |= 0x80;
		if (r_next == NULL) flag |= 0x8;
		else if (r_next->rev) flag |= 0x20;
	}
	mm_sprintf_lite(s, "\t%d", flag);

	// write coordinate, MAPQ and CIGAR
	if (r == 0) {
		if (r_prev) {
			this_rid = r_prev->rid, this_pos = r_prev->rs;
			mm_sprintf_lite(s, "\t%s\t%d\t0\t*", mi->seq[this_rid].name, this_pos+1);
		} else mm_sprintf_lite(s, "\t*\t0\t0\t*");
	} else {
		this_rid = r->rid, this_pos = r->rs;
		mm_sprintf_lite(s, "\t%s\t%d\t%d\t", mi->seq[r->rid].name, r->rs+1, r->mapq);
		if ((opt_flag & MM_F_LONG_CIGAR) && r->p && r->p->n_cigar > max_bam_cigar_op - 2) {
			int n_cigar = r->p->n_cigar;
			if (r->qs != 0) ++n_cigar;
			if (r->qe != t->l_seq) ++n_cigar;
			if (n_cigar > max_bam_cigar_op)
				cigar_in_tag = 1;
		}
		if (cigar_in_tag) {
			int slen;
			if ((flag & 0x900) == 0 || (opt_flag & MM_F_SOFTCLIP)) slen = t->l_seq;
			else if ((flag & 0x100) && !(opt_flag & MM_F_SECONDARY_SEQ)) slen = 0;
			else slen = r->qe - r->qs;
			mm_sprintf_lite(s, "%dS%dN", slen, r->re - r->rs);
		} else write_sam_cigar(s, flag, 0, t->l_seq, r, opt_flag);
	}

	// write mate positions
	if (n_seg > 1) {
		int tlen = 0;
		if (this_rid >= 0 && r_next) {
			if (this_rid == r_next->rid) {
				if (r) {
					int this_pos5 = r->rev? r->re - 1 : this_pos;
					int next_pos5 = r_next->rev? r_next->re - 1 : r_next->rs;
					tlen = next_pos5 - this_pos5;
				}
				mm_sprintf_lite(s, "\t=\t");
			} else mm_sprintf_lite(s, "\t%s\t", mi->seq[r_next->rid].name);
			mm_sprintf_lite(s, "%d\t", r_next->rs + 1);
		} else if (r_next) { // && this_rid < 0
			mm_sprintf_lite(s, "\t%s\t%d\t", mi->seq[r_next->rid].name, r_next->rs + 1);
		} else if (this_rid >= 0) { // && r_next == NULL
			mm_sprintf_lite(s, "\t=\t%d\t", this_pos + 1); // next segment will take r's coordinate
		} else mm_sprintf_lite(s, "\t*\t0\t"); // neither has coordinates
		if (tlen > 0) ++tlen;
		else if (tlen < 0) --tlen;
		mm_sprintf_lite(s, "%d\t", tlen);
	} else mm_sprintf_lite(s, "\t*\t0\t0\t");

	// write SEQ and QUAL
	if (r == 0) {
		sam_write_sq(s, t->seq, t->l_seq, 0, 0);
		mm_sprintf_lite(s, "\t");
		if (t->qual) sam_write_sq(s, t->qual, t->l_seq, 0, 0);
		else mm_sprintf_lite(s, "*");
	} else {
		if ((flag & 0x900) == 0 || (opt_flag & MM_F_SOFTCLIP)) {
			sam_write_sq(s, t->seq, t->l_seq, r->rev, r->rev);
			mm_sprintf_lite(s, "\t");
			if (t->qual) sam_write_sq(s, t->qual, t->l_seq, r->rev, 0);
			else mm_sprintf_lite(s, "*");
		} else if ((flag & 0x100) && !(opt_flag & MM_F_SECONDARY_SEQ)){
			mm_sprintf_lite(s, "*\t*");
		} else {
			sam_write_sq(s, t->seq + r->qs, r->qe - r->qs, r->rev, r->rev);
			mm_sprintf_lite(s, "\t");
			if (t->qual) sam_write_sq(s, t->qual + r->qs, r->qe - r->qs, r->rev, 0);
			else mm_sprintf_lite(s, "*");
		}
	}

	// write tags
	if (mm_rg_id[0]) mm_sprintf_lite(s, "\tRG:Z:%s", mm_rg_id);
	if (n_seg > 2) mm_sprintf_lite(s, "\tFI:i:%d", seg_idx);
	if (r) {
		write_tags(s, r);
		if (r->parent == r->id && r->p && n_regs > 1 && regs && r >= regs && r - regs < n_regs) { // supplementary aln may exist
			int i, n_sa = 0; // n_sa: number of SA fields
			for (i = 0; i < n_regs; ++i)
				if (i != r - regs && regs[i].parent == regs[i].id && regs[i].p)
					++n_sa;
			if (n_sa > 0) {
				mm_sprintf_lite(s, "\tSA:Z:");
				for (i = 0; i < n_regs; ++i) {
					const mm_reg1_t *q = &regs[i];
					int l_M, l_I = 0, l_D = 0, clip5 = 0, clip3 = 0;
					if (r == q || q->parent != q->id || q->p == 0) continue;
					if (q->qe - q->qs < q->re - q->rs) l_M = q->qe - q->qs, l_D = (q->re - q->rs) - l_M;
					else l_M = q->re - q->rs, l_I = (q->qe - q->qs) - l_M;
					clip5 = q->rev? t->l_seq - q->qe : q->qs;
					clip3 = q->rev? q->qs : t->l_seq - q->qe;
					mm_sprintf_lite(s, "%s,%d,%c,", mi->seq[q->rid].name, q->rs+1, "+-"[q->rev]);
					if (clip5) mm_sprintf_lite(s, "%dS", clip5);
					if (l_M) mm_sprintf_lite(s, "%dM", l_M);
					if (l_I) mm_sprintf_lite(s, "%dI", l_I);
					if (l_D) mm_sprintf_lite(s, "%dD", l_D);
					if (clip3) mm_sprintf_lite(s, "%dS", clip3);
					mm_sprintf_lite(s, ",%d,%d;", q->mapq, q->blen - q->mlen + q->p->n_ambi);
				}
			}
		}
		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, 0);
		if (cigar_in_tag)
			write_sam_cigar(s, flag, 1, t->l_seq, r, opt_flag);
	}
	if (rep_len >= 0) mm_sprintf_lite(s, "\trl:i:%d", rep_len);

	if ((opt_flag & MM_F_COPY_COMMENT) && t->comment)
		mm_sprintf_lite(s, "\t%s", t->comment);

	s->s[s->l] = 0; // we always have room for an extra byte (see str_enlarge)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, %r13d
movl %ecx, %r12d
movq %rdx, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, (%rsp)
movq 0x98(%rsp), %rbx
movq 0x90(%rsp), %rbp
movslq %ecx, %rax
movl (%rbp,%rax,4), %ecx
movq (%rbx,%rax,8), %rdx
movl %r8d, %eax
imulq $0x50, %rax, %r15
movq %rdx, 0x50(%rsp)
addq %rdx, %r15
xorl %r14d, %r14d
cmpl %r8d, %ecx
cmovbeq %r14, %r15
movq %rcx, 0x48(%rsp)
testl %ecx, %ecx
cmovleq %r14, %r15
movl $0x0, %esi
cmpl $0x2, %r9d
jl 0xe484
leal 0x1(%r12), %eax
cltd
idivl %r13d
movslq %edx, %rax
movl (%rbp,%rax,4), %edi
movq (%rbx,%rax,8), %rsi
callq 0xed3c
movq %rax, %r14
cmpl $0x2, %r13d
jne 0xe457
movq %r14, %rsi
jmp 0xe484
leal -0x1(%r13), %eax
xorl %esi, %esi
movl %eax, %ecx
subl $0x1, %ecx
jb 0xe484
addl %r12d, %eax
cltd
idivl %r13d
movslq %edx, %rdx
movl (%rbp,%rdx,4), %edi
movl %ecx, %eax
testl %edi, %edi
jle 0xe45f
movq (%rbx,%rdx,8), %rsi
callq 0xed3c
movq %rax, %rsi
movq %rsi, 0x20(%rsp)
movq %r12, 0x10(%rsp)
movq (%rsp), %rbp
andq $0x0, (%rbp)
movq 0x30(%rsp), %rbx
movq 0x8(%rbx), %rdx
leaq 0x1a652(%rip), %rsi     # 0x28af9
xorl %r12d, %r12d
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
cmpl $0x2, %r13d
movq %r14, 0x40(%rsp)
jl 0xe505
movq 0x8(%rbx), %rbp
movq %rbp, %rdi
callq 0x2130
cmpl $0x3, %eax
movq %rbx, %r12
jl 0xe4ed
movl %eax, %ecx
decl %ecx
movb (%rbp,%rcx), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0xe4ed
leal -0x2(%rax), %ecx
cmpb $0x2f, (%rbp,%rcx)
je 0xe4ef
movl %eax, %ecx
movslq %ecx, %rax
movq (%rsp), %rbp
movq %rax, (%rbp)
testq %r15, %r15
je 0xe55a
pushq $0x1
popq %r12
jmp 0xe50a
testq %r15, %r15
je 0xe57c
movl 0x20(%r15), %ecx
movl 0x3c(%r15), %eax
movl %eax, %edx
shrl $0x6, %edx
andl $0x10, %edx
orl %r12d, %edx
cmpl (%r15), %ecx
jne 0xe533
movl %eax, %ecx
shrl %ecx
movl $0x800, %esi            # imm = 0x800
andl %esi, %ecx
orl %ecx, %edx
xorl %esi, %edx
jmp 0xe539
orl $0x100, %edx            # imm = 0x100
movq 0x30(%rsp), %r12
movq 0x10(%rsp), %rsi
cmpl $0x2, %r13d
jl 0xe555
shrl $0xc, %eax
andl $0x2, %eax
orl %edx, %eax
xorl %edi, %edi
jmp 0xe565
xorl %r14d, %r14d
jmp 0xe5a7
pushq $0x5
popq %rax
movb $0x1, %dil
movq 0x10(%rsp), %rsi
testl %esi, %esi
je 0xe589
leal -0x1(%r13), %ecx
movl %eax, %edx
orl $0x80, %edx
cmpl %esi, %ecx
cmovel %edx, %eax
jmp 0xe58c
pushq $0x4
popq %rdx
movb $0x1, %r14b
movq 0x30(%rsp), %r12
jmp 0xe5a7
orl $0x40, %eax
testq %r14, %r14
je 0xe59f
movl 0x3c(%r14), %edx
shrl $0x5, %edx
andl $0x20, %edx
orl %eax, %edx
jmp 0xe5a4
orl $0x8, %eax
movl %eax, %edx
movl %edi, %r14d
movq 0xa8(%rsp), %rbx
leaq 0x1a527(%rip), %rsi     # 0x28add
movq %rbp, %rdi
movl %edx, 0xc(%rsp)
xorl %eax, %eax
callq 0xce8e
testb %r14b, %r14b
movl %r14d, 0x1c(%rsp)
je 0xe618
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0xe6b6
movq %rbp, %rdi
movslq 0x8(%rax), %rbp
movl 0x18(%rax), %esi
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
imulq $0x18, %rbp, %rcx
movq (%rax,%rcx), %rdx
movq %rsi, 0x38(%rsp)
leal 0x1(%rsi), %ecx
leaq 0x1a4f6(%rip), %rsi     # 0x28afc
xorl %eax, %eax
callq 0xce8e
movb $0x1, %al
movl %eax, 0x20(%rsp)
jmp 0xe6d5
movq %rbp, %rdi
movslq 0x8(%r15), %rbp
movl 0x18(%r15), %esi
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
imulq $0x18, %rbp, %rcx
movq (%rax,%rcx), %rdx
movq %rsi, 0x38(%rsp)
leal 0x1(%rsi), %ecx
movzbl 0x3c(%r15), %r8d
leaq 0x1a4c8(%rip), %rsi     # 0x28b10
xorl %eax, %eax
callq 0xce8e
btl $0x10, %ebx
movq %r12, %rbx
jae 0xe692
movq 0x48(%r15), %rax
testq %rax, %rax
je 0xe692
movl 0x18(%rax), %esi
cmpl $0xfffe, %esi           # imm = 0xFFFE
jb 0xe692
movl 0x10(%r15), %ecx
movl 0x14(%r15), %eax
cmpl $0x1, %ecx
sbbl $-0x1, %esi
movl (%rbx), %edx
xorl %edi, %edi
cmpl %edx, %eax
setne %dil
addl %esi, %edi
cmpl $0x10000, %edi          # imm = 0x10000
jge 0xe7e5
movl (%rbx), %ecx
movq (%rsp), %rdi
movl 0xc(%rsp), %esi
xorl %edx, %edx
movq %r15, %r8
movq 0xa8(%rsp), %r9
callq 0xed89
movb $0x1, %al
movl %eax, 0x20(%rsp)
jmp 0xe6d8
leaq 0x1a44a(%rip), %rsi     # 0x28b07
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movb $0x1, %al
movl %eax, 0x20(%rsp)
pushq $-0x1
popq %rbp
movq %rbp, 0x38(%rsp)
movq %r12, %rbx
movq 0x40(%rsp), %r14
cmpl $0x2, %r13d
jl 0xe735
testl %ebp, %ebp
setns %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xe75c
movslq 0x8(%r14), %rax
cmpl %eax, %ebp
jne 0xe798
xorl %ebp, %ebp
movl 0x1c(%rsp), %eax
testb %al, %al
jne 0xe867
testb $0x4, 0x3d(%r15)
movq 0x38(%rsp), %rax
je 0xe721
movl 0x1c(%r15), %eax
decl %eax
testb $0x4, 0x3d(%r14)
jne 0xe85f
movl 0x18(%r14), %ebp
jmp 0xe865
leaq 0x1a404(%rip), %rsi     # 0x28b40
movq (%rsp), %rbp
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movq 0xa8(%rsp), %r14
movq 0x10(%rsp), %r12
jmp 0xe8cb
testq %r14, %r14
je 0xe7c5
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x8(%r14), %rcx
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %rdx
movl 0x18(%r14), %ecx
incl %ecx
leaq 0x1a3a8(%rip), %rsi     # 0x28b2b
xorl %ebp, %ebp
movq (%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
jmp 0xe893
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rdx
leaq 0x1a376(%rip), %rsi     # 0x28b26
xorl %ebp, %ebp
movq (%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
jmp 0xe87c
testl %ebp, %ebp
js 0xe846
movq 0x38(%rsp), %rdx
incl %edx
leaq 0x1a35c(%rip), %rsi     # 0x28b33
xorl %ebp, %ebp
movq (%rsp), %rbx
movq %rbx, %rdi
jmp 0xe88c
movq 0xa8(%rsp), %rsi
btl $0x13, %esi
movl 0xc(%rsp), %edi
movq 0x40(%rsp), %r14
jb 0xe81f
movl %edi, %esi
andl $0x900, %esi            # imm = 0x900
je 0xe81f
subl %ecx, %eax
xorl %edx, %edx
testw $0x100, %di             # imm = 0x100
cmovel %eax, %edx
btq $0x24, 0xa8(%rsp)
cmovbl %eax, %edx
movl 0x1c(%r15), %ecx
subl 0x18(%r15), %ecx
leaq 0x1a2ed(%rip), %rsi     # 0x28b1b
movl $0x0, 0x20(%rsp)
movq (%rsp), %rdi
xorl %eax, %eax
callq 0xce8e
jmp 0xe6dd
leaq 0x1a2ed(%rip), %rsi     # 0x28b3a
xorl %ebp, %ebp
movq (%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
jmp 0xe893
movl 0x1c(%r14), %ebp
decl %ebp
subl %eax, %ebp
leaq 0x1a2b4(%rip), %rsi     # 0x28b22
movq (%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
movl 0x18(%r14), %edx
incl %edx
leaq 0x1a2ad(%rip), %rsi     # 0x28b36
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
movq 0xa8(%rsp), %r14
movq 0x10(%rsp), %r12
leal 0x1(%rbp), %eax
leal -0x1(%rbp), %ecx
movl %ebp, %edx
sarl $0x1f, %edx
andl %ecx, %edx
testl %ebp, %ebp
cmovgl %eax, %edx
leaq 0x1a27d(%rip), %rsi     # 0x28b36
movq %rbx, %rdi
xorl %eax, %eax
callq 0xce8e
movq %rbx, %rbp
movq 0x30(%rsp), %rbx
cmpb $0x0, 0x1c(%rsp)
je 0xe90f
movq 0x10(%rbx), %rsi
movl (%rbx), %edx
movq %rbp, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef8d
leaq 0x1a252(%rip), %rsi     # 0x28b3e
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0xe9e0
movl (%rbx), %edx
movq %rbp, %rdi
xorl %ecx, %ecx
jmp 0xe9d6
btl $0x13, %r14d
movl 0xc(%rsp), %ecx
jb 0xe93f
movl %ecx, %eax
andl $0x900, %eax            # imm = 0x900
je 0xe93f
btq $0x24, %r14
jb 0xe97c
movl %ecx, %eax
andl $0x100, %eax            # imm = 0x100
je 0xe97c
leaq 0x1a20e(%rip), %rsi     # 0x28b48
jmp 0xe9e7
movq 0x10(%rbx), %rsi
movl (%rbx), %edx
movl 0x3c(%r15), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
movq %rbp, %rdi
movl %ecx, %r8d
callq 0xef8d
leaq 0x1a1dd(%rip), %rsi     # 0x28b3e
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0xe9e0
movl (%rbx), %edx
movl 0x3c(%r15), %ecx
jmp 0xe9cd
movslq 0x10(%r15), %rax
movq %rax, %rsi
addq 0x10(%rbx), %rsi
movl 0x14(%r15), %edx
subl %eax, %edx
movl 0x3c(%r15), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
movq %rbp, %rdi
movl %ecx, %r8d
callq 0xef8d
leaq 0x1a195(%rip), %rsi     # 0x28b3e
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0xe9e0
movslq 0x10(%r15), %rax
addq %rax, %rsi
movl 0x14(%r15), %edx
movl 0x3c(%r15), %ecx
subl %eax, %edx
shrl $0xa, %ecx
andl $0x1, %ecx
movq %rbp, %rdi
xorl %r8d, %r8d
callq 0xef8d
jmp 0xe9f1
leaq 0x1a163(%rip), %rsi     # 0x28b4a
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
cmpb $0x0, 0x23f48(%rip)     # 0x32940
je 0xea12
leaq 0x1a14b(%rip), %rsi     # 0x28b4c
leaq 0x23f38(%rip), %rdx     # 0x32940
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
cmpl $0x3, %r13d
jl 0xea2c
leaq 0x1a136(%rip), %rsi     # 0x28b55
movq %rbp, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xce8e
movl 0xb0(%rsp), %r12d
cmpb $0x0, 0x1c(%rsp)
movq 0x50(%rsp), %r13
jne 0xece7
movq %rbp, %rdi
movq %r15, %rsi
callq 0xe1fb
movl 0x20(%r15), %eax
cmpl (%r15), %eax
movq 0x48(%rsp), %r8
jne 0xec6e
cmpl $0x2, %r8d
jl 0xec6e
cmpq $0x0, 0x48(%r15)
je 0xec6e
testq %r13, %r13
je 0xec6e
movq %r15, %rax
subq %r13, %rax
jb 0xec6e
pushq $0x50
popq %rcx
cqto
idivq %rcx
cmpq %r8, %rax
jge 0xec6e
xorl %ecx, %ecx
movq %r13, %rdx
xorl %esi, %esi
cmpq %rcx, %r8
je 0xeac5
cmpq %rcx, %rax
je 0xeabc
movl 0x20(%rdx), %edi
cmpl (%rdx), %edi
jne 0xeabc
cmpq $0x1, 0x48(%rdx)
sbbl $-0x1, %esi
incq %rcx
addq $0x50, %rdx
jmp 0xeaa3
testl %esi, %esi
jle 0xec6e
leaq 0x1a08a(%rip), %rsi     # 0x28b5e
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movq 0x48(%rsp), %rcx
subq $0x1, %rcx
jb 0xec6e
cmpq %r15, %r13
je 0xec65
movl 0x20(%r13), %eax
cmpl (%r13), %eax
jne 0xec65
cmpq $0x0, 0x48(%r13)
je 0xec65
movq %rcx, 0x48(%rsp)
movl 0x10(%r13), %eax
movl 0x14(%r13), %edx
movl %edx, %esi
subl %eax, %esi
movq %rbp, %rdi
movl 0x1c(%r13), %ebp
movl 0x18(%r13), %ecx
subl %ecx, %ebp
movl %esi, %r12d
subl %ebp, %r12d
negl %r12d
movl %esi, %r14d
subl %ebp, %r14d
cmovll %esi, %ebp
movl $0x0, %esi
cmovll %esi, %r14d
cmovgel %esi, %r12d
movl (%rbx), %ebx
subl %edx, %ebx
movslq 0x8(%r13), %rdx
imulq $0x18, %rdx, %rdx
incl %ecx
movq %r13, 0x50(%rsp)
btl $0xa, 0x3c(%r13)
movl %ebx, %r13d
cmovael %eax, %r13d
cmovbl %eax, %ebx
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax,%rdx), %rdx
leaq 0x19c26(%rip), %rax     # 0x287a9
adcq $0x0, %rax
movsbl (%rax), %r8d
leaq 0x19fd3(%rip), %rsi     # 0x28b65
xorl %eax, %eax
callq 0xce8e
testl %r13d, %r13d
je 0xebb3
movq (%rsp), %rdi
leaq 0x19fc6(%rip), %rsi     # 0x28b6f
movl %r13d, %edx
xorl %eax, %eax
callq 0xce8e
testl %ebp, %ebp
je 0xebcb
movq (%rsp), %rdi
leaq 0x19fb1(%rip), %rsi     # 0x28b73
movl %ebp, %edx
xorl %eax, %eax
callq 0xce8e
testl %r14d, %r14d
movq (%rsp), %rbp
movq 0x50(%rsp), %r13
je 0xebed
movq %rbp, %rdi
leaq 0x19f94(%rip), %rsi     # 0x28b77
movl %r14d, %edx
xorl %eax, %eax
callq 0xce8e
testl %r12d, %r12d
je 0xec06
movq %rbp, %rdi
leaq 0x19f7f(%rip), %rsi     # 0x28b7b
movl %r12d, %edx
xorl %eax, %eax
callq 0xce8e
testl %ebx, %ebx
movq 0xa8(%rsp), %r14
je 0xec25
movq %rbp, %rdi
leaq 0x19f53(%rip), %rsi     # 0x28b6f
movl %ebx, %edx
xorl %eax, %eax
callq 0xce8e
movzbl 0x3c(%r13), %edx
movl 0x30(%r13), %eax
subl 0x2c(%r13), %eax
movq 0x48(%r13), %rcx
movl 0x14(%rcx), %ecx
movl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
andl %esi, %ecx
addl %eax, %ecx
movq %rbp, %rdi
leaq 0x19f33(%rip), %rsi     # 0x28b7f
xorl %eax, %eax
callq 0xce8e
movq 0x30(%rsp), %rbx
movq 0x48(%rsp), %rcx
movl 0xb0(%rsp), %r12d
addq $0x50, %r13
jmp 0xeae3
movabsq $0x2001000040, %rax     # imm = 0x2001000040
testq %rax, %r14
je 0xecc9
cmpq $0x0, 0x48(%r15)
je 0xecc9
movq 0xa0(%rsp), %rdi
xorl %r9d, %r9d
btl $0xb, %r14d
setae %r9b
movl %r14d, %eax
andl $0x1000000, %eax        # imm = 0x1000000
movq %r14, %r10
shrq $0x25, %r10
andl $0x1, %r10d
movq %rbp, %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rcx
movq %r15, %r8
pushq $0x0
pushq $0x1
pushq %r10
pushq %rax
callq 0xd4c5
addq $0x20, %rsp
cmpb $0x0, 0x20(%rsp)
jne 0xece7
movl (%rbx), %ecx
pushq $0x1
popq %rdx
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq %r15, %r8
movq %r14, %r9
callq 0xed89
testl %r12d, %r12d
js 0xed00
leaq 0x19dd0(%rip), %rsi     # 0x28ac3
movq %rbp, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xce8e
btl $0x19, %r14d
jae 0xed21
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
je 0xed21
leaq 0x19de1(%rip), %rsi     # 0x28af8
movq %rbp, %rdi
xorl %eax, %eax
callq 0xce8e
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb $0x0, (%rcx,%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq