// File: /workspace/github_c_makefile_star2_O1/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 0xc922(%rip), %rdi      # 0x10e1e
leaq 0x5b60(%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 0x4643
movq %rax, %r14
leaq 0x1(,%r15,2), %rdi
callq 0x10e0
testq %rax, %rax
je 0x4643
movq %rax, %r15
leaq 0x5b0e(%rip), %rdi      # 0xa063
xorl %esi, %esi
xorl %eax, %eax
callq 0x1110
testl %eax, %eax
js 0x464c
movl %eax, %ebp
leaq 0xc1d8(%rip), %rcx      # 0x10747
leaq 0x8(%rsp), %rsi
movl %eax, %edi
movq %rbx, %rdx
movq %r14, %r8
callq 0x8fdc
testl %eax, %eax
jne 0x465a
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 0x8f64
leaq 0x5abb(%rip), %rsi      # 0xa06d
movq %r15, %rdi
callq 0x10c0
movl %eax, %r13d
testl %eax, %eax
leaq 0x7121(%rip), %rax      # 0xb6e7
leaq 0xc931(%rip), %rsi      # 0x10efe
cmovneq %rax, %rsi
leaq 0x6534(%rip), %rdx      # 0xab0c
cmovneq %r15, %rdx
leaq 0x70fe(%rip), %rdi      # 0xb6e1
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x1080
testl %r13d, %r13d
je 0x460b
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
leaq 0x70ea(%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
movq $0x0, 0x120(%rsp)
negl %r13d
sbbl %r12d, %r12d
jmp 0x4673
leaq 0x5b67(%rip), %rdi      # 0xa1b1
jmp 0x4653
leaq 0xc7f8(%rip), %rdi      # 0x10e4b
callq 0x1120
jmp 0x466d
leaq 0xc7ef(%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