// File: /workspace/github_c_makefile_star2_O0/maandree[P]libkeccak/hmac/libkeccak_hmac_update.c
// Function: libkeccak_hmac_update
int
libkeccak_hmac_update(struct libkeccak_hmac_state *restrict state, const void *restrict msg_, size_t msglen)
{
	const unsigned char *restrict msg = msg_;
	size_t i;
	int n, cn, r;

	if (state->key_ipad) {
		if (libkeccak_update(&state->sponge, state->key_ipad, state->key_length >> 3) < 0)
			return -1;
		if (state->key_length & 7)
			state->leftover = state->key_ipad[state->key_length >> 3];
		state->key_ipad = NULL;
	}

	if (!msg || !msglen)
		return 0;

	if (!(state->key_length & 7))
		return libkeccak_update(&state->sponge, msg, msglen);

	if (msglen != state->buffer_size) {
		free(state->buffer);
		state->buffer = malloc(state->buffer_size = msglen);
		if (!state->buffer)
			return -1;
	}

	n = (int)(state->key_length & 7);
	cn = 8 - n;
	for (i = 1; i < msglen; i++)
		state->buffer[i] = (unsigned char)((msg[i - 1] >> cn) | (msg[i] << n));
	state->buffer[0] = (unsigned char)((state->leftover & ((1 << n) - 1)) | (msg[0] << n));
	state->leftover = (unsigned char)(msg[msglen - 1] >> cn);

	r = libkeccak_update(&state->sponge, state->buffer, msglen);
	my_explicit_bzero(state->buffer, msglen);
	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x9a88
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
shrq $0x3, %rdx
callq 0x21d0
cmpl $0x0, %eax
jge 0x9a49
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9c3d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x7, %rax
cmpq $0x0, %rax
je 0x9a7c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
shrq $0x3, %rcx
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x148(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x9a96
cmpq $0x0, -0x20(%rbp)
jne 0x9aa2
movl $0x0, -0x4(%rbp)
jmp 0x9c3d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x7, %rax
cmpq $0x0, %rax
jne 0x9ad1
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x21d0
movl %eax, -0x4(%rbp)
jmp 0x9c3d
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x140(%rcx), %rax
je 0x9b30
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rdi
callq 0x2040
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rdi, 0x140(%rax)
callq 0x21c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x138(%rax)
jne 0x9b2e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9c3d
jmp 0x9b30
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x7, %rax
movl %eax, -0x34(%rbp)
movl $0x8, %eax
subl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movq $0x1, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x9ba8
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %eax
movl -0x38(%rbp), %ecx
sarl %cl, %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
movzbl (%rcx,%rdx), %edx
movl -0x34(%rbp), %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rax
movq -0x30(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x9b52
movq -0x10(%rbp), %rax
movzbl 0x148(%rax), %eax
movl -0x34(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
subl $0x1, %ecx
andl %ecx, %eax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %edx
movl -0x34(%rbp), %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %eax
movl -0x38(%rbp), %ecx
sarl %cl, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x148(%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x21d0
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x9c50
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)