// File: /workspace/github_c_makefile_star2_O0/maandree[P]libkeccak/hmac/libkeccak_hmac_set_key.c
// Function: libkeccak_hmac_set_key
int
libkeccak_hmac_set_key(struct libkeccak_hmac_state *restrict state, const void *restrict key, size_t key_length)
{
	size_t i, size, new_key_length, key_bytes;
	void *new;

	size = (size_t)(state->sponge.r) > key_length ? (size_t)(state->sponge.r) : key_length;
	new_key_length = size;
	size = (size + 7) >> 3;
	key_bytes = (key_length + 7) >> 3;

	if (size != key_bytes) {
		new = realloc(state->key_opad, 2 * size);
		if (!new)
			return -1;
		state->key_opad = new;
		state->key_ipad = state->key_opad + size;
	}

	memcpy(state->key_opad, key, key_bytes);
	if (key_length & 7)
		state->key_opad[(key_bytes >> 3) - 1] &= (unsigned char)((1 << (key_length & 7)) - 1);

	if ((size_t)(state->sponge.r) > key_length)
		__builtin_memset(state->key_opad + key_bytes, 0, size - key_bytes);

	for (i = 0; i < size; i++) {
		state->key_ipad[i] = state->key_opad[i] ^ HMAC_INNER_PAD;
		state->key_opad[i] ^= HMAC_OUTER_PAD;
	}

	state->key_length = new_key_length;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
cmpq -0x20(%rbp), %rax
jbe 0x9686
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x968e
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x9710
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
shlq %rsi
callq 0x21e0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x96f2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x97fb
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x2180
movq -0x20(%rbp), %rax
andq $0x7, %rax
cmpq $0x0, %rax
je 0x9765
movq -0x20(%rbp), %rax
andq $0x7, %rax
movl %eax, %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movzbl %al, %esi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
shrq $0x3, %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %edx
andl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
cmpq -0x20(%rbp), %rax
jbe 0x9790
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rdx
subq -0x40(%rbp), %rdx
xorl %esi, %esi
callq 0x2120
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x97e8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
xorl $0x36, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl $0x5c, %edx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x9798
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop