// File: /workspace/github_c_makefile_star2_O2/ender672[P]liboil/benchmark.c
// Function: main
int main(int argc, char *argv[])
{
	clock_t t;
	size_t i, num_spaces;
	int iterations;
	char *end;

	enum oil_colorspace spaces[] = {
		OIL_CS_G,
		OIL_CS_GA,
		OIL_CS_RGB,
		OIL_CS_RGBX,
		OIL_CS_RGBA,
		OIL_CS_CMYK,
	};

	char *space_names[] = {
		"G",
		"GA",
		"RGB",
		"RGBX",
		"RGBA",
		"CMYK",
	};

	if (argc < 2 || argc > 3) {
		fprintf(stderr, "Usage: %s <path> [colorspace]\n", argv[0]);
		return 1;
	}

	iterations = 100;
	if (getenv("OILITERATIONS")) {
		iterations = strtoul(getenv("OILITERATIONS"), &end, 10);
		if (!end) {
			fprintf(stderr, "Invalid environment variable OILITERATIONS.");
			return 1;
		}
	}
	fprintf(stderr, "Iterations: %d\n", iterations);

	t = clock();
	oil_global_init();
	t = clock() - t;
	printf("global init: %6.2fms\n", time_to_ms(t));

	num_spaces = sizeof(spaces)/sizeof(spaces[0]);
	if (argc == 2) {
		for (i=0; i<num_spaces; i++) {
			do_bench_sizes(space_names[i], argv[1], spaces[i], iterations);
		}
		return 0;
	}

	for (i=0; i<num_spaces; i++) {
		if (strcmp(space_names[i], argv[2]) == 0) {
			break;
		}
	}

	if (i >= num_spaces) {
		fprintf(stderr, "Colorspace not recognized.\n");
		return 1;
	}

	do_bench_sizes(space_names[i], argv[1], spaces[i], iterations);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r15d
leal -0x4(%r15), %eax
cmpl $-0x3, %eax
ja 0x3510
movq 0x2af6(%rip), %rax      # 0x5ff0
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0xc8b(%rip), %rsi       # 0x4192
xorl %eax, %eax
callq 0x1120
jmp 0x355b
leaq 0xc9a(%rip), %rdi       # 0x41b1
callq 0x1030
testq %rax, %rax
jne 0x3527
pushq $0x64
popq %r14
jmp 0x3567
movq %rsp, %r12
pushq $0xa
popq %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x11c0
cmpq $0x0, (%r12)
jne 0x3564
movq 0x2aaa(%rip), %rax      # 0x5ff0
movq (%rax), %rcx
leaq 0xc6f(%rip), %rdi       # 0x41bf
pushq $0x2b
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
pushq $0x1
popq %r15
jmp 0x363d
movq %rax, %r14
movq 0x2a82(%rip), %rax      # 0x5ff0
movq (%rax), %rdi
leaq 0xc73(%rip), %rsi       # 0x41eb
movl %r14d, %edx
xorl %eax, %eax
callq 0x1120
callq 0x10b0
movq %rax, %r12
callq 0x130c
callq 0x10b0
subq %r12, %rax
cvtsi2sd %rax, %xmm0
divsd 0xb5c(%rip), %xmm0      # 0x4100
leaq 0xc50(%rip), %rdi       # 0x41fb
movb $0x1, %al
callq 0x10e0
cmpl $0x2, %r15d
jne 0x35f0
leaq 0x27d1(%rip), %r12      # 0x5d90
xorl %r15d, %r15d
leaq 0xb77(%rip), %r13       # 0x4140
xorl %ebp, %ebp
cmpq $0x18, %rbp
je 0x363d
movq (%r12), %rdi
movq 0x8(%rbx), %rsi
movl (%rbp,%r13), %edx
movl %r14d, %ecx
callq 0x31d1
addq $0x4, %rbp
addq $0x8, %r12
jmp 0x35cb
movq 0x10(%rbx), %r15
leaq 0x2795(%rip), %r13      # 0x5d90
xorl %ebp, %ebp
cmpq $0x18, %rbp
je 0x364f
movq (%r13), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1110
testl %eax, %eax
je 0x3620
addq $0x4, %rbp
addq $0x8, %r13
jmp 0x35fd
movq 0x8(%rbx), %rsi
leaq 0xb15(%rip), %rax       # 0x4140
movl (%rbp,%rax), %edx
movq %r12, %rdi
movl %r14d, %ecx
callq 0x31d1
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x299a(%rip), %rax      # 0x5ff0
movq (%rax), %rcx
leaq 0xbb1(%rip), %rdi       # 0x4211
pushq $0x1b
jmp 0x3552