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

/* Variables and functions */
int /*<<< orphan*/ __Catena(int *, int /*<<< orphan*/ const, int const *,
                            int const, int const *, int /*<<< orphan*/ const,
                            int const, int const, int const, int const,
                            int /*<<< orphan*/, int /*<<< orphan*/, int *);
int /*<<< orphan*/ __Hash4(int const *, int, int *, int, int const *, int,
                           int const *, int, int *);
void Catena_Keyed_Hashing(uint8_t *pwd, const uint32_t pwdlen,
                          const uint8_t *salt, const uint8_t saltlen,
                          const uint8_t *data, const uint32_t datalen,
                          const uint8_t lambda, const uint8_t min_garlic,
                          const uint8_t garlic, const uint8_t hashlen,
                          const uint8_t *key, const uint64_t uuid,
                          uint8_t *chash) {
  uint8_t keystream[64];
  uint64_t tmp = (uuid);
  int i;
  __Catena(pwd, pwdlen, salt, saltlen, data, datalen, lambda, min_garlic,
           garlic, hashlen, 0, 0, chash);
  __Hash4(key, 16, (uint8_t *)&tmp, 8, &garlic, sizeof(uint8_t), key, 16,
          keystream);
  for (i = 0; i < hashlen; i++)
    chash[i] ^= keystream[i];
}


