// File: /workspace/github_c_makefile_star2_O2/maandree[P]libkeccak/digest.c
// Function: libkeccak_fast_digest
int
libkeccak_fast_digest(struct libkeccak_state *restrict state, const void *restrict msg_, size_t msglen,
                      size_t bits, const char *restrict suffix, void *restrict hashsum)
{
	const unsigned char *restrict msg = msg_;
	auto unsigned char *restrict new;
	register long int rr = state->r >> 3;
	auto size_t suffix_len = suffix ? __builtin_strlen(suffix) : 0;
	register size_t ext;
	register long int i;

	if (!msg) {
		msglen = 0;
		bits = 0;
	} else {
		msglen += bits >> 3;
		bits &= 7;
	}

	ext = msglen + ((bits + suffix_len + 7) >> 3) + (size_t)rr;
	if (__builtin_expect(state->mptr + ext > state->mlen, 0)) {
		state->mlen += ext;
		new = realloc(state->M, state->mlen * sizeof(char));
		if (!new) {
			state->mlen -= ext;
			return -1;
		}
		state->M = new;
	}

	if (msglen)
		__builtin_memcpy(state->M + state->mptr, msg, msglen * sizeof(char));
	state->mptr += msglen;

	if (bits)
		state->M[state->mptr] = msg[msglen] & (unsigned char)((1 << bits) - 1);
	if (__builtin_expect(!!suffix_len, 1)) {
		if (!bits)
			state->M[state->mptr] = 0;
		while (suffix_len--) {
			state->M[state->mptr] |= (unsigned char)((*suffix++ & 1) << bits++);
			if (bits == 8) {
				bits = 0;
				state->M[++(state->mptr)] = 0;
			}
		}
	}
	if (bits)
		state->mptr++;

	state->mptr = libkeccak_pad10star1((size_t)state->r, state->M, state->mptr, bits);
	libkeccak_absorption_phase(state, state->M, state->mptr);

	if (hashsum) {
		libkeccak_squeezing_phase(state, rr, (state->n + 7) >> 3, state->w >> 3, hashsum);
	} else {
		for (i = (state->n - 1) / state->r; i--;)
			libkeccak_f(state);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r12
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r8
movq %rdi, %rbx
movq 0xc8(%rdi), %rax
sarq $0x3, %rax
movq %rax, 0x10(%rsp)
testq %r12, %r12
movq %r9, 0x20(%rsp)
je 0x3d93
movq %r12, %rdi
movq %r8, %r14
callq 0x1050
movq %r14, %r8
movq %rax, %r13
jmp 0x3d96
xorl %r13d, %r13d
movq %rbp, %r14
shrq $0x3, %r14
addq %r15, %r14
andl $0x7, %ebp
testq %r8, %r8
movq %rbp, 0x8(%rsp)
cmoveq %r8, %rbp
cmoveq %r8, %r14
leaq 0x7(,%r13), %rsi
addq %rbp, %rsi
shrq $0x3, %rsi
addq %r14, %rsi
addq 0x10(%rsp), %rsi
movq 0x108(%rbx), %r15
movq 0x110(%rbx), %rcx
leaq (%rsi,%r15), %rax
cmpq %rcx, %rax
ja 0x3f3d
testq %r14, %r14
je 0x3e07
movq 0x118(%rbx), %rdi
addq %r15, %rdi
movq %r8, %rsi
movq %r14, %rdx
movq %r8, (%rsp)
callq 0x10a0
movq (%rsp), %r8
addq %r14, %r15
movq %r15, 0x108(%rbx)
testq %rbp, %rbp
je 0x3e34
movb $-0x1, %dl
movl %ebp, %ecx
shlb %cl, %dl
notb %dl
andb (%r8,%r14), %dl
movq 0x118(%rbx), %rax
movb %dl, (%rax,%r15)
testq %r13, %r13
jne 0x3e45
jmp 0x3e9f
testq %r13, %r13
je 0x3ea9
movq 0x118(%rbx), %rax
movb $0x0, (%rax,%r15)
xorl %edx, %edx
cmpq %rdx, %r13
je 0x3e8e
movzbl (%r12,%rdx), %edi
andl $0x1, %edi
leaq 0x1(%rbp), %rsi
movl %ebp, %ecx
shll %cl, %edi
movq 0x108(%rbx), %rcx
orb %dil, (%rax,%rcx)
cmpq $0x8, %rsi
jne 0x3e86
movq 0x108(%rbx), %rcx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x108(%rbx)
movb $0x0, 0x1(%rax,%rcx)
xorl %esi, %esi
incq %rdx
movq %rsi, %rbp
jmp 0x3e47
movq 0x108(%rbx), %r15
testq %rbp, %rbp
je 0x3ea9
movq %rbp, 0x8(%rsp)
incq %r15
movq 0x8(%rsp), %rcx
jmp 0x3eab
xorl %ecx, %ecx
movq 0xc8(%rbx), %rdi
movq 0x118(%rbx), %r14
movq %r14, %rsi
movq %r15, %rdx
callq 0x27b5
movq %rax, 0x108(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x175a
movq 0xd8(%rbx), %rdx
movq 0x20(%rsp), %r8
testq %r8, %r8
je 0x3f1b
addq $0x7, %rdx
sarq $0x3, %rdx
movq 0xe8(%rbx), %rcx
sarq $0x3, %rcx
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x1110
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %rdx
movq %rdx, %rax
cqto
idivq 0xc8(%rbx)
movq %rax, %r14
subq $0x1, %r14
jb 0x3f0a
movq %rbx, %rdi
callq 0x285b
jmp 0x3f2d
movq %r8, (%rsp)
movq %rcx, 0x18(%rsp)
addq %rcx, %rsi
movq %rsi, 0x110(%rbx)
movq 0x118(%rbx), %rdi
callq 0x10c0
testq %rax, %rax
je 0x3f71
movq %rax, 0x118(%rbx)
movq (%rsp), %r8
jmp 0x3de5
movq 0x18(%rsp), %rax
movq %rax, 0x110(%rbx)
pushq $-0x1
popq %rax
jmp 0x3f0c