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

	if (libkeccak_state_initialise(&state, spec)) {
		perror("libkeccak_state_initialise");
		return -1;
	}
	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;
	}

	if (libkeccak_update(&state, msg, strlen(msg))) {
		perror("libkeccak_update");
		return -1;
	}
	if (libkeccak_digest(&state, NULL, 0, 0, suffix, hashsum)) {
		perror("libkeccak_digest");
		return -1;
	}
	libkeccak_state_fast_destroy(&state);

	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);

	free(hashsum);
	free(hexsum);

	return ok - 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x8fb8
testl %eax, %eax
jne 0x47d6
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 0x47cd
movq %rax, %r14
leaq 0x1(,%r15,2), %rdi
callq 0x10e0
testq %rax, %rax
je 0x47cd
movq %rax, %r15
movq %r13, %rdi
callq 0x1070
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x699d
testl %eax, %eax
jne 0x47df
leaq 0xc042(%rip), %r8       # 0x10747
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r9
callq 0x85c5
testl %eax, %eax
jne 0x47e8
movq 0x120(%rsp), %rdi
callq 0x1030
movq $0x0, 0x120(%rsp)
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
movq %r15, %rdi
movq %r12, %rsi
callq 0x10c0
movl %eax, %r12d
testl %eax, %eax
leaq 0x6f75(%rip), %rax      # 0xb6e7
leaq 0xc785(%rip), %rsi      # 0x10efe
cmovneq %rax, %rsi
leaq 0x6388(%rip), %rdx      # 0xab0c
cmovneq %r15, %rdx
leaq 0x6f52(%rip), %rdi      # 0xb6e1
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1080
testl %r12d, %r12d
je 0x47b6
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
leaq 0x6f3f(%rip), %rdi      # 0xb6ee
xorl %eax, %eax
callq 0x1080
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
negl %r12d
sbbl %ebp, %ebp
jmp 0x47f9
leaq 0x59dd(%rip), %rdi      # 0xa1b1
jmp 0x47ef
leaq 0x599f(%rip), %rdi      # 0xa17c
jmp 0x47ef
leaq 0xc363(%rip), %rdi      # 0x10b49
jmp 0x47ef
leaq 0x6ee1(%rip), %rdi      # 0xb6d0
callq 0x1120
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq