// File: /workspace/github_c_makefile_star2_O0/maandree[P]libkeccak/hmac/libkeccak_hmac_unmarshal.c
// Function: libkeccak_hmac_unmarshal
size_t
libkeccak_hmac_unmarshal(struct libkeccak_hmac_state *restrict state, const void *restrict data_)
{
	const unsigned char *restrict data = data_;
	size_t parsed, size, i;

	state->key_opad = NULL;
	state->key_ipad = NULL;

	parsed = libkeccak_state_unmarshal(state ? &state->sponge : NULL, data);
	if (!parsed)
		return 0;
	data += parsed;

	__builtin_memcpy(&size, data, sizeof(size));
	data += sizeof(size_t);
	if (state)
		size = state->key_length;
	size = (state->key_length + 7) >> 3;

	if (state) {
		state->key_opad = malloc(2 * size);
		if (!state->key_opad) {
			libkeccak_state_destroy(&state->sponge);
			return 0;
		}
		memcpy(state->key_opad, data, size);
		data += size;

		if (data[0]) {
			state->key_ipad = &state->key_opad[size];
			memcpy(state->key_ipad, state->key_opad, size);
			for (i = 0; i < size; i++)
				state->key_ipad[i] ^= (char)(HMAC_OUTER_PAD ^ HMAC_INNER_PAD);
		}

		state->leftover = data[1];
		state->buffer = NULL;
		state->buffer_size = 0;
	}

	return parsed + sizeof(size_t) + size + 2 * sizeof(char);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x9854
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x40(%rbp)
jmp 0x985c
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x985c
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2270
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9881
movq $0x0, -0x8(%rbp)
jmp 0x99df
movq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x98b7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x99cb
movq -0x30(%rbp), %rdi
shlq %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x9910
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
callq 0x2130
movq $0x0, -0x8(%rbp)
jmp 0x99df
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x2180
movq -0x30(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x999c
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rdx
callq 0x2180
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x999a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl $0x6a, %edx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x996c
jmp 0x999c
movq -0x20(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x148(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x138(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x140(%rax)
movq -0x28(%rbp), %rax
addq $0x8, %rax
addq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)