// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movl %r9d, %r13d
movq %rsi, 0x18(%rsp)
movq %rdi, %r15
movq 0x88(%rsp), %r11
movq 0x80(%rsp), %rsi
movslq %ecx, %rax
movl (%rsi,%rax,4), %r9d
movq (%r11,%rax,8), %r10
movl %r8d, %eax
leaq (%rax,%rax,4), %r12
shlq $0x4, %r12
addq %r10, %r12
xorl %r14d, %r14d
cmpl %r8d, %r9d
cmovbeq %r14, %r12
testl %r9d, %r9d
cmovleq %r14, %r12
cmpl $0x2, %r13d
movq %rdi, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
movq %r9, 0x38(%rsp)
movq %r10, 0x30(%rsp)
jl 0xff15
leal 0x1(%rcx), %eax
cltd
idivl %r13d
movslq %edx, %rdx
movslq (%rsi,%rdx,4), %rax
testq %rax, %rax
jle 0xfe66
movq (%r11,%rdx,8), %rbp
movq %rax, %rdx
testb $0x10, 0x3d(%rbp)
jne 0xfe70
addq $0x50, %rbp
decq %rdx
jne 0xfe57
testl %eax, %eax
jne 0x101e1
xorl %ebp, %ebp
movq %rbp, %r14
cmpl $0x2, %r13d
je 0xfea0
leal -0x1(%r13), %edi
xorl %r14d, %r14d
movq 0x28(%rsp), %rcx
leal (%rcx,%rdi), %eax
cltd
idivl %r13d
movslq %edx, %rdx
movslq (%rsi,%rdx,4), %rax
testq %rax, %rax
jg 0x101c9
decl %edi
jne 0xfe85
movq $0x0, (%r15)
movq 0x20(%rsp), %rbx
movq 0x8(%rbx), %rdx
leaq 0x1dc42(%rip), %rsi     # 0x2daf9
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x2130
cmpl $0x3, %eax
jl 0xfeea
movl %eax, %ecx
decl %ecx
movb (%rbx,%rcx), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0xfeea
leal -0x2(%rax), %ecx
cmpb $0x2f, (%rbx,%rcx)
je 0xfeec
movl %eax, %ecx
xorl %edx, %edx
cmpl $0x2, %r13d
setge %dl
movslq %ecx, %rax
movq %rax, (%r15)
testq %r12, %r12
movq 0x28(%rsp), %rdi
jne 0xff3f
orl $0x4, %edx
movb $0x1, %bl
cmpl $0x1, %r13d
jg 0xff82
jmp 0xffba
movq $0x0, (%r15)
movq 0x8(%rdx), %rdx
leaq 0x1dbd2(%rip), %rsi     # 0x2daf9
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
testq %r12, %r12
je 0xffb3
xorl %edx, %edx
xorl %ebp, %ebp
movq 0x28(%rsp), %rdi
movl 0x20(%r12), %esi
movl 0x3c(%r12), %eax
movl %eax, %ecx
shrl $0x6, %ecx
andl $0x10, %ecx
orl %edx, %ecx
cmpl (%r12), %esi
jne 0xff6a
movl %eax, %edx
shrl %edx
movl $0x800, %esi            # imm = 0x800
andl %esi, %edx
orl %edx, %ecx
xorl %esi, %ecx
jmp 0xff70
orl $0x100, %ecx            # imm = 0x100
movl %ecx, %edx
cmpl $0x1, %r13d
jle 0xff99
shrl $0xc, %eax
andl $0x2, %eax
orl %eax, %edx
xorl %ebx, %ebx
testl %edi, %edi
je 0xffd1
leal -0x1(%r13), %eax
movl %edx, %ecx
orl $0x80, %ecx
cmpl %edi, %eax
cmovel %ecx, %edx
jmp 0xffd4
leaq 0x1db3d(%rip), %rsi     # 0x2dadd
movq %r15, %rdi
movl %edx, 0xc(%rsp)
xorl %eax, %eax
callq 0xe575
jmp 0x10049
movl $0x4, %edx
xorl %ebp, %ebp
leaq 0x1db1c(%rip), %rsi     # 0x2dadd
movq %r15, %rdi
movl %edx, 0xc(%rsp)
xorl %eax, %eax
callq 0xe575
jmp 0x1000b
orl $0x40, %edx
testq %rbp, %rbp
je 0xffed
movl 0x3c(%rbp), %eax
shrl $0x5, %eax
andl $0x20, %eax
orl %eax, %edx
leaq 0x1daf2(%rip), %rsi     # 0x2dadd
jmp 0xfff9
orl $0x8, %edx
leaq 0x1dae6(%rip), %rsi     # 0x2dadd
xorl %ebp, %ebp
movq %r15, %rdi
movl %edx, 0xc(%rsp)
xorl %eax, %eax
callq 0xe575
testb %bl, %bl
je 0x10049
testq %r14, %r14
je 0x100f5
movq %r15, %rdi
movslq 0x8(%r14), %r15
movl 0x18(%r14), %r14d
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
leaq (%r15,%r15,2), %rcx
movq (%rax,%rcx,8), %rdx
leal 0x1(%r14), %ecx
leaq 0x1dac1(%rip), %rsi     # 0x2dafc
xorl %eax, %eax
callq 0xe575
movb $0x1, %bl
jmp 0x10114
movq %r15, %rdi
movslq 0x8(%r12), %r15
movl 0x18(%r12), %r14d
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
leaq (%r15,%r15,2), %rcx
movq (%rax,%rcx,8), %rdx
leal 0x1(%r14), %ecx
movzbl 0x3c(%r12), %r8d
leaq 0x1da98(%rip), %rsi     # 0x2db10
xorl %eax, %eax
callq 0xe575
movq 0x98(%rsp), %rax
btl $0x10, %eax
jae 0x100cf
movq 0x48(%r12), %rax
testq %rax, %rax
je 0x100cf
movl 0x18(%rax), %esi
cmpl $0xfffe, %esi           # imm = 0xFFFE
jb 0x100cf
movl 0x10(%r12), %ecx
movl 0x14(%r12), %eax
cmpl $0x1, %ecx
sbbl $-0x1, %esi
movq 0x20(%rsp), %rdx
movl (%rdx), %edx
xorl %edi, %edi
cmpl %edx, %eax
setne %dil
addl %esi, %edi
cmpl $0x10000, %edi          # imm = 0x10000
jge 0x1025c
movq 0x20(%rsp), %rax
movl (%rax), %ecx
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
xorl %edx, %edx
movq %r12, %r8
movq 0x98(%rsp), %r9
callq 0x107e2
jmp 0x10114
leaq 0x1da0b(%rip), %rsi     # 0x2db07
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movb $0x1, %bl
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movb $0x1, %cl
cmpl $0x2, %r13d
movl %ecx, 0x44(%rsp)
jl 0x10165
testq %rbp, %rbp
je 0x10188
testl %r15d, %r15d
js 0x10188
movslq 0x8(%rbp), %rax
cmpl %eax, %r15d
jne 0x10200
xorl %r15d, %r15d
testb %bl, %bl
jne 0x102dd
testb $0x4, 0x3d(%r12)
je 0x10152
movl 0x1c(%r12), %r14d
decl %r14d
testb $0x4, 0x3d(%rbp)
jne 0x102d3
movl 0x18(%rbp), %r15d
jmp 0x102da
leaq 0x1d9d4(%rip), %rsi     # 0x2db40
movq 0x10(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movq 0x98(%rsp), %r14
jmp 0x10345
testq %rbp, %rbp
je 0x1022f
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x8(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rdx
movl 0x18(%rbp), %ecx
incl %ecx
leaq 0x1d979(%rip), %rsi     # 0x2db2b
xorl %r15d, %r15d
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
xorl %eax, %eax
callq 0xe575
jmp 0x10326
movq (%r11,%rdx,8), %r14
testb $0x10, 0x3d(%r14)
jne 0xfea0
addq $0x50, %r14
decq %rax
jne 0x101cd
leaq 0x1dcb2(%rip), %rdi     # 0x2de9a
leaq 0x1d835(%rip), %rsi     # 0x2da24
leaq 0x1dcb0(%rip), %rcx     # 0x2dea6
movl $0x1e0, %edx            # imm = 0x1E0
callq 0x21a0
movq 0x18(%rsp), %rcx
movq 0x20(%rcx), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rdx
leaq 0x1d90e(%rip), %rsi     # 0x2db26
xorl %r15d, %r15d
movq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0xe575
jmp 0x102f3
testl %r15d, %r15d
js 0x102b8
incl %r14d
leaq 0x1d8f1(%rip), %rsi     # 0x2db33
xorl %r15d, %r15d
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe575
jmp 0x10326
movq 0x98(%rsp), %rsi
btl $0x13, %esi
movl 0xc(%rsp), %edi
jb 0x10292
movl %edi, %esi
andl $0x900, %esi            # imm = 0x900
je 0x10292
subl %ecx, %eax
xorl %edx, %edx
testl $0x100, %edi            # imm = 0x100
cmovel %eax, %edx
btq $0x24, 0x98(%rsp)
cmovbl %eax, %edx
movl 0x1c(%r12), %ecx
subl 0x18(%r12), %ecx
leaq 0x1d878(%rip), %rsi     # 0x2db1b
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0xe575
xorl %ecx, %ecx
jmp 0x10116
leaq 0x1d87b(%rip), %rsi     # 0x2db3a
xorl %r15d, %r15d
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
xorl %eax, %eax
callq 0xe575
jmp 0x10326
movl 0x1c(%rbp), %r15d
decl %r15d
subl %r14d, %r15d
leaq 0x1d83e(%rip), %rsi     # 0x2db22
movq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0xe575
movl 0x18(%rbp), %edx
incl %edx
leaq 0x1d837(%rip), %rsi     # 0x2db36
movq %r14, %rdi
xorl %eax, %eax
callq 0xe575
testl %r15d, %r15d
js 0x1031e
leal 0x1(%r15), %eax
testl %r15d, %r15d
cmovel %r15d, %eax
movl %eax, %r15d
jmp 0x10321
decl %r15d
movq 0x10(%rsp), %rbp
movq 0x98(%rsp), %r14
leaq 0x1d801(%rip), %rsi     # 0x2db36
movq %rbp, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe575
movq %rbp, %r15
testb %bl, %bl
movq 0x20(%rsp), %rbp
je 0x1038d
movq 0x10(%rbp), %rsi
movl (%rbp), %edx
movq %r15, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x10a0c
leaq 0x1d7d5(%rip), %rsi     # 0x2db3e
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x10468
movl (%rbp), %edx
movq %r15, %rdi
xorl %ecx, %ecx
jmp 0x1045e
btl $0x13, %r14d
movl 0xc(%rsp), %ecx
jb 0x103bd
movl %ecx, %eax
andl $0x900, %eax            # imm = 0x900
je 0x103bd
btq $0x24, %r14
jb 0x103fe
movl %ecx, %eax
andl $0x100, %eax            # imm = 0x100
je 0x103fe
leaq 0x1d790(%rip), %rsi     # 0x2db48
jmp 0x1046f
movq 0x10(%rbp), %rsi
movl (%rbp), %edx
movl 0x3c(%r12), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
movq %r15, %rdi
movl %ecx, %r8d
callq 0x10a0c
leaq 0x1d75d(%rip), %rsi     # 0x2db3e
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x10468
movl (%rbp), %edx
movl 0x3c(%r12), %ecx
jmp 0x10455
movslq 0x10(%r12), %rax
movq %rax, %rsi
addq 0x10(%rbp), %rsi
movl 0x14(%r12), %edx
subl %eax, %edx
movl 0x3c(%r12), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
movq %r15, %rdi
movl %ecx, %r8d
callq 0x10a0c
leaq 0x1d710(%rip), %rsi     # 0x2db3e
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x10468
movslq 0x10(%r12), %rax
addq %rax, %rsi
movl 0x14(%r12), %edx
movl 0x3c(%r12), %ecx
subl %eax, %edx
shrl $0xa, %ecx
andl $0x1, %ecx
movq %r15, %rdi
xorl %r8d, %r8d
callq 0x10a0c
jmp 0x10479
leaq 0x1d6db(%rip), %rsi     # 0x2db4a
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
cmpb $0x0, 0x264c0(%rip)     # 0x36940
je 0x1049a
leaq 0x1d6c3(%rip), %rsi     # 0x2db4c
leaq 0x264b0(%rip), %rdx     # 0x36940
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
cmpl $0x3, %r13d
jl 0x104b6
leaq 0x1d6ae(%rip), %rsi     # 0x2db55
movq %r15, %rdi
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0xe575
movl 0xa0(%rsp), %r13d
testb %bl, %bl
jne 0x1078e
movq %r15, %rdi
movq %r12, %rsi
callq 0xfbe5
movl 0x20(%r12), %eax
cmpl (%r12), %eax
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
jne 0x10711
cmpl $0x2, %r8d
jl 0x10711
cmpq $0x0, 0x48(%r12)
je 0x10711
testq %r9, %r9
je 0x10711
movq %r12, %rcx
subq %r9, %rcx
jb 0x10711
sarq $0x4, %rcx
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
cmpq %r8, %rax
jge 0x10711
xorl %ecx, %ecx
movq %r9, %rdx
xorl %esi, %esi
cmpq %rcx, %rax
je 0x1054b
movl 0x20(%rdx), %edi
cmpl (%rdx), %edi
jne 0x1054b
cmpq $0x1, 0x48(%rdx)
sbbl $-0x1, %esi
incq %rcx
addq $0x50, %rdx
cmpq %rcx, %r8
jne 0x10537
testl %esi, %esi
jle 0x10711
leaq 0x1d5f8(%rip), %rsi     # 0x2db5e
movq %r15, %rdi
xorl %eax, %eax
movq %r8, %rbx
movq %r9, %r13
callq 0xe575
movq %r13, %r8
movl 0xa0(%rsp), %r13d
movq %rbx, %rcx
cmpq %r12, %r8
je 0x10704
movl 0x20(%r8), %eax
cmpl (%r8), %eax
jne 0x10704
cmpq $0x0, 0x48(%r8)
je 0x10704
movq %rcx, 0x38(%rsp)
movl 0x10(%r8), %eax
movl 0x14(%r8), %edx
movl %edx, %esi
subl %eax, %esi
movq %rbp, %r9
movl 0x1c(%r8), %ebp
movl 0x18(%r8), %ecx
subl %ecx, %ebp
movl %esi, %r14d
subl %ebp, %r14d
negl %r14d
movq %r15, %rdi
movl %esi, %r15d
subl %ebp, %r15d
cmovll %esi, %ebp
movl $0x0, %esi
cmovll %esi, %r15d
cmovgel %esi, %r14d
movl (%r9), %ebx
subl %edx, %ebx
incl %ecx
btl $0xa, 0x3c(%r8)
movl %ebx, %r13d
cmovael %eax, %r13d
cmovbl %eax, %ebx
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movq %r8, 0x30(%rsp)
movslq 0x8(%r8), %rdx
leaq (%rdx,%rdx,2), %rdx
movq (%rax,%rdx,8), %rdx
leaq 0x1d18c(%rip), %rax     # 0x2d7a9
adcq $0x0, %rax
movsbl (%rax), %r8d
leaq 0x1d539(%rip), %rsi     # 0x2db65
xorl %eax, %eax
callq 0xe575
testl %r13d, %r13d
je 0x1064e
movq 0x10(%rsp), %rdi
leaq 0x1d52b(%rip), %rsi     # 0x2db6f
movl %r13d, %edx
xorl %eax, %eax
callq 0xe575
testl %ebp, %ebp
je 0x10667
movq 0x10(%rsp), %rdi
leaq 0x1d515(%rip), %rsi     # 0x2db73
movl %ebp, %edx
xorl %eax, %eax
callq 0xe575
testl %r15d, %r15d
movl 0xa0(%rsp), %r13d
je 0x1068a
movq 0x10(%rsp), %rdi
leaq 0x1d4f7(%rip), %rsi     # 0x2db77
movl %r15d, %edx
xorl %eax, %eax
callq 0xe575
testl %r14d, %r14d
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rbp
je 0x106ad
movq %r15, %rdi
leaq 0x1d4d8(%rip), %rsi     # 0x2db7b
movl %r14d, %edx
xorl %eax, %eax
callq 0xe575
testl %ebx, %ebx
je 0x106c4
movq %r15, %rdi
leaq 0x1d4b4(%rip), %rsi     # 0x2db6f
movl %ebx, %edx
xorl %eax, %eax
callq 0xe575
movq 0x30(%rsp), %rbx
movzbl 0x3c(%rbx), %edx
movl 0x30(%rbx), %eax
subl 0x2c(%rbx), %eax
movq 0x48(%rbx), %rcx
movl 0x14(%rcx), %ecx
movl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
andl %esi, %ecx
addl %eax, %ecx
movq %r15, %rdi
leaq 0x1d492(%rip), %rsi     # 0x2db7f
xorl %eax, %eax
callq 0xe575
movq %rbx, %r8
movq 0x98(%rsp), %r14
movq 0x38(%rsp), %rcx
addq $0x50, %r8
decq %rcx
jne 0x10584
movabsq $0x2001000040, %rax     # imm = 0x2001000040
testq %rax, %r14
je 0x1076d
cmpq $0x0, 0x48(%r12)
je 0x1076d
movq 0x90(%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 %r15, %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq %r12, %r8
pushq $0x0
pushq $0x1
pushq %r10
pushq %rax
callq 0xee3a
addq $0x20, %rsp
cmpb $0x0, 0x44(%rsp)
jne 0x1078e
movl (%rbp), %ecx
movq %r15, %rdi
movl 0xc(%rsp), %esi
movl $0x1, %edx
movq %r12, %r8
movq %r14, %r9
callq 0x107e2
testl %r13d, %r13d
js 0x107a7
leaq 0x1d329(%rip), %rsi     # 0x2dac3
movq %r15, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe575
btl $0x19, %r14d
jae 0x107c8
movq 0x20(%rbp), %rdx
testq %rdx, %rdx
je 0x107c8
leaq 0x1d33a(%rip), %rsi     # 0x2daf8
movq %r15, %rdi
xorl %eax, %eax
callq 0xe575
movq (%r15), %rax
movq 0x10(%r15), %rcx
movb $0x0, (%rcx,%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq