// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam2bcf.c
// Function: bcf_call2bcf
int bcf_call2bcf(int tid, int pos, bcf_call_t *bc, bcf1_t *b, bcf_callret1_t *bcr, int fmt_flag,
				 const bcf_callaux_t *bca, const char *ref)
{
	extern double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two);
	kstring_t s;
	int i, j;
	b->n_smpl = bc->n;
	b->tid = tid; b->pos = pos; b->qual = 0;
	s.s = b->str; s.m = b->m_str; s.l = 0;
	kputc('\0', &s);
	if (bc->ori_ref < 0) { // an indel
		// write REF
		kputc(ref[pos], &s);
		for (j = 0; j < bca->indelreg; ++j) kputc(ref[pos+1+j], &s);
		kputc('\0', &s);
		// write ALT
		kputc(ref[pos], &s);
		for (i = 1; i < 4; ++i) {
			if (bc->a[i] < 0) break;
			if (i > 1) {
				kputc(',', &s); kputc(ref[pos], &s);
			}
			if (bca->indel_types[bc->a[i]] < 0) { // deletion
				for (j = -bca->indel_types[bc->a[i]]; j < bca->indelreg; ++j)
					kputc(ref[pos+1+j], &s);
			} else { // insertion; cannot be a reference unless a bug
				char *inscns = &bca->inscns[bc->a[i] * bca->maxins];
				for (j = 0; j < bca->indel_types[bc->a[i]]; ++j)
					kputc("ACGTN"[(int)inscns[j]], &s);
				for (j = 0; j < bca->indelreg; ++j) kputc(ref[pos+1+j], &s);
			}
		}
		kputc('\0', &s);
	} else { // a SNP
		kputc("ACGTN"[bc->ori_ref], &s); kputc('\0', &s);
		for (i = 1; i < 5; ++i) {
			if (bc->a[i] < 0) break;
			if (i > 1) kputc(',', &s);
			kputc(bc->unseen == i? 'X' : "ACGT"[bc->a[i]], &s);
		}
		kputc('\0', &s);
	}
	kputc('\0', &s);
	// INFO
	if (bc->ori_ref < 0) ksprintf(&s,"INDEL;IS=%d,%f;", bca->max_support, bca->max_frac);
	kputs("DP=", &s); kputw(bc->ori_depth, &s); kputs(";I16=", &s);
	for (i = 0; i < 16; ++i) {
		if (i) kputc(',', &s);
		kputw(bc->anno[i], &s);
	}
    //ksprintf(&s,";RPS=%d,%f,%f", bc->read_pos.dp,bc->read_pos.avg,bc->read_pos.var);
    ksprintf(&s,";QS=%f,%f,%f,%f", bc->qsum[0],bc->qsum[1],bc->qsum[2],bc->qsum[3]);
    if (bc->vdb != -1)
        ksprintf(&s, ";VDB=%e", bc->vdb);
    if (bc->read_pos_bias != -1 )
        ksprintf(&s, ";RPB=%e", bc->read_pos_bias);
	kputc('\0', &s);
	// FMT
	kputs("PL", &s);
	if (bcr && fmt_flag) {
		if (fmt_flag & B2B_FMT_DP) kputs(":DP", &s);
		if (fmt_flag & B2B_FMT_DV) kputs(":DV", &s);
		if (fmt_flag & B2B_FMT_SP) kputs(":SP", &s);
	}
	kputc('\0', &s);
	b->m_str = s.m; b->str = s.s; b->l_str = s.l;
	bcf_sync(b);
	memcpy(b->gi[0].data, bc->PL, b->gi[0].len * bc->n);
	if (bcr && fmt_flag) {
		uint16_t *dp = (fmt_flag & B2B_FMT_DP)? b->gi[1].data : 0;
		uint16_t *dv = (fmt_flag & B2B_FMT_DV)? b->gi[1 + ((fmt_flag & B2B_FMT_DP) != 0)].data : 0;
		int32_t  *sp = (fmt_flag & B2B_FMT_SP)? b->gi[1 + ((fmt_flag & B2B_FMT_DP) != 0) + ((fmt_flag & B2B_FMT_DV) != 0)].data : 0;
		for (i = 0; i < bc->n; ++i) {
			bcf_callret1_t *p = bcr + i;
			if (dp) dp[i] = p->depth  < 0xffff? p->depth  : 0xffff;
			if (dv) dv[i] = p->n_supp < 0xffff? p->n_supp : 0xffff;
			if (sp) {
				if (p->anno[0] + p->anno[1] < 2 || p->anno[2] + p->anno[3] < 2
					|| p->anno[0] + p->anno[2] < 2 || p->anno[1] + p->anno[3] < 2)
				{
					sp[i] = 0;
				} else {
					double left, right, two;
					int x;
					kt_fisher_exact(p->anno[0], p->anno[1], p->anno[2], p->anno[3], &left, &right, &two);
					x = (int)(-4.343 * log(two) + .499);
					if (x > 255) x = 255;
					sp[i] = x;
				}
			}
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %r14
movl %esi, %r12d
movq %rdx, 0x30(%rsp)
movl 0x24(%rdx), %eax
movl %eax, 0x5c(%rcx)
movl %edi, (%rcx)
movl %esi, 0x4(%rcx)
movl $0x0, 0x10(%rcx)
movq 0x18(%rcx), %rax
movq %rax, 0x20(%rsp)
movslq 0xc(%rcx), %rdx
movq %rdx, 0x18(%rsp)
cmpq $0x1, %rdx
movq %rcx, 0x38(%rsp)
movl %r9d, 0x54(%rsp)
ja 0x11c0f
movq $0x2, 0x18(%rsp)
movl $0x2, %esi
movq %rax, %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rsi
movq $0x1, 0x10(%rsp)
xorl %ecx, %ecx
movb %cl, (%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rdx
movb %cl, (%rdx,%rax)
movq 0x30(%rsp), %rax
movslq 0x30(%rax), %rcx
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rax
leaq 0x1(%rbx), %r15
testq %rcx, %rcx
movq %r14, 0x58(%rsp)
js 0x11c69
leaq 0x2ff27(%rip), %rdx     # 0x41b80
movb (%rcx,%rdx), %bpl
cmpq %rax, %r15
jae 0x11c90
movq 0x20(%rsp), %rax
jmp 0x11cd8
movq 0xb8(%rsp), %rcx
movslq %r12d, %rdx
movq %rdx, 0x40(%rsp)
movb (%rcx,%rdx), %bpl
cmpq %rax, %r15
jae 0x11ea2
movq 0x20(%rsp), %rax
jmp 0x11ef2
movq %r15, %rax
shrq %rax
orq %r15, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %r15, 0x10(%rsp)
movb %bpl, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%rsp), %rbx
leaq 0x1(%rbx), %r14
cmpq 0x18(%rsp), %r14
jae 0x11d06
movq 0x20(%rsp), %rax
jmp 0x11d4e
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %r14, 0x10(%rsp)
xorl %ecx, %ecx
movb %cl, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rdx
movb %cl, (%rdx,%rax)
movl $0x1, %r15d
leaq 0x2d470(%rip), %r12     # 0x3f1e2
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax,%r15,4)
js 0x1242c
cmpq $0x2, %r15
jb 0x11dfe
movq 0x10(%rsp), %rbx
leaq 0x1(%rbx), %r14
cmpq 0x18(%rsp), %r14
jae 0x11d9f
movq 0x20(%rsp), %rax
jmp 0x11de7
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %r14, 0x10(%rsp)
movb $0x2c, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rsp), %rax
movl 0x34(%rax), %eax
movb $0x58, %bl
cmpq %rax, %r15
je 0x11e1a
movq 0x30(%rsp), %rax
movslq (%rax,%r15,4), %rax
movb (%rax,%r12), %bl
movq 0x10(%rsp), %r14
leaq 0x1(%r14), %r13
cmpq 0x18(%rsp), %r13
jae 0x11e31
movq 0x20(%rsp), %rax
jmp 0x11e79
movq %r13, %rax
shrq %rax
orq %r13, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %r13, 0x10(%rsp)
movb %bl, (%rax,%r14)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r15
cmpq $0x5, %r15
jne 0x11d72
jmp 0x1242c
movq %r15, %rax
shrq %rax
orq %r15, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq 0xb0(%rsp), %rsi
movq %rax, 0x20(%rsp)
movq %r15, 0x10(%rsp)
movb %bpl, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
cmpl $0x0, 0x64(%rsi)
jle 0x11fbc
movq 0xb8(%rsp), %rax
movq 0x40(%rsp), %rcx
leaq (%rax,%rcx), %rbx
incq %rbx
xorl %r14d, %r14d
movb (%rbx,%r14), %bpl
movq 0x10(%rsp), %r15
leaq 0x1(%r15), %r13
cmpq 0x18(%rsp), %r13
jae 0x11f45
movq 0x20(%rsp), %rax
jmp 0x11f95
movq %r13, %rax
shrq %rax
orq %r13, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq 0xb0(%rsp), %rsi
movq %rax, 0x20(%rsp)
movq %r13, 0x10(%rsp)
movb %bpl, (%rax,%r15)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r14
movslq 0x64(%rsi), %rax
cmpq %rax, %r14
jl 0x11f2a
movq 0x10(%rsp), %rbx
leaq 0x1(%rbx), %r14
cmpq 0x18(%rsp), %r14
jae 0x11fd3
movq 0x20(%rsp), %rax
jmp 0x1201b
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %r14, 0x10(%rsp)
xorl %ecx, %ecx
movb %cl, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rdx
movb %cl, (%rdx,%rax)
movq 0xb8(%rsp), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %bl
movq 0x10(%rsp), %r14
leaq 0x1(%r14), %r15
cmpq 0x18(%rsp), %r15
jae 0x12059
movq 0x20(%rsp), %rax
jmp 0x120a1
movq %r15, %rax
shrq %rax
orq %r15, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rdx
movq %r15, 0x10(%rsp)
movb %bl, (%rax,%r14)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incl %r12d
movslq %r12d, %r13
addq 0xb8(%rsp), %r13
movl $0x1, %r15d
movq %r13, 0x48(%rsp)
movq 0x30(%rsp), %rax
movl (%rax,%r15,4), %eax
testl %eax, %eax
js 0x1242c
cmpq $0x2, %r15
jb 0x12206
movq 0x10(%rsp), %rbx
leaq 0x1(%rbx), %r14
cmpq 0x18(%rsp), %r14
jae 0x1210b
movq 0x20(%rsp), %rax
jmp 0x12153
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %r14, 0x10(%rsp)
movb $0x2c, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0xb8(%rsp), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %bl
movq 0x10(%rsp), %r14
leaq 0x1(%r14), %r13
cmpq 0x18(%rsp), %r13
jae 0x12191
movq 0x20(%rsp), %rax
jmp 0x121d9
movq %r13, %rax
shrq %rax
orq %r13, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rdx
movq %r13, 0x10(%rsp)
movb %bl, (%rax,%r14)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rsp), %rax
movl (%rax,%r15,4), %eax
movq 0x48(%rsp), %r13
movslq %eax, %rcx
movl 0x50(%rdx,%rcx,4), %ecx
testl %ecx, %ecx
js 0x1237a
je 0x122d1
imull 0x60(%rdx), %eax
movslq %eax, %rbx
addq 0x70(%rdx), %rbx
xorl %r14d, %r14d
movsbq (%rbx,%r14), %rax
leaq 0x2f94b(%rip), %rcx     # 0x41b80
movb (%rax,%rcx), %bpl
movq 0x10(%rsp), %r13
leaq 0x1(%r13), %r12
cmpq 0x18(%rsp), %r12
jae 0x12250
movq 0x20(%rsp), %rax
jmp 0x122a0
movq %r12, %rax
shrq %rax
orq %r12, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq 0xb0(%rsp), %rdx
movq %rax, 0x20(%rsp)
movq %r12, 0x10(%rsp)
movb %bpl, (%rax,%r13)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r14
movq 0x30(%rsp), %rax
movslq (%rax,%r15,4), %rax
movslq 0x50(%rdx,%rax,4), %rax
cmpq %rax, %r14
jl 0x12229
cmpl $0x0, 0x64(%rdx)
movq 0x48(%rsp), %r13
jle 0x1241f
xorl %ebx, %ebx
movb (%r13,%rbx), %bpl
movq 0x10(%rsp), %r14
leaq 0x1(%r14), %r12
cmpq 0x18(%rsp), %r12
jae 0x122fe
movq 0x20(%rsp), %rax
jmp 0x1234e
movq %r12, %rax
shrq %rax
orq %r12, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq 0xb0(%rsp), %rdx
movq %rax, 0x20(%rsp)
movq %r12, 0x10(%rsp)
movb %bpl, (%rax,%r14)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %rbx
movslq 0x64(%rdx), %rax
cmpq %rax, %rbx
jl 0x122e2
jmp 0x1241f
negl %ecx
cmpl %ecx, 0x64(%rdx)
jle 0x1241f
movl %ecx, %ebx
movb (%r13,%rbx), %r14b
movq 0x10(%rsp), %rbp
leaq 0x1(%rbp), %r13
cmpq 0x18(%rsp), %r13
jae 0x123a3
movq 0x20(%rsp), %rax
jmp 0x123f3
movq %r13, %rax
shrq %rax
orq %r13, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq 0xb0(%rsp), %rdx
movq %rax, 0x20(%rsp)
movq %r13, 0x10(%rsp)
movb %r14b, (%rax,%rbp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %rbx
movslq 0x64(%rdx), %rax
cmpq %rax, %rbx
movq 0x48(%rsp), %r13
jl 0x12387
incq %r15
cmpq $0x4, %r15
jne 0x120d9
movq 0x10(%rsp), %rbx
leaq 0x1(%rbx), %r14
cmpq 0x18(%rsp), %r14
jae 0x12443
movq 0x20(%rsp), %rax
jmp 0x1248b
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %r15
movq %r14, 0x10(%rsp)
movb $0x0, (%rax,%rbx)
movq 0x20(%rsp), %rax
addq 0x10(%rsp), %rax
movb $0x0, (%rax)
movq 0x10(%rsp), %rbx
leaq 0x1(%rbx), %r14
cmpq 0x18(%rsp), %r14
jae 0x124bd
movq 0x20(%rsp), %rax
jmp 0x12505
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rsi
movq %r14, 0x10(%rsp)
xorl %ecx, %ecx
movb %cl, (%rax,%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rdx
movb %cl, (%rdx,%rax)
movq 0x30(%rsp), %rax
cmpl $0x0, 0x30(%rax)
jns 0x1254a
movl 0x18(%rsi), %edx
movsd 0x28(%rsi), %xmm0
leaq 0x2f648(%rip), %rsi     # 0x41b86
leaq 0x10(%rsp), %rdi
movb $0x1, %al
callq 0x21b28
movq 0x10(%rsp), %rcx
leaq 0x4(%rcx), %rax
cmpq 0x18(%rsp), %rax
movq 0x58(%rsp), %r14
jae 0x12566
movq 0x20(%rsp), %rax
jmp 0x125b3
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movb $0x3d, 0x2(%rax,%rcx)
movw $0x5044, (%rax,%rcx)    # imm = 0x5044
leaq 0x10(%rsp), %r12
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x3(%rax), %rdx
movq %rdx, (%r12)
movb $0x0, 0x3(%rcx,%rax)
movq 0x30(%rsp), %rax
movl 0x80(%rax), %edi
movq %r12, %rsi
callq 0x12c76
movq (%r12), %rcx
leaq 0x6(%rcx), %rax
cmpq 0x8(%r12), %rax
jae 0x12602
movq 0x20(%rsp), %rax
jmp 0x1264f
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movb $0x3d, 0x4(%rax,%rcx)
movl $0x3631493b, (%rax,%rcx) # imm = 0x3631493B
leaq 0x10(%rsp), %r12
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x5(%rax), %rdx
movq %rdx, (%r12)
movb $0x0, 0x5(%rcx,%rax)
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x126fc
movq 0x10(%rsp), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x18(%rsp), %rcx
jae 0x12694
movq 0x20(%rsp), %rax
jmp 0x126e5
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x10(%rsp)
movb $0x2c, (%rax,%rdx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rsp), %rax
movl 0x3c(%rax,%rbx,4), %edi
movq %r12, %rsi
callq 0x12c76
incq %rbx
cmpq $0x10, %rbx
jne 0x12678
movq 0x30(%rsp), %rbx
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rbx), %xmm0
cvtss2sd 0x18(%rbx), %xmm1
cvtss2sd 0x1c(%rbx), %xmm2
cvtss2sd 0x20(%rbx), %xmm3
leaq 0x2f463(%rip), %rsi     # 0x41ba0
leaq 0x10(%rsp), %rdi
movb $0x4, %al
callq 0x21b28
movss 0x90(%rbx), %xmm0
ucomiss 0x2f358(%rip), %xmm0    # 0x41ab0
jne 0x1275c
jnp 0x12773
cvtss2sd %xmm0, %xmm0
leaq 0x2f449(%rip), %rsi     # 0x41bb0
leaq 0x10(%rsp), %rdi
movb $0x1, %al
callq 0x21b28
movq 0x30(%rsp), %rax
movss 0x94(%rax), %xmm0
ucomiss 0x2f329(%rip), %xmm0    # 0x41ab0
movl 0x54(%rsp), %ebx
jne 0x1278f
jnp 0x127a6
cvtss2sd %xmm0, %xmm0
leaq 0x2f41e(%rip), %rsi     # 0x41bb8
leaq 0x10(%rsp), %rdi
movb $0x1, %al
callq 0x21b28
movq 0x10(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x18(%rsp), %rdx
jae 0x127bd
movq 0x20(%rsp), %rax
jmp 0x1280e
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rcx
leaq 0x3(%rcx), %rax
cmpq 0x18(%rsp), %rax
jae 0x1283c
movq 0x20(%rsp), %rax
jmp 0x12889
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movw $0x4c50, (%rax,%rcx)    # imm = 0x4C50
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x2(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, 0x2(%rcx,%rax)
testq %r14, %r14
setne %al
testl %ebx, %ebx
setne %bpl
andb %al, %bpl
cmpb $0x1, %bpl
jne 0x12a70
testb $0x1, %bl
je 0x12950
movq 0x10(%rsp), %rcx
leaq 0x4(%rcx), %rax
cmpq 0x18(%rsp), %rax
jae 0x128e0
movq 0x20(%rsp), %rax
jmp 0x1292d
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movb $0x50, 0x2(%rax,%rcx)
movw $0x443a, (%rax,%rcx)    # imm = 0x443A
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x3(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, 0x3(%rcx,%rax)
testb $0x4, %bl
je 0x129e0
movq 0x10(%rsp), %rcx
leaq 0x4(%rcx), %rax
cmpq 0x18(%rsp), %rax
jae 0x12970
movq 0x20(%rsp), %rax
jmp 0x129bd
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movb $0x56, 0x2(%rax,%rcx)
movw $0x443a, (%rax,%rcx)    # imm = 0x443A
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x3(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, 0x3(%rcx,%rax)
testb $0x2, %bl
je 0x12a70
movq 0x10(%rsp), %rcx
leaq 0x4(%rcx), %rax
cmpq 0x18(%rsp), %rax
jae 0x12a00
movq 0x20(%rsp), %rax
jmp 0x12a4d
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movb $0x50, 0x2(%rax,%rcx)
movw $0x533a, (%rax,%rcx)    # imm = 0x533A
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x3(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, 0x3(%rcx,%rax)
movq 0x10(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x18(%rsp), %rdx
jae 0x12a87
movq 0x20(%rsp), %rax
jmp 0x12ad8
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3720
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%r15)
pshufd $0xe8, 0x10(%rsp), %xmm0 # xmm0 = mem[0,2,2,3]
movq %xmm0, 0x8(%r15)
movq %r15, %rdi
callq 0x3ab86
movq 0x50(%r15), %rax
movq 0x8(%rax), %rdi
movq 0x30(%rsp), %rcx
movq 0x88(%rcx), %rsi
movslq 0x4(%rax), %rax
movslq 0x24(%rcx), %rdx
imulq %rax, %rdx
callq 0x37d0
testb %bpl, %bpl
je 0x12c65
movl %ebx, %eax
andl $0x1, %eax
jne 0x12b47
xorl %r13d, %r13d
jmp 0x12b4f
movq 0x50(%r15), %rcx
movq 0x18(%rcx), %r13
movl %ebx, %ecx
andl $0x4, %ecx
jne 0x12b5a
xorl %ebp, %ebp
jmp 0x12b68
movq 0x50(%r15), %rdx
movl %eax, %esi
shll $0x4, %esi
movq 0x18(%rdx,%rsi), %rbp
testb $0x2, %bl
jne 0x12b72
xorl %r15d, %r15d
jmp 0x12b83
movq 0x50(%r15), %rdx
shrl $0x2, %ecx
addl %ecx, %eax
shll $0x4, %eax
movq 0x18(%rax,%rdx), %r15
movq 0x30(%rsp), %rax
cmpl $0x0, 0x24(%rax)
jle 0x12c65
addq $0x28, %r14
xorl %r12d, %r12d
movl $0xffff, %ebx           # imm = 0xFFFF
testq %r13, %r13
je 0x12bb2
movl -0x28(%r14), %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
movw %ax, (%r13,%r12,2)
testq %rbp, %rbp
je 0x12bc6
movl -0x24(%r14), %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
movw %ax, (%rbp,%r12,2)
testq %r15, %r15
je 0x12c49
movl -0xc(%r14), %edi
movl -0x8(%r14), %esi
leal (%rsi,%rdi), %eax
cmpl $0x2, %eax
jae 0x12be5
movl $0x0, (%r15,%r12,4)
jmp 0x12c49
movl (%r14), %ecx
leal (%rcx,%rsi), %eax
cmpl $0x2, %eax
jb 0x12bdb
movl -0x4(%r14), %edx
leal (%rdx,%rdi), %eax
cmpl $0x2, %eax
jb 0x12bdb
leal (%rcx,%rdx), %eax
cmpl $0x1, %eax
jbe 0x12bdb
leaq 0x60(%rsp), %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %r8
leaq 0x68(%rsp), %r9
callq 0x3de7c
movsd 0x60(%rsp), %xmm0
callq 0x3330
mulsd 0x2ee51(%rip), %xmm0    # 0x41a80
addsd 0x2c3f9(%rip), %xmm0    # 0x3f030
cvttsd2si %xmm0, %eax
movl $0xff, %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, (%r15,%r12,4)
incq %r12
movq 0x30(%rsp), %rax
movslq 0x24(%rax), %rax
addq $0xc0, %r14
cmpq %rax, %r12
jl 0x12b9e
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq