#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ keccak_absorb(scalar_t__ *, int, unsigned char const *,
                                 unsigned long long, int);
int /*<<< orphan*/ keccak_squeezeblocks(unsigned char *, int, scalar_t__ *,
                                        int);
void shake256(unsigned char *output, unsigned long long outputByteLen,
              const unsigned char *input, unsigned long long inputByteLen) {
  unsigned long long i;
  uint64_t s[25];
  unsigned char d[136];
  for (i = 0; i < 25; i++)
    s[i] = 0;
  keccak_absorb(s, 136, input, inputByteLen, 0x1F);
  keccak_squeezeblocks(output, outputByteLen / 136, s, 136);
  output += (outputByteLen / 136) * 136;
  if (outputByteLen % 136) {
    keccak_squeezeblocks(d, 1, s, 136);
    for (i = 0; i < outputByteLen % 136; i++) {
      output[i] = d[i];
    }
  }
}


x86 assembly (clang, -O0):
<shake256>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x19,-0x28(%rbp)
jae    116f <shake256+0x4f>
mov    -0x28(%rbp),%rax
movq   $0x0,-0xf0(%rbp,%rax,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1143 <shake256+0x23>
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x88,%esi
mov    $0x1f,%r8d
call   1040 <keccak_absorb@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0x88,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,%esi
lea    -0xf0(%rbp),%rdx
mov    $0x88,%ecx
call   1030 <keccak_squeezeblocks@plt>
mov    -0x10(%rbp),%rax
mov    $0x88,%ecx
xor    %edx,%edx
div    %rcx
imul   $0x88,%rax,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x88,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
je     1262 <shake256+0x142>
lea    -0x180(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
mov    $0x1,%esi
mov    $0x88,%ecx
call   1030 <keccak_squeezeblocks@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x88,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x188(%rbp),%rax
cmp    %rdx,%rax
jae    125d <shake256+0x13d>
mov    -0x28(%rbp),%rax
mov    -0x180(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    120d <shake256+0xed>
jmp    1262 <shake256+0x142>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shake256>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movq   $0x0,0xc0(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x88,%esi
mov    $0x1f,%r8d
call   1050 <keccak_absorb@plt>
movabs $0xf0f0f0f0f0f0f0f1,%rcx
f0 f0 f0
mov    %r12,%rax
mul    %rcx
mov    %rdx,%rbx
shr    $0x7,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    $0x88,%ecx
call   1030 <keccak_squeezeblocks@plt>
mov    %rbx,%rax
shl    $0x7,%rax
lea    (%rax,%rbx,8),%rax
sub    %rax,%r12
je     1217 <shake256+0xe7>
add    %rax,%r14
lea    0xd0(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x88,%ecx
call   1030 <keccak_squeezeblocks@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1040 <memcpy@plt>
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @shake256(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca [25 x i64]
%11 = alloca [136 x i8]
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i64 0, i64* %9
br label %12
12: ; preds = %18, %4
%13 = load i64, i64* %9
%14 = icmp ult i64 %13, 25
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i64, i64* %9
%17 = getelementptr inbounds [25 x i64], [25 x i64]* %10, i64 0, i64 %16
store i64 0, i64* %17
br label %18
18: ; preds = %15
%19 = load i64, i64* %9
%20 = add i64 %19, 1
store i64 %20, i64* %9
br label %12
21: ; preds = %12
%22 = getelementptr inbounds [25 x i64], [25 x i64]* %10, i64 0, i64 0
%23 = load i8*, i8** %7
%24 = load i64, i64* %8
%25 = call i32 @keccak_absorb(i64* %22, i32 136, i8* %23, i64 %24, i32 31)
%26 = load i8*, i8** %5
%27 = load i64, i64* %6
%28 = udiv i64 %27, 136
%29 = trunc i64 %28 to i32
%30 = getelementptr inbounds [25 x i64], [25 x i64]* %10, i64 0, i64 0
%31 = call i32 @keccak_squeezeblocks(i8* %26, i32 %29, i64* %30, i32 136)
%32 = load i64, i64* %6
%33 = udiv i64 %32, 136
%34 = mul i64 %33, 136
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 %34
store i8* %36, i8** %5
%37 = load i64, i64* %6
%38 = urem i64 %37, 136
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %60
40: ; preds = %21
%41 = getelementptr inbounds [136 x i8], [136 x i8]* %11, i64 0, i64 0
%42 = getelementptr inbounds [25 x i64], [25 x i64]* %10, i64 0, i64 0
%43 = call i32 @keccak_squeezeblocks(i8* %41, i32 1, i64* %42, i32 136)
store i64 0, i64* %9
br label %44
44: ; preds = %56, %40
%45 = load i64, i64* %9
%46 = load i64, i64* %6
%47 = urem i64 %46, 136
%48 = icmp ult i64 %45, %47
br i1 %48, label %49, label %59
49: ; preds = %44
%50 = load i64, i64* %9
%51 = getelementptr inbounds [136 x i8], [136 x i8]* %11, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = load i8*, i8** %5
%54 = load i64, i64* %9
%55 = getelementptr inbounds i8, i8* %53, i64 %54
store i8 %52, i8* %55
br label %56
56: ; preds = %49
%57 = load i64, i64* %9
%58 = add i64 %57, 1
store i64 %58, i64* %9
br label %44
59: ; preds = %44
br label %60
60: ; preds = %59, %21
ret void
}

LLVM IR (-O2):
define void @shake256(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca [25 x i64]
%6 = bitcast [25 x i64]* %5 to i8*
%7 = alloca [136 x i8]
%8 = getelementptr inbounds [136 x i8], [136 x i8]* %7, i64 0, i64 0
%9 = getelementptr inbounds [25 x i64], [25 x i64]* %5, i64 0, i64 0
%10 = call i32 @keccak_absorb(i64* %9, i32 136, i8* %2, i64 %3, i32 31)
%11 = udiv i64 %1, 136
%12 = trunc i64 %11 to i32
%13 = call i32 @keccak_squeezeblocks(i8* %0, i32 %12, i64* %9, i32 136)
%14 = urem i64 %1, 136
%15 = icmp eq i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %4
%17 = mul nuw i64 %11, 136
%18 = getelementptr i8, i8* %0, i64 %17
%19 = getelementptr inbounds [136 x i8], [136 x i8]* %7, i64 0, i64 0
%20 = call i32 @keccak_squeezeblocks(i8* %8, i32 1, i64* %9, i32 136)
br label %21
21: ; preds = %16, %4
ret void
}