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

	if (state->key_ipad) {
		if (libkeccak_fast_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_fast_update(&state->sponge, msg, msglen);

	if (msglen != state->buffer_size) {
		new = realloc(state->buffer, msglen);
		if (!new)
			return -1;
		state->buffer = new;
		state->buffer_size = msglen;
	}

	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);

	return libkeccak_fast_update(&state->sponge, state->buffer, msglen);
}

// 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 0x9298
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 0x2210
cmpl $0x0, %eax
jge 0x9259
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x942e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x7, %rax
cmpq $0x0, %rax
je 0x928c
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 0x92a6
cmpq $0x0, -0x20(%rbp)
jne 0x92b2
movl $0x0, -0x4(%rbp)
jmp 0x942e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x7, %rax
cmpq $0x0, %rax
jne 0x92e1
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x2210
movl %eax, -0x4(%rbp)
jmp 0x942e
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x140(%rcx), %rax
je 0x933b
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x21e0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x931d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x942e
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x140(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x7, %rax
movl %eax, -0x3c(%rbp)
movl $0x8, %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movq $0x1, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x93b3
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
sarl %cl, %eax
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rdx
movzbl (%rcx,%rdx), %edx
movl -0x3c(%rbp), %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rax
movq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x935d
movq -0x10(%rbp), %rax
movzbl 0x148(%rax), %eax
movl -0x3c(%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 -0x3c(%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 -0x40(%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 0x2210
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)