#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
int bytes_to_ull(unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ shake256(unsigned char *, int, unsigned char *,
                            unsigned long long);
void hash_message(unsigned char *digest, uint64_t *tree, uint32_t *leaf_idx,
                  const unsigned char *R, const unsigned char *pk,
                  unsigned char *m, unsigned long long mlen) {
  unsigned char buf[(((9 * 30 + 7) / 8) + ((((60 / 20) * (20 - 1)) + 7) / 8) +
                     (((60 / 20) + 7) / 8))];
  unsigned char *bufp = buf;
  memcpy(m - 16 - (2 * 16), R, 16);
  memcpy(m - (2 * 16), pk, (2 * 16));
  shake256(buf,
           (((9 * 30 + 7) / 8) + ((((60 / 20) * (20 - 1)) + 7) / 8) +
            (((60 / 20) + 7) / 8)),
           m - 16 - (2 * 16), mlen + 16 + (2 * 16));
  memcpy(digest, bufp, ((9 * 30 + 7) / 8));
  bufp += ((9 * 30 + 7) / 8);
  *tree = bytes_to_ull(bufp, ((((60 / 20) * (20 - 1)) + 7) / 8));
  *tree &= (~(uint64_t)0) >> (64 - ((60 / 20) * (20 - 1)));
  bufp += ((((60 / 20) * (20 - 1)) + 7) / 8);
  *leaf_idx = bytes_to_ull(bufp, (((60 / 20) + 7) / 8));
  *leaf_idx &= (~(uint32_t)0) >> (32 - (60 / 20));
}


x86 assembly (clang, -O0):
<hash_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
add    $0xfffffffffffffff0,%rdi
add    $0xffffffffffffffe0,%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rdi
add    $0xffffffffffffffe0,%rdi
mov    -0x28(%rbp),%rsi
mov    $0x20,%edx
call   1030 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rdx
add    $0xfffffffffffffff0,%rdx
add    $0xffffffffffffffe0,%rdx
mov    0x10(%rbp),%rcx
add    $0x10,%rcx
add    $0x20,%rcx
mov    $0x2b,%esi
call   1050 <shake256@plt>
mov    -0x8(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    $0x22,%edx
call   1030 <memcpy@plt>
mov    -0x68(%rbp),%rax
add    $0x22,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x8,%esi
call   1040 <bytes_to_ull@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x68(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x1,%esi
call   1040 <bytes_to_ull@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
and    $0xffffffff,%ecx
mov    %ecx,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%rbx
mov    %r8,%r13
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x80(%rsp),%rbp
lea    -0x30(%r9),%r14
mov    %r14,%rdi
mov    %rcx,%rsi
mov    $0x10,%edx
call   1030 <memcpy@plt>
add    $0xffffffffffffffe0,%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x20,%edx
call   1030 <memcpy@plt>
add    $0x30,%rbp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2b,%esi
mov    %r14,%rdx
mov    %rbp,%rcx
call   1050 <shake256@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x22,%edx
call   1030 <memcpy@plt>
lea    0x32(%rsp),%rdi
mov    $0x8,%esi
call   1040 <bytes_to_ull@plt>
mov    %eax,(%r15)
lea    0x3a(%rsp),%rdi
mov    $0x1,%esi
call   1040 <bytes_to_ull@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hash_message(i8* %0, i32* %1, i32* %2, i8* %3, i8* %4, i8* %5, i64 %6) {
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca [43 x i8]
%16 = alloca i8*
store i8* %0, i8** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i64 %6, i64* %14
%17 = getelementptr inbounds [43 x i8], [43 x i8]* %15, i64 0, i64 0
store i8* %17, i8** %16
%18 = load i8*, i8** %13
%19 = getelementptr inbounds i8, i8* %18, i64 -16
%20 = getelementptr inbounds i8, i8* %19, i64 -32
%21 = load i8*, i8** %11
%22 = call i32 @memcpy(i8* %20, i8* %21, i32 16)
%23 = load i8*, i8** %13
%24 = getelementptr inbounds i8, i8* %23, i64 -32
%25 = load i8*, i8** %12
%26 = call i32 @memcpy(i8* %24, i8* %25, i32 32)
%27 = getelementptr inbounds [43 x i8], [43 x i8]* %15, i64 0, i64 0
%28 = load i8*, i8** %13
%29 = getelementptr inbounds i8, i8* %28, i64 -16
%30 = getelementptr inbounds i8, i8* %29, i64 -32
%31 = load i64, i64* %14
%32 = add i64 %31, 16
%33 = add i64 %32, 32
%34 = call i32 @shake256(i8* %27, i32 43, i8* %30, i64 %33)
%35 = load i8*, i8** %8
%36 = load i8*, i8** %16
%37 = call i32 @memcpy(i8* %35, i8* %36, i32 34)
%38 = load i8*, i8** %16
%39 = getelementptr inbounds i8, i8* %38, i64 34
store i8* %39, i8** %16
%40 = load i8*, i8** %16
%41 = call i32 @bytes_to_ull(i8* %40, i32 8)
%42 = load i32*, i32** %9
store i32 %41, i32* %42
%43 = load i32*, i32** %9
%44 = load i32, i32* %43
%45 = and i32 %44, -1
store i32 %45, i32* %43
%46 = load i8*, i8** %16
%47 = getelementptr inbounds i8, i8* %46, i64 8
store i8* %47, i8** %16
%48 = load i8*, i8** %16
%49 = call i32 @bytes_to_ull(i8* %48, i32 1)
%50 = load i32*, i32** %10
store i32 %49, i32* %50
%51 = load i32*, i32** %10
%52 = load i32, i32* %51
%53 = and i32 %52, -1
store i32 %53, i32* %51
ret void
}

LLVM IR (-O2):
define void @hash_message(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i8* %3, i8* %4, i8* %5, i64 %6) {
%8 = alloca [43 x i8]
%9 = getelementptr inbounds [43 x i8], [43 x i8]* %8, i64 0, i64 0
%10 = getelementptr inbounds i8, i8* %5, i64 -48
%11 = tail call i32 @memcpy(i8* %10, i8* %3, i32 16)
%12 = getelementptr inbounds i8, i8* %5, i64 -32
%13 = tail call i32 @memcpy(i8* %12, i8* %4, i32 32)
%14 = add i64 %6, 48
%15 = call i32 @shake256(i8* %9, i32 43, i8* %10, i64 %14)
%16 = call i32 @memcpy(i8* %0, i8* %9, i32 34)
%17 = getelementptr inbounds [43 x i8], [43 x i8]* %8, i64 0, i64 34
%18 = call i32 @bytes_to_ull(i8* %17, i32 8)
store i32 %18, i32* %1
%19 = getelementptr inbounds [43 x i8], [43 x i8]* %8, i64 0, i64 42
%20 = call i32 @bytes_to_ull(i8* %19, i32 1)
store i32 %20, i32* %2
ret void
}