// File: /workspace/github_c_makefile_star2_O0/tditlu[P]shadetabler/src/shadetabler.c
// Function: allocate_generate_and_save_shadetable
static int allocate_generate_and_save_shadetable(exq_data *exq, char *path, unsigned char *palette, unsigned int colors, unsigned int shades, int light, int verbose, int force) {
	int write_shadetable = 1;
	if (!force && path_file_exists(path)) {
		fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", path);
		fflush(stderr);
		int c = getchar();
		write_shadetable = (c == 'y' || c == 'Y') ? 1 : 0;
		while (c != '\n' && c != EOF) { c = getchar(); }
	}

	if (write_shadetable) {
		unsigned char *buffer_rgba = allocate_and_generate_shadetable(palette, colors, shades, light);
		if (buffer_rgba != NULL) {
			unsigned char *buffer_8bit = malloc(colors * shades * sizeof(unsigned char));
			if (buffer_8bit != NULL) {
				exq_map_image(exq, colors * shades, buffer_rgba, buffer_8bit);

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

				save_image(path, buffer_8bit, colors, shades, palette, colors);
				free(buffer_8bit);
			} else {
				free(buffer_rgba);
				fprintf(stderr, "Unable to allocate memory for shadetable.\n");
				return 0;
			}
			free(buffer_rgba);
		} else {
			fprintf(stderr, "Unable to allocate memory for shadetable.\n");
			return 0;
		}
	} else {
		if (verbose) {
			printf("Skipping image \"%s\"\n", path);
		}
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
cmpl $0x0, 0x18(%rbp)
jne 0x1aa6d
movq -0x18(%rbp), %rdi
callq 0x192a0
cmpl $0x0, %eax
je 0x1aa6d
movq 0x7609(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x2248(%rip), %rsi      # 0x1cc45
movb $0x0, %al
callq 0x10e0
movq 0x75ed(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
callq 0x1130
callq 0x10d0
movl %eax, -0x34(%rbp)
movb $0x1, %al
cmpl $0x79, -0x34(%rbp)
movb %al, -0x49(%rbp)
je 0x1aa30
cmpl $0x59, -0x34(%rbp)
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x30(%rbp)
xorl %eax, %eax
cmpl $0xa, -0x34(%rbp)
movb %al, -0x4a(%rbp)
je 0x1aa58
cmpl $-0x1, -0x34(%rbp)
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0x1aa61
jmp 0x1aa6b
callq 0x10d0
movl %eax, -0x34(%rbp)
jmp 0x1aa43
jmp 0x1aa6d
cmpl $0x0, -0x30(%rbp)
je 0x1ab65
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movl -0x2c(%rbp), %ecx
callq 0x1ac80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x1ab42
movl -0x24(%rbp), %eax
imull -0x28(%rbp), %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x1120
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1ab0d
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
imull -0x28(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x2f70
cmpl $0x0, 0x10(%rbp)
je 0x1aae7
movq -0x18(%rbp), %rsi
leaq 0x21bc(%rip), %rdi      # 0x1cc9c
movb $0x0, %al
callq 0x10a0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %r8
movl -0x24(%rbp), %r9d
callq 0x1a750
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0x1ab37
movq -0x40(%rbp), %rdi
callq 0x1030
movq 0x74db(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x256e(%rip), %rsi      # 0x1d095
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x4(%rbp)
jmp 0x1ab86
movq -0x40(%rbp), %rdi
callq 0x1030
jmp 0x1ab63
movq 0x74af(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
leaq 0x2542(%rip), %rsi      # 0x1d095
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x4(%rbp)
jmp 0x1ab86
jmp 0x1ab7f
cmpl $0x0, 0x10(%rbp)
je 0x1ab7d
movq -0x18(%rbp), %rsi
leaq 0x2139(%rip), %rdi      # 0x1ccaf
movb $0x0, %al
callq 0x10a0
jmp 0x1ab7f
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop