// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq %r8, %r12
movq %rcx, %rbp
movq %rsi, %r14
movq %rdi, %rbx
movq 0xc8(%rdi), %rax
sarq $0x3, %rax
movq %rax, (%rsp)
testq %r8, %r8
movq %r9, 0x10(%rsp)
je 0x4a82
movq %r12, %rdi
movq %rdx, %r15
callq 0x1050
movq %r15, %rdx
movq %rax, %r13
jmp 0x4a85
xorl %r13d, %r13d
movq %rbp, %r15
shrq $0x3, %r15
addq %rdx, %r15
andl $0x7, %ebp
testq %r14, %r14
cmoveq %r14, %rbp
movq %r14, 0x8(%rsp)
cmoveq %r14, %r15
leaq 0x7(,%r13), %r14
addq %rbp, %r14
shrq $0x3, %r14
addq %r15, %r14
addq (%rsp), %r14
movq 0x108(%rbx), %rax
addq %r14, %rax
movq 0x110(%rbx), %rsi
cmpq %rsi, %rax
ja 0x4ccf
testq %r15, %r15
movq 0x8(%rsp), %r14
je 0x4af5
movq 0x118(%rbx), %rdi
addq 0x108(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x10a0
movq 0x108(%rbx), %rax
addq %r15, %rax
movq %rax, 0x108(%rbx)
testq %rbp, %rbp
je 0x4b21
movb $-0x1, %dl
movl %ebp, %ecx
shlb %cl, %dl
notb %dl
andb (%r14,%r15), %dl
movq 0x118(%rbx), %rcx
movb %dl, (%rcx,%rax)
testq %r13, %r13
je 0x4cf6
testq %rbp, %rbp
jne 0x4b41
movq 0x108(%rbx), %rax
movq 0x118(%rbx), %rcx
movb $0x0, (%rcx,%rax)
xorl %eax, %eax
movzbl (%r12,%rax), %edx
andl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
leaq 0x1(%rbp), %rcx
movq 0x108(%rbx), %rsi
movq 0x118(%rbx), %rdi
orb %dl, (%rdi,%rsi)
cmpq $0x8, %rcx
jne 0x4b8a
movq 0x108(%rbx), %rcx
movq 0x118(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x108(%rbx)
movb $0x0, 0x1(%rdx,%rcx)
xorl %ecx, %ecx
incq %rax
movq %rcx, %rbp
cmpq %rax, %r13
jne 0x4b43
testq %rcx, %rcx
je 0x4ba1
incq 0x108(%rbx)
movq 0xc8(%rbx), %rsi
movq 0x108(%rbx), %r8
xorl %eax, %eax
testq %rcx, %rcx
setne %al
subq %rax, %r8
leaq (,%r8,8), %rax
orq %rcx, %rax
xorl %edx, %edx
divq %rsi
movq 0x118(%rbx), %r14
testq %rcx, %rcx
je 0x4be5
movl $0x1, %r9d
shll %cl, %r9d
orb (%r14,%r8), %r9b
jmp 0x4be8
movb $0x1, %r9b
leaq -0x8(%rsi), %rcx
cmpq %rdx, %rcx
seta %al
leaq -0x2(%rsi), %rdi
cmpq %rdi, %rdx
seta %dl
orb %al, %dl
je 0x4c40
leaq 0x1(%r8), %r10
leaq 0x8(,%r8,8), %rax
xorl %edx, %edx
divq %rsi
leaq (%rcx,%r8,8), %r15
addq $0x8, %r15
subq %rdx, %r15
shrq $0x3, %r15
leaq (%r14,%r8), %rdi
incq %rdi
movb %r9b, -0x1(%rdi)
movq %r15, %rdx
subq %r10, %rdx
xorl %esi, %esi
callq 0x1070
movb $-0x80, %r9b
movq %r15, %r8
jmp 0x4c44
addb $-0x80, %r9b
movb %r9b, (%r14,%r8)
incq %r8
movq %r8, 0x108(%rbx)
movq 0x118(%rbx), %rsi
movq %rbx, %rdi
movq %r8, %rdx
callq 0x1976
movq 0xd8(%rbx), %rdx
movq 0x10(%rsp), %r8
testq %r8, %r8
je 0x4c98
addq $0x7, %rdx
sarq $0x3, %rdx
movq 0xe8(%rbx), %rcx
sarq $0x3, %rcx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x1364
xorl %ebp, %ebp
jmp 0x4cbe
decq %rdx
movq %rdx, %rax
cqto
idivq 0xc8(%rbx)
xorl %ebp, %ebp
testq %rax, %rax
je 0x4cbe
movq %rax, %r14
movq %rbx, %rdi
callq 0x3519
decq %r14
jne 0x4cb1
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r14, %rsi
movq %rsi, 0x110(%rbx)
movq 0x118(%rbx), %rdi
callq 0x10c0
testq %rax, %rax
je 0x4cfe
movq %rax, 0x118(%rbx)
jmp 0x4ad2
movq %rbp, %rcx
jmp 0x4b95
subq %r14, 0x110(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4cbe