// File: /workspace/github_c_makefile_star2_O1/tditlu[P]shadetabler/src/shadetabler.c
// Function: main
int main(int argc, char *argv[]) {
	const struct option longopts[] = {
		{"output", required_argument, 0, 'o' },
		{"verbose", no_argument, 0, 'v' },
		{"force", no_argument, 0, 'f' },
		{"colors", optional_argument, 0, 'c' },
		{"shades", optional_argument, 0, 's' },
 		{"type", optional_argument, 0, 't' },
		{"hq", no_argument, 0, 'h' },
		{"reserve", no_argument, 0, 'r' },
		{"priority", optional_argument, 0, 'p' },
		{"light", optional_argument, 0, 'l' },
		{"dark", optional_argument, 0, 'd' },
		{0, 0, 0, 0}
	};

	const char *optstring = "o:vfc:s:t:hrp:l:d:";

	if (argc <= 1) {
		usage();
		exit(EXIT_FAILURE);
	}

	char *output = NULL;
	unsigned int verbose = 0;
	unsigned int force = 0;
	unsigned int colors = 256;
	unsigned int shades = 64;
	unsigned int type = TYPE_LIGHT;
	unsigned int hq = 0;
	unsigned int reserve = 0;
	unsigned int priority = 0;
	char *light_output = "shadetable_light.png";
	char *dark_output = "shadetable_dark.png";

	int opt = 0;
	while ((opt = getopt_long(argc, argv, optstring, longopts, 0)) != EOF) {
		switch (opt) {
			case 'o':
				output = optarg;
				break;
			case 'v':
				verbose = 1;
				break;
			case 'f':
				force = 1;
				break;
			case 'c':
				colors = atoi(optarg);
				break;
			case 's':
				shades = atoi(optarg);
				break;
			case 't':
				if (optarg[0] == 'd' || optarg[0] == 'D') {
					type = TYPE_DARK;
				} else if (optarg[0] == 'b' || optarg[0] == 'B') {
					type = TYPE_BOTH;
				}
				break;
			case 'h':
				hq = 1;
				break;
			case 'r':
				reserve = 1;
				break;
			case 'p':
				priority = atoi(optarg);
				break;
			case 'l':
				light_output = optarg;
				break;
			case 'd':
				dark_output = optarg;
				break;
			default:
				usage();
				exit(EXIT_FAILURE);
		}
	}

	if (output == NULL) {
		usage();
		fprintf(stderr, "No output directory specified.\n\n");
		exit(EXIT_FAILURE);
	}

	if ((argc - optind) == 0) {
		usage();
		fprintf(stderr, "No input file specified.\n\n");
		exit(EXIT_FAILURE);
	}

	if ((colors < 4 && reserve) || colors < 2 || colors > 256) {
		usage();
		fprintf(stderr, "Invalid number of colors%s.\n\n", reserve ? " (2 colors are reserved for black & white)." : "");
		exit(EXIT_FAILURE);
	}

	if (shades < 2 || shades > 256) {
		usage();
		fprintf(stderr, "Invalid number of shades.\n\n");
		exit(EXIT_FAILURE);
	}

	if (verbose) {
		printf(SHADETABLER_HEADER "\n");
	}

	exq_data *exq = exq_init();
	exq_no_transparency(exq);

	image_t *images = NULL;
	unsigned char *palette = NULL;
	char path[FILENAME_MAX];

	unsigned int number_of_images = (argc - optind);
	images = calloc(number_of_images, sizeof(image_t));
	if (images == NULL) {
		fprintf(stderr, "Unable to allocate memory for images.\n");
		goto error;
	}

	for (unsigned int i = 0; i < number_of_images; i++) {
		const char *infile = argv[optind + i];
		if (cwk_path_normalize(infile, path, sizeof(path)) == 0)  {
			fprintf(stderr, "Invalid input file path \"%s\".", infile);
			goto error;
		}

		const image_error_t image_error = image_load_rgba(&images[i], path);
		if (image_error) {
			fprintf(stderr, "Could not load input file \"%s\". %s.\n", path, image_error_text(image_error));
			goto error;
		}

		unsigned char *buffer = images[i].buffer;
		unsigned int width = images[i].width;
		unsigned int height = images[i].height;

		if (verbose) {
			printf("Generating priority colors for input file \"%s\".\n", path);
		}

		for (int j = 0; j < priority; j++) {
			exq_feed_extened(exq, buffer, width * height, 0, reserve);
		}

		if (type == TYPE_LIGHT || type == TYPE_BOTH) {
			if (verbose) {
				printf("Generating light shades for input file \"%s\".\n", path);
			}
			for (int j = 1; j < shades; j++) {
				int shade = (int)floor((((float)j) / ((float)(shades - 1)) * 255.0f) + 0.5);
				exq_feed_extened(exq, buffer, width * height, shade, reserve);
			}
		}

		if (type == TYPE_DARK || type == TYPE_BOTH) {
			if (verbose) {
				printf("Generating dark shades for input file \"%s\".\n", path);
			}
			for (int j = 0; j < (shades - 1); j++) {
				int shade = ((int)floor((((float)j) / ((float)(shades - 1)) * 255.0f) - 0.5)) - 255;
				exq_feed_extened(exq, buffer, width * height, shade, reserve);
			}
		}
	}

	if (verbose) {
		printf("Quantizing images%s.\n", hq ? ", high quality" : "");
	}

	exq_quantize_ex(exq, reserve ? colors - 2 : colors, hq);

	palette = malloc(colors * 4 * sizeof(unsigned char));
	if (palette == NULL) {
		fprintf(stderr, "Unable to allocate memory for palette.\n");
		goto error;
	}

	if (verbose) {
		printf("Generating & sorting palette.\n");
	}

	exq_get_palette(exq, palette, reserve ? colors - 2 : colors);

	if (reserve) {
		palette[((colors - 2) * 4) + 0] = 0; // Force black
		palette[((colors - 2) * 4) + 1] = 0;
		palette[((colors - 2) * 4) + 2] = 0;
		palette[((colors - 2) * 4) + 3] = 255;

		palette[((colors - 1) * 4) + 0] = 255; // Force white
		palette[((colors - 1) * 4) + 1] = 255;
		palette[((colors - 1) * 4) + 2] = 255;
		palette[((colors - 1) * 4) + 3] = 255;
	}

	qsort(palette, colors, sizeof(unsigned char) * 4, palette_qsort_compare); // Sort palette

	exq_set_palette(exq, palette, colors);

	for (unsigned int i = 0; i < number_of_images; i++) {
		const char *infile = argv[optind + i];
		path_get_output_filename(path, sizeof(path), output, infile);

		int write_image = 1;
		if (!force && path_file_exists(path)) {
			fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", path);
			fflush(stderr);
			int c = getchar();
			write_image = (c == 'y' || c == 'Y') ? 1 : 0;
			while (c != '\n' && c != EOF) { c = getchar(); }
		}

		if (write_image) {
			unsigned int width = images[i].width;
			unsigned int height = images[i].height;
			unsigned char *buffer = malloc(width * height * sizeof(unsigned char));
			if (buffer == NULL) {
				fprintf(stderr, "Unable to allocate memory for image \"%s\".\n", path);
				goto error;
			}

			if (verbose) {
				printf("Saving image \"%s\"\n", path);
			}

			exq_map_image(exq, width * height, images[i].buffer, buffer);
			save_image(path, buffer, width, height, palette, colors);
			free(buffer);
		} else {
			if (verbose) {
				printf("Skipping image \"%s\"\n", path);
			}
		}
	}

	if (type == TYPE_LIGHT || type == TYPE_BOTH) {
		path_get_output_filename(path, sizeof(path), output, light_output);
		if (!allocate_generate_and_save_shadetable(exq, path, palette, colors, shades, 1, verbose, force)) {
			goto error;
		}
	}

	if (type == TYPE_DARK || type == TYPE_BOTH) {
		path_get_output_filename(path, sizeof(path), output, dark_output);
		if (!allocate_generate_and_save_shadetable(exq, path, palette, colors, shades, 0, verbose, force)) {
			goto error;
		}
	}

error:
	if (palette != NULL) {
		free(palette);
	}

	if (images != NULL) {
		for (unsigned int i = 0; i < number_of_images; i++) {
			image_free_rgba(&images[i]);
		}
		free(images);
	}

	exq_free(exq);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1238, %rsp           # imm = 0x1238
movq %rsi, 0x80(%rsp)
movl %edi, %r13d
leaq 0x86e9(%rip), %rsi      # 0x18c50
leaq 0xb0(%rsp), %rdi
movl $0x180, %edx            # imm = 0x180
callq 0x1130
cmpl $0x2, %r13d
jl 0x10eaa
movl $0x100, %eax            # imm = 0x100
movq %rax, 0x38(%rsp)
movl $0x40, %eax
movq %rax, 0x48(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x3a3f(%rip), %rax      # 0x13fe6
movq %rax, 0x90(%rsp)
leaq 0x3a45(%rip), %rax      # 0x13ffb
movq %rax, 0x98(%rsp)
leaq 0x3a0e(%rip), %rbx      # 0x13fd3
leaq 0xb0(%rsp), %r14
leaq 0x3974(%rip), %r15      # 0x13f48
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
xorl %eax, %eax
movq $0x0, 0x68(%rsp)
xorl %ecx, %ecx
movq $0x0, 0x58(%rsp)
movl %ecx, %ebp
movl %eax, %r12d
movl %r13d, %edi
movq 0x80(%rsp), %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x10b0
leal -0x63(%rax), %edx
cmpl $0x13, %edx
ja 0x10730
movl $0x1, %ecx
movslq (%r15,%rdx,4), %rdx
addq %r15, %rdx
movl %r12d, %eax
jmpq *%rdx
movq 0x899c(%rip), %rax      # 0x18fd8
movq (%rax), %rdi
callq 0x11b0
movq %rax, 0x38(%rsp)
jmp 0x10701
movq 0x8983(%rip), %rax      # 0x18fd8
movq (%rax), %rax
movzbl (%rax), %edx
movl $0x1, %eax
cmpl $0x61, %edx
jg 0x1070b
cmpl $0x42, %edx
je 0x10724
movl %ebp, %ecx
cmpl $0x44, %edx
je 0x105fa
jmp 0x10701
movq 0x8953(%rip), %rax      # 0x18fd8
movq (%rax), %rdi
callq 0x11b0
movq %rax, 0x48(%rsp)
jmp 0x10701
movq 0x893d(%rip), %rax      # 0x18fd8
movq (%rax), %rax
movq %rax, 0x90(%rsp)
jmp 0x10701
movq 0x8929(%rip), %rax      # 0x18fd8
movq (%rax), %rax
movq %rax, 0x58(%rsp)
jmp 0x10701
movl $0x1, %eax
movq %rax, 0x68(%rsp)
jmp 0x10701
movl $0x1, 0x8(%rsp)
jmp 0x10701
movl $0x1, 0xc(%rsp)
jmp 0x10701
movq 0x88f8(%rip), %rax      # 0x18fd8
movq (%rax), %rax
movq %rax, 0x98(%rsp)
jmp 0x10701
movq 0x88e4(%rip), %rax      # 0x18fd8
movq (%rax), %rdi
callq 0x11b0
movq %rax, 0x10(%rsp)
movl %r12d, %eax
movl %ebp, %ecx
jmp 0x105fa
movl %ebp, %ecx
cmpl $0x64, %edx
je 0x105fa
movl %r12d, %eax
movl %ebp, %ecx
cmpl $0x62, %edx
jne 0x105fa
movl $0x2, %eax
movl %ebp, %ecx
jmp 0x105fa
cmpl $-0x1, %eax
jne 0x10eaa
cmpq $0x0, 0x58(%rsp)
je 0x10eb9
movq 0x8884(%rip), %rax      # 0x18fd0
cmpl %r13d, (%rax)
movq 0x38(%rsp), %rdx
movq 0x48(%rsp), %rsi
movl 0xc(%rsp), %r14d
je 0x10ebe
cmpl $0x4, %edx
setb %al
cmpl $0x0, 0x8(%rsp)
setne %cl
testb %cl, %al
jne 0x10ec3
leal -0x101(%rdx), %eax
cmpl $0xffffff00, %eax       # imm = 0xFFFFFF00
jbe 0x10ec3
leal -0x101(%rsi), %eax
cmpl $0xffffff00, %eax       # imm = 0xFFFFFF00
jbe 0x10ed3
testl %ebp, %ebp
je 0x107ac
leaq 0x3b44(%rip), %rdi      # 0x142eb
callq 0x1060
xorl %eax, %eax
callq 0x155c
movq %rax, 0x28(%rsp)
movq %rax, %rdi
callq 0x158c
movq 0x8809(%rip), %rax      # 0x18fd0
movl (%rax), %ebx
movl %r13d, %edi
subl %ebx, %edi
movl $0x10, %esi
movq %rdi, 0x70(%rsp)
callq 0x10f0
movq %rax, 0x50(%rsp)
testq %rax, %rax
movl %ebx, 0x60(%rsp)
je 0x10ddf
cmpl %ebx, %r13d
setne %sil
movl %r13d, 0x64(%rsp)
je 0x10ab1
movq 0x48(%rsp), %rax
decl %eax
cvtsi2ss %eax, %xmm1
leal -0x1(%r12), %ecx
movl %ecx, 0x8c(%rsp)
movl 0x70(%rsp), %ecx
movq %rcx, 0xa0(%rsp)
leaq 0x230(%rsp), %r15
xorl %ebx, %ebx
movq %rbp, 0x78(%rsp)
movl %eax, 0x24(%rsp)
movss %xmm1, 0x18(%rsp)
movl %r14d, 0xc(%rsp)
movb %sil, 0x30(%rsp)
movq 0x8782(%rip), %rax      # 0x18fd0
movl (%rax), %eax
addl %ebx, %eax
movq 0x80(%rsp), %rcx
movq (%rcx,%rax,8), %r14
movl $0x1000, %edx           # imm = 0x1000
movq %r14, %rdi
movq %r15, %rsi
callq 0xfc47
testq %rax, %rax
je 0x10ded
movq %rbx, 0xa8(%rsp)
shlq $0x4, %rbx
addq 0x50(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10336
testl %eax, %eax
jne 0x10e0a
movq (%rbx), %r14
movl 0x8(%rbx), %eax
movl %eax, 0x44(%rsp)
movl 0xc(%rbx), %eax
movl %eax, 0x30(%rsp)
testl %ebp, %ebp
je 0x108c6
leaq 0x3864(%rip), %rdi      # 0x1411b
leaq 0x230(%rsp), %rsi
xorl %eax, %eax
callq 0x10c0
cmpl $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rbx
movl 0x8(%rsp), %ebp
je 0x10901
movl 0x30(%rsp), %r15d
imull 0x44(%rsp), %r15d
movq 0x10(%rsp), %rax
movl %eax, %r13d
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x10ed8
decl %r13d
jne 0x108e9
testb $0x1, %r12b
movss 0x18(%rsp), %xmm1
movss 0x172d(%rip), %xmm2     # 0x12040
jne 0x109be
cmpl $0x0, 0x78(%rsp)
je 0x10944
leaq 0x3825(%rip), %rdi      # 0x1414c
leaq 0x230(%rsp), %rsi
xorl %eax, %eax
callq 0x10c0
movss 0x1702(%rip), %xmm2     # 0x12040
movss 0x18(%rsp), %xmm1
movq 0x48(%rsp), %rbp
cmpl $0x2, %ebp
movq 0x28(%rsp), %rbx
movsd 0x35d7(%rip), %xmm3     # 0x13f30
jb 0x109be
movl 0x30(%rsp), %r15d
imull 0x44(%rsp), %r15d
movl $0x1, %r13d
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
divss %xmm1, %xmm0
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm3, %xmm0
callq 0x11a0
cvttsd2si %xmm0, %ecx
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl 0x8(%rsp), %r8d
callq 0x10ed8
movsd 0x3588(%rip), %xmm3     # 0x13f30
movss 0x1690(%rip), %xmm2     # 0x12040
movss 0x18(%rsp), %xmm1
incl %r13d
cmpl %r13d, %ebp
jne 0x1096c
cmpl $0x1, 0x8c(%rsp)
movl 0x24(%rsp), %eax
movsd 0x3566(%rip), %xmm3     # 0x13f38
ja 0x10a7d
cmpl $0x0, 0x78(%rsp)
je 0x10a0f
leaq 0x3794(%rip), %rdi      # 0x1417a
leaq 0x230(%rsp), %rsi
xorl %eax, %eax
callq 0x10c0
movsd 0x353b(%rip), %xmm3     # 0x13f38
movss 0x163b(%rip), %xmm2     # 0x12040
movss 0x18(%rsp), %xmm1
movl 0x24(%rsp), %eax
testl %eax, %eax
movl 0x8(%rsp), %r13d
movl 0x30(%rsp), %ebp
je 0x10a7d
imull 0x44(%rsp), %ebp
xorl %r15d, %r15d
xorps %xmm0, %xmm0
cvtsi2ss %r15d, %xmm0
divss %xmm1, %xmm0
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm3, %xmm0
callq 0x11a0
cvttsd2si %xmm0, %ecx
addl $0xffffff01, %ecx       # imm = 0xFFFFFF01
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r13d, %r8d
callq 0x10ed8
movsd 0x34d5(%rip), %xmm3     # 0x13f38
movss 0x15d5(%rip), %xmm2     # 0x12040
movss 0x18(%rsp), %xmm1
movl 0x24(%rsp), %eax
incl %r15d
cmpl %r15d, %eax
jne 0x10a24
movq 0xa8(%rsp), %rbx
incq %rbx
cmpq 0xa0(%rsp), %rbx
setb %sil
movl 0x64(%rsp), %r13d
movl 0xc(%rsp), %r14d
leaq 0x230(%rsp), %r15
movq 0x78(%rsp), %rbp
jne 0x10842
testl %ebp, %ebp
je 0x10ad8
testl %r14d, %r14d
leaq 0x358b(%rip), %rax      # 0x1404a
leaq 0x36f7(%rip), %rsi      # 0x141bd
cmoveq %rax, %rsi
leaq 0x36d6(%rip), %rdi      # 0x141a7
xorl %eax, %eax
callq 0x10c0
movl %r14d, %edx
movq 0x38(%rsp), %r15
leal -0x2(%r15), %ebx
cmpl $0x0, 0x8(%rsp)
movl %r15d, %r14d
cmovnel %ebx, %r14d
movq 0x28(%rsp), %rdi
movl %r14d, %esi
callq 0x17b8
movl %r15d, %eax
movq %rax, 0x18(%rsp)
leaq (,%rax,4), %r15
movq %r15, %rdi
callq 0x1140
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x10de6
testl %ebp, %ebp
je 0x10b33
leaq 0x379f(%rip), %rdi      # 0x142cd
callq 0x1060
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %r14d, %edx
movq %rsi, %r14
callq 0x202b
cmpl $0x0, 0x8(%rsp)
je 0x10b80
movl %ebx, %eax
movb $0x0, (%r14,%rax,4)
shlq $0x2, %rax
movl %eax, %eax
movw $0x0, 0x1(%r14,%rax)
movb $-0x1, %cl
movb %cl, 0x3(%r14,%rax)
movl %r15d, %eax
movb %cl, -0x4(%r14,%rax)
movw $0xffff, -0x3(%r14,%r15) # imm = 0xFFFF
movb %cl, -0x1(%r14,%r15)
leaq 0x5ee(%rip), %rcx       # 0x11175
movl $0x4, %edx
movq %r14, %rdi
movq 0x18(%rsp), %rsi
callq 0x1070
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq 0x38(%rsp), %rdx
callq 0x2137
cmpl 0x60(%rsp), %r13d
setne 0xc(%rsp)
je 0x10d11
movl 0x70(%rsp), %eax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x18(%rsp)
leaq 0x230(%rsp), %r14
xorl %r15d, %r15d
movq 0x83ec(%rip), %rax      # 0x18fd0
movl (%rax), %eax
addl %r15d, %eax
movq 0x80(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq 0x58(%rsp), %rdx
callq 0x104bd
cmpl $0x0, 0x68(%rsp)
jne 0x10c1e
movq %r14, %rdi
callq 0x10498
testl %eax, %eax
jne 0x10cf0
movq 0x18(%rsp), %rax
movl -0x4(%rax), %ecx
movl (%rax), %eax
movl %eax, 0x24(%rsp)
movl %eax, %ebx
movl %ecx, 0x8(%rsp)
imull %ecx, %ebx
movq %rbx, %rdi
callq 0x1140
movq %rax, %r13
testq %rax, %rax
je 0x10cce
testl %ebp, %ebp
je 0x10c5e
leaq 0x35f7(%rip), %rdi      # 0x1424b
movq %r14, %rsi
xorl %eax, %eax
callq 0x10c0
movq 0x18(%rsp), %rax
movq -0xc(%rax), %rdx
movq 0x28(%rsp), %rdi
movl %ebx, %esi
movq %r13, %rcx
callq 0x2363
movq %r14, %rdi
movq %r13, %rsi
movl 0x8(%rsp), %edx
movl 0x24(%rsp), %ecx
movq 0x10(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0x11218
movq %r13, %rdi
callq 0x1030
xorl %eax, %eax
testq %r13, %r13
movl 0x64(%rsp), %r13d
je 0x10ca9
xorl %eax, %eax
testl %eax, %eax
jne 0x10d0a
incq %r15
movq 0x30(%rsp), %rax
cmpq %rax, %r15
setb 0xc(%rsp)
addq $0x10, 0x18(%rsp)
cmpq %r15, %rax
jne 0x10bdd
jmp 0x10d11
movq 0x8323(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x3541(%rip), %rsi      # 0x14220
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
movl $0x5, %eax
jmp 0x10c9d
xorl %esi, %esi
testl %ebp, %ebp
sete %sil
movq %r14, %rdi
callq 0x1220
testb $0x1, %al
jne 0x10c1e
jmp 0x10ca7
testb $0x1, 0xc(%rsp)
jne 0x10d7a
testb $0x1, %r12b
jne 0x10d84
leaq 0x230(%rsp), %rbx
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
movq 0x58(%rsp), %rdx
movq 0x90(%rsp), %rcx
callq 0x104bd
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
movq 0x38(%rsp), %r14
movl %r14d, %ecx
movq 0x48(%rsp), %r8
movl $0x1, %r9d
pushq 0x68(%rsp)
pushq %rbp
callq 0x1137b
addq $0x10, %rsp
testl %eax, %eax
setne %al
decl %r12d
cmpl $0x2, %r12d
setb %cl
testb %cl, %al
jne 0x10d92
movq 0x10(%rsp), %rbx
jmp 0x10e49
decl %r12d
cmpl $0x1, %r12d
movq 0x38(%rsp), %r14
ja 0x10d7a
leaq 0x230(%rsp), %rbx
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
movq 0x58(%rsp), %rdx
movq 0x98(%rsp), %rcx
callq 0x104bd
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
movl %r14d, %ecx
movq 0x48(%rsp), %r8
xorl %r9d, %r9d
pushq 0x68(%rsp)
pushq %rbp
callq 0x1137b
addq $0x10, %rsp
jmp 0x10e49
callq 0x12b3
jmp 0x10e47
callq 0x1291
jmp 0x10e47
movq 0x8204(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x32da(%rip), %rsi      # 0x140d8
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x10e37
movq 0x81e7(%rip), %rcx      # 0x18ff8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x10474
leaq 0x32d4(%rip), %rsi      # 0x140f6
leaq 0x230(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x1110
testb $0x1, 0x30(%rsp)
movl 0xc(%rsp), %r14d
je 0x10ab1
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x10e56
movq %rbx, %rdi
callq 0x1030
cmpq $0x0, 0x50(%rsp)
movl 0x60(%rsp), %eax
je 0x10e8c
cmpl %eax, %r13d
je 0x10e82
movl 0x70(%rsp), %r14d
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x1031c
addq $0x10, %rbx
decq %r14
jne 0x10e71
movq 0x50(%rsp), %rdi
callq 0x1030
movq 0x28(%rsp), %rdi
callq 0x1597
xorl %eax, %eax
addq $0x1238, %rsp           # imm = 0x1238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1159b
movl $0x1, %edi
callq 0x11c0
callq 0x1366
callq 0x133c
xorl %edi, %edi
cmpl $0x0, 0x8(%rsp)
setne %dil
callq 0x12ff
callq 0x12d5