// File: funny-falcon[P]fanom_hash/test_fanom.cpp
// Function: main
int main(int argc, char** argv) {
	unsigned i;
	int hex = 0;
	int use_std = 0;
	int check = 0;
	int binary = 0;
	int only_hash = 2;
	uint32_t sum = 0;
	ssize_t lsize;
	char *lbuf = NULL;
	size_t lcapa = 0;
	FILE* r;
	table tbl = {0, 0, NULL};
	std::unordered_set<std::string> set;

	for (i=1; i<argc; i++) {
		if (strcmp(argv[i], "--help") == 0) {
			goto usage;
		} else if (strcmp(argv[i], "-s") == 0) {
			use_std = 1;
		} else if (strcmp(argv[i], "-c") == 0) {
			check = 1;
		} else if (strcmp(argv[i], "-32") == 0) {
			use_32 = 1;
		} else if (strcmp(argv[i], "-x") == 0) {
			hex = 1;
			fill_dehex();
		} else if (strcmp(argv[i], "-r") == 0) {
			custom_seed = -1;
		} else if (strcmp(argv[i], "-speed") == 0) {
			only_hash = 1;
		} else if (strcmp(argv[i], "-table") == 0) {
			only_hash = 0;
		} else if (strcmp(argv[i], "-seed") == 0) {
			uint64_t s;
			i++;
			if (i == argc)
				goto usage;
			if (custom_seed == sizeof(seed)/sizeof(seed[0]))
				goto usage;
			s = strtoll(argv[i], NULL, 0); /* strtol recognize hex */
			seed[custom_seed++] = s;
		} else if (strcmp(argv[i], "-b") == 0) {
			i++;
			if (i == argc)
				goto usage;
			binary = atoi(argv[i]);
		} else {
			goto usage;
		}
	}

	if (only_hash != 2) {
		setbuffer(stdin, buffer, sizeof(buffer));
	}

	if (custom_seed == 0 && !only_hash || custom_seed == -1) {
		r = fopen("/dev/urandom", "rb");
		if (r == NULL) {
			perror("open /dev/urandom");
			return 1;
		}
		if (fread(&seed, sizeof(seed), 1, r) != 1) {
			perror("Could not read seed from /dev/urandom");
			return 1;
		}
		fclose(r);
	} else if (custom_seed == 1) {
		const uint64_t c = ((uint64_t)0x6385a7c9<<32)|0xeb0d2f41;
		seed[1] = seed[0] ^ c;
	}
	

	if (binary) {
		lbuf = (char*)malloc(binary+1);
		while ((lsize = fread(lbuf, 1, binary, stdin)) > 0) {
			if (only_hash) {
				uint64_t hash;
				if (use_32 == 0) {
					hash = fanom64_string_hash2(lbuf, lsize, seed[0], seed[1]);
				} else {
					hash = fanom32_string_hash2(lbuf, lsize, seed[0], seed[1]);
				}
				if (only_hash == 2) {
					printf("%0*" PRIx64 "\n", use_32?8:16, hash);
				}
				sum += hash;
			} else if (use_std == 0) {
				table_insert(&tbl, lbuf, lsize);
			} else {
				set.insert(std::string(lbuf, lsize));
			}
		}
	} else {
		char* copy;
		while ((lsize = getline(&lbuf, &lcapa, stdin)) != -1) {
			lsize--;
			if (only_hash == 2) {
				copy = strndup(lbuf, lsize);
			}
			if (hex) {
				assert((lsize&1) == 0);
				dehexify(lbuf, lsize);
				lsize /= 2;
			}
			if (only_hash) {
				uint64_t hash;
				if (use_32 == 0) {
					hash = fanom64_string_hash2(lbuf, lsize, seed[0], seed[1]);
				} else {
					hash = fanom32_string_hash2(lbuf, lsize, seed[0], seed[1]);
				}
				if (only_hash == 2) {
					printf("%0*" PRIx64 "\t%s\n", use_32?8:16, hash, copy);
					free(copy);
				}
				sum += hash;
			} else if (use_std == 0) {
				table_insert(&tbl, lbuf, lsize);
			} else {
				set.insert(std::string(lbuf, lsize));
			}
		}
	}

	if (only_hash) {
		if (only_hash == 1)
			printf("Sum = %x\n", sum);
		return 0;
	}

	if (use_std == 0) {
		if (tbl.size == 0) {
			goto usage;
		}

		printf("tbl->size == %u\n", tbl.size);
		if (check) {
			return check_table(&tbl, use_32);
		}
	} else {
		if (set.size() == 0) {
			goto usage;
		}
		printf("tbl->size == %zu\n", set.size());
		if (check) {
			for (auto& s: set) {
				checksum_add(s.data(), s.size());
			}
			printf("checksum %08x %08x\n", checksum[0], checksum[1]);
		}
	}
	return 0;
usage:
	printf("Usage: %s [-seed N] [-x] [-b N] [-32] [-speed|-table] [-s] [-c] < input_file\n%s", argv[0],
	"  Default, \"test vector mode\": reads lines from stdin and report checksum for every line.\n" \
	"  With -speed , only checksumming performed.\n" \
	"  With -table , puts them into chained hash table, on exit it \n" \
	"    calculates and outputs checksum and table size.\n" \
	"\t--help  - this help.\n" \
	"\t-seed N - use custom seed instead of random.\n" \
	"\t          Every invocation fills next seed array element,\n" \
	"\t          so you may give this option 1 or 2 times.\n" \
	"\t-b N    - input is binary, slice it to chunks of fixed size N\n" \
	"\t-x      - input lines are hexified, so de-hexify it\n" \
	"\t-r      - force random seed for \"test vector\"\n" \
	"\t-32     - use 32bit fanom hash function\n" \
	"\t-speed  - test speed only\n" \
	"\t-table  - test hash table (all options below for this mode)\n" \
	"\t-s      - use c++ set to verify hash table implementation\n" \
	"\t-c      - at the end, detect collisions and chain length, and\n" \
	"\t          calculate independent checksum for all inserted strings\n");
	printf("  example for \"test vector\":\n" \
		"\t%s < test_fansom.cpp\n" \
		"\techo 'a1b2bc3def' | %s \n" \
		"\techo 'a1b2bc3def' | %s -seed 2 -seed 3\n" \
		"\techo 'a1b2bc3def' | %s -x -seed 2 -seed 3\n",
		argv[0], argv[0], argv[0], argv[0]
		);
	return 0;
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movl $0x0, 0x1f4(%rsp)
movl %edi, 0x1f0(%rsp)
movq %rsi, 0x1e8(%rsp)
movl $0x0, 0x1e0(%rsp)
movl $0x0, 0x1dc(%rsp)
movl $0x0, 0x1d8(%rsp)
movl $0x0, 0x1d4(%rsp)
movl $0x2, 0x1d0(%rsp)
movl $0x0, 0x1cc(%rsp)
movq $0x0, 0x1b8(%rsp)
movq $0x0, 0x1b0(%rsp)
leaq 0x198(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x20d0
leaq 0x160(%rsp), %rdi
callq 0x4710
movl $0x1, 0x1e4(%rsp)
movl 0x1e4(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jae 0x326c
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x51b6(%rip), %rsi      # 0x815b
callq 0x2230
cmpl $0x0, %eax
jne 0x2fb4
jmp 0x3b10
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x5194(%rip), %rsi      # 0x8162
callq 0x2230
cmpl $0x0, %eax
jne 0x2fe8
movl $0x1, 0x1dc(%rsp)
jmp 0x3252
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x5163(%rip), %rsi      # 0x8165
callq 0x2230
cmpl $0x0, %eax
jne 0x301c
movl $0x1, 0x1d8(%rsp)
jmp 0x3250
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x5132(%rip), %rsi      # 0x8168
callq 0x2230
cmpl $0x0, %eax
jne 0x304f
movl $0x1, 0x9276(%rip)      # 0xc2c0
jmp 0x324e
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x5103(%rip), %rsi      # 0x816c
callq 0x2230
cmpl $0x0, %eax
jne 0x3088
movl $0x1, 0x1e0(%rsp)
callq 0x2850
jmp 0x324c
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x50cd(%rip), %rsi      # 0x816f
callq 0x2230
cmpl $0x0, %eax
jne 0x30bb
movl $0xffffffff, 0x920e(%rip) # imm = 0xFFFFFFFF
jmp 0x324a
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x509d(%rip), %rsi      # 0x8172
callq 0x2230
cmpl $0x0, %eax
jne 0x30ef
movl $0x1, 0x1d0(%rsp)
jmp 0x3248
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x5070(%rip), %rsi      # 0x8179
callq 0x2230
cmpl $0x0, %eax
jne 0x3123
movl $0x0, 0x1d0(%rsp)
jmp 0x3246
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x5043(%rip), %rsi      # 0x8180
callq 0x2230
cmpl $0x0, %eax
jne 0x31d2
movl 0x1e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e4(%rsp)
movl 0x1e4(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jne 0x3171
jmp 0x3b10
movslq 0x914c(%rip), %rax      # 0xc2c4
cmpq $0x2, %rax
jne 0x3183
jmp 0x3b10
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2050
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rdx
movl 0x910d(%rip), %eax      # 0xc2c4
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x9102(%rip)      # 0xc2c4
movslq %eax, %rcx
leaq 0x8fb4(%rip), %rax      # 0xc180
movq %rdx, (%rax,%rcx,8)
jmp 0x3244
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x4f9a(%rip), %rsi      # 0x8186
callq 0x2230
cmpl $0x0, %eax
jne 0x323d
movl 0x1e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e4(%rsp)
movl 0x1e4(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jne 0x321c
jmp 0x3b10
movq 0x1e8(%rsp), %rax
movl 0x1e4(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x2270
movl %eax, 0x1d4(%rsp)
jmp 0x3242
jmp 0x3b10
jmp 0x3244
jmp 0x3246
jmp 0x3248
jmp 0x324a
jmp 0x324c
jmp 0x324e
jmp 0x3250
jmp 0x3252
jmp 0x3254
jmp 0x3256
movl 0x1e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e4(%rsp)
jmp 0x2f77
cmpl $0x2, 0x1d0(%rsp)
je 0x3291
movq 0x8d63(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
leaq 0x9049(%rip), %rsi      # 0xc2d0
movl $0x100000, %edx         # imm = 0x100000
callq 0x2080
cmpl $0x0, 0x902c(%rip)      # 0xc2c4
jne 0x32a4
cmpl $0x0, 0x1d0(%rsp)
je 0x32b1
cmpl $-0x1, 0x9019(%rip)     # 0xc2c4
jne 0x339b
leaq 0x4eff(%rip), %rdi      # 0x81b7
leaq 0x4eca(%rip), %rsi      # 0x8189
callq 0x21d0
movq %rax, 0x90(%rsp)
jmp 0x32ce
movq 0x90(%rsp), %rax
movq %rax, 0x1a8(%rsp)
cmpq $0x0, 0x1a8(%rsp)
jne 0x332b
leaq 0x4e9c(%rip), %rdi      # 0x818c
callq 0x2160
jmp 0x32f7
movl $0x1, 0x1f4(%rsp)
movl $0x1, 0x148(%rsp)
jmp 0x3b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x3b88
movq 0x1a8(%rsp), %rcx
leaq 0x8e46(%rip), %rdi      # 0xc180
movl $0x10, %esi
movl $0x1, %edx
callq 0x2250
movq %rax, 0x88(%rsp)
jmp 0x3353
movq 0x88(%rsp), %rax
cmpq $0x1, %rax
je 0x338a
leaq 0x4e36(%rip), %rdi      # 0x819e
callq 0x2160
jmp 0x336f
movl $0x1, 0x1f4(%rsp)
movl $0x1, 0x148(%rsp)
jmp 0x3b6c
movq 0x1a8(%rsp), %rdi
callq 0x2180
jmp 0x3399
jmp 0x33d0
cmpl $0x1, 0x8f22(%rip)      # 0xc2c4
jne 0x33ce
movabsq $0x6385a7c9eb0d2f41, %rax # imm = 0x6385A7C9EB0D2F41
movq %rax, 0x140(%rsp)
movabsq $0x6385a7c9eb0d2f41, %rax # imm = 0x6385A7C9EB0D2F41
xorq 0x8db9(%rip), %rax      # 0xc180
movq %rax, 0x8dba(%rip)      # 0xc188
jmp 0x33d0
cmpl $0x0, 0x1d4(%rsp)
je 0x363f
movl 0x1d4(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x2220
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1d4(%rsp), %rdx
movq 0x8bd1(%rip), %rax      # 0xbfe0
movq (%rax), %rcx
movl $0x1, %esi
callq 0x2250
movq %rax, 0x80(%rsp)
jmp 0x3426
movq 0x80(%rsp), %rax
movq %rax, 0x1c0(%rsp)
cmpq $0x0, %rax
jle 0x363a
cmpl $0x0, 0x1d0(%rsp)
je 0x351e
cmpl $0x0, 0x8e6b(%rip)      # 0xc2c0
jne 0x3490
movq 0x1b8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movq 0x8d12(%rip), %rdx      # 0xc180
movq 0x8d13(%rip), %rcx      # 0xc188
callq 0x3bb0
movq %rax, 0x78(%rsp)
jmp 0x3481
movq 0x78(%rsp), %rax
movq %rax, 0x138(%rsp)
jmp 0x34c5
movq 0x1b8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movl 0x8cda(%rip), %edx      # 0xc180
movl 0x8cdc(%rip), %ecx      # 0xc188
callq 0x3bf0
movl %eax, 0x74(%rsp)
jmp 0x34b7
movl 0x74(%rsp), %eax
movl %eax, %eax
movq %rax, 0x138(%rsp)
cmpl $0x2, 0x1d0(%rsp)
jne 0x3500
movl 0x8deb(%rip), %eax      # 0xc2c0
testl %eax, %eax
sete %al
movzbl %al, %ecx
movl %ecx, %eax
leal 0x8(,%rax,8), %esi
movq 0x138(%rsp), %rdx
leaq 0x4ccf(%rip), %rdi      # 0x81c4
xorl %eax, %eax
callq 0x2030
jmp 0x34fe
jmp 0x3500
movq 0x138(%rsp), %rcx
movl 0x1cc(%rsp), %eax
addq %rcx, %rax
movl %eax, 0x1cc(%rsp)
jmp 0x3635
cmpl $0x0, 0x1dc(%rsp)
jne 0x354c
movq 0x1b8(%rsp), %rsi
movq 0x1c0(%rsp), %rdx
leaq 0x198(%rsp), %rdi
callq 0x2580
jmp 0x3547
jmp 0x3633
movq 0x1b8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x117(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x22c0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rcx
leaq 0x118(%rsp), %rdi
callq 0x21c0
jmp 0x3596
leaq 0x160(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x4720
movb %dl, 0x4f(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x35b6
movb 0x4f(%rsp), %al
movq 0x50(%rsp), %rcx
movq %rcx, 0x100(%rsp)
movb %al, 0x108(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x20f0
leaq 0x117(%rsp), %rdi
callq 0x21b0
jmp 0x3633
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x3621
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x20f0
leaq 0x117(%rsp), %rdi
callq 0x21b0
jmp 0x3b88
jmp 0x3635
jmp 0x33f8
jmp 0x3934
jmp 0x3641
movq 0x8998(%rip), %rax      # 0xbfe0
movq (%rax), %rdx
leaq 0x1b8(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x21f0
movq %rax, 0x40(%rsp)
jmp 0x3667
movq 0x40(%rsp), %rax
movq %rax, 0x1c0(%rsp)
cmpq $-0x1, %rax
je 0x3932
movq 0x1c0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x1c0(%rsp)
cmpl $0x2, 0x1d0(%rsp)
jne 0x36b9
movq 0x1b8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
callq 0x2040
movq %rax, 0xf8(%rsp)
cmpl $0x0, 0x1e0(%rsp)
je 0x3725
movq 0x1c0(%rsp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x36d7
jmp 0x36f6
leaq 0x4aed(%rip), %rdi      # 0x81cb
leaq 0x4af5(%rip), %rsi      # 0x81da
movl $0x84, %edx
leaq 0x4af8(%rip), %rcx      # 0x81e9
callq 0x2100
movq 0x1b8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
callq 0x2930
movq 0x1c0(%rsp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, 0x1c0(%rsp)
cmpl $0x0, 0x1d0(%rsp)
je 0x3816
cmpl $0x0, 0x8b86(%rip)      # 0xc2c0
jne 0x3775
movq 0x1b8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movq 0x8a2d(%rip), %rdx      # 0xc180
movq 0x8a2e(%rip), %rcx      # 0xc188
callq 0x3bb0
movq %rax, 0x38(%rsp)
jmp 0x3766
movq 0x38(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x37aa
movq 0x1b8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movl 0x89f5(%rip), %edx      # 0xc180
movl 0x89f7(%rip), %ecx      # 0xc188
callq 0x3bf0
movl %eax, 0x34(%rsp)
jmp 0x379c
movl 0x34(%rsp), %eax
movl %eax, %eax
movq %rax, 0xf0(%rsp)
cmpl $0x2, 0x1d0(%rsp)
jne 0x37f8
movl 0x8b06(%rip), %eax      # 0xc2c0
testl %eax, %eax
sete %al
movzbl %al, %ecx
movl %ecx, %eax
leal 0x8(,%rax,8), %esi
movq 0xf0(%rsp), %rdx
movq 0xf8(%rsp), %rcx
leaq 0x4a1e(%rip), %rdi      # 0x8200
xorl %eax, %eax
callq 0x2030
jmp 0x37eb
movq 0xf8(%rsp), %rdi
callq 0x21e0
movq 0xf0(%rsp), %rcx
movl 0x1cc(%rsp), %eax
addq %rcx, %rax
movl %eax, 0x1cc(%rsp)
jmp 0x392d
cmpl $0x0, 0x1dc(%rsp)
jne 0x3844
movq 0x1b8(%rsp), %rsi
movq 0x1c0(%rsp), %rdx
leaq 0x198(%rsp), %rdi
callq 0x2580
jmp 0x383f
jmp 0x392b
movq 0x1b8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x22c0
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
leaq 0xd0(%rsp), %rdi
callq 0x21c0
jmp 0x388e
leaq 0x160(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x4720
movb %dl, 0xf(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x38ae
movb 0xf(%rsp), %al
movq 0x10(%rsp), %rcx
movq %rcx, 0xb8(%rsp)
movb %al, 0xc0(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x20f0
leaq 0xcf(%rsp), %rdi
callq 0x21b0
jmp 0x392b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x3919
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x20f0
leaq 0xcf(%rsp), %rdi
callq 0x21b0
jmp 0x3b88
jmp 0x392d
jmp 0x3641
jmp 0x3934
cmpl $0x0, 0x1d0(%rsp)
je 0x397c
cmpl $0x1, 0x1d0(%rsp)
jne 0x3961
movl 0x1cc(%rsp), %esi
leaq 0x48b4(%rip), %rdi      # 0x820a
xorl %eax, %eax
callq 0x2030
jmp 0x395f
jmp 0x3961
movl $0x0, 0x1f4(%rsp)
movl $0x1, 0x148(%rsp)
jmp 0x3b6c
cmpl $0x0, 0x1dc(%rsp)
jne 0x39ef
cmpl $0x0, 0x198(%rsp)
jne 0x3995
jmp 0x3b10
movl 0x198(%rsp), %esi
leaq 0x4871(%rip), %rdi      # 0x8214
xorl %eax, %eax
callq 0x2030
jmp 0x39ac
cmpl $0x0, 0x1d8(%rsp)
je 0x39ea
movl 0x8904(%rip), %esi      # 0xc2c0
leaq 0x198(%rsp), %rdi
callq 0x2a20
movl %eax, 0x8(%rsp)
jmp 0x39cf
movl 0x8(%rsp), %eax
movl %eax, 0x1f4(%rsp)
movl $0x1, 0x148(%rsp)
jmp 0x3b6c
jmp 0x3af8
leaq 0x160(%rsp), %rdi
callq 0x4770
cmpq $0x0, %rax
jne 0x3a07
jmp 0x3b10
leaq 0x160(%rsp), %rdi
callq 0x4770
movq %rax, %rsi
leaq 0x4807(%rip), %rdi      # 0x8225
xorl %eax, %eax
callq 0x2030
jmp 0x3a27
cmpl $0x0, 0x1d8(%rsp)
je 0x3af6
leaq 0x160(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x4780
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x47b0
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x47e0
testb $0x1, %al
jne 0x3a8a
jmp 0x3ad8
leaq 0xa8(%rsp), %rdi
callq 0x4800
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
callq 0x2200
movq %rax, (%rsp)
movq 0x98(%rsp), %rdi
callq 0x2120
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x2750
leaq 0xa8(%rsp), %rdi
callq 0x4820
jmp 0x3a6f
movl 0x86d2(%rip), %esi      # 0xc1b0
movl 0x86d0(%rip), %edx      # 0xc1b4
leaq 0x45cc(%rip), %rdi      # 0x80b7
xorl %eax, %eax
callq 0x2030
jmp 0x3af4
jmp 0x3af6
jmp 0x3af8
movl $0x0, 0x1f4(%rsp)
movl $0x1, 0x148(%rsp)
jmp 0x3b6c
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x4715(%rip), %rdi      # 0x8237
leaq 0x475e(%rip), %rdx      # 0x8287
xorl %eax, %eax
callq 0x2030
jmp 0x3b32
movq 0x1e8(%rsp), %rax
movq (%rax), %r8
leaq 0x4ad3(%rip), %rdi      # 0x8617
xorl %eax, %eax
movq %r8, %rsi
movq %r8, %rdx
movq %r8, %rcx
callq 0x2030
jmp 0x3b56
movl $0x0, 0x1f4(%rsp)
movl $0x1, 0x148(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x4850
movl 0x1f4(%rsp), %eax
addq $0x1f8, %rsp            # imm = 0x1F8
retq
leaq 0x160(%rsp), %rdi
callq 0x4850
movq 0x150(%rsp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)