// File: /workspace/github_cpp_makefile_star2_O3/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/misc/wgsim.c
// Function: wgsim_core
void wgsim_core(FILE *fpout1, FILE *fpout2, FILE *fp_fa, int is_hap, uint64_t N, int dist, int std_dev, int size_l, int size_r)
{
	seq_t seq;
    mutseq_t rseq[2];
	uint64_t tot_len, ii;
	int i, l, n_ref;
	char name[256], *qstr;
	int size[2], Q;
	uint8_t *tmp_seq[2];
    mut_t *target;

	INIT_SEQ(seq);
	srand48(time(0));
	seq_set_block_size(0x1000000);
	l = size_l > size_r? size_l : size_r;
	qstr = (char*)calloc(l+1, 1);
	tmp_seq[0] = (uint8_t*)calloc(l+2, 1);
	tmp_seq[1] = (uint8_t*)calloc(l+2, 1);
	size[0] = size_l; size[1] = size_r;

	Q = (int)(-10.0 * log(ERR_RATE) / log(10.0) + 0.499) + 33;

	tot_len = n_ref = 0;
	while ((l = seq_read_fasta(fp_fa, &seq, name, 0)) >= 0) {
		tot_len += l;
		++n_ref;
	}
	fprintf(stderr, "[wgsim_core] %d sequences, total length: %llu\n", n_ref, (long long)tot_len);
	rewind(fp_fa);

	while ((l = seq_read_fasta(fp_fa, &seq, name, 0)) >= 0) {
		uint64_t n_pairs = (uint64_t)((long double)l / tot_len * N + 0.5);
		if (l < dist + 3 * std_dev) {
			fprintf(stderr, "[wgsim_core] kkip sequence '%s' as it is shorter than %d!\n", name, dist + 3 * std_dev);
			continue;
		}

		// generate mutations and print them out
		maq_mut_diref(&seq, is_hap, rseq, rseq+1);
		maq_print_mutref(name, &seq, rseq, rseq+1);

		for (ii = 0; ii != n_pairs; ++ii) { // the core loop
			double ran;
			int d, pos, s[2], is_flip = 0;
			int n_sub[2], n_indel[2], n_err[2], ext_coor[2], j, k;
			FILE *fpo[2];

			do { // avoid boundary failure
				ran = ran_normal();
				ran = ran * std_dev + dist;
				d = (int)(ran + 0.5);
				pos = (int)((l - d + 1) * drand48());
			} while (pos < 0 || pos >= seq.l || pos + d - 1 >= seq.l);

			// flip or not
			if (drand48() < 0.5) {
				fpo[0] = fpout1; fpo[1] = fpout2;
				s[0] = size[0]; s[1] = size[1];
			} else {
				fpo[1] = fpout1; fpo[0] = fpout2;
				s[1] = size[0]; s[0] = size[1];
				is_flip = 1;
			}

			// generate the read sequences
			target = rseq[drand48()<0.5?0:1].s; // haplotype from which the reads are generated
			n_sub[0] = n_sub[1] = n_indel[0] = n_indel[1] = n_err[0] = n_err[1] = 0;

#define __gen_read(x, start, iter) do {									\
				for (i = (start), k = 0, ext_coor[x] = -10; i >= 0 && i < seq.l && k < s[x]; iter) {	\
					int c = target[i], mut_type = c & mutmsk;			\
					if (ext_coor[x] < 0) {								\
						if (mut_type != NOCHANGE && mut_type != SUBSTITUTE) continue; \
						ext_coor[x] = i;								\
					}													\
					if (mut_type == DELETE) ++n_indel[x];				\
					else if (mut_type == NOCHANGE || mut_type == SUBSTITUTE) { \
						tmp_seq[x][k++] = c & 0xf;						\
						if (mut_type == SUBSTITUTE) ++n_sub[x];			\
					} else {											\
						int n, ins;										\
						++n_indel[x];									\
						tmp_seq[x][k++] = c & 0xf;						\
						for (n = mut_type>>12, ins = c>>4; n > 0 && k < s[x]; --n, ins >>= 2) \
							tmp_seq[x][k++] = ins & 0x3;				\
					}													\
				}														\
				if (k != s[x]) ext_coor[x] = -10;						\
			} while (0)

			if (!IS_SOLID) {
				__gen_read(0, pos, ++i);
				__gen_read(1, pos + d - 1, --i);
				for (k = 0; k < s[1]; ++k) tmp_seq[1][k] = tmp_seq[1][k] < 4? 3 - tmp_seq[1][k] : 4; // complement
			} else {
				int c1, c2, c;
				++s[0]; ++s[1]; // temporarily increase read length by 1
				if (is_flip) { // RR pair
					__gen_read(0, pos + s[0], --i);
					__gen_read(1, pos + d - 1, --i);
				} else { // FF pair
					__gen_read(0, pos, ++i);
					__gen_read(1, pos + d - 1 - s[1], ++i);
					++ext_coor[0]; ++ext_coor[1];
				}
				// change to color sequence: (0,1,2,3) -> (A,C,G,T)
				for (j = 0; j < 2; ++j) {
					c1 = tmp_seq[j][0];
					for (i = 1; i < s[j]; ++i) {
						c2 = tmp_seq[j][i];
						c = (c1 >= 4 || c2 >= 4)? 4 : nst_color_space_table[(1<<c1)|(1<<c2)];
						tmp_seq[j][i-1] = c;
						c1 = c2;
					}
				}
				--s[0]; --s[1]; // change back
			}
			if (ext_coor[0] < 0 || ext_coor[1] < 0) { // fail to generate the read(s)
				--ii;
				continue;
			}

			// generate sequencing errors
			for (j = 0; j < 2; ++j) {
				for (i = 0; i < s[j]; ++i) {
					int c = tmp_seq[j][i];
					if (c >= 4) c = 4; // actually c should be never larger than 4 if everything is correct
					else if (drand48() < ERR_RATE) {
						c = (c + (int)(drand48() * 3.0 + 1)) & 3;
						++n_err[j];
					}
					tmp_seq[j][i] = c;
				}
			}

			// print
			for (j = 0; j < 2; ++j) {
				for (i = 0; i < s[j]; ++i) qstr[i] = Q;
				qstr[i] = 0;
				if (SHOW_MM_INFO) {
					fprintf(fpo[j], "@%s_%u_%u_%d:%d:%d_%d:%d:%d_%llx/%d\n", name, ext_coor[0]+1, ext_coor[1]+1,
							n_err[0], n_sub[0], n_indel[0], n_err[1], n_sub[1], n_indel[1],
							(long long)ii, j==0? is_flip+1 : 2-is_flip);
				} else {
					fprintf(fpo[j], "@%s_%u_%u_%llx/%d %d:%d:%d_%d:%d:%d\n", name, ext_coor[0]+1, ext_coor[1]+1,
							(long long)ii, j==0? is_flip+1 : 2-is_flip,
							n_err[0], n_sub[0], n_indel[0], n_err[1], n_sub[1], n_indel[1]);
				}
				for (i = 0; i < s[j]; ++i)
					fputc("ACGTN"[(int)tmp_seq[j][i]], fpo[j]);
				fprintf(fpo[j], "\n+\n%s\n", qstr);
			}
		}
		free(rseq[0].s); free(rseq[1].s);
	}
	free(seq.s); free(qstr);
	free(tmp_seq[0]); free(tmp_seq[1]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movl %r9d, 0x1c(%rsp)
movq %r8, 0x30(%rsp)
movl %ecx, 0xc0(%rsp)
movq %rdx, %r12
movq %rsi, 0xf8(%rsp)
movq %rdi, 0xf0(%rsp)
movl 0x2c0(%rsp), %ebx
movl 0x2b8(%rsp), %ebp
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %r14
movaps %xmm0, (%r14)
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x1150
movq %rax, %rdi
callq 0x1180
movl $0x1000000, 0x4e9a(%rip) # imm = 0x1000000
cmpl %ebx, %ebp
cmovgl %ebp, %ebx
leal 0x1(%rbx), %eax
movslq %eax, %rdi
pushq $0x1
popq %rbp
movq %rbp, %rsi
callq 0x1110
movq %rax, 0x48(%rsp)
addl $0x2, %ebx
movslq %ebx, %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1110
movq %rax, 0x68(%rsp)
movq %rax, 0xb0(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1110
movq %rax, 0x58(%rsp)
movq %rax, 0xb8(%rsp)
movsd 0x4e61(%rip), %xmm0     # 0x6128
callq 0x10f0
movsd %xmm0, 0x10(%rsp)
leaq 0x170(%rsp), %rdx
movq %r12, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x27b1
movl $0x0, %r14d
testl %eax, %eax
js 0x1323
xorl %r14d, %r14d
leaq 0xd0(%rsp), %r13
leaq 0x170(%rsp), %rbp
xorl %r15d, %r15d
movl %eax, %eax
addq %rax, %r14
incl %r15d
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x27b1
testl %eax, %eax
jns 0x1307
movq 0x4cce(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x2f5b(%rip), %rsi      # 0x428f
movl %r15d, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1120
movq %r12, %rdi
callq 0x10b0
leaq 0xd0(%rsp), %rsi
leaq 0x170(%rsp), %rdx
movq %r12, 0x90(%rsp)
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x27b1
testl %eax, %eax
movq 0x48(%rsp), %r15
js 0x23d2
movl %eax, %r13d
movsd 0x10(%rsp), %xmm0
mulsd 0x2cbf(%rip), %xmm0     # 0x4048
divsd 0x2cbf(%rip), %xmm0     # 0x4050
addsd 0x2cbf(%rip), %xmm0     # 0x4058
cvttsd2si %xmm0, %edx
movq %r14, 0x128(%rsp)
xorl %eax, %eax
testq %r14, %r14
sets %al
fildll 0x128(%rsp)
leaq 0x2ca5(%rip), %rcx      # 0x4060
fadds (%rcx,%rax,4)
fstpt 0x144(%rsp)
movq 0x30(%rsp), %rsi
movq %rsi, 0x130(%rsp)
xorl %eax, %eax
testq %rsi, %rsi
sets %al
fildll 0x130(%rsp)
fadds (%rcx,%rax,4)
fstpt 0x138(%rsp)
movl 0x2b0(%rsp), %eax
leal (%rax,%rax,2), %ecx
movl 0x1c(%rsp), %esi
addl %esi, %ecx
movl %ecx, 0x9c(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x118(%rsp)
cvtsi2sd %esi, %xmm0
movsd %xmm0, 0x110(%rsp)
addb $0x21, %dl
movl %edx, 0xc4(%rsp)
leaq 0xd0(%rsp), %r14
pushq $0x1
popq %rbp
movl %r13d, 0xcc(%rsp)
fldt 0x144(%rsp)
fidivrl 0xcc(%rsp)
fldt 0x138(%rsp)
fmulp %st, %st(1)
fadds 0x2c12(%rip)            # 0x4068
flds 0x2c10(%rip)            # 0x406c
xorl %r8d, %r8d
fxch %st(1)
fucomi %st(1), %st
fldz
fcmovnb %st(2), %st
fstp %st(2)
fsubp %st, %st(1)
setae %al
fnstcw 0x56(%rsp)
movzwl 0x56(%rsp), %ecx
orl $0xc00, %ecx            # imm = 0xC00
movw %cx, 0x8e(%rsp)
fldcw 0x8e(%rsp)
fistpll 0x120(%rsp)
fldcw 0x56(%rsp)
cmpl 0x9c(%rsp), %r13d
jl 0x23a1
movb %al, %r8b
shlq $0x3f, %r8
xorq 0x120(%rsp), %r8
movq %r14, %rdi
movl 0xc0(%rsp), %esi
leaq 0x150(%rsp), %rdx
movq %r14, %r12
movq %r8, %r14
leaq 0x160(%rsp), %rbx
movq %rbx, %rcx
callq 0x2a30
leaq 0x170(%rsp), %rdi
movq %r12, %rsi
leaq 0x150(%rsp), %rdx
leaq 0x2c9a(%rip), %r12      # 0x4190
movq %rbx, %rcx
callq 0x2d4b
movq %r14, 0x108(%rsp)
testq %r14, %r14
movq 0x90(%rsp), %rbx
je 0x235d
incl %r13d
movl 0xd0(%rsp), %eax
movl %eax, 0x1c(%rsp)
xorl %eax, %eax
movl %r13d, 0x88(%rsp)
movq %rax, 0xa8(%rsp)
callq 0x26cc
mulsd 0x118(%rsp), %xmm0
addsd 0x110(%rsp), %xmm0
addsd 0x2ae2(%rip), %xmm0     # 0x4038
cvttsd2si %xmm0, %r15d
movl %r13d, %eax
subl %r15d, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x30(%rsp)
callq 0x11e0
mulsd 0x30(%rsp), %xmm0
cvttsd2si %xmm0, %ebx
testl %ebx, %ebx
js 0x1537
cmpl %ebx, 0x1c(%rsp)
jle 0x1537
addl %ebx, %r15d
cmpl 0x1c(%rsp), %r15d
jg 0x1537
callq 0x11e0
movapd %xmm0, %xmm1
movsd 0x2a99(%rip), %xmm0     # 0x4038
movsd %xmm1, 0x10(%rsp)
ucomisd %xmm1, %xmm0
jbe 0x15eb
movq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x100(%rsp)
movl $0x0, 0x7c(%rsp)
movl 0x2c0(%rsp), %eax
movl %eax, %r13d
movl 0x2b8(%rsp), %eax
movq %rax, 0x28(%rsp)
jmp 0x1625
movq 0xf0(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0xe0(%rsp)
movl 0x2b8(%rsp), %eax
movl %eax, %r13d
movl 0x2c0(%rsp), %eax
movq %rax, 0x28(%rsp)
movl %ebp, 0x7c(%rsp)
leal -0x1(%r15), %r14d
callq 0x11e0
xorl %eax, %eax
movsd 0x2a00(%rip), %xmm1     # 0x4038
ucomisd %xmm0, %xmm1
setbe %al
andl $0x0, 0xa0(%rsp)
shll $0x4, %eax
andl $0x0, 0xa4(%rsp)
movq 0x158(%rsp,%rax), %rax
cmpb $0x0, 0x4ae7(%rip)      # 0x6148
movl %r13d, %esi
movl %r14d, 0xc(%rsp)
movl %r14d, %edi
movslq %r13d, %r8
movq 0x28(%rsp), %r14
movl %r14d, %r9d
movl %ebx, %r10d
movq %r13, 0x30(%rsp)
movq %rsi, 0x80(%rsp)
movq %rax, 0x70(%rsp)
je 0x1824
leal 0x1(%r14), %ecx
leal 0x1(%r13), %edx
movl %edx, 0x60(%rsp)
ucomisd 0x10(%rsp), %xmm1
movq 0x58(%rsp), %r14
jbe 0x1b06
xorl %esi, %esi
movl $0x0, %edi
pushq $-0x9
popq %r13
movl $0x0, %r11d
movq %r11, 0x10(%rsp)
movl $0x0, %r11d
movq %r11, 0x40(%rsp)
cmpl $0x0, 0x28(%rsp)
movq 0x48(%rsp), %r15
movl 0xc(%rsp), %edx
js 0x1e7b
movq $0x0, 0x40(%rsp)
movq $0x0, 0x10(%rsp)
pushq $-0xa
popq %rbx
xorl %edi, %edi
movzwl (%rax,%r10,2), %r11d
movl %r11d, %ebp
andl $0xf000, %ebp           # imm = 0xF000
testl %ebx, %ebx
js 0x1724
cmpl $0xf000, %ebp           # imm = 0xF000
jne 0x1738
movq 0x10(%rsp), %r11
incl %r11d
movq %r11, 0x10(%rsp)
jmp 0x1733
movl %r10d, %r13d
testl %ebp, %ebp
je 0x173b
cmpl $0xe000, %ebp           # imm = 0xE000
je 0x173b
movl %ebx, %r13d
jmp 0x1786
movl %ebx, %r13d
movslq %edi, %rbx
cmpw $0xe000, %bp            # imm = 0xE000
je 0x174e
movzwl %bp, %r15d
testl %r15d, %r15d
jne 0x17aa
xorl %r15d, %r15d
cmpl $0xe000, %ebp           # imm = 0xE000
sete %r15b
andb $0xf, %r11b
leal 0x1(%rbx), %edi
movq 0x68(%rsp), %r14
movb %r11b, (%r14,%rbx)
movq 0x40(%rsp), %r11
addl %r15d, %r11d
movq %r11, 0x40(%rsp)
movq 0x48(%rsp), %r15
movq 0x58(%rsp), %r14
movl 0xc(%rsp), %edx
incq %r10
cmpl %r10d, 0x1c(%rsp)
movq 0x28(%rsp), %r11
jle 0x1e75
movl %r13d, %ebx
cmpl %r11d, %edi
jle 0x16fb
jmp 0x1e75
movq 0x10(%rsp), %r14
incl %r14d
movq %r14, 0x10(%rsp)
movl %r11d, %ebp
andb $0xf, %bpl
movq 0x68(%rsp), %r14
movb %bpl, (%r14,%rbx)
leal 0x1(%rbx), %ebp
cmpw $0x1000, %r11w          # imm = 0x1000
jb 0x181d
cmpl 0x28(%rsp), %edi
jge 0x181d
movl %r11d, %ebp
shrl $0x4, %ebp
shrl $0xc, %r11d
incq %rbx
incl %edi
movl %ebp, %r15d
andb $0x3, %r15b
movq 0x68(%rsp), %r14
movb %r15b, (%r14,%rbx)
incl %edi
cmpl $0x2, %r11d
jb 0x1778
movzwl %bp, %ebp
decl %r11d
shrl $0x2, %ebp
leaq 0x1(%rbx), %r15
cmpq %r9, %rbx
movq %r15, %rbx
jl 0x17e7
jmp 0x1778
movl %ebp, %edi
jmp 0x1778
xorl %ecx, %ecx
movl $0x0, %edx
pushq $-0xa
popq %r13
movl $0x0, %r11d
movq %r11, 0x10(%rsp)
movl $0x0, %r11d
movq %r11, 0x40(%rsp)
testl %r14d, %r14d
jle 0x19a4
movq $0x0, 0x40(%rsp)
movq $0x0, 0x10(%rsp)
pushq $-0xa
popq %rbx
xorl %edx, %edx
movzwl (%rax,%r10,2), %r11d
movl %r11d, %ebp
andl $0xf000, %ebp           # imm = 0xF000
testl %ebx, %ebx
js 0x188e
cmpl $0xf000, %ebp           # imm = 0xF000
jne 0x18a2
movq 0x10(%rsp), %r11
incl %r11d
movq %r11, 0x10(%rsp)
jmp 0x189d
movl %r10d, %r13d
testl %ebp, %ebp
je 0x18a5
cmpl $0xe000, %ebp           # imm = 0xE000
je 0x18a5
movl %ebx, %r13d
jmp 0x18ee
movl %ebx, %r13d
movslq %edx, %rbx
cmpw $0xe000, %bp            # imm = 0xE000
je 0x18b6
movzwl %bp, %edx
testl %edx, %edx
jne 0x1912
xorl %r12d, %r12d
cmpl $0xe000, %ebp           # imm = 0xE000
sete %r12b
andb $0xf, %r11b
leal 0x1(%rbx), %edx
movl %r13d, %esi
movq 0x68(%rsp), %r13
movb %r11b, (%r13,%rbx)
movl %esi, %r13d
movq 0x40(%rsp), %r11
addl %r12d, %r11d
movq %r11, 0x40(%rsp)
leaq 0x28a2(%rip), %r12      # 0x4190
movq 0x28(%rsp), %r14
incq %r10
cmpl %r10d, 0x1c(%rsp)
jle 0x19a4
movl %r13d, %ebx
cmpl %r14d, %edx
jl 0x1865
jmp 0x19a4
movq 0x10(%rsp), %rdx
incl %edx
movq %rdx, 0x10(%rsp)
movl %r11d, %edx
andb $0xf, %dl
movq 0x68(%rsp), %r12
movb %dl, (%r12,%rbx)
movl %ebx, %edx
incl %edx
cmpw $0x1000, %r11w          # imm = 0x1000
jb 0x18e7
movq 0x28(%rsp), %r14
cmpl %r14d, %edx
jge 0x1998
movl %r13d, %esi
movl %r11d, %ebx
shrl $0x4, %ebx
shrl $0xc, %r11d
movslq %edx, %r12
incq %r12
movl %ebx, %ebp
andb $0x3, %bpl
movq 0x68(%rsp), %r13
movb %bpl, -0x1(%r13,%r12)
incl %edx
cmpl $0x2, %r11d
jb 0x1984
movzwl %bx, %ebx
decl %r11d
shrl $0x2, %ebx
leaq 0x1(%r12), %r13
cmpq %r9, %r12
movq %r13, %r12
jl 0x1956
leaq 0x2805(%rip), %r12      # 0x4190
movq 0x28(%rsp), %r14
movl %esi, %r13d
jmp 0x18f3
leaq 0x27f1(%rip), %r12      # 0x4190
jmp 0x18f3
cmpl %r14d, %edx
pushq $-0xa
popq %rdx
cmovnel %edx, %r13d
movl %edx, %r10d
movl $0x0, %edx
movq %rdx, 0x20(%rsp)
movl $0x0, %edx
movq %rdx, 0x38(%rsp)
testl %r15d, %r15d
movq 0x48(%rsp), %r15
pushq $0x4
popq %rbp
movq 0x30(%rsp), %rbx
movl 0xc(%rsp), %esi
movq 0x58(%rsp), %r14
jle 0x207c
movq $0x0, 0x38(%rsp)
movq $0x0, 0x20(%rsp)
pushq $-0xa
popq %r9
xorl %ecx, %ecx
cmpl %ebx, %ecx
jge 0x1e6d
movzwl (%rax,%rdi,2), %edx
movl %edx, %r10d
andl $0xf000, %r10d          # imm = 0xF000
testl %r9d, %r9d
js 0x1a2e
cmpl $0xf000, %r10d          # imm = 0xF000
jne 0x1a43
movq 0x20(%rsp), %rdx
incl %edx
movq %rdx, 0x20(%rsp)
jmp 0x1a3e
movl %edi, %eax
testl %r10d, %r10d
je 0x1a46
cmpl $0xe000, %r10d          # imm = 0xE000
je 0x1a46
movl %r9d, %eax
jmp 0x1a7e
movl %r9d, %eax
movslq %ecx, %r9
cmpw $0xe000, %r10w          # imm = 0xE000
je 0x1a5a
movzwl %r10w, %r11d
testl %r11d, %r11d
jne 0x1aa3
xorl %r11d, %r11d
cmpl $0xe000, %r10d          # imm = 0xE000
sete %r11b
andb $0xf, %dl
incl %ecx
movb %dl, (%r14,%r9)
movq 0x38(%rsp), %rdx
addl %r11d, %edx
movq %rdx, 0x38(%rsp)
testl %edi, %edi
jle 0x2079
decq %rdi
movl %eax, %r10d
movl %eax, %r9d
cmpl 0x1c(%rsp), %esi
movq 0x70(%rsp), %rax
jle 0x19fc
jmp 0x207c
movq 0x20(%rsp), %r10
incl %r10d
movq %r10, 0x20(%rsp)
movl %edx, %r10d
andb $0xf, %r10b
movb %r10b, (%r14,%r9)
incl %ecx
cmpw $0x1000, %dx            # imm = 0x1000
jb 0x1a7e
cmpl %ebx, %ecx
jge 0x1a7e
movl %edx, %r9d
shrl $0x4, %r9d
shrl $0xc, %edx
movslq %ecx, %r10
incq %r10
movl %r9d, %r11d
andb $0x3, %r11b
movb %r11b, -0x1(%r14,%r10)
incl %ecx
cmpl $0x2, %edx
jb 0x1a7e
movzwl %r9w, %r9d
decl %edx
shrl $0x2, %r9d
leaq 0x1(%r10), %r11
cmpq %r8, %r10
movq %r11, %r10
jl 0x1ad8
jmp 0x1a7e
addl %ecx, %ebx
cmpl 0x1c(%rsp), %ebx
setge %r9b
movl %ebx, %r8d
orl 0x28(%rsp), %r8d
sets %r10b
xorl %r8d, %r8d
orb %r9b, %r10b
movl $0x0, %r11d
pushq $-0xa
popq %r13
movl $0x0, %r9d
movq %r9, 0x10(%rsp)
movl $0x0, %r9d
movq %r9, 0x40(%rsp)
jne 0x1cc0
movslq 0x28(%rsp), %r9
movl %ebx, %r10d
movq $0x0, 0x40(%rsp)
movq $0x0, 0x10(%rsp)
pushq $-0xa
popq %rbp
xorl %r11d, %r11d
movzwl (%rax,%r10,2), %ebx
movl %ebx, %r13d
andl $0xf000, %r13d          # imm = 0xF000
testl %ebp, %ebp
js 0x1b92
cmpl $0xf000, %r13d          # imm = 0xF000
jne 0x1ba8
movq 0x10(%rsp), %rbx
incl %ebx
movq %rbx, 0x10(%rsp)
jmp 0x1ba3
movl %r10d, %edx
testl %r13d, %r13d
je 0x1baa
cmpl $0xe000, %r13d          # imm = 0xE000
je 0x1baa
movl %ebp, %r13d
jmp 0x1bf2
movl %ebp, %edx
movslq %r11d, %r12
cmpw $0xe000, %r13w          # imm = 0xE000
je 0x1bbd
movzwl %r13w, %ebp
testl %ebp, %ebp
jne 0x1c11
xorl %ebp, %ebp
cmpl $0xe000, %r13d          # imm = 0xE000
sete %bpl
andb $0xf, %bl
leal 0x1(%r12), %r11d
movq 0x68(%rsp), %r13
movb %bl, (%r13,%r12)
movq 0x40(%rsp), %rbx
addl %ebp, %ebx
movq %rbx, 0x40(%rsp)
leaq 0x25a1(%rip), %r12      # 0x4190
movl %edx, %r13d
testl %r10d, %r10d
jle 0x1cc0
decq %r10
movl %r13d, %ebp
cmpl 0x28(%rsp), %r11d
jle 0x1b68
jmp 0x1cc0
movq %r14, %rsi
movq 0x10(%rsp), %r14
incl %r14d
movq %r14, 0x10(%rsp)
movl %ebx, %ebp
andb $0xf, %bpl
movq 0x68(%rsp), %r13
movb %bpl, (%r13,%r12)
leal 0x1(%r12), %ebp
cmpw $0x1000, %bx            # imm = 0x1000
jb 0x1ca3
cmpl 0x28(%rsp), %r11d
jge 0x1c91
movl %ebx, %ebp
shrl $0x4, %ebp
shrl $0xc, %ebx
incq %r12
incl %r11d
movq 0x80(%rsp), %rsi
movl %ebp, %r13d
andb $0x3, %r13b
movq 0x68(%rsp), %r14
movb %r13b, (%r14,%r12)
incl %r11d
cmpl $0x2, %ebx
jb 0x1c87
movzwl %bp, %ebp
decl %ebx
shrl $0x2, %ebp
leaq 0x1(%r12), %r13
cmpq %r9, %r12
movq %r13, %r12
jl 0x1c5a
movq 0x58(%rsp), %r14
jmp 0x1be8
movq %rsi, %r14
movl %ebp, %r11d
leaq 0x24f2(%rip), %r12      # 0x4190
movl %edx, %r13d
jmp 0x1cb3
movl %ebp, %r11d
leaq 0x24e3(%rip), %r12      # 0x4190
movl %edx, %r13d
movq %rsi, %r14
movq 0x80(%rsp), %rsi
jmp 0x1bf2
cmpl %ecx, %r11d
pushq $-0xa
popq %r11
cmovnel %r11d, %r13d
testl %r15d, %r15d
setle %r9b
movq 0x30(%rsp), %rbx
testl %ebx, %ebx
sets %r10b
orb %r9b, %r10b
movl %r11d, %ebp
movl $0x0, %edx
movq %rdx, 0x20(%rsp)
movl $0x0, %edx
movq %rdx, 0x38(%rsp)
movq 0x48(%rsp), %r15
movl 0x60(%rsp), %edx
jne 0x1e58
movq $0x0, 0x38(%rsp)
movq $0x0, 0x20(%rsp)
pushq $-0xa
popq %r10
xorl %r8d, %r8d
movzwl (%rax,%rdi,2), %r9d
movl %r9d, %r11d
andl $0xf000, %r11d          # imm = 0xF000
testl %r10d, %r10d
js 0x1d4e
cmpl $0xf000, %r11d          # imm = 0xF000
jne 0x1d63
movq 0x20(%rsp), %rdx
incl %edx
movq %rdx, 0x20(%rsp)
movl 0x60(%rsp), %edx
jmp 0x1d5e
movl %edi, %ebp
testl %r11d, %r11d
je 0x1d66
cmpl $0xe000, %r11d          # imm = 0xE000
je 0x1d66
movl %r10d, %ebp
jmp 0x1da6
movl %r10d, %ebp
movslq %r8d, %r10
cmpw $0xe000, %r11w          # imm = 0xE000
je 0x1d79
movzwl %r11w, %ebx
testl %ebx, %ebx
jne 0x1dd2
xorl %ebx, %ebx
cmpl $0xe000, %r11d          # imm = 0xE000
sete %bl
andb $0xf, %r9b
leal 0x1(%r10), %r8d
movb %r9b, (%r14,%r10)
movq 0x38(%rsp), %rdx
addl %ebx, %edx
movq %rdx, 0x38(%rsp)
movq 0x30(%rsp), %rbx
movl 0x60(%rsp), %edx
testl %edi, %edi
jle 0x1e58
movl 0xc(%rsp), %r9d
cmpl 0x1c(%rsp), %r9d
jg 0x1e58
decq %rdi
movl %ebp, %r10d
cmpl %ebx, %r8d
jle 0x1d1f
jmp 0x1e58
movq 0x20(%rsp), %rdx
incl %edx
movq %rdx, 0x20(%rsp)
movl %r9d, %r11d
andb $0xf, %r11b
movb %r11b, (%r14,%r10)
leal 0x1(%r10), %r11d
cmpw $0x1000, %r9w           # imm = 0x1000
jb 0x1e50
movq 0x30(%rsp), %rbx
cmpl %ebx, %r8d
movl 0x60(%rsp), %edx
jge 0x1e48
movl %r9d, %r11d
shrl $0x4, %r11d
shrl $0xc, %r9d
incq %r10
incl %r8d
movl %r11d, %ebx
andb $0x3, %bl
movb %bl, (%r14,%r10)
incl %r8d
cmpl $0x2, %r9d
jb 0x1e3e
movzwl %r11w, %r11d
decl %r9d
shrl $0x2, %r11d
leaq 0x1(%r10), %rbx
cmpq %rsi, %r10
movq %rbx, %r10
jl 0x1e14
movq 0x30(%rsp), %rbx
jmp 0x1da6
movl %r11d, %r8d
jmp 0x1da6
movl %r11d, %r8d
jmp 0x1d9d
cmpl %edx, %r8d
pushq $-0xa
popq %rax
cmovnel %eax, %ebp
movl %ebp, 0x70(%rsp)
pushq $0x1
popq %rbp
jmp 0x2003
movl %r9d, %r10d
jmp 0x207c
incl %r13d
pushq $0x1
popq %rbp
subl 0x60(%rsp), %edx
cmpl 0x1c(%rsp), %edx
setge %r9b
movl %edx, %r10d
orl 0x30(%rsp), %r10d
sets %r10b
orb %r9b, %r10b
pushq $-0x9
popq %r10
movl $0x0, %r9d
movq %r9, 0x20(%rsp)
movl $0x0, %r9d
movq %r9, 0x38(%rsp)
jne 0x1feb
movl %edx, %r9d
movq $0x0, 0x38(%rsp)
movq $0x0, 0x20(%rsp)
pushq $-0xa
popq %r11
xorl %esi, %esi
movq 0x70(%rsp), %rax
movzwl (%rax,%r9,2), %r10d
movl %r10d, %ebx
andl $0xf000, %ebx           # imm = 0xF000
testl %r11d, %r11d
js 0x1f00
cmpl $0xf000, %ebx           # imm = 0xF000
jne 0x1f14
movq 0x20(%rsp), %r10
incl %r10d
movq %r10, 0x20(%rsp)
jmp 0x1f0f
movl %r9d, %eax
testl %ebx, %ebx
je 0x1f17
cmpl $0xe000, %ebx           # imm = 0xE000
je 0x1f17
movl %r11d, %eax
jmp 0x1f50
movl %r11d, %eax
movslq %esi, %r11
cmpw $0xe000, %bx            # imm = 0xE000
je 0x1f28
movzwl %bx, %ebp
testl %ebp, %ebp
jne 0x1f76
xorl %ebp, %ebp
cmpl $0xe000, %ebx           # imm = 0xE000
sete %bpl
andb $0xf, %r10b
leal 0x1(%r11), %esi
movb %r10b, (%r14,%r11)
movq 0x38(%rsp), %r10
addl %ebp, %r10d
movq %r10, 0x38(%rsp)
pushq $0x1
popq %rbp
cmpl $-0x1, %edx
movq 0x30(%rsp), %r10
jl 0x1fe5
incq %r9
cmpl %r9d, 0x1c(%rsp)
jle 0x1fe5
movl %eax, %r11d
cmpl %r10d, %esi
jle 0x1ed1
jmp 0x1fe5
movq 0x20(%rsp), %rbx
incl %ebx
movq %rbx, 0x20(%rsp)
movl %r10d, %ebx
andb $0xf, %bl
movb %bl, (%r14,%r11)
leal 0x1(%r11), %ebx
cmpw $0x1000, %r10w          # imm = 0x1000
jb 0x1fde
cmpl 0x30(%rsp), %esi
jge 0x1fde
movl %r10d, %ebx
shrl $0x4, %ebx
shrl $0xc, %r10d
incq %r11
incl %esi
movl %ebx, %ebp
andb $0x3, %bpl
movb %bpl, (%r14,%r11)
incl %esi
cmpl $0x2, %r10d
jb 0x1f4d
movzwl %bx, %ebx
decl %r10d
shrl $0x2, %ebx
leaq 0x1(%r11), %r15
cmpq %r8, %r11
movq %r15, %r11
movq 0x48(%rsp), %r15
jl 0x1fad
jmp 0x1f4d
movl %ebx, %esi
jmp 0x1f4d
movl %eax, %r10d
incl %r10d
cmpl %ecx, %edi
pushq $-0x9
popq %rax
cmovnel %eax, %r13d
movl 0x60(%rsp), %edx
cmpl %edx, %esi
cmovnel %eax, %r10d
movl %r10d, 0x70(%rsp)
movb $0x1, %al
leaq 0xb0(%rsp), %rsi
movq 0x90(%rsp), %rbx
pushq $0x1
popq %r14
cmpl $0x2, %ecx
jl 0x2064
movq (%rsi), %rsi
movzbl (%rsi), %r9d
movl %ecx, %edi
movq %r14, %r8
movb (%rsi,%r8), %cl
cmpl $0x4, %r9d
setae %r10b
cmpb $0x4, %cl
setae %r11b
orb %r10b, %r11b
movb $0x4, %r10b
jne 0x2053
movl %ebp, %r10d
shll %cl, %r10d
btsl %r9d, %r10d
movb (%r12,%r10,4), %r10b
movzbl %cl, %r9d
movb %r10b, -0x1(%rsi,%r8)
incq %r8
cmpq %r8, %rdi
jne 0x202a
movl %edx, %ecx
leaq 0xb8(%rsp), %rsi
testb $0x1, %al
movl $0x0, %eax
jne 0x2019
jmp 0x20ca
movl %eax, %r10d
cmpl %ebx, %ecx
pushq $-0xa
popq %rax
cmovnel %eax, %r10d
movl %r10d, 0x70(%rsp)
testl %ebx, %ebx
movq 0x80(%rsp), %rsi
jle 0x20bf
xorl %eax, %eax
movq 0x90(%rsp), %rbx
movb (%r14,%rax), %cl
movb $0x3, %dl
subb %cl, %dl
cmpb $0x4, %cl
movzbl %dl, %ecx
cmovael %ebp, %ecx
movb %cl, (%r14,%rax)
incq %rax
cmpq %rax, %rsi
jne 0x20a0
jmp 0x20c7
movq 0x90(%rsp), %rbx
pushq $0x1
popq %rbp
testl %r13d, %r13d
movq 0xa8(%rsp), %rax
js 0x2347
cmpl $0x0, 0x70(%rsp)
js 0x2347
movl %r13d, 0xc(%rsp)
movb $0x1, %bl
leaq 0xa4(%rsp), %r14
movq 0x28(%rsp), %rax
leaq 0xb0(%rsp), %rcx
testl %eax, %eax
jle 0x215f
movq (%rcx), %r15
movl %eax, %r12d
xorl %r13d, %r13d
movb (%r15,%r13), %bpl
movb $0x4, %al
cmpb $0x3, %bpl
ja 0x2153
callq 0x11e0
movsd 0x4000(%rip), %xmm1     # 0x6128
ucomisd %xmm0, %xmm1
jbe 0x2151
callq 0x11e0
mulsd 0x1eed(%rip), %xmm0     # 0x4028
addsd 0x1ecd(%rip), %xmm0     # 0x4010
cvttsd2si %xmm0, %eax
incl (%r14)
addb %al, %bpl
andb $0x3, %bpl
movl %ebp, %eax
movb %al, (%r15,%r13)
incq %r13
cmpq %r13, %r12
jne 0x210f
leaq 0xa0(%rsp), %r14
movq 0x30(%rsp), %rax
leaq 0xb8(%rsp), %rcx
testb $0x1, %bl
movl $0x0, %ebx
jne 0x2102
incl 0xc(%rsp)
incl 0x70(%rsp)
movl 0xa4(%rsp), %eax
movq %rax, 0x60(%rsp)
movl 0xa0(%rsp), %eax
movq %rax, 0x80(%rsp)
pushq $0x2
popq %rbp
movl 0x7c(%rsp), %eax
subl %eax, %ebp
movl %ebp, 0xc8(%rsp)
incl %eax
movl %eax, 0x7c(%rsp)
movb $0x1, %bl
leaq 0xe0(%rsp), %r14
leaq 0xb0(%rsp), %r12
movq 0x48(%rsp), %r15
movq 0x28(%rsp), %rbp
movl %ebp, %r13d
testl %ebp, %ebp
jle 0x21f2
movzbl 0xc4(%rsp), %esi
movq %r15, %rdi
movq %r13, %rdx
callq 0x10d0
movq %r13, %rax
jmp 0x21f4
xorl %eax, %eax
movb $0x0, (%r15,%rax)
movq (%r14), %r14
testb $0x1, %bl
movl 0xc8(%rsp), %eax
movl %eax, %r10d
cmovnel 0x7c(%rsp), %r10d
cmpb $0x0, 0x3f36(%rip)      # 0x614c
je 0x2268
subq $0x8, %rsp
movq %r14, %rdi
leaq 0x20f8(%rip), %rsi      # 0x431e
leaq 0x178(%rsp), %rdx
movl 0x14(%rsp), %ecx
movl 0x78(%rsp), %r8d
movq 0xb0(%rsp), %r9
xorl %eax, %eax
pushq 0x28(%rsp)
pushq 0x48(%rsp)
pushq 0x98(%rsp)
pushq 0x30(%rsp)
pushq 0x68(%rsp)
pushq 0x90(%rsp)
pushq %r10
callq 0x1120
jmp 0x22b3
subq $0x8, %rsp
movq %r14, %rdi
leaq 0x2083(%rip), %rsi      # 0x42f9
leaq 0x178(%rsp), %rdx
movl 0x14(%rsp), %ecx
movl 0x78(%rsp), %r8d
movq 0x68(%rsp), %r9
xorl %eax, %eax
pushq %r10
pushq 0xb8(%rsp)
pushq 0x38(%rsp)
pushq 0x58(%rsp)
pushq 0xa8(%rsp)
pushq 0x40(%rsp)
pushq 0x78(%rsp)
callq 0x1120
addq $0x40, %rsp
testl %ebp, %ebp
leaq 0x1f47(%rip), %rbp      # 0x4207
jle 0x22e2
movq (%r12), %r12
xorl %r15d, %r15d
movzbl (%r12,%r15), %eax
movsbl (%rax,%rbp), %edi
movq %r14, %rsi
callq 0x1100
incq %r15
cmpq %r15, %r13
jne 0x22c9
movq %r14, %rdi
leaq 0x2057(%rip), %rsi      # 0x4343
movq 0x48(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x1120
leaq 0x100(%rsp), %r14
movq 0x30(%rsp), %rax
movl %eax, %ebp
leaq 0xb8(%rsp), %r12
testb $0x1, %bl
movl $0x0, %ebx
jne 0x21d3
movq 0xa8(%rsp), %rax
incq %rax
movq 0x90(%rsp), %rbx
movl 0x88(%rsp), %r13d
pushq $0x1
popq %rbp
leaq 0x1e4b(%rip), %r12      # 0x4190
jmp 0x234f
movl 0x88(%rsp), %r13d
cmpq 0x108(%rsp), %rax
jne 0x152f
movq 0x158(%rsp), %rdi
callq 0x1030
movq 0x168(%rsp), %rdi
callq 0x1030
leaq 0xd0(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x170(%rsp), %rdx
xorl %ecx, %ecx
callq 0x27b1
movl %eax, %r13d
testl %eax, %eax
jns 0x1431
jmp 0x23d2
movq 0x3c50(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1f0c(%rip), %rsi      # 0x42be
leaq 0x170(%rsp), %rdx
movl 0x9c(%rsp), %ecx
xorl %eax, %eax
callq 0x1120
movq 0x90(%rsp), %rbx
jmp 0x237f
movq 0xd8(%rsp), %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq 0x68(%rsp), %rdi
callq 0x1030
movq 0x58(%rsp), %rdi
callq 0x1030
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq