// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
leaq 0x1528(%rip), %rdi      # 0x7188
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x2230
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq 0x4362(%rip), %rsi      # 0x9fe0
movl $0xc8, %edx
callq 0x21e0
movq %rax, %rdi
callq 0x2090
cmpl $0x0, %eax
je 0x5cb7
movq 0x434c(%rip), %rax      # 0x9fe8
movq (%rax), %rdi
leaq 0x14e9(%rip), %rsi      # 0x718f
movb $0x0, %al
callq 0x2360
movl $0x1, %edi
callq 0x20c0
movq -0x30(%rbp), %rdi
callq 0x2250
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x22c0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x21c0
movq -0x30(%rbp), %rdi
callq 0x22a0
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2190
movq -0x30(%rbp), %rdi
callq 0x2140
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x21b0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2120
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x22f0
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %edi
movl -0x24(%rbp), %esi
leaq -0x14(%rbp), %rdx
leaq -0x18(%rbp), %rcx
callq 0x33c0
leaq 0x143f(%rip), %rdi      # 0x7188
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x2370
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2250
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x22c0
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl -0x14(%rbp), %ecx
movl -0x18(%rbp), %r8d
leaq -0xd0(%rbp), %rdi
callq 0x55a0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x5dbc
movq 0x4247(%rip), %rax      # 0x9fe8
movq (%rax), %rdi
leaq 0x13f9(%rip), %rsi      # 0x71a4
movb $0x0, %al
callq 0x2360
movl $0x1, %edi
callq 0x20c0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2130
movb %al, -0x49(%rbp)
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movzbl -0x49(%rbp), %r9d
movl $0x8, %r8d
xorl %eax, %eax
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x2350
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x22b0
movl -0x14(%rbp), %eax
movl -0xc0(%rbp), %ecx
andl $0xff, %ecx
imull %ecx, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x20d0
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
jne 0x5e5e
movq 0x41a5(%rip), %rax      # 0x9fe8
movq (%rax), %rdi
leaq 0x1357(%rip), %rsi      # 0x71a4
movb $0x0, %al
callq 0x2360
movl $0x1, %edi
callq 0x20c0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x5e9b
movq -0xd8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x5920
movq -0x38(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x21d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5e65
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x20a0
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2320
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2080
movq -0xd8(%rbp), %rdi
callq 0x21a0
leaq -0xd0(%rbp), %rdi
callq 0x5870
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)