// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0xafd0
cmpl $0x0, %eax
je 0x5108
leaq 0x812c(%rip), %rdi      # 0xd223
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5334
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 0x514f
leaq 0x815b(%rip), %rdi      # 0xd299
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5334
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 0x519d
leaq 0x810d(%rip), %rdi      # 0xd299
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5334
movq -0x20(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1050
movq -0x168(%rbp), %rsi
movq %rax, %rdx
leaq -0x148(%rbp), %rdi
callq 0x6970
cmpl $0x0, %eax
je 0x51e4
leaq 0xebf1(%rip), %rdi      # 0x13dc4
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5334
movq -0x18(%rbp), %r8
movq -0x150(%rbp), %r9
leaq -0x148(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x7900
cmpl $0x0, %eax
je 0x5222
leaq 0x96b8(%rip), %rdi      # 0xe8c9
callq 0x1100
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5334
leaq -0x148(%rbp), %rdi
callq 0xaf90
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 0x9659(%rip), %rax      # 0xe8e3
leaq 0x964f(%rip), %rcx      # 0xe8e0
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x170(%rbp)
cmpl $0x0, -0x15c(%rbp)
je 0x52b8
leaq 0x8a56(%rip), %rax      # 0xdd05
movq %rax, -0x178(%rbp)
jmp 0x52c6
movq -0x158(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x170(%rbp), %rsi
movq -0x178(%rbp), %rdx
leaq 0x95ff(%rip), %rdi      # 0xe8da
movb $0x0, %al
callq 0x1060
cmpl $0x0, -0x15c(%rbp)
jne 0x5310
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x95e1(%rip), %rdi      # 0xe8ea
movb $0x0, %al
callq 0x1060
movq -0x150(%rbp), %rdi
callq 0x1030
movq -0x158(%rbp), %rdi
callq 0x1030
movl -0x15c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq