#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 */

/* Variables and functions */
int /*<<< orphan*/ haraka512_perm(unsigned char *, unsigned char const *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void haraka512(unsigned char *out, const unsigned char *in) {
  int i;
  unsigned char buf[64];
  haraka512_perm(buf, in);
  for (i = 0; i < 64; i++) {
    buf[i] = buf[i] ^ in[i];
  }
  memcpy(out, buf + 8, 8);
  memcpy(out + 8, buf + 24, 8);
  memcpy(out + 16, buf + 32, 8);
  memcpy(out + 24, buf + 48, 8);
}


x86 assembly (clang, -O0):
<haraka512>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <haraka512_perm@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jge    117d <haraka512+0x5d>
movslq -0x14(%rbp),%rax
movzbl -0x60(%rbp,%rax,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <haraka512+0x24>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
add    $0x8,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
lea    -0x60(%rbp),%rsi
add    $0x18,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
lea    -0x60(%rbp),%rsi
add    $0x20,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x18,%rdi
lea    -0x60(%rbp),%rsi
add    $0x30,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<haraka512>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%rdi
call   1040 <haraka512_perm@plt>
movups (%rbx),%xmm0
xorps  (%rsp),%xmm0
movaps %xmm0,(%rsp)
movups 0x10(%rbx),%xmm0
xorps  0x10(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0x20(%rbx),%xmm0
xorps  0x20(%rsp),%xmm0
lea    0x20(%rsp),%r12
movaps %xmm0,0x20(%rsp)
lea    0x30(%rsp),%r14
movups 0x30(%rbx),%xmm0
xorps  0x30(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    0x8(%r15),%rdi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    0x10(%r15),%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
add    $0x18,%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @haraka512(i8* %0, i8* %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call i32 @haraka512_perm(i8* %4, i8* %1)
%6 = bitcast [64 x i8]* %3 to <16 x i8>*
%7 = load <16 x i8>, <16 x i8>* %6
%8 = bitcast i8* %1 to <16 x i8>*
%9 = load <16 x i8>, <16 x i8>* %8
%10 = xor <16 x i8> %9, %7
%11 = bitcast [64 x i8]* %3 to <16 x i8>*
store <16 x i8> %10, <16 x i8>* %11
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 16
%13 = bitcast i8* %12 to <16 x i8>*
%14 = load <16 x i8>, <16 x i8>* %13
%15 = getelementptr inbounds i8, i8* %1, i64 16
%16 = bitcast i8* %15 to <16 x i8>*
%17 = load <16 x i8>, <16 x i8>* %16
%18 = xor <16 x i8> %17, %14
%19 = bitcast i8* %12 to <16 x i8>*
store <16 x i8> %18, <16 x i8>* %19
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 32
%21 = bitcast i8* %20 to <16 x i8>*
%22 = load <16 x i8>, <16 x i8>* %21
%23 = getelementptr inbounds i8, i8* %1, i64 32
%24 = bitcast i8* %23 to <16 x i8>*
%25 = load <16 x i8>, <16 x i8>* %24
%26 = xor <16 x i8> %25, %22
%27 = bitcast i8* %20 to <16 x i8>*
store <16 x i8> %26, <16 x i8>* %27
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 48
%29 = bitcast i8* %28 to <16 x i8>*
%30 = load <16 x i8>, <16 x i8>* %29
%31 = getelementptr inbounds i8, i8* %1, i64 48
%32 = bitcast i8* %31 to <16 x i8>*
%33 = load <16 x i8>, <16 x i8>* %32
%34 = xor <16 x i8> %33, %30
%35 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> %34, <16 x i8>* %35
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 8
%37 = call i32 @memcpy(i8* %0, i8* %36, i32 8)
%38 = getelementptr inbounds i8, i8* %0, i64 8
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 24
%40 = call i32 @memcpy(i8* %38, i8* %39, i32 8)
%41 = getelementptr inbounds i8, i8* %0, i64 16
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 32
%43 = call i32 @memcpy(i8* %41, i8* %42, i32 8)
%44 = getelementptr inbounds i8, i8* %0, i64 24
%45 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 48
%46 = call i32 @memcpy(i8* %44, i8* %45, i32 8)
ret void
}