// File: /workspace/github_c_makefile_star2_O3/maandree[P]libkeccak/test.c
// Function: test_file
static int
test_file(const struct libkeccak_spec *restrict spec, const char *restrict suffix,
          const char *restrict filename, const char *restrict expected_answer)
{
	struct libkeccak_state state;
	unsigned char *restrict hashsum;
	char *restrict hexsum;
	int ok, fd;

	printf("Testing libkeccak_generalised_sum_fd on %s: ", filename);

	hashsum = malloc((size_t)((spec->output + 7) / 8));
	if (!hashsum) {
		perror("malloc");
		return -1;
	}
	hexsum = malloc((size_t)((spec->output + 7) / 8 * 2 + 1));
	if (!hexsum) {
		perror("malloc");
		return -1;
	}

	fd = open(filename, O_RDONLY);
	if (fd < 0) {
		perror("open");
		return -1;
	}

	if (libkeccak_generalised_sum_fd(fd, &state, spec, suffix, hashsum)) {
		perror("libkeccak_generalised_sum_fd");
		close(fd);
		return -1;
	}

	libkeccak_behex_lower(hexsum, hashsum, (size_t)((spec->output + 7) / 8));
	ok = !strcmp(hexsum, expected_answer);
	printf("%s%s\n", ok ? "OK" : "Fail: ", ok ? "" : hexsum);
	if (!ok)
		printf("  r, c, n = %li, %li, %li\n", spec->bitrate, spec->capacity, spec->output);

	close(fd);
	free(hashsum);
	free(hexsum);
	libkeccak_state_fast_destroy(&state);
	return ok - 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %rbx
leaq 0xcbbf(%rip), %rdi      # 0x10e1e
leaq 0x5dfd(%rip), %rsi      # 0xa063
xorl %eax, %eax
callq 0x1080
movq 0x10(%rbx), %r15
leaq 0x7(%r15), %rax
addq $0xe, %r15
testq %rax, %rax
cmovnsq %rax, %r15
sarq $0x3, %r15
movq %r15, %rdi
callq 0x10e0
testq %rax, %rax
je 0x439a
movq %rax, %r14
leaq 0x1(,%r15,2), %rdi
callq 0x10e0
testq %rax, %rax
je 0x439a
movq %rax, %r15
leaq 0x5dab(%rip), %rdi      # 0xa063
xorl %esi, %esi
xorl %eax, %eax
callq 0x1110
testl %eax, %eax
js 0x43a3
movl %eax, %ebp
leaq 0xc475(%rip), %rcx      # 0x10747
leaq 0x8(%rsp), %rsi
movl %eax, %edi
movq %rbx, %rdx
movq %r14, %r8
callq 0x9640
testl %eax, %eax
jne 0x43b1
movq 0x10(%rbx), %rdx
leaq 0x7(%rdx), %rax
addq $0xe, %rdx
testq %rax, %rax
cmovnsq %rax, %rdx
sarq $0x3, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x95c8
leaq 0x5d58(%rip), %rsi      # 0xa06d
movq %r15, %rdi
callq 0x10c0
movl %eax, %r13d
testl %eax, %eax
leaq 0x73be(%rip), %rax      # 0xb6e7
leaq 0xcbce(%rip), %rsi      # 0x10efe
cmovneq %rax, %rsi
leaq 0x67d1(%rip), %rdx      # 0xab0c
cmovneq %r15, %rdx
leaq 0x739b(%rip), %rdi      # 0xb6e1
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x1080
testl %r13d, %r13d
je 0x436e
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
leaq 0x7387(%rip), %rdi      # 0xb6ee
xorl %eax, %eax
callq 0x1080
movl %ebp, %edi
callq 0x10a0
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq 0x120(%rsp), %rdi
callq 0x1030
negl %r13d
sbbl %r12d, %r12d
jmp 0x43ca
leaq 0x5e10(%rip), %rdi      # 0xa1b1
jmp 0x43aa
leaq 0xcaa1(%rip), %rdi      # 0x10e4b
callq 0x1120
jmp 0x43c4
leaq 0xca98(%rip), %rdi      # 0x10e50
callq 0x1120
movl %ebp, %edi
callq 0x10a0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq