// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %rbp
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %rdx
movq %rdi, %rbx
movq 0xc8(%rdi), %rax
movq %rax, 0x20(%rsp)
sarq $0x3, %rax
movq %rax, 0x28(%rsp)
testq %r8, %r8
je 0x4ff0
movq %rbp, %rdi
movq %rdx, %r15
callq 0x1050
movq %r15, %rdx
movq %rax, %r15
jmp 0x4ff3
xorl %r15d, %r15d
movq %r13, %r12
shrq $0x3, %r12
addq %r14, %r12
andl $0x7, %r13d
testq %rdx, %rdx
movq %r13, %r14
cmoveq %rdx, %r14
cmoveq %rdx, %r12
leaq (%r14,%r15), %rsi
addq $0x7, %rsi
shrq $0x3, %rsi
addq %r12, %rsi
addq 0x28(%rsp), %rsi
movq 0x108(%rbx), %r9
movq 0x110(%rbx), %rcx
leaq (%rsi,%r9), %rax
cmpq %rcx, %rax
ja 0x52bc
testq %r12, %r12
je 0x506c
movq 0x118(%rbx), %rdi
addq %r9, %rdi
movq %rdx, %rsi
movq %rdx, 0x10(%rsp)
movq %r12, %rdx
movq %r9, 0x18(%rsp)
callq 0x10a0
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %r9
addq %r12, %r9
movq %r9, 0x108(%rbx)
testq %r14, %r14
je 0x50a5
movb $-0x1, %sil
movl %r14d, %ecx
shlb %cl, %sil
notb %sil
andb (%rdx,%r12), %sil
movq 0x118(%rbx), %r12
movb %sil, (%r12,%r9)
testq %r15, %r15
movq 0x20(%rsp), %rdi
jne 0x50ba
jmp 0x512d
testq %r15, %r15
je 0x530f
movq 0x118(%rbx), %r12
movb $0x0, (%r12,%r9)
decq %r15
xorl %eax, %eax
movzbl (%rbp,%rax), %edx
andl $0x1, %edx
leaq 0x1(%r14), %r13
movl %r14d, %ecx
shll %cl, %edx
movq 0x108(%rbx), %rcx
orb %dl, (%r12,%rcx)
cmpq $0x8, %r13
je 0x50e8
cmpq %rax, %r15
jne 0x510c
jmp 0x5114
movq 0x108(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x108(%rbx)
movb $0x0, 0x1(%r12,%rcx)
cmpq %rax, %r15
je 0x51b6
xorl %r13d, %r13d
incq %rax
movq %r13, %r14
jmp 0x50bf
movq 0xc8(%rbx), %rdi
movq 0x108(%rbx), %r9
movq 0x118(%rbx), %r12
movb (%r12,%r9), %sil
movl $0x1, %r8d
movl %r13d, %ecx
shll %cl, %r8d
leaq (,%r9,8), %rax
orq %r13, %rax
xorl %edx, %edx
divq %rdi
orb %sil, %r8b
leaq -0x8(%rdi), %rcx
cmpq %rdx, %rcx
seta %al
leaq -0x2(%rdi), %rsi
cmpq %rsi, %rdx
seta %dl
orb %al, %dl
je 0x51a4
leaq 0x1(%r9), %rsi
leaq 0x8(,%r9,8), %rax
xorl %edx, %edx
divq %rdi
leaq (%rcx,%r9,8), %r14
addq $0x8, %r14
subq %rdx, %r14
shrq $0x3, %r14
leaq (%r12,%r9), %rdi
incq %rdi
movb %r8b, -0x1(%rdi)
movq %r14, %rdx
subq %rsi, %rdx
xorl %esi, %esi
callq 0x1070
movb $-0x80, %r8b
movq %r14, %r9
jmp 0x51a8
addb $-0x80, %r8b
movq 0x8(%rsp), %r14
movb %r8b, (%r12,%r9)
jmp 0x523a
movq 0xc8(%rbx), %rdi
movq 0x108(%rbx), %r9
movq 0x118(%rbx), %r12
leaq (,%r9,8), %rax
xorl %edx, %edx
divq %rdi
leaq -0x8(%rdi), %rcx
cmpq %rdx, %rcx
setbe %sil
leaq -0x2(%rdi), %rax
cmpq %rax, %rdx
setbe %dl
movb $-0x7f, %al
testb %dl, %sil
jne 0x5231
leaq 0x1(%r9), %rsi
leaq 0x8(,%r9,8), %rax
xorl %edx, %edx
divq %rdi
leaq (%rcx,%r9,8), %r14
addq $0x8, %r14
subq %rdx, %r14
shrq $0x3, %r14
leaq (%r12,%r9), %rdi
incq %rdi
movb $0x1, -0x1(%rdi)
movq %r14, %rdx
subq %rsi, %rdx
xorl %esi, %esi
callq 0x1070
movb $-0x80, %al
movq %r14, %r9
movq 0x8(%rsp), %r14
movb %al, (%r12,%r9)
incq %r9
movq %r9, 0x108(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r9, %rdx
callq 0x16d2
movq 0xd8(%rbx), %rdx
testq %r14, %r14
je 0x5285
addq $0x7, %rdx
sarq $0x3, %rdx
movq 0xe8(%rbx), %rcx
sarq $0x3, %rcx
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq %r14, %r8
callq 0x1110
xorl %ebp, %ebp
jmp 0x52ab
decq %rdx
movq %rdx, %rax
cqto
idivq 0xc8(%rbx)
xorl %ebp, %ebp
testq %rax, %rax
je 0x52ab
movq %rax, %r14
movq %rbx, %rdi
callq 0x3a32
decq %r14
jne 0x529e
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, 0x10(%rsp)
movq %r9, 0x18(%rsp)
movq %rcx, 0x30(%rsp)
addq %rcx, %rsi
movq %rsi, 0x110(%rbx)
movq 0x118(%rbx), %rdi
callq 0x10c0
testq %rax, %rax
je 0x52fc
movq %rax, 0x118(%rbx)
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %rdx
jmp 0x503e
movq 0x30(%rsp), %rax
movq %rax, 0x110(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x52ab
movq 0x20(%rsp), %rdi
jmp 0x51c4