// File: /workspace/github_c_makefile_star2_O3/ender672[P]liboil/benchmark.c
// Function: png
static struct bench_image png(char *path, enum oil_colorspace cs)
{
	struct bench_image bench_image;
	int i;
	png_structp rpng;
	png_infop rinfo;
	FILE *input;
	size_t row_stride, buf_len;
	unsigned char **buf_ptrs;

	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);
	}

	input = fopen(path, "r");
	if (!input) {
		fprintf(stderr, "Unable to open file.\n");
		exit(1);
	}

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

	if (png_get_color_type(rpng, rinfo) != PNG_COLOR_TYPE_RGBA) {
		fprintf(stderr, "Input image must be RGBA.\n");
		exit(1);
	};

	switch(cs) {
	case OIL_CS_G:
		png_set_rgb_to_gray(rpng, 1, -1, -1);
		png_set_strip_alpha(rpng);
		break;
	case OIL_CS_GA:
		png_set_rgb_to_gray(rpng, 1, -1, -1);
		break;
	case OIL_CS_RGB:
		png_set_strip_alpha(rpng);
		break;
	case OIL_CS_RGBX:
		png_set_strip_alpha(rpng);
		png_set_filler(rpng, 0xffff, PNG_FILLER_AFTER);
		break;
	case OIL_CS_CMYK: /* Kind of cheating on CMYK by giving it RGBA */
	case OIL_CS_RGBA:
	case OIL_CS_UNKNOWN:
		break;
	}

	bench_image.width = png_get_image_width(rpng, rinfo);
	bench_image.height = png_get_image_height(rpng, rinfo);
	bench_image.cs = cs;

	row_stride = bench_image.width * OIL_CMP(cs);
	buf_len = (size_t)bench_image.height * row_stride;
	bench_image.buffer = malloc(buf_len);
	buf_ptrs = malloc(bench_image.height * sizeof(unsigned char *));
	if (!bench_image.buffer || !buf_ptrs) {
		fprintf(stderr, "Unable to allocate buffers.\n");
		exit(1);
	}

	for (i=0; i<bench_image.height; i++) {
		buf_ptrs[i] = bench_image.buffer + i * row_stride;
	}

	png_read_image(rpng, buf_ptrs);
	png_destroy_read_struct(&rpng, &rinfo, NULL);

	free(buf_ptrs);
	fclose(input);
	return bench_image;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0xaf0(%rip), %rdi       # 0x42cd
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x1210
movq %rax, %r14
movq %rax, 0x10(%rsp)
movq 0x27dd(%rip), %rsi      # 0x5fd8
movl $0xc8, %edx
movq %rax, %rdi
callq 0x10d0
movq %rax, %rdi
callq 0x1100
testl %eax, %eax
jne 0x39a7
leaq 0xaca(%rip), %rsi       # 0x42e9
movq %rbx, %rdi
callq 0x11c0
testq %rax, %rax
je 0x39ac
movq %rax, %rbx
movq %r14, %rdi
callq 0x1140
movq %rax, %r12
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11a0
movq %r14, %rdi
movq %r12, %rsi
callq 0x1170
movq %r14, %rdi
movq %r12, %rsi
callq 0x1070
cmpb $0x6, %al
jne 0x39b1
movl %ebp, %eax
decl %eax
cmpl $0x3, %eax
ja 0x38db
leaq 0x954(%rip), %rcx       # 0x41d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x7db(%rip), %xmm0      # 0x4068
movq %r14, %rdi
movl $0x1, %esi
movaps %xmm0, %xmm1
callq 0x1080
movq %r14, %rdi
callq 0x1190
jmp 0x38db
movsd 0x7b9(%rip), %xmm0      # 0x4068
movq %r14, %rdi
movl $0x1, %esi
movaps %xmm0, %xmm1
callq 0x1080
jmp 0x38db
movq %r14, %rdi
callq 0x1190
movq %r14, %rdi
movl $0xffff, %esi           # imm = 0xFFFF
movl $0x1, %edx
callq 0x1160
movq %rbx, (%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x11b0
movl %eax, %r13d
movl %eax, 0x8(%r15)
movq %r14, %rdi
movq %r12, %rsi
callq 0x1200
movl %eax, %r12d
movl %eax, 0xc(%r15)
movl %ebp, 0x10(%r15)
movzbl %bpl, %eax
imull %r13d, %eax
movl %eax, %ebp
movslq %r12d, %rbx
movq %rbx, %rdi
imulq %rbp, %rdi
callq 0x1150
movq %rax, %r13
movq %rax, (%r15)
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x1150
testq %r13, %r13
je 0x39b6
testq %rax, %rax
je 0x39b6
movq %rax, %r15
testl %r12d, %r12d
movq (%rsp), %rbx
jle 0x396a
movl %r12d, %r12d
movl %r12d, %eax
xorl %ecx, %ecx
movl %ecx, %edx
movq %r13, %rcx
movq %rcx, (%r15,%rdx,8)
movq %rdx, %rsi
incq %rsi
addq %rbp, %rcx
movq %rsi, %rdx
cmpq %rsi, %rax
jne 0x3955
movq %r14, %rdi
movq %r15, %rsi
callq 0x1050
xorl %eax, %eax
movl %eax, %edx
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1180
movq %r15, %rdi
callq 0x1040
movq %rbx, %rdi
callq 0x10c0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1230
callq 0x129f
callq 0x1255
callq 0x127a