x86 assembly (clang, -O0):
<Catena_Keyed_Hashing>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x178,%rsp
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %ecx,-0x34(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9d,-0x44(%rbp)
mov    0x38(%rbp),%eax
mov    %eax,-0x154(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x40(%rbp),%r8
mov    -0x44(%rbp),%r9d
mov    0x10(%rbp),%r14d
mov    0x18(%rbp),%ebx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x40(%rbp),%rax
xor    %r15d,%r15d
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <__Catena@plt>
mov    0x30(%rbp),%rdi
mov    0x30(%rbp),%r10
lea    -0x150(%rbp),%rax
mov    $0x10,%esi
lea    -0x154(%rbp),%rdx
mov    $0x8,%ecx
lea    0x20(%rbp),%r8
mov    $0x4,%r9d
mov    %r10,(%rsp)
movl   $0x10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <__Hash4@plt>
movl   $0x0,-0x158(%rbp)
mov    -0x158(%rbp),%eax
cmp    0x28(%rbp),%eax
jge    124a <Catena_Keyed_Hashing+0x12a>
movslq -0x158(%rbp),%rax
mov    -0x150(%rbp,%rax,4),%edx
mov    0x40(%rbp),%rax
movslq -0x158(%rbp),%rcx
xor    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
jmp    1208 <Catena_Keyed_Hashing+0xe8>
add    $0x178,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<Catena_Keyed_Hashing>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    0x170(%rsp),%rbx
mov    0x158(%rsp),%r15d
mov    0x160(%rsp),%r14
mov    0x140(%rsp),%r10d
mov    0x148(%rsp),%r11d
mov    0x150(%rsp),%eax
mov    0x168(%rsp),%ebp
mov    %ebp,0xc(%rsp)
sub    $0x8,%rsp
push   %rbx
push   $0x0
push   $0x0
push   %r15
push   %rax
push   %r11
push   %r10
call   1030 <__Catena@plt>
add    $0x38,%rsp
lea    0x18(%rsp),%rax
lea    0x14(%rsp),%rdx
lea    0x158(%rsp),%r8
mov    %r14,%rdi
mov    $0x10,%esi
mov    $0x8,%ecx
mov    $0x4,%r9d
push   %rax
push   $0x10
push   %r14
call   1040 <__Hash4@plt>
add    $0x20,%rsp
test   %r15d,%r15d
jle    1280 <Catena_Keyed_Hashing+0x160>
mov    %r15d,%eax
cmp    $0x8,%r15d
jae    11cc <Catena_Keyed_Hashing+0xac>
xor    %ecx,%ecx
jmp    1270 <Catena_Keyed_Hashing+0x150>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x3,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     128e <Catena_Keyed_Hashing+0x16e>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups (%rbx,%rdx,4),%xmm0
movups 0x10(%rbx,%rdx,4),%xmm1
movups 0x20(%rbx,%rdx,4),%xmm2
movups 0x30(%rbx,%rdx,4),%xmm3
xorps  0x10(%rsp,%rdx,4),%xmm0
xorps  0x20(%rsp,%rdx,4),%xmm1
movups %xmm0,(%rbx,%rdx,4)
movups %xmm1,0x10(%rbx,%rdx,4)
xorps  0x30(%rsp,%rdx,4),%xmm2
xorps  0x40(%rsp,%rdx,4),%xmm3
movups %xmm2,0x20(%rbx,%rdx,4)
movups %xmm3,0x30(%rbx,%rdx,4)
add    $0x10,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1200 <Catena_Keyed_Hashing+0xe0>
test   $0x1,%sil
je     1266 <Catena_Keyed_Hashing+0x146>
movups (%rbx,%rdx,4),%xmm0
movups 0x10(%rbx,%rdx,4),%xmm1
xorps  0x10(%rsp,%rdx,4),%xmm0
xorps  0x20(%rsp,%rdx,4),%xmm1
movups %xmm0,(%rbx,%rdx,4)
movups %xmm1,0x10(%rbx,%rdx,4)
cmp    %rax,%rcx
je     1280 <Catena_Keyed_Hashing+0x160>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rcx,4),%edx
xor    %edx,(%rbx,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1270 <Catena_Keyed_Hashing+0x150>
add    $0x118,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    124a <Catena_Keyed_Hashing+0x12a>
jmp    1266 <Catena_Keyed_Hashing+0x146>

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

LLVM IR (-O2):
define void @Catena_Keyed_Hashing(i32* %0, i32 %1, i32* %2, i32 %3, i32* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32* %10, i32 %11, i32* %12) {
%14 = alloca i32
%15 = alloca [64 x i32]
%16 = alloca i32
store i32 %8, i32* %14
%17 = bitcast [64 x i32]* %15 to i8*
%18 = bitcast i32* %16 to i8*
store i32 %11, i32* %16
%19 = tail call i32 @__Catena(i32* %0, i32 %1, i32* %2, i32 %3, i32* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 0, i32 0, i32* %12)
%20 = getelementptr inbounds [64 x i32], [64 x i32]* %15, i64 0, i64 0
%21 = call i32 @__Hash4(i32* %10, i32 16, i32* %16, i32 8, i32* %14, i32 4, i32* %10, i32 16, i32* %20)
%22 = icmp sgt i32 %9, 0
br i1 %22, label %23, label %107
23: ; preds = %13
%24 = zext i32 %9 to i64
%25 = icmp ult i32 %9, 8
br i1 %25, label %96, label %26
26: ; preds = %23
%27 = and i64 %24, 4294967288
%28 = add nsw i64 %27, -8
%29 = lshr exact i64 %28, 3
%30 = add nuw nsw i64 %29, 1
%31 = and i64 %30, 1
%32 = icmp eq i64 %28, 0
br i1 %32, label %74, label %33
33: ; preds = %26
%34 = and i64 %30, 4611686018427387902
br label %35
35: ; preds = %35, %33
%36 = phi i64 [ 0, %33 ], [ %71, %35 ]
%37 = phi i64 [ 0, %33 ], [ %72, %35 ]
%38 = getelementptr inbounds [64 x i32], [64 x i32]* %15, i64 0, i64 %36
%39 = bitcast i32* %38 to <4 x i32>*
%40 = load <4 x i32>, <4 x i32>* %39
%41 = getelementptr inbounds i32, i32* %38, i64 4
%42 = bitcast i32* %41 to <4 x i32>*
%43 = load <4 x i32>, <4 x i32>* %42
%44 = getelementptr inbounds i32, i32* %12, i64 %36
%45 = bitcast i32* %44 to <4 x i32>*
%46 = load <4 x i32>, <4 x i32>* %45
%47 = getelementptr inbounds i32, i32* %44, i64 4
%48 = bitcast i32* %47 to <4 x i32>*
%49 = load <4 x i32>, <4 x i32>* %48
%50 = xor <4 x i32> %46, %40
%51 = xor <4 x i32> %49, %43
%52 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %52
%53 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> %51, <4 x i32>* %53
%54 = or i64 %36, 8
%55 = getelementptr inbounds [64 x i32], [64 x i32]* %15, i64 0, i64 %54
%56 = bitcast i32* %55 to <4 x i32>*
%57 = load <4 x i32>, <4 x i32>* %56
%58 = getelementptr inbounds i32, i32* %55, i64 4
%59 = bitcast i32* %58 to <4 x i32>*
%60 = load <4 x i32>, <4 x i32>* %59
%61 = getelementptr inbounds i32, i32* %12, i64 %54
%62 = bitcast i32* %61 to <4 x i32>*
%63 = load <4 x i32>, <4 x i32>* %62
%64 = getelementptr inbounds i32, i32* %61, i64 4
%65 = bitcast i32* %64 to <4 x i32>*
%66 = load <4 x i32>, <4 x i32>* %65
%67 = xor <4 x i32> %63, %57
%68 = xor <4 x i32> %66, %60
%69 = bitcast i32* %61 to <4 x i32>*
store <4 x i32> %67, <4 x i32>* %69
%70 = bitcast i32* %64 to <4 x i32>*
store <4 x i32> %68, <4 x i32>* %70
%71 = add nuw i64 %36, 16
%72 = add i64 %37, 2
%73 = icmp eq i64 %72, %34
br i1 %73, label %74, label %35
74: ; preds = %35, %26
%75 = phi i64 [ 0, %26 ], [ %71, %35 ]
%76 = icmp eq i64 %31, 0
br i1 %76, label %94, label %77
77: ; preds = %74
%78 = getelementptr inbounds [64 x i32], [64 x i32]* %15, i64 0, i64 %75
%79 = bitcast i32* %78 to <4 x i32>*
%80 = load <4 x i32>, <4 x i32>* %79
%81 = getelementptr inbounds i32, i32* %78, i64 4
%82 = bitcast i32* %81 to <4 x i32>*
%83 = load <4 x i32>, <4 x i32>* %82
%84 = getelementptr inbounds i32, i32* %12, i64 %75
%85 = bitcast i32* %84 to <4 x i32>*
%86 = load <4 x i32>, <4 x i32>* %85
%87 = getelementptr inbounds i32, i32* %84, i64 4
%88 = bitcast i32* %87 to <4 x i32>*
%89 = load <4 x i32>, <4 x i32>* %88
%90 = xor <4 x i32> %86, %80
%91 = xor <4 x i32> %89, %83
%92 = bitcast i32* %84 to <4 x i32>*
store <4 x i32> %90, <4 x i32>* %92
%93 = bitcast i32* %87 to <4 x i32>*
store <4 x i32> %91, <4 x i32>* %93
br label %94
94: ; preds = %74, %77
%95 = icmp eq i64 %27, %24
br i1 %95, label %107, label %96
96: ; preds = %23, %94
%97 = phi i64 [ 0, %23 ], [ %27, %94 ]
br label %98
98: ; preds = %96, %98
%99 = phi i64 [ %105, %98 ], [ %97, %96 ]
%100 = getelementptr inbounds [64 x i32], [64 x i32]* %15, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = getelementptr inbounds i32, i32* %12, i64 %99
%103 = load i32, i32* %102
%104 = xor i32 %103, %101
store i32 %104, i32* %102
%105 = add nuw nsw i64 %99, 1
%106 = icmp eq i64 %105, %24
br i1 %106, label %107, label %98
107: ; preds = %98, %94, %13
ret void
}