// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movl %r9d, %r15d
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %rbp
movl %esi, %r12d
movl 0x24(%rdx), %eax
movl %eax, 0x5c(%rcx)
movl %edi, (%rcx)
movl %esi, 0x4(%rcx)
movl $0x0, 0x10(%rcx)
movq 0x18(%rcx), %rdi
movq %rdi, 0x20(%rsp)
movslq 0xc(%rcx), %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x1, %rax
ja 0x1183c
movq $0x2, 0x18(%rsp)
movl $0x2, %esi
callq 0x3720
movq %rax, 0x20(%rsp)
movq %rbx, 0x48(%rsp)
movq 0xa0(%rsp), %r13
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movslq 0x30(%rbp), %rdx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
incq %rax
testq %rdx, %rdx
movq %rbp, 0x28(%rsp)
movl %r15d, 0x34(%rsp)
js 0x11b3c
leaq 0x2f297(%rip), %rsi     # 0x40b30
movb (%rdx,%rsi), %bl
cmpq %rcx, %rax
jb 0x118e9
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %bl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11964
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movl $0x1, %r15d
leaq 0x2c82c(%rip), %r12     # 0x3e1c2
cmpl $0x0, (%rbp,%r15,4)
js 0x11abf
cmpq $0x2, %r15
jb 0x11a24
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x119ff
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x2c, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movl 0x34(%rbp), %eax
movb $0x58, %bl
cmpq %rax, %r15
je 0x11a37
movslq (%rbp,%r15,4), %rax
movb (%rax,%r12), %bl
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11a8e
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %bl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r15
cmpq $0x5, %r15
jne 0x11996
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11b16
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, (%rcx,%rax)
movq 0x20(%rsp), %rax
addq 0x10(%rsp), %rax
jmp 0x1216a
movq %r14, 0x40(%rsp)
movq 0xa8(%rsp), %rdx
movslq %r12d, %rsi
movq %rsi, 0x38(%rsp)
movb (%rdx,%rsi), %bl
cmpq %rcx, %rax
jb 0x11ba1
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %bl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
cmpl $0x0, 0x64(%r13)
jle 0x11c77
movq 0xa8(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq (%rax,%rcx), %rbx
incq %rbx
xorl %r14d, %r14d
movb (%rbx,%r14), %bpl
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11c42
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %bpl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r14
movslq 0x64(%r13), %rax
cmpq %rax, %r14
jl 0x11be7
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11cce
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movq 0xa8(%rsp), %rax
movq 0x38(%rsp), %rcx
movb (%rax,%rcx), %bl
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11d5a
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %bl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0xa8(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq (%rax,%rcx), %rbp
incq %rbp
movl $0x1, %r15d
movq 0x40(%rsp), %r14
movq 0x28(%rsp), %rax
cmpl $0x0, (%rax,%r15,4)
js 0x120ed
cmpq $0x2, %r15
jb 0x11ebe
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11e0e
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x2c, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0xa8(%rsp), %rax
movq 0x38(%rsp), %rcx
movb (%rax,%rcx), %bl
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11e9a
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %bl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x28(%rsp), %rdx
movslq (%rdx,%r15,4), %rax
movl 0x50(%r13,%rax,4), %ecx
testl %ecx, %ecx
js 0x1203c
movslq (%rdx,%r15,4), %rcx
cmpl $0x0, 0x50(%r13,%rcx,4)
jle 0x11f99
imull 0x60(%r13), %eax
movslq %eax, %rbx
addq 0x70(%r13), %rbx
xorl %r14d, %r14d
movsbq (%rbx,%r14), %rax
leaq 0x2ec31(%rip), %rcx     # 0x40b30
movb (%rax,%rcx), %r12b
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x11f5a
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %r12b, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r14
movq 0x28(%rsp), %rax
movslq (%rax,%r15,4), %rax
movslq 0x50(%r13,%rax,4), %rax
cmpq %rax, %r14
jl 0x11ef3
cmpl $0x0, 0x64(%r13)
jle 0x120db
xorl %ebx, %ebx
movb (%rbp,%rbx), %r14b
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x12002
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %r14b, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %rbx
movslq 0x64(%r13), %rax
cmpq %rax, %rbx
jl 0x11fa6
jmp 0x120db
negl %ecx
cmpl %ecx, 0x64(%r13)
jle 0x120db
movl %ecx, %ebx
movb (%rbp,%rbx), %r14b
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x120a6
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb %r14b, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %rbx
movslq 0x64(%r13), %rax
cmpq %rax, %rbx
jl 0x1204a
incq %r15
cmpq $0x4, %r15
movq 0x40(%rsp), %r14
jne 0x11d9d
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x12144
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, (%rcx,%rax)
movq 0x20(%rsp), %rax
addq 0x10(%rsp), %rax
movq 0x28(%rsp), %rbp
movl 0x34(%rsp), %r15d
movb $0x0, (%rax)
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x121c9
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
cmpl $0x0, 0x30(%rbp)
jns 0x12211
movl 0x18(%r13), %edx
movsd 0x28(%r13), %xmm0
leaq 0x2e931(%rip), %rsi     # 0x40b36
leaq 0x10(%rsp), %rdi
movb $0x1, %al
callq 0x21558
movq 0x10(%rsp), %rax
addq $0x4, %rax
cmpq 0x18(%rsp), %rax
jb 0x12269
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)
leaq 0x10(%rsp), %r12
movq (%r12), %rax
movq 0x10(%r12), %rcx
movb $0x3d, 0x2(%rcx,%rax)
movw $0x5044, (%rcx,%rax)    # imm = 0x5044
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x3(%rax), %rdx
movq %rdx, (%r12)
movb $0x0, 0x3(%rcx,%rax)
movl 0x80(%rbp), %edi
movq %r12, %rsi
callq 0x12916
movq (%r12), %rax
addq $0x6, %rax
cmpq 0x8(%r12), %rax
jb 0x122fd
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)
leaq 0x10(%rsp), %r12
movq (%r12), %rax
movq 0x10(%r12), %rcx
movb $0x3d, 0x4(%rcx,%rax)
movl $0x3631493b, (%rcx,%rax) # imm = 0x3631493B
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 0x123b0
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x1238b
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x2c, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movl 0x3c(%rbp,%rbx,4), %edi
movq %r12, %rsi
callq 0x12916
incq %rbx
cmpq $0x10, %rbx
jne 0x1232f
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rbp), %xmm0
cvtss2sd 0x18(%rbp), %xmm1
cvtss2sd 0x1c(%rbp), %xmm2
cvtss2sd 0x20(%rbp), %xmm3
leaq 0x2e769(%rip), %rsi     # 0x40b50
leaq 0x10(%rsp), %rdi
movb $0x4, %al
callq 0x21558
movss 0x90(%rbp), %xmm0
ucomiss 0x2e63e(%rip), %xmm0    # 0x40a40
jne 0x12406
jnp 0x1241d
cvtss2sd %xmm0, %xmm0
leaq 0x2e74f(%rip), %rsi     # 0x40b60
leaq 0x10(%rsp), %rdi
movb $0x1, %al
callq 0x21558
movss 0x94(%rbp), %xmm0
ucomiss 0x2e614(%rip), %xmm0    # 0x40a40
movq 0x48(%rsp), %rbx
jne 0x12435
jnp 0x1244c
cvtss2sd %xmm0, %xmm0
leaq 0x2e728(%rip), %rsi     # 0x40b68
leaq 0x10(%rsp), %rdi
movb $0x1, %al
callq 0x21558
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x124a3
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
addq $0x3, %rax
cmpq 0x18(%rsp), %rax
jb 0x12520
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), %rax
movq 0x20(%rsp), %rcx
movw $0x4c50, (%rcx,%rax)    # 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 %r15d, %r15d
setne %bpl
andb %al, %bpl
cmpb $0x1, %bpl
jne 0x1270f
testb $0x1, %r15b
je 0x125f1
movq 0x10(%rsp), %rax
addq $0x4, %rax
cmpq 0x18(%rsp), %rax
jb 0x125c4
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), %rax
movq 0x20(%rsp), %rcx
movb $0x50, 0x2(%rcx,%rax)
movw $0x443a, (%rcx,%rax)    # 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, %r15b
je 0x12680
movq 0x10(%rsp), %rax
addq $0x4, %rax
cmpq 0x18(%rsp), %rax
jb 0x12653
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), %rax
movq 0x20(%rsp), %rcx
movb $0x56, 0x2(%rcx,%rax)
movw $0x443a, (%rcx,%rax)    # 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, %r15b
je 0x1270f
movq 0x10(%rsp), %rax
addq $0x4, %rax
cmpq 0x18(%rsp), %rax
jb 0x126e2
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), %rax
movq 0x20(%rsp), %rcx
movb $0x50, 0x2(%rcx,%rax)
movw $0x533a, (%rcx,%rax)    # 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), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jb 0x12766
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), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
movb %dl, (%rcx,%rax)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rcx,%rax)
movl 0x18(%rsp), %eax
movl %eax, 0xc(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rbx)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rdi
callq 0x3a436
movq 0x50(%rbx), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rcx
movq 0x88(%rcx), %rsi
movslq 0x4(%rax), %rax
movslq 0x24(%rcx), %rdx
imulq %rax, %rdx
callq 0x37d0
testb %bpl, %bpl
je 0x12905
movl %r15d, %eax
andl $0x1, %eax
jne 0x127e5
xorl %r13d, %r13d
jmp 0x127ed
movq 0x50(%rbx), %rcx
movq 0x18(%rcx), %r13
movl %r15d, %ecx
andl $0x4, %ecx
jne 0x127f9
xorl %ebp, %ebp
jmp 0x12807
movq 0x50(%rbx), %rdx
movl %eax, %esi
shll $0x4, %esi
movq 0x18(%rdx,%rsi), %rbp
testb $0x2, %r15b
jne 0x12812
xorl %r15d, %r15d
jmp 0x12823
movq 0x50(%rbx), %rdx
shrl $0x2, %ecx
addl %ecx, %eax
shll $0x4, %eax
movq 0x18(%rax,%rdx), %r15
movq 0x28(%rsp), %rax
cmpl $0x0, 0x24(%rax)
jle 0x12905
addq $0x28, %r14
xorl %r12d, %r12d
movl $0xffff, %ebx           # imm = 0xFFFF
testq %r13, %r13
je 0x12852
movl -0x28(%r14), %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
movw %ax, (%r13,%r12,2)
testq %rbp, %rbp
je 0x12866
movl -0x24(%r14), %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
movw %ax, (%rbp,%r12,2)
testq %r15, %r15
je 0x128e9
movl -0xc(%r14), %edi
movl -0x8(%r14), %esi
leal (%rsi,%rdi), %eax
cmpl $0x2, %eax
jae 0x12885
movl $0x0, (%r15,%r12,4)
jmp 0x128e9
movl (%r14), %ecx
leal (%rcx,%rsi), %eax
cmpl $0x2, %eax
jb 0x1287b
movl -0x4(%r14), %edx
leal (%rdx,%rdi), %eax
cmpl $0x2, %eax
jb 0x1287b
leal (%rcx,%rdx), %eax
cmpl $0x1, %eax
jbe 0x1287b
leaq 0x50(%rsp), %rax
movq %rax, (%rsp)
leaq 0x60(%rsp), %r8
leaq 0x58(%rsp), %r9
callq 0x3d5b0
movsd 0x50(%rsp), %xmm0
callq 0x3330
mulsd 0x2e169(%rip), %xmm0    # 0x40a38
addsd 0x2b749(%rip), %xmm0    # 0x3e020
cvttsd2si %xmm0, %eax
movl $0xff, %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, (%r15,%r12,4)
incq %r12
movq 0x28(%rsp), %rax
movslq 0x24(%rax), %rax
addq $0xc0, %r14
cmpq %rax, %r12
jl 0x1283e
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq