// File: /workspace/github_c_makefile_star2_O3/ender672[P]liboil/imgscale.c
// Function: png
static void png(FILE *input, FILE *output, int width, int height)
{
	int i, in_width, in_height, ret;
	png_structp rpng, wpng;
	png_infop rinfo, winfo;
	png_byte ctype;
	struct oil_libpng ol;
	unsigned char *outbuf;

	rpng = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

	if (setjmp(png_jmpbuf(rpng))) {
		fprintf(stderr, "PNG Decoding Error.\n");
		exit(1);
	}

	rinfo = png_create_info_struct(rpng);
	png_init_io(rpng, input);
	png_read_info(rpng, rinfo);

	png_set_packing(rpng);
	png_set_strip_16(rpng);
	png_set_expand(rpng);
	png_set_interlace_handling(rpng);
	png_read_update_info(rpng, rinfo);

	in_width = png_get_image_width(rpng, rinfo);
	in_height = png_get_image_height(rpng, rinfo);
	oil_fix_ratio(in_width, in_height, &width, &height);

	wpng = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	winfo = png_create_info_struct(wpng);
	png_init_io(wpng, output);

	ret = oil_libpng_init(&ol, rpng, rinfo, width, height);
	if (ret!=0) {
		fprintf(stderr, "Unable to allocate buffers.\n");
		exit(1);
	}

	ctype = png_get_color_type(rpng, rinfo);
	png_set_IHDR(wpng, winfo, width, height, 8, ctype, PNG_INTERLACE_NONE,
		PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);

	png_write_info(wpng, winfo);

	outbuf = malloc(width * OIL_CMP(ol.os.cs));
	if (!outbuf) {
		fprintf(stderr, "Unable to allocate buffers.\n");
		exit(1);
	}

	for(i=0; i<height; i++) {
		oil_libpng_read_scanline(&ol, outbuf);
		png_write_row(wpng, outbuf);
	}

	png_write_end(wpng, winfo);
	png_destroy_write_struct(&wpng, &winfo);
	png_destroy_read_struct(&rpng, &rinfo, NULL);

	free(outbuf);
	oil_libpng_free(&ol);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r12
movl %edx, 0xc(%rsp)
movl %ecx, 0x8(%rsp)
leaq 0x1412(%rip), %rdi      # 0x62bc
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x2240
movq %rax, %r14
movq %rax, 0x30(%rsp)
movq 0x3118(%rip), %rsi      # 0x7fe0
movl $0xc8, %edx
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x20a0
testl %eax, %eax
jne 0x50a8
movq %r14, %rdi
callq 0x2260
movq %rax, %r15
movq %rax, 0x20(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x22d0
movq %r14, %rdi
movq %r15, %rsi
callq 0x21d0
movq %r14, %rdi
callq 0x22b0
movq %r14, %rdi
callq 0x2220
movq %r14, %rdi
callq 0x21a0
movq %r14, %rdi
callq 0x2150
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x2130
movl %eax, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x2300
leaq 0xc(%rsp), %rbx
leaq 0x8(%rsp), %r13
movl %ebp, %edi
movl %eax, %esi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x44bf
leaq 0x134e(%rip), %rdi      # 0x62bc
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x2390
movq %rax, %rbp
movq %rax, 0x28(%rsp)
movq %rax, %rdi
callq 0x2260
movq %rax, %r12
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x22d0
movl (%rbx), %ecx
movl (%r13), %r8d
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x47fc
testl %eax, %eax
jne 0x50ad
movq %r15, %rsi
movq %rbp, %rbx
movq %r12, %r15
movq %r14, %rdi
callq 0x2140
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movzbl %al, %r9d
subq $0x8, %rsp
xorl %r10d, %r10d
movl %r10d, %eax
movq %rbp, %rdi
movq %r12, %rsi
movl $0x8, %r8d
pushq %rax
pushq %rax
pushq %rax
callq 0x2370
addq $0x20, %rsp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x22c0
movzbl 0x48(%rsp), %eax
imull 0xc(%rsp), %eax
movl %eax, %edi
callq 0x20e0
testq %rax, %rax
je 0x50b2
movq %rax, %r14
cmpl $0x0, 0x8(%rsp)
jle 0x5057
xorl %eax, %eax
leaq 0x38(%rsp), %r12
movl %eax, %ebp
movq %r12, %rdi
movq %r14, %rsi
callq 0x4a0d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21e0
incl %ebp
movl %ebp, %eax
cmpl 0x8(%rsp), %ebp
jl 0x5035
movq %rbx, %rdi
movq %r15, %rsi
callq 0x20b0
leaq 0x28(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2330
xorl %eax, %eax
movl %eax, %edx
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2080
movq %r14, %rdi
callq 0x21b0
leaq 0x38(%rsp), %rdi
callq 0x49b4
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x24fd
callq 0x2522
callq 0x2547