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

/* Variables and functions */
int /*<<< orphan*/ keccak_absorb(int /*<<< orphan*/ *, int,
                                 int /*<<< orphan*/ const *, size_t, int);
int /*<<< orphan*/ keccak_squeezeblocks(int /*<<< orphan*/ *, int,
                                        int /*<<< orphan*/ *, int);
void sha3_256(uint8_t *output, const uint8_t *input, size_t inlen) {
  uint64_t s[25];
  uint8_t t[136];
  keccak_absorb(s, 136, input, inlen, 0x06);
  keccak_squeezeblocks(t, 1, s, 136);
  for (size_t i = 0; i < 32; i++) {
    output[i] = t[i];
  }
}


x86 assembly (clang, -O0):
<sha3_256>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x88,%esi
mov    $0x6,%r8d
call   1040 <keccak_absorb@plt>
lea    -0x2a0(%rbp),%rdi
lea    -0x80(%rbp),%rdx
mov    $0x1,%esi
mov    $0x88,%ecx
call   1030 <keccak_squeezeblocks@plt>
movq   $0x0,-0x2a8(%rbp)
cmpq   $0x20,-0x2a8(%rbp)
20
jae    11b9 <sha3_256+0x99>
mov    -0x2a8(%rbp),%rax
mov    -0x2a0(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x2a8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2a8(%rbp)
jmp    1178 <sha3_256+0x58>
add    $0x2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha3_256>:
push   %r14
push   %rbx
sub    $0x288,%rsp
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0x220(%rsp),%r14
mov    %r14,%rdi
mov    $0x88,%esi
mov    $0x6,%r8d
call   1040 <keccak_absorb@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    $0x88,%ecx
call   1030 <keccak_squeezeblocks@plt>
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
movaps 0x30(%rsp),%xmm3
movups %xmm0,(%rbx)
movups %xmm1,0x10(%rbx)
movups %xmm2,0x20(%rbx)
movups %xmm3,0x30(%rbx)
movaps 0x40(%rsp),%xmm0
movups %xmm0,0x40(%rbx)
movaps 0x50(%rsp),%xmm0
movups %xmm0,0x50(%rbx)
movaps 0x60(%rsp),%xmm0
movups %xmm0,0x60(%rbx)
movaps 0x70(%rsp),%xmm0
movups %xmm0,0x70(%rbx)
add    $0x288,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @sha3_256(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca [25 x i32]
%8 = alloca [136 x i32]
%9 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%10 = getelementptr inbounds [25 x i32], [25 x i32]* %7, i64 0, i64 0
%11 = load i32*, i32** %5
%12 = load i64, i64* %6
%13 = call i32 @keccak_absorb(i32* %10, i32 136, i32* %11, i64 %12, i32 6)
%14 = getelementptr inbounds [136 x i32], [136 x i32]* %8, i64 0, i64 0
%15 = getelementptr inbounds [25 x i32], [25 x i32]* %7, i64 0, i64 0
%16 = call i32 @keccak_squeezeblocks(i32* %14, i32 1, i32* %15, i32 136)
store i64 0, i64* %9
br label %17
17: ; preds = %27, %3
%18 = load i64, i64* %9
%19 = icmp ult i64 %18, 32
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i64, i64* %9
%22 = getelementptr inbounds [136 x i32], [136 x i32]* %8, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = load i32*, i32** %4
%25 = load i64, i64* %9
%26 = getelementptr inbounds i32, i32* %24, i64 %25
store i32 %23, i32* %26
br label %27
27: ; preds = %20
%28 = load i64, i64* %9
%29 = add i64 %28, 1
store i64 %29, i64* %9
br label %17
30: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @sha3_256(i32* nocapture writeonly %0, i32* %1, i64 %2) {
%4 = bitcast i32* %0 to i8*
%5 = alloca [25 x i32]
%6 = alloca [136 x i32]
%7 = bitcast [136 x i32]* %6 to i8*
%8 = bitcast [25 x i32]* %5 to i8*
%9 = getelementptr inbounds [25 x i32], [25 x i32]* %5, i64 0, i64 0
%10 = call i32 @keccak_absorb(i32* %9, i32 136, i32* %1, i64 %2, i32 6)
%11 = getelementptr inbounds [136 x i32], [136 x i32]* %6, i64 0, i64 0
%12 = call i32 @keccak_squeezeblocks(i32* %11, i32 1, i32* %9, i32 136)
ret void
}