// File: /workspace/github_c_makefile_star2_O3/maandree[P]libkeccak/test.c
// Function: test_state
static int
test_state(struct libkeccak_spec *restrict spec)
{
	struct libkeccak_state *restrict state;
	struct libkeccak_state *restrict state2;
	size_t marshal_size, marshalled_size, i, n;
	char *restrict marshalled_data;

	state = libkeccak_state_create(spec);
	if (!state) {
		perror("libkeccak_state_initialise");
		return -1;
	}

	n = state->mlen / 2;
	for (i = 0; i < n; i++)
		state->M[state->mptr++] = (unsigned char)i;

	state2 = libkeccak_state_duplicate(state);
	if (!state2) {
		perror("libkeccak_state_duplicate");
		return -1;
	}

	if (state->M[state->mptr - 1] != state2->M[state2->mptr - 1]) {
		printf("Inconsistency found between original state and duplicate state.\n");
		return -1;
	}

	marshal_size = libkeccak_state_marshal(state2, NULL);
	marshalled_data = malloc(marshal_size);
	if (!marshalled_data) {
		perror("malloc");
		return -1;
	}

	marshalled_size = libkeccak_state_marshal(state2, marshalled_data);
	if (marshalled_size != marshal_size) {
		printf("libkeccak_state_marshal returned an unexpected value.\n");
		return -1;
	}

	libkeccak_state_free(state);

	state = malloc(sizeof(struct libkeccak_state));
	if (!state) {
		perror("malloc");
		return -1;
	}
	marshalled_size = libkeccak_state_unmarshal(state, marshalled_data);
	if (!marshalled_size) {
		perror("libkeccak_state_unmarshal");
		return -1;
	}
	if (marshalled_size != marshal_size) {
		printf("libkeccak_state_unmarshal returned an unexpected value.\n");
		return -1;
	}

	if (libkeccak_state_unmarshal(NULL, marshalled_data) != marshal_size) {
		printf("libkeccak_state_unmarshal(NULL, .) returned an unexpected value.\n");
		return -1;
	}

	if (state->M[state->mptr - 1] != state2->M[state2->mptr - 1]) {
		printf("Inconsistency found between original state and unmarshalled state.\n");
		return -1;
	}

	free(marshalled_data);
	libkeccak_state_free(state);
	libkeccak_state_free(state2);
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
callq 0x90f8
testq %rax, %rax
je 0x1977
movq %rax, %r14
movq 0x110(%rax), %rax
cmpq $0x2, %rax
jb 0x17ff
shrq %rax
movq 0x108(%r14), %rcx
leaq 0x1(%rcx), %rdx
addq 0x118(%r14), %rcx
xorl %esi, %esi
leaq (%rdx,%rsi), %rdi
movq %rdi, 0x108(%r14)
movb %sil, (%rcx,%rsi)
incq %rsi
cmpq %rsi, %rax
jne 0x17e8
movq %r14, %rdi
callq 0x9138
testq %rax, %rax
je 0x1980
movq %rax, %rbx
movq 0x108(%r14), %rax
movq 0x118(%r14), %rcx
movb -0x1(%rcx,%rax), %al
movq 0x108(%rbx), %rcx
movq 0x118(%rbx), %rdx
cmpb -0x1(%rdx,%rcx), %al
jne 0x195c
movq %rbx, %rdi
xorl %esi, %esi
callq 0x9194
movq %rax, %r12
movq %rax, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1992
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9194
cmpq %r12, %rax
jne 0x1965
movq %r14, %rdi
callq 0x9304
movq 0x118(%r14), %rdi
callq 0x1030
movq $0x0, 0x118(%r14)
movq %r14, %rdi
callq 0x1030
movl $0x120, %edi            # imm = 0x120
callq 0x10e0
testq %rax, %rax
je 0x1992
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x9238
testq %rax, %rax
je 0x19bc
cmpq %r12, %rax
jne 0x196e
xorl %edi, %edi
movq %r15, %rsi
callq 0x9238
cmpq %r12, %rax
jne 0x1989
movq 0x108(%r14), %rax
movq 0x118(%r14), %rcx
movb -0x1(%rcx,%rax), %al
movq 0x108(%rbx), %rcx
movq 0x118(%rbx), %rdx
cmpb -0x1(%rdx,%rcx), %al
jne 0x199b
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x9304
movq 0x118(%r14), %rdi
callq 0x1030
xorl %r15d, %r15d
movq %r15, 0x118(%r14)
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x9304
movq 0x118(%rbx), %rdi
callq 0x1030
movq %r15, 0x118(%rbx)
movq %rbx, %rdi
callq 0x1030
jmp 0x19ad
leaq 0xf695(%rip), %rdi      # 0x10ff8
jmp 0x19a2
leaq 0xf656(%rip), %rdi      # 0x10fc2
jmp 0x19a2
leaq 0xf615(%rip), %rdi      # 0x10f8a
jmp 0x19a2
leaq 0x87fe(%rip), %rdi      # 0xa17c
jmp 0x19c3
leaq 0x8810(%rip), %rdi      # 0xa197
jmp 0x19c3
leaq 0xf5b9(%rip), %rdi      # 0x10f49
jmp 0x19a2
leaq 0x8818(%rip), %rdi      # 0xa1b1
jmp 0x19c3
leaq 0xf564(%rip), %rdi      # 0x10f06
callq 0x1060
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x87f5(%rip), %rdi      # 0xa1b8
callq 0x1120
jmp 0x19a7