// File: /workspace/github_c_makefile_star2_O0/maandree[P]libkeccak/benchmark.c
// Function: main
int
main(void)
{
	char message[MESSAGE_LEN];
	struct libkeccak_spec spec;
	struct libkeccak_state state;
	char hashsum[OUTPUT / 8];
#ifndef IGNORE_BEHEXING
	char hexsum[OUTPUT / 8 * 2 + 1];
#endif
	struct timespec start, end;
	long int i, r;
	int fd;
	ssize_t got;
	size_t ptr;

	/* Fill message with content from the file. */
	fd = open(MESSAGE_FILE, O_RDONLY);
	if (fd < 0) {
		perror("open");
		return 1;
	}
	for (ptr = 0; ptr < MESSAGE_LEN; ptr += (size_t)got) {
		got = read(fd, message, MESSAGE_LEN - ptr);
		if (got <= 0) {
			perror("read");
			close(fd);
			return 1;
		}
	}
	close(fd);

	/* Initialise state. */
	spec.bitrate = BITRATE;
	spec.capacity = CAPACITY;
	spec.output = OUTPUT;
	if (libkeccak_state_initialise(&state, &spec)) {
		perror("libkeccak_state_initialise");
		return 1;
	}

	/* Get start-time. */
	if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start) < 0) {
		perror("clock_gettime");
		return 1;
	}

	/* Run benchmarking loop. */
	for (r = 0; r < RERUNS; r++) {
		/* Updates. */
#if UPDATE_RUNS > 0
		for (i = 0; i < UPDATE_RUNS; i++) {
			if (libkeccak_fast_update(&state, message, MESSAGE_LEN) < 0) {
				perror("libkeccak_update");
				return 1;
			}
		}
#endif

		/* Digest. */
		if (libkeccak_fast_digest(&state, NULL, 0, 0, NULL, hashsum) < 0) {
			perror("libkeccak_digest");
			return 1;
		}
#ifndef IGNORE_BEHEXING
		libkeccak_behex_lower(hexsum, hashsum, OUTPUT / 8);
#endif

		/* Fast squeezes. */
#if FAST_SQUEEZE_RUNS > 0
		libkeccak_fast_squeeze(&state, FAST_SQUEEZE_RUNS);
#endif

		/* Slow squeezes. */
#if SLOW_SQUEEZE_RUNS > 0
		for (i = 0; i < SLOW_SQUEEZE_RUNS; i++) {
			libkeccak_squeeze(&state, hashsum);
# ifndef IGNORE_BEHEXING
			libkeccak_behex_lower(hexsum, hashsum, OUTPUT / 8);
# endif
		}
#endif
	}

	/* Get end-time. */
	if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end) < 0) {
		perror("clock_gettime");
		return -1;
	}

	/* Print execution-time. */
	end.tv_sec -= start.tv_sec;
	end.tv_nsec -= start.tv_nsec;
	if (end.tv_nsec < 0) {
		end.tv_sec--;
		end.tv_nsec += 1000000000L;
	}
	printf("%03li%09li\n", (long)(end.tv_sec), end.tv_nsec);

	/* Release resources and exit. */
	libkeccak_state_fast_destroy(&state);
	return 0;

#if (UPDATE_RUNS == 0) && (SLOW_SQUEEZE_RUNS == 0)
	(void) i;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc510, %rsp           # imm = 0xC510
movl $0x0, -0x4(%rbp)
leaq 0x5deb(%rip), %rdi      # 0x7004
xorl %esi, %esi
movb $0x0, %al
callq 0x10e0
movl %eax, -0xc4f4(%rbp)
cmpl $0x0, -0xc4f4(%rbp)
jge 0x1249
leaq 0x5dd6(%rip), %rdi      # 0x700e
callq 0x10f0
movl $0x1, -0x4(%rbp)
jmp 0x1560
movq $0x0, -0xc508(%rbp)
cmpq $0xc350, -0xc508(%rbp) # imm = 0xC350
jae 0x12cc
movl -0xc4f4(%rbp), %edi
leaq -0xc360(%rbp), %rsi
movl $0xc350, %edx           # imm = 0xC350
subq -0xc508(%rbp), %rdx
callq 0x1090
movq %rax, -0xc500(%rbp)
cmpq $0x0, -0xc500(%rbp)
jg 0x12b3
leaq 0x5d7c(%rip), %rdi      # 0x7013
callq 0x10f0
movl -0xc4f4(%rbp), %edi
callq 0x1080
movl $0x1, -0x4(%rbp)
jmp 0x1560
jmp 0x12b5
movq -0xc500(%rbp), %rax
addq -0xc508(%rbp), %rax
movq %rax, -0xc508(%rbp)
jmp 0x1254
movl -0xc4f4(%rbp), %edi
callq 0x1080
movq $0x80, -0xc378(%rbp)
movq $0x48, -0xc370(%rbp)
movq $0x40, -0xc368(%rbp)
leaq -0xc498(%rbp), %rdi
leaq -0xc378(%rbp), %rsi
callq 0x65f0
cmpl $0x0, %eax
je 0x1328
leaq 0x5d01(%rip), %rdi      # 0x7018
callq 0x10f0
movl $0x1, -0x4(%rbp)
jmp 0x1560
movl $0x2, %edi
leaq -0xc4d0(%rbp), %rsi
callq 0x1040
cmpl $0x0, %eax
jge 0x1356
leaq 0x5cee(%rip), %rdi      # 0x7033
callq 0x10f0
movl $0x1, -0x4(%rbp)
jmp 0x1560
movq $0x0, -0xc4f0(%rbp)
cmpq $0x32, -0xc4f0(%rbp)
jge 0x14a3
movq $0x0, -0xc4e8(%rbp)
cmpq $0x64, -0xc4e8(%rbp)
jge 0x13cf
leaq -0xc360(%rbp), %rsi
leaq -0xc498(%rbp), %rdi
movl $0xc350, %edx           # imm = 0xC350
callq 0x2860
cmpl $0x0, %eax
jge 0x13b9
leaq 0x5c99(%rip), %rdi      # 0x7041
callq 0x10f0
movl $0x1, -0x4(%rbp)
jmp 0x1560
jmp 0x13bb
movq -0xc4e8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc4e8(%rbp)
jmp 0x137a
leaq -0xc4a0(%rbp), %r9
leaq -0xc498(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
movq %r8, %rdx
movq %r8, %rcx
callq 0x35d0
cmpl $0x0, %eax
jge 0x140d
leaq 0x5c56(%rip), %rdi      # 0x7052
callq 0x10f0
movl $0x1, -0x4(%rbp)
jmp 0x1560
leaq -0xc4c0(%rbp), %rdi
leaq -0xc4a0(%rbp), %rsi
movl $0x8, %edx
callq 0x6870
leaq -0xc498(%rbp), %rdi
movl $0x64, %esi
callq 0x3da0
movq $0x0, -0xc4e8(%rbp)
cmpq $0x64, -0xc4e8(%rbp)
jge 0x148a
leaq -0xc4a0(%rbp), %rsi
leaq -0xc498(%rbp), %rdi
callq 0x3df0
leaq -0xc4c0(%rbp), %rdi
leaq -0xc4a0(%rbp), %rsi
movl $0x8, %edx
callq 0x6870
movq -0xc4e8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc4e8(%rbp)
jmp 0x1441
jmp 0x148c
movq -0xc4f0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc4f0(%rbp)
jmp 0x1361
movl $0x2, %edi
leaq -0xc4e0(%rbp), %rsi
callq 0x1040
cmpl $0x0, %eax
jge 0x14d1
leaq 0x5b73(%rip), %rdi      # 0x7033
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1560
movq -0xc4d0(%rbp), %rcx
movq -0xc4e0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xc4e0(%rbp)
movq -0xc4c8(%rbp), %rcx
movq -0xc4d8(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xc4d8(%rbp)
cmpq $0x0, -0xc4d8(%rbp)
jge 0x1531
movq -0xc4e0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xc4e0(%rbp)
movq -0xc4d8(%rbp), %rax
addq $0x3b9aca00, %rax       # imm = 0x3B9ACA00
movq %rax, -0xc4d8(%rbp)
movq -0xc4e0(%rbp), %rsi
movq -0xc4d8(%rbp), %rdx
leaq 0x5b1d(%rip), %rdi      # 0x7063
movb $0x0, %al
callq 0x1060
leaq -0xc498(%rbp), %rdi
callq 0x65b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc510, %rsp           # imm = 0xC510
popq %rbp
retq
nopl (%rax)