// File: /workspace/github_c_makefile_star2_O3/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 0x4e2f
movl %edi, %ebp
movq 0x3515(%rip), %rax      # 0x7ff8
movq (%rax), %rbx
cmpl $0x3, %edi
jne 0x4af7
movq 0x34e6(%rip), %rax      # 0x7fd8
movq (%rax), %r14
jmp 0x4b34
movq 0x18(%r15), %rdi
leaq 0x1748(%rip), %rsi      # 0x624a
callq 0x20f0
testq %rax, %rax
je 0x4e47
movq %rax, %r14
cmpl $0x5, %ebp
jb 0x4b34
movq 0x20(%r15), %rdi
leaq 0x1746(%rip), %rsi      # 0x6269
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x4e4e
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 0x4e39
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 0x4e40
movq %r14, %rdi
callq 0x23e0
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0x2190
cmpl $0x89, %ebp
jne 0x4bb2
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x4e82
jmp 0x4e1b
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 0x4c0e
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 0x16d9(%rip), %rdi      # 0x632e
callq 0x2280
testq %rax, %rax
je 0x4c7d
cmpl $0x2, 0xc8(%rsp)
jne 0x4c7d
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 0x44bf
movl (%r13), %edx
movl (%rbp), %ecx
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x46ac
testl %eax, %eax
jne 0x4e6a
movzbl 0x30(%rsp), %edi
imull 0xc(%rsp), %edi
callq 0x20e0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x4e7d
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 0x47d8
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 0x4d97
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 0x4d76
movl 0x8(%rsp), %ebp
testl %ebp, %ebp
jle 0x4dd7
incl %ebp
leaq 0x20(%rsp), %r15
leaq 0x318(%rsp), %r12
leaq 0x10(%rsp), %r13
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x4787
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x2210
decl %ebp
cmpl $0x1, %ebp
ja 0x4db3
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 0x476c
movq %r14, %rdi
callq 0x22f0
movq %rbx, %rdi
callq 0x22f0
xorl %eax, %eax
jmp 0x4e58
movq %r15, %rdi
callq 0x24df
jmp 0x4e53
callq 0x2438
jmp 0x4e53
callq 0x2454
jmp 0x4e53
callq 0x241c
jmp 0x4e53
callq 0x2400
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 0x2470
callq 0x24ba