// File: /workspace/github_c_makefile_star2_O2/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 0x4939
movl %edi, %ebp
movq 0x29e1(%rip), %rax      # 0x6ff8
movq (%rax), %rbx
cmpl $0x3, %edi
jne 0x462b
movq 0x29b2(%rip), %rax      # 0x6fd8
movq (%rax), %r14
jmp 0x4668
movq 0x18(%r15), %rdi
leaq 0xb30(%rip), %rsi       # 0x5166
callq 0x20e0
testq %rax, %rax
je 0x4980
movq %rax, %r14
cmpl $0x5, %ebp
jb 0x4668
movq 0x20(%r15), %rdi
leaq 0xb2e(%rip), %rsi       # 0x5185
callq 0x20e0
movq %rax, %rbx
testq %rax, %rax
je 0x4995
movq 0x8(%r15), %rdi
leaq 0x18(%rsp), %r13
pushq $0xa
popq %rdx
movq %r13, %rsi
callq 0x23a0
movq %rax, %r12
movq (%r13), %rax
cmpb $0x0, (%rax)
jne 0x4956
movq 0x10(%r15), %rdi
leaq 0x18(%rsp), %r13
pushq $0xa
popq %rdx
movq %r13, %rsi
callq 0x23a0
movq %rax, %r15
movq (%r13), %rax
cmpb $0x0, (%rax)
jne 0x496b
movq %r14, %rdi
callq 0x45c8
testl %eax, %eax
je 0x46d2
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x4a25
jmp 0x4925
movq %rbx, 0x10(%rsp)
movl %r12d, 0x4(%rsp)
movl %r15d, (%rsp)
leaq 0x318(%rsp), %r15
movq %r15, %rdi
callq 0x2260
leaq 0x88(%rsp), %r12
movq %rax, (%r12)
pushq $0x50
popq %rsi
movl $0x290, %edx            # imm = 0x290
movq %r12, %rdi
callq 0x2150
movq %r12, %rdi
movq %r14, %rsi
callq 0x2050
movq %r12, %rdi
movl $0xfe, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2030
pushq $-0xd
popq %rbx
testq %rbx, %rbx
je 0x4749
leal 0xee(%rbx), %esi
movq %r12, %rdi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2030
incq %rbx
jmp 0x472c
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movl $0xef, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x2030
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x2350
leaq 0xad5(%rip), %rdi       # 0x524a
callq 0x2270
testq %rax, %rax
je 0x479d
cmpl $0x2, 0xc8(%rsp)
jne 0x479d
leaq 0x88(%rsp), %rdi
movl $0x7, 0x40(%rdi)
callq 0x2240
leaq 0x88(%rsp), %r12
movq %r12, %rdi
callq 0x20f0
movl 0x88(%r12), %edi
movl 0x8c(%r12), %esi
leaq 0x4(%rsp), %r13
movq %rsp, %rbp
movq %r13, %rdx
movq %rbp, %rcx
callq 0x3f1c
movl (%r13), %edx
movl (%rbp), %ecx
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x420c
testl %eax, %eax
movq 0x10(%rsp), %rbx
jne 0x49c6
movzbl 0x30(%rsp), %edi
imull 0x4(%rsp), %edi
callq 0x20d0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x4a01
leaq 0x3c0(%rsp), %r12
movq %r15, (%r12)
pushq $0x50
popq %rsi
movl $0x248, %edx            # imm = 0x248
movq %r12, %rdi
callq 0x2170
movq %r12, %rdi
movq %rbx, %rsi
callq 0x20b0
movl 0x4(%rsp), %eax
movl %eax, 0x30(%r12)
movl (%rsp), %eax
movl %eax, 0x34(%r12)
movl 0x30(%rsp), %edi
movzbl %dil, %eax
movl %eax, 0x38(%r12)
callq 0x431a
movl %eax, 0x3c(%r12)
movq %r12, %rdi
callq 0x2160
pushq $0x5e
popq %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x2330
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x2040
leaq 0x218(%rsp), %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x48a2
movzbl 0x8(%rbx), %esi
movq 0x18(%rbx), %rdx
movl 0x10(%rbx), %ecx
movq %r12, %rdi
callq 0x2290
jmp 0x4885
movl (%rsp), %ebx
leaq 0x20(%rsp), %r15
leaq 0x3c0(%rsp), %r12
leaq 0x8(%rsp), %r13
pushq $0x1
popq %rbp
testl %ebx, %ebx
jle 0x48dc
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x42c9
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x2200
decl %ebx
jmp 0x48ba
leaq 0x3c0(%rsp), %r15
movq %r15, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x23c0
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x23b0
movq %r15, %rdi
callq 0x2110
movq 0x8(%rsp), %rdi
callq 0x21a0
leaq 0x20(%rsp), %rdi
callq 0x42b3
movq 0x10(%rsp), %rbx
movq %r14, %rdi
callq 0x22e0
movq %rbx, %rdi
callq 0x22e0
xorl %eax, %eax
jmp 0x49b4
movq 0x26a8(%rip), %rax      # 0x6fe8
movq (%rax), %rdi
movq (%r15), %rdx
leaq 0x7f3(%rip), %rsi       # 0x5140
xorl %eax, %eax
callq 0x2370
jmp 0x49b1
movq 0x268b(%rip), %rax      # 0x6fe8
movq (%rax), %rcx
leaq 0x842(%rip), %rdi       # 0x51a9
pushq $0x16
jmp 0x49a8
movq 0x2676(%rip), %rax      # 0x6fe8
movq (%rax), %rcx
leaq 0x844(%rip), %rdi       # 0x51c0
pushq $0x17
jmp 0x49a8
movq 0x2661(%rip), %rax      # 0x6fe8
movq (%rax), %rcx
leaq 0x7d7(%rip), %rdi       # 0x5168
pushq $0x1c
jmp 0x49a8
movq 0x264c(%rip), %rax      # 0x6fe8
movq (%rax), %rcx
leaq 0x7e1(%rip), %rdi       # 0x5187
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
pushq $0x1
popq %rax
addq $0x608, %rsp            # imm = 0x608
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x261b(%rip), %rax      # 0x6fe8
movq (%rax), %rcx
leaq 0x83a(%rip), %rdi       # 0x5211
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
leaq 0x88(%rsp), %rdi
callq 0x2110
movq %r14, %rdi
callq 0x22e0
movq %rbx, %rdi
callq 0x22e0
jmp 0x4a1d
movq 0x25e0(%rip), %rax      # 0x6fe8
movq (%rax), %rcx
leaq 0x81c(%rip), %rdi       # 0x522e
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
pushq $0x1
popq %rdi
callq 0x20c0