#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 int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ cshake128_simple_absorb(int /*<<< orphan*/ *,
                                           int /*<<< orphan*/,
                                           unsigned char const *,
                                           unsigned long long);
int /*<<< orphan*/ keccak_squeezeblocks(unsigned char *, int,
                                        int /*<<< orphan*/ *, int);
void cshake128_simple(unsigned char *output, unsigned long long outlen,
                      uint16_t cstm, const unsigned char *in,
                      unsigned long long inlen) {
  uint64_t s[25];
  unsigned char t[168];
  unsigned int i;
  cshake128_simple_absorb(s, cstm, in, inlen);
  keccak_squeezeblocks(output, outlen / 168, s, 168);
  output += (outlen / 168) * 168;
  if (outlen % 168) {
    keccak_squeezeblocks(t, 1, s, 168);
    for (i = 0; i < outlen % 168; i++)
      output[i] = t[i];
  }
}


x86 assembly (clang, -O0):
<cshake128_simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <cshake128_simple_absorb@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0xa8,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,%esi
lea    -0x90(%rbp),%rdx
mov    $0xa8,%ecx
call   1030 <keccak_squeezeblocks@plt>
mov    -0x10(%rbp),%rax
mov    $0xa8,%ecx
xor    %edx,%edx
div    %rcx
imul   $0xa8,%rax,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa8,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
je     1234 <cshake128_simple+0x114>
lea    -0x140(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    $0x1,%esi
mov    $0xa8,%ecx
call   1030 <keccak_squeezeblocks@plt>
movl   $0x0,-0x144(%rbp)
mov    -0x144(%rbp),%eax
mov    %rax,-0x150(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa8,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x150(%rbp),%rax
cmp    %rdx,%rax
jae    122f <cshake128_simple+0x10f>
mov    -0x144(%rbp),%eax
mov    -0x140(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x144(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    11d6 <cshake128_simple+0xb6>
jmp    1234 <cshake128_simple+0x114>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cshake128_simple>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8,%rcx
call   1040 <cshake128_simple_absorb@plt>
mov    %rbx,%rax
shr    $0x3,%rax
movabs $0xc30c30c30c30c31,%rcx
c3 30 0c
mul    %rcx
mov    %rdx,%r12
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
mov    $0xa8,%ecx
call   1030 <keccak_squeezeblocks@plt>
imul   $0xa8,%r12,%rax
sub    %rax,%rbx
je     11b1 <cshake128_simple+0x91>
add    %rax,%r14
lea    0x70(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x1,%esi
mov    $0xa8,%ecx
call   1030 <keccak_squeezeblocks@plt>
xor    %eax,%eax
nopl   0x0(%rax)
movzbl 0x70(%rsp,%rax,1),%ecx
mov    %cl,(%r14,%rax,1)
add    $0x1,%eax
cmp    %rax,%rbx
ja     11a0 <cshake128_simple+0x80>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @cshake128_simple(i8* %0, i64 %1, i32 %2, i8* %3, i64 %4) {
%6 = alloca [25 x i32]
%7 = alloca [168 x i8]
%8 = bitcast [25 x i32]* %6 to i8*
%9 = getelementptr inbounds [168 x i8], [168 x i8]* %7, i64 0, i64 0
%10 = getelementptr inbounds [25 x i32], [25 x i32]* %6, i64 0, i64 0
%11 = call i32 @cshake128_simple_absorb(i32* %10, i32 %2, i8* %3, i64 %4)
%12 = udiv i64 %1, 168
%13 = trunc i64 %12 to i32
%14 = call i32 @keccak_squeezeblocks(i8* %0, i32 %13, i32* %10, i32 168)
%15 = mul nuw i64 %12, 168
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = urem i64 %1, 168
%18 = icmp eq i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %5
%20 = call i32 @keccak_squeezeblocks(i8* %9, i32 1, i32* %10, i32 168)
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ %27, %21 ], [ 0, %19 ]
%23 = getelementptr inbounds [168 x i8], [168 x i8]* %7, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %16, i64 %22
store i8 %24, i8* %25
%26 = add nuw nsw i64 %22, 1
%27 = and i64 %26, 4294967295
%28 = icmp ugt i64 %17, %27
br i1 %28, label %21, label %29
29: ; preds = %21, %5
ret void
}