// File: /workspace/github_c_makefile_star2_O2/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 0xf7a(%rip), %rdi       # 0x422d
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x1200
movq %rax, %r15
movq %rax, 0x10(%rsp)
movq 0x2d07(%rip), %rsi      # 0x5fd8
movl $0xc8, %edx
movq %rax, %rdi
callq 0x10d0
movq %rax, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x3476
leaq 0xf54(%rip), %rsi       # 0x4249
movq %rbx, %rdi
callq 0x11b0
testq %rax, %rax
je 0x348b
movq %rax, %rbx
movq %r15, %rdi
callq 0x1130
movq %rax, %r12
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1190
movq %r15, %rdi
movq %r12, %rsi
callq 0x1160
movq %r15, %rdi
movq %r12, %rsi
callq 0x1070
cmpb $0x6, %al
jne 0x34a0
movl %ebp, %eax
decl %eax
cmpl $0x3, %eax
ja 0x33ab
leaq 0xdde(%rip), %rcx       # 0x4130
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x1
popq %rsi
movsd 0xd12(%rip), %xmm0      # 0x4078
movq %r15, %rdi
movaps %xmm0, %xmm1
callq 0x1080
movq %r15, %rdi
callq 0x1180
jmp 0x33ab
pushq $0x1
popq %rsi
movsd 0xcf2(%rip), %xmm0      # 0x4078
movq %r15, %rdi
movaps %xmm0, %xmm1
callq 0x1080
jmp 0x33ab
movq %r15, %rdi
callq 0x1180
pushq $0x1
popq %rdx
movq %r15, %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x1150
movq %rbx, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x11a0
movl %eax, %ebx
movl %eax, 0x8(%r14)
movq %r15, %rdi
movq %r12, %rsi
callq 0x11f0
movl %eax, %r13d
movl %eax, 0xc(%r14)
movl %ebp, 0x10(%r14)
movzbl %bpl, %eax
imull %ebx, %eax
movl %eax, %ebx
movslq %r13d, %rbp
movq %rbp, %rdi
imulq %rbx, %rdi
callq 0x1140
movq %rax, %r12
movq %rax, (%r14)
movq %rbp, %rdi
shlq $0x3, %rdi
callq 0x1140
testq %r12, %r12
je 0x34b5
testq %rax, %rax
je 0x34b5
movq %r12, %rcx
movq %rax, %r12
xorl %edx, %edx
testl %r13d, %r13d
cmovlel %edx, %r13d
movl %r13d, %eax
cmpq %rdx, %rax
je 0x3435
movq %rcx, (%r12,%rdx,8)
incq %rdx
addq %rbx, %rcx
jmp 0x3424
movq %r15, %rdi
movq %r12, %rsi
callq 0x1050
xorl %eax, %eax
movl %eax, %edx
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1170
movq %r12, %rdi
callq 0x1040
movq (%rsp), %rdi
callq 0x10c0
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b73(%rip), %rax      # 0x5ff0
movq (%rax), %rcx
leaq 0xdad(%rip), %rdi       # 0x4234
pushq $0x14
jmp 0x34c8
movq 0x2b5e(%rip), %rax      # 0x5ff0
movq (%rax), %rcx
leaq 0xdaf(%rip), %rdi       # 0x424b
pushq $0x15
jmp 0x34c8
movq 0x2b49(%rip), %rax      # 0x5ff0
movq (%rax), %rcx
leaq 0xdb0(%rip), %rdi       # 0x4261
pushq $0x1a
jmp 0x34c8
movq 0x2b34(%rip), %rax      # 0x5ff0
movq (%rax), %rcx
leaq 0xdb6(%rip), %rdi       # 0x427c
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
pushq $0x1
popq %rdi
callq 0x11d0