// File: /workspace/github_c_makefile_star2_O1/ender672[P]liboil/imgscale.c
// Function: main
int main(int argc, char *argv[])
{
	int width, height;
	char *end;
	FILE *io_in, *io_out;

	io_in = stdin;
	io_out = stdout;

	if (argc < 3) {
		fprintf(stderr, "Usage: %s WIDTH HEIGHT [file] [file]\n", argv[0]);
		return 1;
	}

	if (argc > 3) {
		io_in = fopen(argv[3], "r");
		if (!io_in) {
			fprintf(stderr, "Unable to open source file.\n");
			return 1;
		}
	}

	if (argc > 4) {
		io_out = fopen(argv[4], "w");
		if (!io_out) {
			fprintf(stderr, "Unable to open destination file.\n");
			return 1;
		}
	}

	width = strtoul(argv[1], &end, 10);
	if (*end) {
		fprintf(stderr, "Error: Invalid width.\n");
		return 1;
	}

	height = strtoul(argv[2], &end, 10);
	if (*end) {
		fprintf(stderr, "Error: Invalid height.\n");
		return 1;
	}

	if (looks_like_png(io_in)) {
		png(io_in, io_out, width, height);
	} else {
		jpeg(io_in, io_out, width, height);
	}

	fclose(io_in);
	fclose(io_out);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x608, %rsp            # imm = 0x608
movq %rsi, %r15
cmpl $0x2, %edi
jle 0x4cf3
movl %edi, %ebp
movq 0x2651(%rip), %rax      # 0x6ff8
movq (%rax), %rbx
cmpl $0x3, %edi
jne 0x49bb
movq 0x2622(%rip), %rax      # 0x6fd8
movq (%rax), %r14
jmp 0x49d7
movq 0x18(%r15), %rdi
leaq 0x7e0(%rip), %rsi       # 0x51a6
callq 0x20f0
movq %rax, %r14
testq %rax, %rax
je 0x4d0b
cmpl $0x5, %ebp
jl 0x49f8
movq 0x20(%r15), %rdi
leaq 0x7de(%rip), %rsi       # 0x51c5
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x4d12
movq 0x8(%r15), %rdi
leaq 0x18(%rsp), %r13
movq %r13, %rsi
movl $0xa, %edx
callq 0x23b0
movq %rax, %r12
movq (%r13), %rax
cmpb $0x0, (%rax)
jne 0x4cfd
movq 0x10(%r15), %rdi
leaq 0x18(%rsp), %r13
movq %r13, %rsi
movl $0xa, %edx
callq 0x23b0
movq %rax, %r15
movq (%r13), %rax
cmpb $0x0, (%rax)
jne 0x4d04
movq %r14, %rdi
callq 0x23e0
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0x2190
cmpl $0x89, %ebp
jne 0x4a76
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x4d46
jmp 0x4cdf
movl %r12d, 0xc(%rsp)
movl %r15d, 0x8(%rsp)
leaq 0x560(%rsp), %r15
movq %r15, %rdi
callq 0x2270
leaq 0x88(%rsp), %r12
movq %rax, (%r12)
movl $0x290, %edx            # imm = 0x290
movq %r12, %rdi
movl $0x50, %esi
callq 0x2160
movq %r12, %rdi
movq %r14, %rsi
callq 0x2050
movq %r12, %rdi
movl $0xfe, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2030
movq $-0xd, %r13
leal 0xee(%r13), %esi
movq %r12, %rdi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2030
incq %r13
jne 0x4ad2
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movl $0xef, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2030
movq %r12, %rdi
movl $0x1, %esi
callq 0x2360
leaq 0x771(%rip), %rdi       # 0x528a
callq 0x2280
testq %rax, %rax
je 0x4b41
cmpl $0x2, 0xc8(%rsp)
jne 0x4b41
leaq 0x88(%rsp), %rdi
movl $0x7, 0x40(%rdi)
callq 0x2250
leaq 0x88(%rsp), %r12
movq %r12, %rdi
callq 0x2100
movl 0x88(%r12), %edi
movl 0x8c(%r12), %esi
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r13, %rdx
movq %rbp, %rcx
callq 0x4322
movl (%r13), %edx
movl (%rbp), %ecx
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x451c
testl %eax, %eax
jne 0x4d2e
movzbl 0x30(%rsp), %edi
imull 0xc(%rsp), %edi
callq 0x20e0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x4d41
leaq 0x318(%rsp), %r12
movq %r15, (%r12)
movl $0x248, %edx            # imm = 0x248
movq %r12, %rdi
movl $0x50, %esi
callq 0x2180
movq %r12, %rdi
movq %rbx, %rsi
callq 0x20c0
movl 0xc(%rsp), %eax
movl %eax, 0x30(%r12)
movl 0x8(%rsp), %eax
movl %eax, 0x34(%r12)
movl 0x30(%rsp), %edi
movzbl %dil, %eax
movl %eax, 0x38(%r12)
callq 0x466d
movl %eax, 0x3c(%r12)
movq %r12, %rdi
callq 0x2170
movq %r12, %rdi
movl $0x5e, %esi
xorl %edx, %edx
callq 0x2340
movq %r12, %rdi
movl $0x1, %esi
callq 0x2040
movq 0x218(%rsp), %r12
testq %r12, %r12
je 0x4c5b
leaq 0x318(%rsp), %r15
movzbl 0x8(%r12), %esi
movq 0x18(%r12), %rdx
movl 0x10(%r12), %ecx
movq %r15, %rdi
callq 0x22a0
movq (%r12), %r12
testq %r12, %r12
jne 0x4c3a
movl 0x8(%rsp), %ebp
testl %ebp, %ebp
jle 0x4c9b
incl %ebp
leaq 0x20(%rsp), %r15
leaq 0x318(%rsp), %r12
leaq 0x10(%rsp), %r13
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x461c
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x2210
decl %ebp
cmpl $0x1, %ebp
jg 0x4c77
leaq 0x318(%rsp), %r15
movq %r15, %rdi
callq 0x2110
movq %r15, %rdi
callq 0x23d0
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x23c0
movq %r15, %rdi
callq 0x2120
movq 0x10(%rsp), %rdi
callq 0x21b0
leaq 0x20(%rsp), %rdi
callq 0x4601
movq %r14, %rdi
callq 0x22f0
movq %rbx, %rdi
callq 0x22f0
xorl %eax, %eax
jmp 0x4d1c
movq %r15, %rdi
callq 0x24df
jmp 0x4d17
callq 0x241c
jmp 0x4d17
callq 0x2438
jmp 0x4d17
callq 0x2400
jmp 0x4d17
callq 0x24c3
movl $0x1, %eax
addq $0x608, %rsp            # imm = 0x608
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2454
callq 0x249e