// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rsi
leaq 0xf5fd(%rip), %rdi      # 0x14103
movb $0x0, %al
callq 0x1060
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x7, %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, %rdi
callq 0x10c0
movq %rax, -0x150(%rbp)
cmpq $0x0, -0x150(%rbp)
jne 0x4b54
leaq 0x8756(%rip), %rdi      # 0xd299
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d3c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x7, %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, %rdi
shlq %rdi
addq $0x1, %rdi
callq 0x10c0
movq %rax, -0x158(%rbp)
cmpq $0x0, -0x158(%rbp)
jne 0x4ba2
leaq 0x8708(%rip), %rdi      # 0xd299
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d3c
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x10f0
movl %eax, -0x160(%rbp)
cmpl $0x0, -0x160(%rbp)
jge 0x4bd6
leaq 0xf56b(%rip), %rdi      # 0x14130
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d3c
movl -0x160(%rbp), %edi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x150(%rbp), %r8
leaq -0x148(%rbp), %rsi
callq 0xbf70
cmpl $0x0, %eax
je 0x4c1f
leaq 0xf532(%rip), %rdi      # 0x14135
callq 0x1100
movl -0x160(%rbp), %edi
callq 0x1080
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d3c
movq -0x158(%rbp), %rdi
movq -0x150(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x7, %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, %rdx
callq 0xbe30
movq -0x158(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x10a0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x15c(%rbp)
movl -0x15c(%rbp), %edx
leaq 0x9c68(%rip), %rax      # 0xe8e3
leaq 0x9c5e(%rip), %rcx      # 0xe8e0
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x168(%rbp)
cmpl $0x0, -0x15c(%rbp)
je 0x4ca9
leaq 0x9065(%rip), %rax      # 0xdd05
movq %rax, -0x170(%rbp)
jmp 0x4cb7
movq -0x158(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x168(%rbp), %rsi
movq -0x170(%rbp), %rdx
leaq 0x9c0e(%rip), %rdi      # 0xe8da
movb $0x0, %al
callq 0x1060
cmpl $0x0, -0x15c(%rbp)
jne 0x4d01
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x9bf0(%rip), %rdi      # 0xe8ea
movb $0x0, %al
callq 0x1060
movl -0x160(%rbp), %edi
callq 0x1080
movq -0x150(%rbp), %rdi
callq 0x1030
movq -0x158(%rbp), %rdi
callq 0x1030
leaq -0x148(%rbp), %rdi
callq 0xaf90
movl -0x15c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax,%rax)