// File: /workspace/github_c_makefile_star2_O1/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 0x8a1c
testq %rax, %rax
je 0x1c08
movq %rax, %r14
movq 0x110(%rax), %rax
cmpq $0x2, %rax
jb 0x1a90
shrq %rax
xorl %ecx, %ecx
movq 0x108(%r14), %rdx
movq 0x118(%r14), %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, 0x108(%r14)
movb %cl, (%rsi,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x1a6c
movq %r14, %rdi
callq 0x8a5c
testq %rax, %rax
je 0x1c11
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 0x1bed
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8ac4
movq %rax, %r12
movq %rax, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1c23
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8ac4
cmpq %r12, %rax
jne 0x1bf6
movq %r14, %rdi
callq 0x8c98
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 0x1c23
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x8b9c
testq %rax, %rax
je 0x1c4d
cmpq %r12, %rax
jne 0x1bff
xorl %edi, %edi
movq %r15, %rsi
callq 0x8b9c
cmpq %r12, %rax
jne 0x1c1a
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 0x1c2c
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x8c98
movq 0x118(%r14), %rdi
callq 0x1030
xorl %r15d, %r15d
movq %r15, 0x118(%r14)
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x8c98
movq 0x118(%rbx), %rdi
callq 0x1030
movq %r15, 0x118(%rbx)
movq %rbx, %rdi
callq 0x1030
jmp 0x1c3e
leaq 0xf404(%rip), %rdi      # 0x10ff8
jmp 0x1c33
leaq 0xf3c5(%rip), %rdi      # 0x10fc2
jmp 0x1c33
leaq 0xf384(%rip), %rdi      # 0x10f8a
jmp 0x1c33
leaq 0x856d(%rip), %rdi      # 0xa17c
jmp 0x1c54
leaq 0x857f(%rip), %rdi      # 0xa197
jmp 0x1c54
leaq 0xf328(%rip), %rdi      # 0x10f49
jmp 0x1c33
leaq 0x8587(%rip), %rdi      # 0xa1b1
jmp 0x1c54
leaq 0xf2d3(%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 0x8564(%rip), %rdi      # 0xa1b8
callq 0x1120
jmp 0x1c38