// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/phase.c
// Function: main_phase
int main_phase(int argc, char *argv[])
{
	extern void bam_init_header_hash(bam_header_t *header);
	int c, tid, pos, vpos = 0, n, lasttid = -1, max_vpos = 0;
	const bam_pileup1_t *plp;
	bam_plp_t iter;
	bam_header_t *h;
	nseq_t *seqs;
	uint64_t *cns = 0;
	phaseg_t g;
	char *fn_list = 0;
	khash_t(set64) *set = 0;
	errmod_t *em;
	uint16_t *bases;

	memset(&g, 0, sizeof(phaseg_t));
	g.flag = FLAG_FIX_CHIMERA;
	g.min_varLOD = 37; g.k = 13; g.min_baseQ = 13; g.max_depth = 256;
	while ((c = getopt(argc, argv, "Q:eFq:k:b:l:D:A:")) >= 0) {
		switch (c) {
			case 'D': g.max_depth = atoi(optarg); break;
			case 'q': g.min_varLOD = atoi(optarg); break;
			case 'Q': g.min_baseQ = atoi(optarg); break;
			case 'k': g.k = atoi(optarg); break;
			case 'F': g.flag &= ~FLAG_FIX_CHIMERA; break;
			case 'e': g.flag |= FLAG_LIST_EXCL; break;
			case 'A': g.flag |= FLAG_DROP_AMBI; break;
			case 'b': g.pre = strdup(optarg); break;
			case 'l': fn_list = strdup(optarg); break;
		}
	}
	if (argc == optind) {
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage:   samtools phase [options] <in.bam>\n\n");
		fprintf(stderr, "Options: -k INT    block length [%d]\n", g.k);
		fprintf(stderr, "         -b STR    prefix of BAMs to output [null]\n");
		fprintf(stderr, "         -q INT    min het phred-LOD [%d]\n", g.min_varLOD);
		fprintf(stderr, "         -Q INT    min base quality in het calling [%d]\n", g.min_baseQ);
		fprintf(stderr, "         -D INT    max read depth [%d]\n", g.max_depth);
//		fprintf(stderr, "         -l FILE   list of sites to phase [null]\n");
		fprintf(stderr, "         -F        do not attempt to fix chimeras\n");
		fprintf(stderr, "         -A        drop reads with ambiguous phase\n");
//		fprintf(stderr, "         -e        do not discover SNPs (effective with -l)\n");
		fprintf(stderr, "\n");
		return 1;
	}
	g.fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r");
	h = bam_header_read(g.fp);
	if (fn_list) { // read the list of sites to phase
		bam_init_header_hash(h);
		set = loadpos(fn_list, h);
		free(fn_list);
	} else g.flag &= ~FLAG_LIST_EXCL;
	if (g.pre) { // open BAMs to write
		char *s = malloc(strlen(g.pre) + 20);
		strcpy(s, g.pre); strcat(s, ".0.bam"); g.out[0] = bam_open(s, "w");
		strcpy(s, g.pre); strcat(s, ".1.bam"); g.out[1] = bam_open(s, "w");
		strcpy(s, g.pre); strcat(s, ".chimera.bam"); g.out[2] = bam_open(s, "w");
		for (c = 0; c <= 2; ++c) bam_header_write(g.out[c], h);
		free(s);
	}

	iter = bam_plp_init(readaln, &g);
	g.vpos_shift = 0;
	seqs = kh_init(64);
	em = errmod_init(1. - 0.83);
	bases = calloc(g.max_depth, 2);
	printf("CC\n");
	printf("CC\tDescriptions:\nCC\n");
	printf("CC\t  CC      comments\n");
	printf("CC\t  PS      start of a phase set\n");
	printf("CC\t  FL      filtered region\n");
	printf("CC\t  M[012]  markers; 0 for singletons, 1 for phased and 2 for filtered\n");
	printf("CC\t  EV      supporting reads; SAM format\n");
	printf("CC\t  //      end of a phase set\nCC\n");
	printf("CC\tFormats of PS, FL and M[012] lines (1-based coordinates):\nCC\n");
	printf("CC\t  PS  chr  phaseSetStart  phaseSetEnd\n");
	printf("CC\t  FL  chr  filterStart    filterEnd\n");
	printf("CC\t  M?  chr  PS  pos  allele0  allele1  hetIndex  #supports0  #errors0  #supp1  #err1\n");
	printf("CC\nCC\n");
	fflush(stdout);
	while ((plp = bam_plp_auto(iter, &tid, &pos, &n)) != 0) {
		int i, k, c, tmp, dophase = 1, in_set = 0;
		float q[16];
		if (tid < 0) break;
		if (tid != lasttid) { // change of chromosome
			g.vpos_shift = 0;
			if (lasttid >= 0) {
				seqs = shrink_hash(seqs);
				phase(&g, h->target_name[lasttid], vpos, cns, seqs);
				update_vpos(0x7fffffff, seqs);
			}
			lasttid = tid;
			vpos = 0;
		}
		if (set && kh_get(set64, set, (uint64_t)tid<<32 | pos) != kh_end(set)) in_set = 1;
		if (n > g.max_depth) continue; // do not proceed if the depth is too high
		// fill the bases array and check if there is a variant
		for (i = k = 0; i < n; ++i) {
			const bam_pileup1_t *p = plp + i;
			uint8_t *seq;
			int q, baseQ, b;
			if (p->is_del || p->is_refskip) continue;
			baseQ = bam1_qual(p->b)[p->qpos];
			if (baseQ < g.min_baseQ) continue;
			seq = bam1_seq(p->b);
			b = bam_nt16_nt4_table[bam1_seqi(seq, p->qpos)];
			if (b > 3) continue;
			q = baseQ < p->b->core.qual? baseQ : p->b->core.qual;
			if (q < 4) q = 4;
			if (q > 63) q = 63;
			bases[k++] = q<<5 | (int)bam1_strand(p->b)<<4 | b;
		}
		if (k == 0) continue;
		errmod_cal(em, k, 4, bases, q); // compute genotype likelihood
		c = gl2cns(q); // get the consensus
		// tell if to proceed
		if (set && (g.flag&FLAG_LIST_EXCL) && !in_set) continue; // not in the list
		if (!in_set && (c&0xffff)>>2 < g.min_varLOD) continue; // not a variant
		// add the variant
		if (vpos == max_vpos) {
			max_vpos = max_vpos? max_vpos<<1 : 128;
			cns = realloc(cns, max_vpos * 8);
		}
		cns[vpos] = (uint64_t)pos<<32 | c;
		for (i = 0; i < n; ++i) {
			const bam_pileup1_t *p = plp + i;
			uint64_t key;
			khint_t k;
			uint8_t *seq = bam1_seq(p->b);
			frag_t *f;
			if (p->is_del || p->is_refskip) continue;
			if (p->b->core.qual == 0) continue;
			// get the base code
			c = nt16_nt4_table[(int)bam1_seqi(seq, p->qpos)];
			if (c == (cns[vpos]&3)) c = 1;
			else if (c == (cns[vpos]>>16&3)) c = 2;
			else c = 0;
			// write to seqs
			key = X31_hash_string(bam1_qname(p->b));
			k = kh_put(64, seqs, key, &tmp);
			f = &kh_val(seqs, k);
			if (tmp == 0) { // present in the hash table
				if (vpos - f->vpos + 1 < MAX_VARS) {
					f->vlen = vpos - f->vpos + 1;
					f->seq[f->vlen-1] = c;
					f->end = bam_calend(&p->b->core, bam1_cigar(p->b));
				}
				dophase = 0;
			} else { // absent
				memset(f->seq, 0, MAX_VARS);
				f->beg = p->b->core.pos;
				f->end = bam_calend(&p->b->core, bam1_cigar(p->b));
				f->vpos = vpos, f->vlen = 1, f->seq[0] = c, f->single = f->phased = f->flip = f->ambig = 0;
			}
		}
		if (dophase) {
			seqs = shrink_hash(seqs);
			phase(&g, h->target_name[tid], vpos, cns, seqs);
			update_vpos(vpos, seqs);
			cns[0] = cns[vpos];
			vpos = 0;
		}
		++vpos;
	}
	if (tid >= 0) phase(&g, h->target_name[tid], vpos, cns, seqs);
	bam_header_destroy(h);
	bam_plp_destroy(iter);
	bam_close(g.fp);
	kh_destroy(64, seqs);
	kh_destroy(set64, set);
	free(cns);
	errmod_destroy(em);
	free(bases);
	if (g.pre) {
		for (c = 0; c <= 2; ++c) bam_close(g.out[c]);
		free(g.pre); free(g.b);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movl %edi, %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movl $0x1, 0x50(%rsp)
movl $0x25, 0x5c(%rsp)
movabsq $0xd0000000d, %rax      # imm = 0xD0000000D
movq %rax, 0x54(%rsp)
movl $0x100, 0x60(%rsp)      # imm = 0x100
leaq 0x28a02(%rip), %rdx     # 0x40ec8
callq 0x3210
xorl %r12d, %r12d
testl %eax, %eax
js 0x185a4
movq 0x36b03(%rip), %r15     # 0x4efe0
leaq 0x289e4(%rip), %r14     # 0x40ec8
cmpl $0x61, %eax
jle 0x18513
cmpl $0x6a, %eax
jle 0x18548
cmpl $0x6b, %eax
je 0x18567
cmpl $0x6c, %eax
je 0x18584
cmpl $0x71, %eax
jne 0x1858f
movq (%r15), %rdi
callq 0x34c0
movl %eax, 0x5c(%rsp)
jmp 0x1858f
cmpl $0x45, %eax
jg 0x18530
cmpl $0x41, %eax
je 0x18559
cmpl $0x44, %eax
jne 0x1858f
movq (%r15), %rdi
callq 0x34c0
movl %eax, 0x60(%rsp)
jmp 0x1858f
cmpl $0x46, %eax
je 0x18560
cmpl $0x51, %eax
jne 0x1858f
movq (%r15), %rdi
callq 0x34c0
movl %eax, 0x58(%rsp)
jmp 0x1858f
cmpl $0x62, %eax
je 0x18575
cmpl $0x65, %eax
jne 0x1858f
orb $0x4, 0x50(%rsp)
jmp 0x1858f
orb $0x8, 0x50(%rsp)
jmp 0x1858f
andb $-0x2, 0x50(%rsp)
jmp 0x1858f
movq (%r15), %rdi
callq 0x34c0
movl %eax, 0x54(%rsp)
jmp 0x1858f
movq (%r15), %rdi
callq 0x3570
movq %rax, 0x70(%rsp)
jmp 0x1858f
movq (%r15), %rdi
callq 0x3570
movq %rax, %r12
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3210
testl %eax, %eax
jns 0x184e4
movq 0x36a0d(%rip), %rax     # 0x4efb8
movslq (%rax), %rax
cmpl %ebp, %eax
je 0x193f9
movq (%rbx,%rax,8), %rbx
leaq 0x26897(%rip), %rsi     # 0x3ee58
movq %rbx, %rdi
callq 0x35a0
testl %eax, %eax
je 0x185de
leaq 0x2c69b(%rip), %rsi     # 0x44c6f
movq %rbx, %rdi
callq 0x1fdb8
jmp 0x185fb
movq 0x369eb(%rip), %rax     # 0x4efd0
movq (%rax), %rdi
callq 0x3030
leaq 0x2c67b(%rip), %rsi     # 0x44c6f
movl %eax, %edi
callq 0x1ff6b
movq %rax, 0x68(%rsp)
movq %rax, %rdi
callq 0x22efa
movq %rax, %r13
testq %r12, %r12
movq %rax, 0x30(%rsp)
je 0x1866f
movq %r13, %rdi
callq 0x2210c
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x3610
movq %r12, %rbx
movq %rax, %r12
leaq 0x2680b(%rip), %rsi     # 0x3ee58
movq %rbx, %rdi
callq 0x35a0
testl %eax, %eax
movq %rbx, 0x48(%rsp)
je 0x1867c
leaq 0x2c60a(%rip), %rsi     # 0x44c6f
movq %rbx, %rdi
callq 0x3420
jmp 0x18699
andb $-0x5, 0x50(%rsp)
xorl %r12d, %r12d
jmp 0x18986
movq 0x3694d(%rip), %rax     # 0x4efd0
movq (%rax), %rdi
callq 0x3030
leaq 0x2c5dd(%rip), %rsi     # 0x44c6f
movl %eax, %edi
callq 0x33e0
movq %rax, %rbx
movl $0x1, %edi
movl $0x20, %esi
callq 0x3610
movq %rax, %rbp
movq %rbx, 0x38(%rsp)
movq %rbx, 0x18(%rax)
movl $0x4000, %edi           # imm = 0x4000
callq 0x3240
movq %rax, (%rbp)
leaq 0xc0(%rsp), %rbx
movl $0x1, %r13d
movq %rbp, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1a1c7
testl %eax, %eax
js 0x18945
movq 0x10(%r12), %rsi
movq 0x30(%rsp), %rdi
callq 0x2235b
testl %eax, %eax
js 0x188b7
cmpl $0xa, 0xc0(%rsp)
je 0x188b7
movl %eax, %r15d
movq %rbp, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1a1c7
testl %eax, %eax
js 0x18945
movq %r12, %rax
movq %rbx, %r12
movq %rax, %r13
movq 0x10(%rax), %rdi
callq 0x34c0
movl %eax, %r14d
movq 0x20(%rsp), %rbx
movl 0x8(%rbx), %eax
cmpl 0xc(%rbx), %eax
jb 0x18766
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
addl %ecx, %ecx
cmpl %eax, %ecx
movl $0x0, %esi
sbbl %esi, %esi
orl $0x1, %esi
addl %eax, %esi
movq %rbx, %rdi
callq 0x1a38f
shlq $0x20, %r15
decl %r14d
movslq %r14d, %rax
orq %rax, %r15
movl (%rbx), %r9d
movq %r15, %rcx
shrq $0x21, %rcx
movl %eax, %edi
shll $0xb, %edi
xorl %eax, %edi
xorl %ecx, %edi
movl %edi, %eax
xorl %edx, %edx
divl %r9d
movl %edx, %esi
movq 0x10(%rbx), %r8
movl %edx, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x187b0
movq %r12, %rbx
movq %r13, %r12
jmp 0x18840
leal -0x1(%r9), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %esi, %edi
movl %r9d, %eax
movq %r12, %rbx
movq %r13, %r12
xorl %r13d, %r13d
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %r10d
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r10d, %r11d
shrl %cl, %r11d
testb $0x2, %r11b
jne 0x1881a
testb $0x1, %r11b
jne 0x187fd
movq 0x20(%rsp), %r11
movq 0x18(%r11), %r11
movl %edi, %r14d
cmpq %r15, (%r11,%r14,8)
je 0x1881a
btl %ecx, %r10d
cmovbl %edi, %eax
addl %edx, %edi
cmpl %r9d, %edi
movl %r9d, %ecx
cmovbl %r13d, %ecx
subl %ecx, %edi
movl %eax, %ecx
cmpl %esi, %edi
jne 0x187ca
jmp 0x1881d
movl %r9d, %ecx
movl %ecx, %esi
cmpl %r9d, %ecx
jne 0x18840
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %edx
leal (%rdi,%rdi), %ecx
shrl %cl, %edx
cmpl %r9d, %eax
cmovel %edi, %eax
testb $0x2, %dl
cmovel %edi, %eax
movl %eax, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %edx
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %edx, %edi
shrl %cl, %edi
testb $0x2, %dil
movl $0x1, %r13d
jne 0x1888d
testb $0x1, %dil
je 0x188b7
movq 0x20(%rsp), %r10
movq 0x18(%r10), %rdi
movl $0x3, %r9d
shll %cl, %r9d
movl %esi, %ecx
movq %r15, (%rdi,%rcx,8)
notl %r9d
andl %r9d, %edx
movl %edx, (%r8,%rax,4)
incl 0x4(%r10)
jmp 0x188b7
movq 0x20(%rsp), %r10
movq 0x18(%r10), %rdi
movl $0x3, %r9d
shll %cl, %r9d
movl %esi, %ecx
movq %r15, (%rdi,%rcx,8)
notl %r9d
andl %r9d, %edx
movl %edx, (%r8,%rax,4)
incl 0x4(%r10)
incl 0x8(%r10)
cmpl $0xa, 0xc0(%rsp)
je 0x18937
movl 0x10(%rbp), %r14d
testl %r14d, %r14d
je 0x188d7
movl 0x8(%rbp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0xc(%rbp), %ecx
jge 0x1891a
movl 0x8(%rbp), %eax
cmpl 0xc(%rbp), %eax
jl 0x18908
movl $0x0, 0x8(%rbp)
movq (%rbp), %rsi
movq 0x18(%rbp), %rdi
movl $0x4000, %edx           # imm = 0x4000
callq 0x36d0
movl %eax, 0xc(%rbp)
cmpl $0x4000, %eax           # imm = 0x4000
cmovll %r13d, %r14d
testl %eax, %eax
je 0x1892c
movq (%rbp), %rax
movslq 0x8(%rbp), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x8(%rbp)
movzbl (%rax,%rcx), %eax
movl %eax, 0xc0(%rsp)
testl %eax, %eax
jle 0x18933
cmpl $0xa, %eax
jne 0x188c5
jmp 0x18933
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1891a
movl %r14d, 0x10(%rbp)
cmpl $0x0, 0xc0(%rsp)
jns 0x186d3
movq (%rbp), %rdi
callq 0x3350
movq %rbp, %rdi
callq 0x3350
movq 0x38(%rsp), %rdi
callq 0x31c0
movq 0x10(%r12), %rdi
callq 0x3350
movq %r12, %rdi
callq 0x3350
movq 0x48(%rsp), %rdi
callq 0x3350
movq 0x20(%rsp), %r12
movq 0x30(%rsp), %r13
movq 0x70(%rsp), %r14
testq %r14, %r14
je 0x18a7e
movq %r14, %rdi
callq 0x3360
leaq 0x14(%rax), %rdi
callq 0x3240
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x35d0
movq %r15, %rdi
callq 0x3360
movl $0x6d6162, %ebx         # imm = 0x6D6162
movl %ebx, 0x3(%r15,%rax)
movl $0x622e302e, (%r15,%rax) # imm = 0x622E302E
leaq 0x25866(%rip), %r14     # 0x3e23a
movq %r15, %rdi
movq %r14, %rsi
callq 0x1fdb8
movq %rax, 0x78(%rsp)
movq 0x70(%rsp), %rsi
movq %r15, %rdi
callq 0x35d0
movq %r15, %rdi
callq 0x3360
movl %ebx, 0x3(%r15,%rax)
movl $0x622e312e, (%r15,%rax) # imm = 0x622E312E
movq %r15, %rdi
movq %r14, %rsi
callq 0x1fdb8
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %rsi
movq %r15, %rdi
callq 0x35d0
movq %r15, %rdi
callq 0x3360
movabsq $0x6172656d6968632e, %rcx # imm = 0x6172656D6968632E
movq %rcx, (%r15,%rax)
movabsq $0x6d61622e617265, %rcx # imm = 0x6D61622E617265
movq %rcx, 0x5(%r15,%rax)
movq %r15, %rdi
movq %r14, %rsi
callq 0x1fdb8
movq %rax, 0x88(%rsp)
xorl %ebx, %ebx
movq 0x78(%rsp,%rbx,8), %rdi
movq %r13, %rsi
callq 0x230c9
incq %rbx
cmpq $0x3, %rbx
jne 0x18a60
movq %r15, %rdi
callq 0x3350
leaq 0x994(%rip), %rdi       # 0x19419
leaq 0x50(%rsp), %rbx
movq %rbx, %rsi
callq 0x2a940
movq %rax, 0xb8(%rsp)
movl $0x0, 0x14(%rbx)
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %r13
movss 0x28405(%rip), %xmm0    # 0x40ec0
callq 0x15d95
movq %rax, 0xb0(%rsp)
movslq 0x10(%rbx), %rdi
movl $0x2, %esi
callq 0x3610
movq %rax, 0xa0(%rsp)
leaq 0x28770(%rip), %rdi     # 0x41255
callq 0x3150
leaq 0x28629(%rip), %rdi     # 0x4111a
callq 0x3150
leaq 0x28631(%rip), %rdi     # 0x4112e
callq 0x3150
leaq 0x2863b(%rip), %rdi     # 0x41144
callq 0x3150
leaq 0x28651(%rip), %rdi     # 0x41166
callq 0x3150
leaq 0x28662(%rip), %rdi     # 0x41183
callq 0x3150
leaq 0x2869e(%rip), %rdi     # 0x411cb
callq 0x3150
leaq 0x286bc(%rip), %rdi     # 0x411f5
callq 0x3150
leaq 0x286d3(%rip), %rdi     # 0x41218
callq 0x3150
leaq 0x28707(%rip), %rdi     # 0x41258
callq 0x3150
leaq 0x28724(%rip), %rdi     # 0x41281
callq 0x3150
leaq 0x2873f(%rip), %rdi     # 0x412a8
callq 0x3150
leaq 0x2878a(%rip), %rdi     # 0x412ff
callq 0x3150
movq 0x36477(%rip), %rax     # 0x4eff8
movq (%rax), %rdi
callq 0x3800
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
movq $0x0, 0x18(%rsp)
movq $0x0, 0xa8(%rsp)
movl $0x0, 0x8(%rsp)
movq 0xb8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x44(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
callq 0x2b372
testq %rax, %rax
je 0x192ee
movl 0x10(%rsp), %edx
testl %edx, %edx
js 0x192e6
movq %rax, %rbp
cmpl %ebx, %edx
jne 0x18bec
movl %ebx, 0xc(%rsp)
jmp 0x18c3e
movl $0x0, 0x64(%rsp)
testl %ebx, %ebx
js 0x18c2e
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rsi
leaq 0x50(%rsp), %rdi
movl %edx, %ebx
movl 0x8(%rsp), %edx
movq 0x18(%rsp), %rcx
movq %r13, %r8
callq 0x194f9
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq %r13, %rsi
callq 0x1a152
movl %ebx, %edx
movl $0x0, 0x8(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0xc(%rsp)
xorl %ebx, %ebx
testq %r12, %r12
je 0x18cd8
movl (%r12), %edi
testl %edi, %edi
je 0x18cea
movl %edx, %r14d
movl 0x10(%rsp), %r8d
shlq $0x20, %r8
movslq 0x44(%rsp), %rax
orq %rax, %r8
movq %r8, %rdx
shrq $0x21, %rdx
movl %eax, %ecx
shll $0xb, %ecx
xorl %eax, %ecx
xorl %edx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %edx, %esi
leal -0x1(%rdi), %r9d
movl %ecx, %eax
xorl %edx, %edx
divl %r9d
incl %edx
movq 0x10(%r12), %rax
movl %esi, %ebx
movl %ebx, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %r9d
leal (%rbx,%rbx), %ecx
andl $0x1e, %ecx
movl %r9d, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x18cdd
testb $0x1, %r10b
jne 0x18cc4
movq 0x18(%r12), %r10
movl %ebx, %r11d
cmpq %r8, (%r10,%r11,8)
je 0x18cdd
addl %edx, %ebx
cmpl %edi, %ebx
movl %edi, %ecx
cmovbl %r15d, %ecx
subl %ecx, %ebx
cmpl %esi, %ebx
jne 0x18c95
movl %edi, %ebx
jmp 0x18ce7
movb $0x1, %r14b
jmp 0x18cf3
shrl %cl, %r9d
testb $0x3, %r9b
cmovnel %edi, %ebx
movl %r14d, %edx
cmpl %edi, %ebx
sete %r14b
setne %bl
movl 0x2c(%rsp), %ecx
cmpl 0x60(%rsp), %ecx
jg 0x18ef5
movl %edx, 0x14(%rsp)
testl %ecx, %ecx
jle 0x18df9
movl 0x58(%rsp), %eax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rdx
xorl %edi, %edi
xorl %esi, %esi
testb $0x9, 0x14(%rbp,%rdi)
jne 0x18dea
movq (%rbp,%rdi), %rcx
movq 0x8(%rcx), %r8
movq %r8, %r9
shrq $0x30, %r9
shlq $0x2, %r9
addq 0x30(%rcx), %r9
movl %r8d, %r10d
shrl $0x18, %r10d
addq %r9, %r10
movl 0x10(%rcx), %ecx
incl %ecx
sarl %ecx
movslq %ecx, %r9
addq %r10, %r9
movslq 0x8(%rbp,%rdi), %rcx
movzbl (%rcx,%r9), %r9d
cmpl %r9d, %eax
jg 0x18dea
movl %ecx, %r11d
sarl %r11d
movslq %r11d, %r11
movzbl (%r10,%r11), %r10d
shll $0x2, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %r10d
andl $0xf, %r10d
leaq 0x37362(%rip), %rcx     # 0x500f0
movsbl (%rcx,%r10), %ecx
cmpl $0x3, %ecx
jg 0x18dea
movl %r8d, %r10d
shrl $0x10, %r10d
movzbl %r10b, %r10d
cmpl %r9d, %r10d
cmovbl %r10d, %r9d
cmpl $0x5, %r9d
movl $0x4, %r10d
cmovbl %r10d, %r9d
cmpl $0x3f, %r9d
movl $0x3f, %r10d
cmovael %r10d, %r9d
shll $0x5, %r9d
shrq $0x20, %r8
andl $0x10, %r8d
orl %r9d, %r8d
orl %ecx, %r8d
movslq %esi, %rcx
incl %esi
movq 0xa0(%rsp), %r9
movw %r8w, (%r9,%rcx,2)
addq $0x18, %rdi
cmpq %rdi, %rdx
jne 0x18d1d
jmp 0x18dfb
xorl %esi, %esi
testl %esi, %esi
je 0x18efe
movq 0xb0(%rsp), %rdi
movl $0x4, %edx
movq 0xa0(%rsp), %rcx
leaq 0xc0(%rsp), %r15
movq %r15, %r8
callq 0x160f4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edx, %edx
xorl %esi, %esi
movss 0x2808b(%rip), %xmm1    # 0x40ec4
movaps %xmm1, %xmm0
xorl %edi, %edi
movaps %xmm1, %xmm2
movss (%r15,%rdi,4), %xmm3
ucomiss %xmm3, %xmm1
jbe 0x18e58
leaq (%rdx,%rdi), %rax
movaps %xmm3, %xmm1
movaps %xmm2, %xmm0
jmp 0x18e63
movaps %xmm2, %xmm1
ucomiss %xmm3, %xmm0
jbe 0x18e63
movaps %xmm3, %xmm0
leaq (%rsi,%rdi), %r8
incq %r8
incq %rdi
cmpq $0x4, %r8
jne 0x18e3e
incq %rsi
addq $0x5, %rdx
addq $0x14, %r15
cmpq $0x4, %rsi
jne 0x18e3c
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x3, %ecx
andl $0x3, %eax
xorl %r15d, %r15d
cmpl %eax, %ecx
je 0x18ebf
shll $0x10, %ecx
subss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addsd 0x25177(%rip), %xmm0    # 0x3e020
cvttsd2si %xmm0, %r15d
shll $0x2, %r15d
orl %ecx, %r15d
orl %eax, %r15d
orl $0x40000, %r15d         # imm = 0x40000
testq %r12, %r12
movq 0x18(%rsp), %r8
movl 0x14(%rsp), %edx
je 0x18edc
movb 0x50(%rsp), %al
andb $0x4, %al
shrb $0x2, %al
notb %bl
testb %al, %bl
jne 0x18ef2
testb %r14b, %r14b
je 0x18f0b
movl %r15d, %eax
shrl $0x2, %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cmpl 0x5c(%rsp), %eax
jge 0x18f0b
xorl %r15d, %r15d
movl 0xc(%rsp), %ebx
jmp 0x192e6
movl 0xc(%rsp), %ebx
movl 0x14(%rsp), %edx
jmp 0x192e6
movq 0xa8(%rsp), %rbx
cmpl %ebx, 0x8(%rsp)
jne 0x18f3d
movq %rbx, %rax
addl %ebx, %ebx
testl %eax, %eax
movl $0x80, %eax
cmovel %eax, %ebx
leal (,%rbx,8), %eax
movslq %eax, %rsi
movq %r8, %rdi
callq 0x3720
movq %rax, %r8
movq %rbx, 0xa8(%rsp)
movl 0x44(%rsp), %eax
shlq $0x20, %rax
movslq %r15d, %rcx
orq %rax, %rcx
movslq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rcx, (%r8,%rax,8)
cmpl $0x0, 0x2c(%rsp)
movq %r8, 0x18(%rsp)
movl $0x0, %r15d
jle 0x1928b
movq %r12, 0x20(%rsp)
movl $0x1, 0x40(%rsp)
xorl %r12d, %r12d
leaq (%r12,%r12,2), %rax
movq (%rbp,%rax,8), %rcx
movq 0x8(%rcx), %rdx
testb $0x9, 0x14(%rbp,%rax,8)
setne %sil
testl $0xff0000, %edx         # imm = 0xFF0000
sete %dil
orb %sil, %dil
jne 0x1926e
leaq (,%rax,8), %rsi
addq %rbp, %rsi
movq 0x30(%rcx), %rax
movq %rdx, %rcx
shrq $0x30, %rcx
leaq (%rax,%rcx,4), %rcx
shrl $0x18, %edx
addq %rcx, %rdx
movq %rsi, 0x48(%rsp)
movl 0x8(%rsi), %ecx
movl %ecx, %esi
sarl %esi
movslq %esi, %rsi
movzbl (%rsi,%rdx), %edx
shll $0x2, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %edx
andl $0xf, %edx
leaq 0x27eb9(%rip), %rcx     # 0x40eb0
movsbq (%rdx,%rcx), %rcx
movq 0x38(%rsp), %rdx
movq (%r8,%rdx,8), %rdx
movl %edx, %esi
andl $0x3, %esi
shrl $0x10, %edx
andl $0x3, %edx
cmpq %rcx, %rdx
sete %dl
addb %dl, %dl
cmpq %rcx, %rsi
movzbl %dl, %ebx
movl $0x1, %ecx
cmovel %ecx, %ebx
movsbq (%rax), %r14
testq %r14, %r14
je 0x19056
movb 0x1(%rax), %cl
testb %cl, %cl
je 0x19059
addq $0x2, %rax
movq %r14, %rdx
shlq $0x5, %rdx
subq %r14, %rdx
movsbq %cl, %r14
addq %rdx, %r14
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x1903a
jmp 0x19059
xorl %r14d, %r14d
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jb 0x19083
movl (%r13), %eax
movl 0x4(%r13), %ecx
addl %ecx, %ecx
cmpl %eax, %ecx
movl $0x0, %esi
sbbl %esi, %esi
orl $0x1, %esi
addl %eax, %esi
movq %r13, %rdi
callq 0x1ad01
movl (%r13), %r9d
movq %r14, %rdi
shrq $0x21, %rdi
movl %r14d, %eax
shll $0xb, %eax
xorl %eax, %edi
xorl %r14d, %edi
movl %edi, %eax
xorl %edx, %edx
divl %r9d
movl %edx, %esi
movq 0x10(%r13), %r8
movl %edx, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x19144
leal -0x1(%r9), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %esi, %edi
movl %r9d, %eax
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %r10d
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r10d, %r11d
shrl %cl, %r11d
testb $0x2, %r11b
jne 0x1911e
testb $0x1, %r11b
jne 0x19101
movq 0x18(%r13), %r11
movl %edi, %r15d
cmpq %r14, (%r11,%r15,8)
movl $0x0, %r15d
je 0x1911e
btl %ecx, %r10d
cmovbl %edi, %eax
addl %edx, %edi
cmpl %r9d, %edi
movl %r9d, %ecx
cmovbl %r15d, %ecx
subl %ecx, %edi
movl %eax, %ecx
cmpl %esi, %edi
jne 0x190cd
jmp 0x19121
movl %r9d, %ecx
movl %ecx, %esi
cmpl %r9d, %ecx
jne 0x19144
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %edx
leal (%rdi,%rdi), %ecx
shrl %cl, %edx
cmpl %r9d, %eax
cmovel %edi, %eax
testb $0x2, %dl
cmovel %edi, %eax
movl %eax, %esi
movl %esi, %edx
shrl $0x4, %edx
movl (%r8,%rdx,4), %edi
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %edi, %r9d
shrl %cl, %r9d
movl %esi, %eax
testb $0x2, %r9b
jne 0x1918b
movb $0x1, %sil
testb $0x1, %r9b
je 0x191ac
movq 0x18(%r13), %rsi
movl $0x3, %r9d
shll %cl, %r9d
movq %r14, (%rsi,%rax,8)
notl %r9d
andl %r9d, %edi
movl %edi, (%r8,%rdx,4)
incl 0x4(%r13)
jmp 0x191aa
movl $0x3, %esi
shll %cl, %esi
movq 0x18(%r13), %rcx
movq %r14, (%rcx,%rax,8)
notl %esi
andl %esi, %edi
movl %edi, (%r8,%rdx,4)
incl 0x4(%r13)
incl 0x8(%r13)
xorl %esi, %esi
imulq $0x114, %rax, %r14      # imm = 0x114
addq 0x20(%r13), %r14
testb %sil, %sil
je 0x1920e
movslq 0x100(%r14), %rcx
movq 0x38(%rsp), %rax
subq %rcx, %rax
movl $0x0, 0x40(%rsp)
cmpl $0xfe, %eax
jg 0x19269
incl %eax
movzwl %ax, %eax
movw %ax, 0x10c(%r14)
movb %bl, -0x1(%rax,%r14)
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movzbl 0xb(%rdi), %esi
addq 0x30(%rdi), %rsi
callq 0x22d1c
movl %eax, 0x108(%r14)
jmp 0x19269
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x3080
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movl 0x4(%rdi), %eax
movl %eax, 0x104(%r14)
movzbl 0xb(%rdi), %esi
addq 0x30(%rdi), %rsi
callq 0x22d1c
movl %eax, 0x108(%r14)
movl 0x8(%rsp), %eax
movl %eax, 0x100(%r14)
movq 0x10c(%r14), %rax
orq $0x1, %rax
movb %bl, (%r14)
andq $-0x1bffff, %rax        # imm = 0xFFE40001
movq %rax, 0x10c(%r14)
movq 0x18(%rsp), %r8
incq %r12
movslq 0x2c(%rsp), %rax
cmpq %rax, %r12
jl 0x18f87
cmpl $0x0, 0x40(%rsp)
movq 0x20(%rsp), %r12
je 0x192d4
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x50(%rsp), %rdi
movl 0x8(%rsp), %ebp
movl %ebp, %edx
movq %r8, %rcx
movq %r8, %rbx
movq %r13, %r8
callq 0x194f9
movl %ebp, %edi
movq %r13, %rsi
callq 0x1a152
movq 0x38(%rsp), %rax
movq (%rbx,%rax,8), %rax
movq %rax, (%rbx)
xorl %eax, %eax
movl 0xc(%rsp), %ebx
jmp 0x192dc
movl 0xc(%rsp), %ebx
movl 0x8(%rsp), %eax
movl 0x14(%rsp), %edx
incl %eax
movl %eax, 0x8(%rsp)
testl %edx, %edx
jns 0x18bae
movslq 0x10(%rsp), %rax
testq %rax, %rax
movq 0x30(%rsp), %rbx
js 0x1931b
movq 0x8(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x50(%rsp), %rdi
movl 0x8(%rsp), %edx
movq 0x18(%rsp), %rcx
movq %r13, %r8
callq 0x194f9
movq %rbx, %rdi
callq 0x22e78
movq 0xb8(%rsp), %rdi
callq 0x2aa34
movq 0x68(%rsp), %rdi
callq 0x20aae
testq %r13, %r13
je 0x19362
movq 0x18(%r13), %rdi
callq 0x3350
movq 0x10(%r13), %rdi
callq 0x3350
movq 0x20(%r13), %rdi
callq 0x3350
movq %r13, %rdi
callq 0x3350
testq %r12, %r12
je 0x1938d
movq 0x18(%r12), %rdi
callq 0x3350
movq 0x10(%r12), %rdi
callq 0x3350
movq 0x20(%r12), %rdi
callq 0x3350
movq %r12, %rdi
callq 0x3350
movq 0x18(%rsp), %rdi
callq 0x3350
movq 0xb0(%rsp), %rdi
callq 0x160b2
movq 0xa0(%rsp), %rdi
callq 0x3350
cmpq $0x0, 0x70(%rsp)
je 0x193e5
xorl %ebx, %ebx
movq 0x78(%rsp,%rbx,8), %rdi
callq 0x20aae
incq %rbx
cmpq $0x3, %rbx
jne 0x193bb
movq 0x70(%rsp), %rdi
callq 0x3350
movq 0x98(%rsp), %rdi
callq 0x3350
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60(%rsp), %rcx
leaq 0x5c(%rsp), %rsi
leaq 0x54(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x4254
movl $0x1, %eax
jmp 0x193e7