// File: /workspace/github_c_makefile_star2_O1/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, %r14
leaq 0xbd0(%rip), %rdi       # 0x422d
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x1210
movq %rax, 0x8(%rsp)
movq 0x2960(%rip), %rsi      # 0x5fd8
movl $0xc8, %edx
movq %rax, %rdi
callq 0x10d0
movq %rax, %rdi
callq 0x1100
testl %eax, %eax
jne 0x3842
leaq 0xbad(%rip), %rsi       # 0x4249
movq %rbx, %rdi
callq 0x11c0
testq %rax, %rax
je 0x3847
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x1140
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x11a0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x1170
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x1070
cmpb $0x6, %al
jne 0x384c
movl %ebp, %eax
decl %eax
cmpl $0x3, %eax
ja 0x376b
leaq 0xa2e(%rip), %rcx       # 0x4130
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rdi
movsd 0x950(%rip), %xmm0      # 0x4068
movl $0x1, %esi
movaps %xmm0, %xmm1
callq 0x1080
movq 0x8(%rsp), %rdi
callq 0x1190
jmp 0x376b
movq 0x8(%rsp), %rdi
movsd 0x92a(%rip), %xmm0      # 0x4068
movl $0x1, %esi
movaps %xmm0, %xmm1
callq 0x1080
jmp 0x376b
movq 0x8(%rsp), %rdi
callq 0x1190
movq 0x8(%rsp), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
movl $0x1, %edx
callq 0x1160
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x11b0
movl %eax, %r15d
movl %eax, 0x8(%r14)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x1200
movl %eax, %r12d
movl %eax, 0xc(%r14)
movl %ebp, 0x10(%r14)
movzbl %bpl, %eax
imull %r15d, %eax
movl %eax, %ebp
movslq %r12d, %r15
movq %r15, %rdi
imulq %rbp, %rdi
callq 0x1150
movq %rax, %r13
movq %rax, (%r14)
movq %r15, %rdi
shlq $0x3, %rdi
callq 0x1150
testq %r13, %r13
je 0x3851
testq %rax, %rax
je 0x3851
movq %rax, %r15
testl %r12d, %r12d
jle 0x37fe
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 0x37e9
leaq 0x8(%rsp), %r12
movq (%r12), %rdi
movq %r15, %rsi
callq 0x1050
xorl %eax, %eax
movl %eax, %edx
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x1180
movq %r15, %rdi
callq 0x1040
movq %rbx, %rdi
callq 0x10c0
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1230
callq 0x129f
callq 0x1255
callq 0x127a