// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x12b0, %rsp           # imm = 0x12B0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x190(%rbp), %rdi
leaq 0x88a9(%rip), %rsi      # 0x21c50
movl $0x180, %edx            # imm = 0x180
callq 0x1100
leaq 0x35fb(%rip), %rax      # 0x1c9b3
movq %rax, -0x198(%rbp)
cmpl $0x1, -0x8(%rbp)
jg 0x193d4
callq 0x1ab90
movl $0x1, %edi
callq 0x11a0
movq $0x0, -0x1a0(%rbp)
movl $0x0, -0x1a4(%rbp)
movl $0x0, -0x1a8(%rbp)
movl $0x100, -0x1ac(%rbp)    # imm = 0x100
movl $0x40, -0x1b0(%rbp)
movl $0x0, -0x1b4(%rbp)
movl $0x0, -0x1b8(%rbp)
movl $0x0, -0x1bc(%rbp)
movl $0x0, -0x1c0(%rbp)
leaq 0x3590(%rip), %rax      # 0x1c9c6
movq %rax, -0x1c8(%rbp)
leaq 0x3597(%rip), %rax      # 0x1c9db
movq %rax, -0x1d0(%rbp)
movl $0x0, -0x1d4(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x198(%rbp), %rdx
leaq -0x190(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x1090
movl %eax, -0x1d4(%rbp)
cmpl $-0x1, %eax
je 0x195e8
movl -0x1d4(%rbp), %eax
addl $-0x63, %eax
movl %eax, %ecx
movq %rcx, -0x1260(%rbp)
subl $0x13, %eax
ja 0x195d4
movq -0x1260(%rbp), %rax
leaq 0x347c(%rip), %rcx      # 0x1c928
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8b1c(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movq %rax, -0x1a0(%rbp)
jmp 0x195e3
movl $0x1, -0x1a4(%rbp)
jmp 0x195e3
movl $0x1, -0x1a8(%rbp)
jmp 0x195e3
movq 0x8ae8(%rip), %rax      # 0x21fd8
movq (%rax), %rdi
callq 0x1190
movl %eax, -0x1ac(%rbp)
jmp 0x195e3
movq 0x8ace(%rip), %rax      # 0x21fd8
movq (%rax), %rdi
callq 0x1190
movl %eax, -0x1b0(%rbp)
jmp 0x195e3
movq 0x8ab4(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x64, %eax
je 0x19541
movq 0x8aa2(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x44, %eax
jne 0x1954d
movl $0x1, -0x1b4(%rbp)
jmp 0x1957d
movq 0x8a84(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
je 0x19571
movq 0x8a72(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x42, %eax
jne 0x1957b
movl $0x2, -0x1b4(%rbp)
jmp 0x1957d
jmp 0x195e3
movl $0x1, -0x1b8(%rbp)
jmp 0x195e3
movl $0x1, -0x1bc(%rbp)
jmp 0x195e3
movq 0x8a3a(%rip), %rax      # 0x21fd8
movq (%rax), %rdi
callq 0x1190
movl %eax, -0x1c0(%rbp)
jmp 0x195e3
movq 0x8a23(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movq %rax, -0x1c8(%rbp)
jmp 0x195e3
movq 0x8a10(%rip), %rax      # 0x21fd8
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
jmp 0x195e3
callq 0x1ab90
movl $0x1, %edi
callq 0x11a0
jmp 0x19455
cmpq $0x0, -0x1a0(%rbp)
jne 0x19619
callq 0x1ab90
movq 0x89fa(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x33e7(%rip), %rsi      # 0x1c9ef
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x11a0
movl -0x8(%rbp), %eax
movq 0x89ad(%rip), %rcx      # 0x21fd0
subl (%rcx), %eax
cmpl $0x0, %eax
jne 0x19651
callq 0x1ab90
movq 0x89c2(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x33d0(%rip), %rsi      # 0x1ca10
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x11a0
cmpl $0x4, -0x1ac(%rbp)
jae 0x19663
cmpl $0x0, -0x1bc(%rbp)
jne 0x19678
cmpl $0x2, -0x1ac(%rbp)
jb 0x19678
cmpl $0x100, -0x1ac(%rbp)    # imm = 0x100
jbe 0x196ba
callq 0x1ab90
movq 0x8974(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
movl -0x1bc(%rbp), %ecx
leaq 0x3396(%rip), %rdx      # 0x1ca2a
leaq 0x33ae(%rip), %rax      # 0x1ca49
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x3382(%rip), %rsi      # 0x1ca2b
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x11a0
cmpl $0x2, -0x1b0(%rbp)
jb 0x196cf
cmpl $0x100, -0x1b0(%rbp)    # imm = 0x100
jbe 0x196f6
callq 0x1ab90
movq 0x891d(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x3390(%rip), %rsi      # 0x1ca75
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x11a0
cmpl $0x0, -0x1a4(%rbp)
je 0x1970d
leaq 0x338b(%rip), %rdi      # 0x1ca91
movb $0x0, %al
callq 0x10a0
movb $0x0, %al
callq 0x12e0
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rdi
callq 0x1370
movq $0x0, -0x1e8(%rbp)
movq $0x0, -0x1f0(%rbp)
movl -0x8(%rbp), %eax
movq 0x8889(%rip), %rcx      # 0x21fd0
subl (%rcx), %eax
movl %eax, -0x11f4(%rbp)
movl -0x11f4(%rbp), %eax
movl %eax, %edi
movl $0x10, %esi
callq 0x10c0
movq %rax, -0x1e8(%rbp)
cmpq $0x0, -0x1e8(%rbp)
jne 0x1978f
movq 0x887f(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x3360(%rip), %rsi      # 0x1cae3
movb $0x0, %al
callq 0x10e0
jmp 0x1a103
movl $0x0, -0x11f8(%rbp)
movl -0x11f8(%rbp), %eax
cmpl -0x11f4(%rbp), %eax
jae 0x19b20
movq -0x10(%rbp), %rax
movq 0x881a(%rip), %rcx      # 0x21fd0
movl (%rcx), %ecx
addl -0x11f8(%rbp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1200(%rbp)
movq -0x1200(%rbp), %rdi
leaq -0x11f0(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x18620
cmpq $0x0, %rax
jne 0x1980d
movq 0x8808(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
movq -0x1200(%rbp), %rdx
leaq 0x3309(%rip), %rsi      # 0x1cb0a
movb $0x0, %al
callq 0x10e0
jmp 0x1a103
movq -0x1e8(%rbp), %rdi
movl -0x11f8(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdi
leaq -0x11f0(%rbp), %rsi
callq 0x19020
movl %eax, -0x1204(%rbp)
cmpl $0x0, -0x1204(%rbp)
je 0x1988a
movq 0x87b5(%rip), %rax      # 0x21ff8
movq (%rax), %rax
movq %rax, -0x1270(%rbp)
leaq -0x11f0(%rbp), %rax
movq %rax, -0x1268(%rbp)
movl -0x1204(%rbp), %edi
callq 0x19250
movq -0x1270(%rbp), %rdi
movq -0x1268(%rbp), %rdx
movq %rax, %rcx
leaq 0x32aa(%rip), %rsi      # 0x1cb28
movb $0x0, %al
callq 0x10e0
jmp 0x1a103
movq -0x1e8(%rbp), %rax
movl -0x11f8(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x1210(%rbp)
movq -0x1e8(%rbp), %rax
movl -0x11f8(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x1214(%rbp)
movq -0x1e8(%rbp), %rax
movl -0x11f8(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x1218(%rbp)
cmpl $0x0, -0x1a4(%rbp)
je 0x19900
leaq -0x11f0(%rbp), %rsi
leaq 0x3254(%rip), %rdi      # 0x1cb4d
movb $0x0, %al
callq 0x10a0
movl $0x0, -0x121c(%rbp)
movl -0x121c(%rbp), %eax
cmpl -0x1c0(%rbp), %eax
jae 0x19952
movq -0x1e0(%rbp), %rdi
movq -0x1210(%rbp), %rsi
movl -0x1214(%rbp), %edx
imull -0x1218(%rbp), %edx
movl -0x1bc(%rbp), %r8d
xorl %ecx, %ecx
callq 0x1a190
movl -0x121c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x121c(%rbp)
jmp 0x1990a
cmpl $0x0, -0x1b4(%rbp)
je 0x19968
cmpl $0x2, -0x1b4(%rbp)
jne 0x19a29
cmpl $0x0, -0x1a4(%rbp)
je 0x19986
leaq -0x11f0(%rbp), %rsi
leaq 0x31ff(%rip), %rdi      # 0x1cb7e
movb $0x0, %al
callq 0x10a0
movl $0x1, -0x1220(%rbp)
movl -0x1220(%rbp), %eax
cmpl -0x1b0(%rbp), %eax
jae 0x19a27
cvtsi2ssl -0x1220(%rbp), %xmm0
movl -0x1b0(%rbp), %eax
decl %eax
cvtsi2ss %rax, %xmm1
divss %xmm1, %xmm0
movss 0x1645(%rip), %xmm1     # 0x1b008
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x2f3d(%rip), %xmm1     # 0x1c910
addsd %xmm1, %xmm0
callq 0x1180
cvttsd2si %xmm0, %eax
movl %eax, -0x1224(%rbp)
movq -0x1e0(%rbp), %rdi
movq -0x1210(%rbp), %rsi
movl -0x1214(%rbp), %edx
imull -0x1218(%rbp), %edx
movl -0x1224(%rbp), %ecx
movl -0x1bc(%rbp), %r8d
callq 0x1a190
movl -0x1220(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1220(%rbp)
jmp 0x19990
jmp 0x19a29
cmpl $0x1, -0x1b4(%rbp)
je 0x19a3f
cmpl $0x2, -0x1b4(%rbp)
jne 0x19b0a
cmpl $0x0, -0x1a4(%rbp)
je 0x19a5d
leaq -0x11f0(%rbp), %rsi
leaq 0x3156(%rip), %rdi      # 0x1cbac
movb $0x0, %al
callq 0x10a0
movl $0x0, -0x1228(%rbp)
movl -0x1228(%rbp), %eax
movl -0x1b0(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x19b08
cvtsi2ssl -0x1228(%rbp), %xmm0
movl -0x1b0(%rbp), %eax
decl %eax
cvtsi2ss %rax, %xmm1
divss %xmm1, %xmm0
movss 0x1569(%rip), %xmm1     # 0x1b008
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x2e61(%rip), %xmm1     # 0x1c910
subsd %xmm1, %xmm0
callq 0x1180
cvttsd2si %xmm0, %eax
subl $0xff, %eax
movl %eax, -0x122c(%rbp)
movq -0x1e0(%rbp), %rdi
movq -0x1210(%rbp), %rsi
movl -0x1214(%rbp), %edx
imull -0x1218(%rbp), %edx
movl -0x122c(%rbp), %ecx
movl -0x1bc(%rbp), %r8d
callq 0x1a190
movl -0x1228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1228(%rbp)
jmp 0x19a67
jmp 0x19b0a
jmp 0x19b0c
movl -0x11f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11f8(%rbp)
jmp 0x19799
cmpl $0x0, -0x1a4(%rbp)
je 0x19b52
movl -0x1b8(%rbp), %ecx
leaq 0x2ef4(%rip), %rsi      # 0x1ca2a
leaq 0x30b2(%rip), %rax      # 0x1cbef
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x308e(%rip), %rdi      # 0x1cbd9
movb $0x0, %al
callq 0x10a0
movq -0x1e0(%rbp), %rax
movq %rax, -0x1278(%rbp)
cmpl $0x0, -0x1bc(%rbp)
je 0x19b7a
movl -0x1ac(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x127c(%rbp)
jmp 0x19b86
movl -0x1ac(%rbp), %eax
movl %eax, -0x127c(%rbp)
movq -0x1278(%rbp), %rdi
movl -0x127c(%rbp), %esi
movl -0x1b8(%rbp), %edx
callq 0x1840
movl -0x1ac(%rbp), %eax
shll $0x2, %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x1120
movq %rax, -0x1f0(%rbp)
cmpq $0x0, -0x1f0(%rbp)
jne 0x19be2
movq 0x842c(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x3028(%rip), %rsi      # 0x1cbfe
movb $0x0, %al
callq 0x10e0
jmp 0x1a103
cmpl $0x0, -0x1a4(%rbp)
je 0x19bf9
leaq 0x3034(%rip), %rdi      # 0x1cc26
movb $0x0, %al
callq 0x10a0
movq -0x1e0(%rbp), %rax
movq %rax, -0x1290(%rbp)
movq -0x1f0(%rbp), %rax
movq %rax, -0x1288(%rbp)
cmpl $0x0, -0x1bc(%rbp)
je 0x19c2f
movl -0x1ac(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1294(%rbp)
jmp 0x19c3b
movl -0x1ac(%rbp), %eax
movl %eax, -0x1294(%rbp)
movq -0x1288(%rbp), %rsi
movq -0x1290(%rbp), %rdi
movl -0x1294(%rbp), %edx
callq 0x2950
cmpl $0x0, -0x1bc(%rbp)
je 0x19d41
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x2, %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x2, %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x2, %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x2, %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x1, %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x1, %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x1, %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movq -0x1f0(%rbp), %rax
movl -0x1ac(%rbp), %ecx
subl $0x1, %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movq -0x1f0(%rbp), %rdi
movl -0x1ac(%rbp), %eax
movl %eax, %esi
movl $0x4, %edx
leaq 0x8d4(%rip), %rcx       # 0x1a630
callq 0x1050
movq -0x1e0(%rbp), %rdi
movq -0x1f0(%rbp), %rsi
movl -0x1ac(%rbp), %edx
callq 0x2b90
movl $0x0, -0x1230(%rbp)
movl -0x1230(%rbp), %eax
cmpl -0x11f4(%rbp), %eax
jae 0x1a00c
movq -0x10(%rbp), %rax
movq 0x822f(%rip), %rcx      # 0x21fd0
movl (%rcx), %ecx
addl -0x1230(%rbp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1238(%rbp)
leaq -0x11f0(%rbp), %rdi
movq -0x1a0(%rbp), %rdx
movq -0x1238(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
callq 0x192f0
movl $0x1, -0x123c(%rbp)
cmpl $0x0, -0x1a8(%rbp)
jne 0x19eb0
leaq -0x11f0(%rbp), %rdi
callq 0x192a0
cmpl $0x0, %eax
je 0x19eb0
movq 0x81f0(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq -0x11f0(%rbp), %rdx
leaq 0x2e2c(%rip), %rsi      # 0x1cc45
movb $0x0, %al
callq 0x10e0
movq 0x81d1(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
callq 0x1130
callq 0x10d0
movl %eax, -0x1240(%rbp)
movb $0x1, %al
cmpl $0x79, -0x1240(%rbp)
movb %al, -0x1295(%rbp)
je 0x19e5b
cmpl $0x59, -0x1240(%rbp)
sete %al
movb %al, -0x1295(%rbp)
movb -0x1295(%rbp), %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x123c(%rbp)
xorl %eax, %eax
cmpl $0xa, -0x1240(%rbp)
movb %al, -0x1296(%rbp)
je 0x19e95
cmpl $-0x1, -0x1240(%rbp)
setne %al
movb %al, -0x1296(%rbp)
movb -0x1296(%rbp), %al
testb $0x1, %al
jne 0x19ea1
jmp 0x19eae
callq 0x10d0
movl %eax, -0x1240(%rbp)
jmp 0x19e74
jmp 0x19eb0
cmpl $0x0, -0x123c(%rbp)
je 0x19fd6
movq -0x1e8(%rbp), %rax
movl -0x1230(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x1244(%rbp)
movq -0x1e8(%rbp), %rax
movl -0x1230(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x1248(%rbp)
movl -0x1244(%rbp), %eax
imull -0x1248(%rbp), %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x1120
movq %rax, -0x1250(%rbp)
cmpq $0x0, -0x1250(%rbp)
jne 0x19f46
movq 0x80cf(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq -0x11f0(%rbp), %rdx
leaq 0x2d37(%rip), %rsi      # 0x1cc71
movb $0x0, %al
callq 0x10e0
jmp 0x1a103
cmpl $0x0, -0x1a4(%rbp)
je 0x19f64
leaq -0x11f0(%rbp), %rsi
leaq 0x2d3f(%rip), %rdi      # 0x1cc9c
movb $0x0, %al
callq 0x10a0
movq -0x1e0(%rbp), %rdi
movl -0x1244(%rbp), %esi
imull -0x1248(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl -0x1230(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movq -0x1250(%rbp), %rcx
callq 0x2f70
leaq -0x11f0(%rbp), %rdi
movq -0x1250(%rbp), %rsi
movl -0x1244(%rbp), %edx
movl -0x1248(%rbp), %ecx
movq -0x1f0(%rbp), %r8
movl -0x1ac(%rbp), %r9d
callq 0x1a750
movq -0x1250(%rbp), %rdi
callq 0x1030
jmp 0x19ff6
cmpl $0x0, -0x1a4(%rbp)
je 0x19ff4
leaq -0x11f0(%rbp), %rsi
leaq 0x2cc2(%rip), %rdi      # 0x1ccaf
movb $0x0, %al
callq 0x10a0
jmp 0x19ff6
jmp 0x19ff8
movl -0x1230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1230(%rbp)
jmp 0x19d84
cmpl $0x0, -0x1b4(%rbp)
je 0x1a01e
cmpl $0x2, -0x1b4(%rbp)
jne 0x1a088
leaq -0x11f0(%rbp), %rdi
movq -0x1a0(%rbp), %rdx
movq -0x1c8(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
callq 0x192f0
movq -0x1e0(%rbp), %rdi
leaq -0x11f0(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
movl -0x1ac(%rbp), %ecx
movl -0x1b0(%rbp), %r8d
movl -0x1a4(%rbp), %r10d
movl -0x1a8(%rbp), %eax
movl $0x1, %r9d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1a9a0
cmpl $0x0, %eax
jne 0x1a086
jmp 0x1a103
jmp 0x1a088
cmpl $0x1, -0x1b4(%rbp)
je 0x1a09a
cmpl $0x2, -0x1b4(%rbp)
jne 0x1a101
leaq -0x11f0(%rbp), %rdi
movq -0x1a0(%rbp), %rdx
movq -0x1d0(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
callq 0x192f0
movq -0x1e0(%rbp), %rdi
leaq -0x11f0(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
movl -0x1ac(%rbp), %ecx
movl -0x1b0(%rbp), %r8d
movl -0x1a4(%rbp), %r10d
movl -0x1a8(%rbp), %eax
xorl %r9d, %r9d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1a9a0
cmpl $0x0, %eax
jne 0x1a0ff
jmp 0x1a103
jmp 0x1a101
jmp 0x1a103
cmpq $0x0, -0x1f0(%rbp)
je 0x1a119
movq -0x1f0(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x1e8(%rbp)
je 0x1a171
movl $0x0, -0x1254(%rbp)
movl -0x1254(%rbp), %eax
cmpl -0x11f4(%rbp), %eax
jae 0x1a165
movq -0x1e8(%rbp), %rdi
movl -0x1254(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x18fe0
movl -0x1254(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1254(%rbp)
jmp 0x1a12d
movq -0x1e8(%rbp), %rdi
callq 0x1030
movq -0x1e0(%rbp), %rdi
callq 0x1390
movl -0x4(%rbp), %eax
addq $0x12b0, %rsp           # imm = 0x12B0
popq %rbp
retq
nopl (%rax)