// File: /workspace/github_c_makefile_star2_O3/ranbenbasat[P]RHHH/check2.cpp
// Function: main
int main(int argc, char * argv[]) {
	if (argc != 6 && argc != 7 && argc != 3 && argc != 4) {
		printf("Usage: %s <n> <c> <t> <data> <output> [<exact>]\n", argv[0]);
		printf("Usage: %s <data> <output> [<exact>]\n", argv[0]);
		printf("\t<n>=number of IP pairs\n");
		printf("\t<c>=counters (1/eps)\n");
		printf("\t<data>=data file (IP pairs)\n");
		printf("\t<output>=output of HHH algorithm to check\n");
		printf("\t<exact>=file to output exact HHH\n");
		return 0;
	}
	int n, counters, threshold, num;
	float time=-1; char * algname = dummy;
	FILE * data, * output, * exactfile;
	if (argc > 4) {
		n = atoi(argv[1]);
		counters = atoi(argv[2]);
		threshold = atoi(argv[3]);
		data = fopen(argv[4], "r");
		output = fopen(argv[5], "r");
		exactfile = (argc == 7 ? fopen(argv[6], "w") : NULL);
		fscanf(output, "%d", &num);
	} else {
		data = fopen(argv[1], "r");
		output = fopen(argv[2], "r");
		exactfile = (argc == 4 ? fopen(argv[3], "w") : NULL);
		fscanf(output, "%as %d %d %d %d %f\n", &algname, &n, &counters, &threshold, &num, &time);
	}

	if (getenv("DONTCHECKABOVE") != NULL && atoi(getenv("DONTCHECKABOVE")) < n) {
		fclose(data);
		fclose(output);
		if (exactfile != NULL) fclose(exactfile);
		return 0;
	}

	FILE * fsummary = (getenv("SUMMARYFILE") != NULL ? fopen(getenv("SUMMARYFILE"), "a") : NULL);

	map<Item, Counter> m[NUM_MASKS];
	for (int i = 0; i < n; i++) {
		Item x;
		Item item = 0;
		for (int j = 0; j < 8; j++) {
			fscanf(data, "%llu", &x);
			item = ((item << 8) | x);
		}
		for (int j = 0; j < NUM_MASKS; j++) {
			m[j][item & masks[j]].inc();
		}
	}	

	vector<Pair> exact;
	vector<int> exactcount;
	for (int i = 0; i < NUM_MASKS; i++) {
		for (map<Item, Counter>::const_iterator it = m[i].begin(); it != m[i].end(); ++it) {
			if (it->second.get() >= threshold && conditionedcount(m, exact, it->first, i) >= threshold) {
				exact.push_back(Pair(i, it->first));
				exactcount.push_back(it->second.get());
			}
		}
	}
	if (exactfile != NULL) {
		fprintf(exactfile, "%d\n", (int)exact.size()); 
		vector< Pair >::const_iterator it1 = exact.begin();
		vector< int >::const_iterator it2 = exactcount.begin();
		while (it1 != exact.end())  {
			fprintf(exactfile, "%d ", it1->first);
			printip(it1->second >> 32, exactfile);
			fprintf(exactfile, " ");
			printip(it1->second, exactfile);
			fprintf(exactfile, " %d %d\n", *it2, *it2);
			++it1;
			++it2;
		}
	}
	if (fsummary != NULL && argc > 4) {
		fprintf(fsummary, "algorithm=%s nitems=%d counters=%d threshold=%d outputsize=%d\n",
		                   argv[0],     n,        counters,   threshold,   (int)exact.size()); 
	}

	int accErrors=0;
	int covErrors=0;
	double eps=-1;
	double epsil=-1;
	
	vector<Pair> p;
	set<Pair> s;
	for (int i = 0; i < num; i++) {
		int mask;
		fscanf(output, "%d", &mask);
		Item item = 0;
		Item w, x, y, z;
		fscanf(output, "%llu.%llu.%llu.%llu", &w, &x, &y, &z);
		item = ((item << 8)|w);
		item = ((item << 8)|x);
		item = ((item << 8)|y);
		item = ((item << 8)|z);
		fscanf(output, "%llu.%llu.%llu.%llu", &w, &x, &y, &z);
		item = ((item << 8)|w);
		item = ((item << 8)|x);
		item = ((item << 8)|y);
		item = ((item << 8)|z);
		int fmin, fmax;
		fscanf(output, "%d%d", &fmin, &fmax);

		int truecount = m[mask][item].get();
		if (truecount < fmin - n/counters || truecount > fmax + n/counters) {
			accErrors++;
			if (getenv("NONVERBOSE") == NULL){
				printf("Accuracy: [%d] ", mask);
				printip(item >> 32);
				printf(" ");
				printip(item);
				printf(" [%d] %d %d\n", truecount, fmin, fmax);
			}
		}

		double epscand = ((double) (fmax-fmin)) / truecount;
		if (epscand > eps) eps = epscand;
		epsil = max(epsil, ((double)(fmax-fmin))/n);

		p.push_back(Pair(mask, item));
		s.insert(Pair(mask, item));
	}

	for (int i = 0; i < NUM_MASKS; i++) {
		for (map<Item, Counter>::const_iterator it = m[i].begin(); it != m[i].end(); ++it) {
			if (it->second.get() >= threshold && conditionedcount(m, p, it->first, i) >= threshold && 0==s.count(Pair(it->first, i))) {
				covErrors++;
				if (getenv("NONVERBOSE") == NULL){
					printf("Coverage: [%d] ", i);
					printip(it->first);
					printf(" [%d/%d]\n", it->second.get(), conditionedcount(m, p, it->first, i));
				}
			}
		}
	}

	if (accErrors+covErrors > 0 && fsummary != NULL) {
		fprintf(fsummary, "Error: algorithm=%s nitems=%d counters=%d threshold=%d accErrors=%d covErrors=%d\n",
			                  argv[0],     n,        counters,   threshold, accErrors, covErrors); 
	}

	if (fsummary != NULL && argc <= 4) {
		fprintf(fsummary, "check=true  algorithm=%-14s nitems=%-10d counters=%-5d threshold=%-9d outputsize=%-3d exactsize=%-3d time=%f accuracy=%lf epsilon=%lf\n",
		                   algname,        n,           counters,     threshold,     num,        (int)exact.size(), time,   eps, epsil); 
	}

	if (exactfile != NULL) fclose(exactfile);
	if (fsummary != NULL) fclose(fsummary);
	fclose(data);
	fclose(output);
	if (argc <= 4) free(algname);

	printf("%d accErrors %d covErrors %d exact hhhs\n", accErrors, covErrors, (int)exact.size());

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xcd78, %rsp           # imm = 0xCD78
movq %rsi, %r15
cmpl $0x7, %edi
ja 0x229f
movl %edi, %ebp
movl $0xd8, %eax
btl %edi, %eax
jae 0x229f
movl $0xbf800000, 0x5c(%rsp) # imm = 0xBF800000
leaq 0x5baa(%rip), %rax      # 0x7301
movq %rax, 0x78(%rsp)
movq 0x8(%r15), %rdi
cmpl $0x5, %ebp
jb 0x17c9
callq 0x1180
movl %eax, 0xc(%rsp)
movq 0x10(%r15), %rdi
callq 0x1180
movl %eax, 0x14(%rsp)
movq 0x18(%r15), %rdi
callq 0x1180
movl %eax, 0x10(%rsp)
movq 0x20(%r15), %rdi
leaq 0x1966(%rip), %rbx      # 0x30f9
movq %rbx, %rsi
callq 0x1110
movq %rax, %r14
movq 0x28(%r15), %rdi
movq %rbx, %rsi
callq 0x1110
movq %rax, 0x38(%rsp)
cmpl $0x7, %ebp
jne 0x1806
movq 0x30(%r15), %rdi
leaq 0x193c(%rip), %rsi      # 0x30fb
callq 0x1110
movq %rax, %rbx
jmp 0x1808
leaq 0x1929(%rip), %rbx      # 0x30f9
movq %rbx, %rsi
callq 0x1110
movq %rax, %r14
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x1110
movq %rax, 0x38(%rsp)
cmpl $0x4, %ebp
jne 0x1822
movq 0x18(%r15), %rdi
leaq 0x18ff(%rip), %rsi      # 0x30fb
callq 0x1110
movq %rax, %rbx
jmp 0x1824
xorl %ebx, %ebx
leaq 0x182a(%rip), %rsi      # 0x3039
leaq 0x2c(%rsp), %rdx
movq 0x38(%rsp), %rdi
xorl %eax, %eax
callq 0x11b0
jmp 0x185d
xorl %ebx, %ebx
leaq 0x5c(%rsp), %r10
leaq 0x2c(%rsp), %r11
leaq 0x18c8(%rip), %rsi      # 0x30fd
leaq 0x78(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
movq 0x38(%rsp), %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x11b0
addq $0x10, %rsp
leaq 0x18ad(%rip), %rdi      # 0x3111
callq 0x1130
testq %rax, %rax
je 0x18a4
movq %rax, %rdi
callq 0x1180
cmpl 0xc(%rsp), %eax
jge 0x18a4
movq %r14, %rdi
callq 0x10d0
movq 0x38(%rsp), %rdi
callq 0x10d0
testq %rbx, %rbx
je 0x22fd
movq %rbx, %rdi
callq 0x10d0
jmp 0x22fd
leaq 0x1875(%rip), %rdi      # 0x3120
callq 0x1130
testq %rax, %rax
je 0x18c6
leaq 0x1870(%rip), %rsi      # 0x312c
movq %rax, %rdi
callq 0x1110
jmp 0x18c8
xorl %eax, %eax
movq %rax, 0xa8(%rsp)
movq %rbx, 0xb0(%rsp)
movq %r14, 0xb8(%rsp)
movl %ebp, 0x58(%rsp)
leaq 0x148(%rsp), %rax
xorl %ecx, %ecx
xorl %edx, %edx
leaq (%rax,%rdx), %rsi
movl $0x0, 0x148(%rsp,%rdx)
movq %rcx, 0x150(%rsp,%rdx)
movq %rsi, 0x158(%rsp,%rdx)
movq %rsi, 0x160(%rsp,%rdx)
movq %rcx, 0x168(%rsp,%rdx)
addq $0x30, %rdx
cmpq $0xcc30, %rdx           # imm = 0xCC30
jne 0x18f0
movq %r15, 0xa0(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x19d4
leaq 0x100(%rsp), %rbp
leaq 0x40(%rsp), %r12
xorl %eax, %eax
movl %eax, 0x18(%rsp)
movl $0x8, %ebx
xorl %r14d, %r14d
movq 0xb8(%rsp), %r13
leaq 0x1813(%rip), %r15      # 0x317c
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x11b0
shlq $0x8, %r14
orq 0x100(%rsp), %r14
decl %ebx
jne 0x1969
leaq 0x140(%rsp), %r13
xorl %ebx, %ebx
leaq 0x3756(%rip), %r15      # 0x50f0
movq (%rbx,%r15), %rax
andq %r14, %rax
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x24de
incl (%rax)
addq $0x8, %rbx
addq $0x30, %r13
cmpq $0x2208, %rbx           # imm = 0x2208
jne 0x199a
movl 0x18(%rsp), %eax
incl %eax
cmpl 0xc(%rsp), %eax
jl 0x194e
xorpd %xmm0, %xmm0
leaq 0x40(%rsp), %rbx
movapd %xmm0, (%rbx)
xorl %r15d, %r15d
movq %r15, 0x10(%rbx)
leaq 0xe0(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x140(%rsp), %r13
leaq 0x100(%rsp), %rbp
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %r14
addq $0x148, %r14            # imm = 0x148
movq 0x10(%r14), %r12
cmpq %r14, %r12
je 0x1ae3
movl 0x28(%r12), %eax
cmpl 0x10(%rsp), %eax
jl 0x1acf
movq 0x20(%r12), %rdx
movq %r13, %rdi
movq %rbx, %rsi
movl %r15d, %ecx
callq 0x1320
cmpl 0x10(%rsp), %eax
jl 0x1acf
movl %r15d, 0x100(%rsp)
movq 0x20(%r12), %rax
movq %rax, 0x108(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x1a86
movupd 0x100(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x48(%rsp)
jmp 0x1a91
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x25b0
movl 0x28(%r12), %eax
movl %eax, 0x100(%rsp)
movq 0xe8(%rsp), %rsi
cmpq 0xf0(%rsp), %rsi
je 0x1abf
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe8(%rsp)
jmp 0x1acf
leaq 0xe0(%rsp), %rdi
movq %rbp, %rdx
callq 0x28b6
movq %r12, %rdi
callq 0x1100
movq %rax, %r12
cmpq %r14, %rax
jne 0x1a28
incq %r15
cmpq $0x441, %r15            # imm = 0x441
jne 0x1a08
movq 0xb0(%rsp), %r13
testq %r13, %r13
je 0x1c03
movq 0x48(%rsp), %rdx
subq 0x40(%rsp), %rdx
shrq $0x4, %rdx
leaq 0x1691(%rip), %rsi      # 0x31aa
movq %r13, %rdi
xorl %eax, %eax
callq 0x1160
movq 0x40(%rsp), %r14
cmpq 0x48(%rsp), %r14
je 0x1c03
movq 0xe0(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0xff, %ebp
leaq 0x14e4(%rip), %r15      # 0x3030
xorl %ebx, %ebx
leaq (%r14,%rbx,4), %r12
addq $0x10, %r12
movl -0x10(%r12), %edx
movq %r13, %rdi
leaq 0x14d7(%rip), %rsi      # 0x303c
xorl %eax, %eax
callq 0x1160
movq -0x8(%r12), %r8
movq %r8, %r9
shrq $0x20, %r9
movq %r8, %rdx
shrq $0x38, %rdx
movq %r8, %rcx
shrq $0x30, %rcx
andl %ebp, %ecx
shrq $0x28, %r8
andl %ebp, %r8d
andl %ebp, %r9d
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1160
movl $0x20, %edi
movq %r13, %rsi
callq 0x1140
movl -0x8(%r12), %r9d
movl %r9d, %edx
shrl $0x18, %edx
movl %r9d, %ecx
shrl $0x10, %ecx
andl %ebp, %ecx
movl %r9d, %r8d
shrl $0x8, %r8d
andl %ebp, %r8d
andl %ebp, %r9d
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1160
movq 0x18(%rsp), %rax
movl (%rax,%rbx), %ecx
movq %r13, %rdi
leaq 0x15bb(%rip), %rsi      # 0x31a6
movl %ecx, %edx
xorl %eax, %eax
callq 0x1160
addq $0x4, %rbx
cmpq 0x48(%rsp), %r12
jne 0x1b4e
cmpl $0x5, 0x58(%rsp)
setb %al
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x1c5c
movq 0xa0(%rsp), %rax
movq (%rax), %rdx
movl 0xc(%rsp), %ecx
movl 0x14(%rsp), %r8d
movl 0x10(%rsp), %r9d
movq 0x48(%rsp), %r10
subq 0x40(%rsp), %r10
shrq $0x4, %r10
subq $0x8, %rsp
leaq 0x14df(%rip), %rsi      # 0x312e
xorl %eax, %eax
pushq %r10
callq 0x1160
addq $0x10, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
xorl %eax, %eax
movq %rax, 0x90(%rsp)
leaq 0x108(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
cmpl $0x0, 0x2c(%rsp)
jle 0x1fa8
movapd 0x137c(%rip), %xmm0     # 0x3020
xorl %eax, %eax
movq $0x0, 0x60(%rsp)
movl %eax, 0x18(%rsp)
movapd %xmm0, 0x130(%rsp)
movq 0x38(%rsp), %r14
movq %r14, %rdi
leaq 0x136e(%rip), %rsi      # 0x3039
leaq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x11b0
movq $0x0, 0x20(%rsp)
movq %r14, %rdi
leaq 0x1483(%rip), %r15      # 0x316d
movq %r15, %rsi
leaq 0xd8(%rsp), %r12
movq %r12, %rdx
leaq 0xd0(%rsp), %rbp
movq %rbp, %rcx
leaq 0xc8(%rsp), %rbx
movq %rbx, %r8
leaq 0xc0(%rsp), %r13
movq %r13, %r9
xorl %eax, %eax
callq 0x11b0
movq 0x20(%rsp), %rax
movq 0xd8(%rsp), %rcx
shlq $0x10, %rax
shlq $0x8, %rcx
orq %rax, %rcx
orq 0xd0(%rsp), %rcx
movq 0xc8(%rsp), %rax
shlq $0x10, %rcx
shlq $0x8, %rax
orq %rcx, %rax
orq 0xc0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x11b0
movq 0x20(%rsp), %rax
movq 0xd8(%rsp), %rcx
shlq $0x10, %rax
shlq $0x8, %rcx
orq %rax, %rcx
orq 0xd0(%rsp), %rcx
movq 0xc8(%rsp), %rax
shlq $0x10, %rcx
shlq $0x8, %rax
orq %rcx, %rax
orq 0xc0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r14, %rdi
leaq 0x13be(%rip), %rsi      # 0x3181
leaq 0x34(%rsp), %rdx
leaq 0x30(%rsp), %rcx
xorl %eax, %eax
callq 0x11b0
movslq 0x28(%rsp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %rdi
addq $0x140, %rdi            # imm = 0x140
leaq 0x20(%rsp), %rsi
callq 0x24de
movl (%rax), %ebp
movl 0x34(%rsp), %r14d
movl 0xc(%rsp), %r15d
movl %r15d, %eax
cltd
idivl 0x14(%rsp)
movl %r14d, %ecx
subl %eax, %ecx
cmpl %ecx, %ebp
jl 0x1e1f
addl 0x30(%rsp), %eax
cmpl %eax, %ebp
jle 0x1ef4
movq 0x60(%rsp), %rax
incl %eax
movq %rax, 0x60(%rsp)
leaq 0x1354(%rip), %rdi      # 0x3186
callq 0x1130
testq %rax, %rax
jne 0x1ef4
movl 0x28(%rsp), %esi
leaq 0x1346(%rip), %rdi      # 0x3191
xorl %eax, %eax
callq 0x1030
movq 0x20(%rsp), %r8
movq %r8, %r9
shrq $0x20, %r9
movq 0x316b(%rip), %rbx      # 0x4fd0
movq (%rbx), %rdi
movq %r8, %rdx
shrq $0x38, %rdx
movq %r8, %rcx
shrq $0x30, %rcx
movl $0xff, %r14d
andl %r14d, %ecx
shrq $0x28, %r8
andl %r14d, %r8d
andl %r14d, %r9d
leaq 0x11a0(%rip), %r15      # 0x3030
movq %r15, %rsi
xorl %eax, %eax
callq 0x1160
movl $0x20, %edi
callq 0x1150
movl 0x20(%rsp), %r9d
movq (%rbx), %rdi
movl %r9d, %edx
shrl $0x18, %edx
movl %r9d, %ecx
shrl $0x10, %ecx
andl %r14d, %ecx
movl %r9d, %r8d
shrl $0x8, %r8d
andl %r14d, %r8d
andl %r14d, %r9d
movq %r15, %rsi
xorl %eax, %eax
callq 0x1160
movl 0x34(%rsp), %edx
movl 0x30(%rsp), %ecx
leaq 0x12c0(%rip), %rdi      # 0x31a1
movl %ebp, %esi
xorl %eax, %eax
callq 0x1030
movl 0x34(%rsp), %r14d
movl 0xc(%rsp), %r15d
movl 0x30(%rsp), %r12d
movl 0x28(%rsp), %eax
movl %eax, 0x68(%rsp)
movq 0x20(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x1f32
movupd 0x68(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x88(%rsp)
jmp 0x1f4d
leaq 0x80(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x25b0
movl 0x28(%rsp), %eax
movq 0x20(%rsp), %rcx
movl %eax, 0x68(%rsp)
movq %rcx, 0x70(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x29ee
movl 0x18(%rsp), %eax
subl %r14d, %r12d
cvtsi2sd %r12d, %xmm2
movd %ebp, %xmm0
movd %r15d, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm0
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
divpd %xmm0, %xmm2
maxpd 0x130(%rsp), %xmm2
incl %eax
movapd %xmm2, %xmm0
cmpl 0x2c(%rsp), %eax
jl 0x1caf
jmp 0x1fb9
movapd 0x1070(%rip), %xmm2     # 0x3020
movq $0x0, 0x60(%rsp)
movapd %xmm2, 0x130(%rsp)
leaq 0x140(%rsp), %r12
leaq 0x80(%rsp), %rbp
xorl %ebx, %ebx
movq $0x0, 0x18(%rsp)
leaq (%rbx,%rbx,2), %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %r14
addq $0x148, %r14            # imm = 0x148
movq 0x10(%r14), %r13
cmpq %r14, %r13
je 0x20fb
movl 0x28(%r13), %eax
cmpl 0x10(%rsp), %eax
jl 0x20e7
movq 0x20(%r13), %rdx
movq %r12, %rdi
movq %rbp, %rsi
movl %ebx, %ecx
callq 0x1320
cmpl 0x10(%rsp), %eax
jl 0x20e7
movl 0x20(%r13), %eax
movl %eax, 0x68(%rsp)
movq %rbx, 0x70(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2b30
leaq 0x108(%rsp), %rcx
cmpq %rcx, %rax
jne 0x20e7
movq 0x18(%rsp), %rax
incl %eax
movq %rax, 0x18(%rsp)
leaq 0x111d(%rip), %rdi      # 0x3186
callq 0x1130
testq %rax, %rax
jne 0x20e7
leaq 0x1134(%rip), %rdi      # 0x31ae
movl %ebx, %esi
xorl %eax, %eax
callq 0x1030
movl 0x20(%r13), %r9d
movq 0x2f42(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
movl %r9d, %edx
shrl $0x18, %edx
movl %r9d, %ecx
shrl $0x10, %ecx
movl $0xff, %eax
andl %eax, %ecx
movl %r9d, %r8d
shrl $0x8, %r8d
andl %eax, %r8d
andl %eax, %r9d
leaq 0xf78(%rip), %rsi       # 0x3030
xorl %eax, %eax
callq 0x1160
movl 0x28(%r13), %r15d
movq 0x20(%r13), %rdx
movq %r12, %rdi
movq %rbp, %rsi
movl %ebx, %ecx
callq 0x1320
leaq 0x10e3(%rip), %rdi      # 0x31be
movl %r15d, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x1030
movq %r13, %rdi
callq 0x1100
movq %rax, %r13
cmpq %r14, %rax
jne 0x1ffd
incq %rbx
cmpq $0x441, %rbx            # imm = 0x441
jne 0x1fdd
movq 0xa8(%rsp), %r12
testq %r12, %r12
movq 0x60(%rsp), %r13
movq 0x18(%rsp), %rbp
je 0x215c
leal (%rbp,%r13), %eax
testl %eax, %eax
jle 0x215c
movq 0xa0(%rsp), %rax
movq (%rax), %rdx
movl 0xc(%rsp), %ecx
movl 0x14(%rsp), %r8d
movl 0x10(%rsp), %r9d
leaq 0x107d(%rip), %rsi      # 0x31c8
movq %r12, %rdi
xorl %eax, %eax
pushq %rbp
pushq %r13
callq 0x1160
addq $0x10, %rsp
testq %r12, %r12
sete %al
movl 0x58(%rsp), %ebx
cmpl $0x5, %ebx
setge %cl
orb %al, %cl
movq 0xb8(%rsp), %r14
movq 0xb0(%rsp), %r15
jne 0x21d9
movq 0x78(%rsp), %rdx
movl 0xc(%rsp), %ecx
movl 0x14(%rsp), %r8d
movl 0x10(%rsp), %r9d
movl 0x2c(%rsp), %r10d
movq 0x48(%rsp), %r11
subq 0x40(%rsp), %r11
shrq $0x4, %r11
xorps %xmm0, %xmm0
cvtss2sd 0x5c(%rsp), %xmm0
movdqa 0x130(%rsp), %xmm2
movdqa %xmm2, %xmm1
punpckhqdq %xmm2, %xmm1    # xmm1 = xmm1[1],xmm2[1]
leaq 0x1053(%rip), %rsi      # 0x321a
movq %r12, %rdi
movb $0x3, %al
pushq %r11
pushq %r10
callq 0x1160
addq $0x10, %rsp
testq %r15, %r15
je 0x21e6
movq %r15, %rdi
callq 0x10d0
testq %r12, %r12
je 0x21f3
movq %r12, %rdi
callq 0x10d0
movq %r14, %rdi
callq 0x10d0
movq 0x38(%rsp), %rdi
callq 0x10d0
cmpl $0x4, %ebx
jg 0x2214
movq 0x78(%rsp), %rdi
callq 0x1120
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
shrq $0x4, %rcx
leaq 0x1078(%rip), %rdi      # 0x32a1
movl %r13d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1030
leaq 0x100(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x257a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x2258
callq 0x10c0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x226a
callq 0x10c0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2279
callq 0x10c0
xorl %r14d, %r14d
leaq (%rsp,%r14), %rdi
addq $0xcd40, %rdi           # imm = 0xCD40
movq 0x10(%rdi), %rsi
callq 0x2544
addq $-0x30, %r14
cmpq $-0xcc30, %r14          # imm = 0xFFFF33D0
jne 0x227c
jmp 0x22fd
movq (%r15), %rsi
leaq 0xdfa(%rip), %rdi       # 0x30a3
xorl %eax, %eax
callq 0x1030
movq (%r15), %rsi
leaq 0xe1a(%rip), %rdi       # 0x30d4
xorl %eax, %eax
callq 0x1030
leaq 0x101c(%rip), %rdi      # 0x32e4
callq 0x1170
leaq 0x1028(%rip), %rdi      # 0x32fc
callq 0x1170
leaq 0x1032(%rip), %rdi      # 0x3312
callq 0x1170
leaq 0x1043(%rip), %rdi      # 0x332f
callq 0x1170
leaq 0x1062(%rip), %rdi      # 0x335a
callq 0x1170
xorl %eax, %eax
addq $0xcd78, %rsp           # imm = 0xCD78
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x237b
jmp 0x2367
jmp 0x2367
jmp 0x2367
movq %rax, %rbx
movq %r14, %r15
subq $-0xcc00, %r15          # imm = 0xFFFF3400
je 0x23da
negq %r15
addq %rsp, %r14
addq $0xcd10, %r14           # imm = 0xCD10
movq 0x10(%r14), %rsi
movq %r14, %rdi
callq 0x2544
addq $-0x30, %r14
addq $0x30, %r15
jne 0x233c
jmp 0x23da
jmp 0x23e2
jmp 0x2362
jmp 0x2362
jmp 0x2367
movq %rax, %rbx
jmp 0x238d
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x257a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x238d
callq 0x10c0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x239f
callq 0x10c0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x23b5
callq 0x10c0
jmp 0x23b5
jmp 0x23e2
movq %rax, %rbx
movq $-0xcc30, %r15          # imm = 0xFFFF33D0
leaq 0xcd40(%rsp), %r14
movq 0x10(%r14), %rsi
movq %r14, %rdi
callq 0x2544
addq $-0x30, %r14
addq $0x30, %r15
jne 0x23c4
movq %rbx, %rdi
callq 0x11a0
movq %rax, %rdi
callq 0x24d2