#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ TigerKDF_HashPassword(int /*<<< orphan*/ *, int,
                                         int /*<<< orphan*/ *, int,
                                         int /*<<< orphan*/ *, int, int, int,
                                         int, int /*<<< orphan*/ *,
                                         int /*<<< orphan*/, int, int, int);
int /*<<< orphan*/ TigerKDF_UpdatePasswordHash(int /*<<< orphan*/ *, int, int,
                                               int, int, int, int, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
void verifyGarlic(void) {
  uint32_t garlic;
  uint8_t hash1[32], hash2[32];
  if (!TigerKDF_HashPassword(hash1, 32, (uint8_t *)"password", 8,
                             (uint8_t *)"salt", 4, 1 * 1024, 4096, 0, NULL, 0,
                             16384, 1, 1)) {
    fprintf(stderr, "Password hashing failed!\n");
    exit(1);
  }
  for (garlic = 1; garlic < 10; garlic++) {
    if (!TigerKDF_HashPassword(hash2, 32, (uint8_t *)"password", 8,
                               (uint8_t *)"salt", 4, 1 * 1024, 4096, garlic,
                               NULL, 0, 16384, 1, 1)) {
      fprintf(stderr, "Password hashing failed!\n");
      exit(1);
    }
    if (!TigerKDF_UpdatePasswordHash(hash1, 32, 1 * 1024, 4096, garlic, garlic,
                                     16384, 1, 1)) {
      fprintf(stderr, "Password hashing failed!\n");
      exit(1);
    }
    if (memcmp(hash1, hash2, 32)) {
      fprintf(stderr, "Password update got wrong answer!\n");
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<verifyGarlic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
lea    0xe92(%rip),%rdx
mov    $0x8,%ecx
lea    0xe8f(%rip),%r8
mov    $0x4,%r9d
xor    %eax,%eax
xor    %eax,%eax
movl   $0x400,(%rsp)
movl   $0x1000,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x4000,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x1,0x38(%rsp)
call   1030 <TigerKDF_HashPassword@plt>
cmp    $0x0,%eax
jne    11f1 <verifyGarlic+0xa1>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    134f <verifyGarlic+0x1ff>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x20,%esi
lea    0xde8(%rip),%rdx
mov    $0x8,%ecx
lea    0xde5(%rip),%r8
mov    $0x4,%r9d
xor    %r10d,%r10d
xor    %r10d,%r10d
movl   $0x400,(%rsp)
movl   $0x1000,0x8(%rsp)
mov    %eax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x4000,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x1,0x38(%rsp)
call   1030 <TigerKDF_HashPassword@plt>
cmp    $0x0,%eax
jne    1299 <verifyGarlic+0x149>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x90(%rbp),%rdi
mov    -0x4(%rbp),%r8d
mov    -0x4(%rbp),%r9d
mov    $0x20,%esi
mov    $0x400,%edx
mov    $0x1000,%ecx
movl   $0x4000,(%rsp)
movl   $0x1,0x8(%rsp)
movl   $0x1,0x10(%rsp)
call   1060 <TigerKDF_UpdatePasswordHash@plt>
cmp    $0x0,%eax
jne    12fb <verifyGarlic+0x1ab>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x20,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     133c <verifyGarlic+0x1ec>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1341 <verifyGarlic+0x1f1>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11f8 <verifyGarlic+0xa8>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verifyGarlic>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
lea    0xe99(%rip),%rdx
lea    0xe9b(%rip),%r8
mov    %rsp,%rdi
mov    $0x20,%esi
mov    $0x8,%ecx
mov    $0x4,%r9d
push   $0x1
push   $0x1
push   $0x4000
push   $0x0
push   $0x0
push   $0x0
push   $0x1000
push   $0x400
call   1030 <TigerKDF_HashPassword@plt>
add    $0x40,%rsp
test   %eax,%eax
je     1272 <verifyGarlic+0x122>
mov    $0x1,%ebx
lea    0xe49(%rip),%r14
lea    0xe4b(%rip),%r15
lea    0x80(%rsp),%r12
mov    %rsp,%r13
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x20,%esi
mov    %r14,%rdx
mov    $0x8,%ecx
mov    %r15,%r8
mov    $0x4,%r9d
push   $0x1
push   $0x1
push   $0x4000
push   $0x0
push   $0x0
push   %rbx
push   $0x1000
push   $0x400
call   1030 <TigerKDF_HashPassword@plt>
add    $0x40,%rsp
test   %eax,%eax
je     1272 <verifyGarlic+0x122>
sub    $0x8,%rsp
mov    %r13,%rdi
mov    $0x20,%esi
mov    $0x400,%edx
mov    $0x1000,%ecx
mov    %ebx,%r8d
mov    %ebx,%r9d
push   $0x1
push   $0x1
push   $0x4000
call   1060 <TigerKDF_UpdatePasswordHash@plt>
add    $0x20,%rsp
test   %eax,%eax
je     1272 <verifyGarlic+0x122>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x20,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1284 <verifyGarlic+0x134>
add    $0x1,%ebx
cmp    $0xa,%ebx
jne    11d0 <verifyGarlic+0x80>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xd8c(%rip),%rsi
jmp    1294 <verifyGarlic+0x144>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"password\00"
@.str.1 = [5 x i8] c"salt\00"
@stderr = global i32 0
@.str.2 = [26 x i8] c"Password hashing failed!\0A\00"
@.str.3 = [35 x i8] c"Password update got wrong answer!\0A\00"
define void @verifyGarlic() {
%1 = alloca i32
%2 = alloca [32 x i32]
%3 = alloca [32 x i32]
%4 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
%5 = call i32 @TigerKDF_HashPassword(i32* %4, i32 32, i32* bitcast ([9 x i8]* @.str to i32*), i32 8, i32* bitcast ([5 x i8]* @.str.1 to i32*), i32 4, i32 1024, i32 4096, i32 0, i32* null, i32 0, i32 16384, i32 1, i32 1)
%6 = icmp ne i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
store i32 1, i32* %1
br label %12
12: ; preds = %44, %11
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %47
15: ; preds = %12
%16 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%17 = load i32, i32* %1
%18 = call i32 @TigerKDF_HashPassword(i32* %16, i32 32, i32* bitcast ([9 x i8]* @.str to i32*), i32 8, i32* bitcast ([5 x i8]* @.str.1 to i32*), i32 4, i32 1024, i32 4096, i32 %17, i32* null, i32 0, i32 16384, i32 1, i32 1)
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %15
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
%26 = load i32, i32* %1
%27 = load i32, i32* %1
%28 = call i32 @TigerKDF_UpdatePasswordHash(i32* %25, i32 32, i32 1024, i32 4096, i32 %26, i32 %27, i32 16384, i32 1, i32 1)
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %24
%35 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
%36 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%37 = call i64 @memcmp(i32* %35, i32* %36, i32 32)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %34
br label %44
44: ; preds = %43
%45 = load i32, i32* %1
%46 = add nsw i32 %45, 1
store i32 %46, i32* %1
br label %12
47: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"password\00"
@.str.1 = [5 x i8] c"salt\00"
@stderr = global i32 0
@.str.2 = [26 x i8] c"Password hashing failed!\0A\00"
@.str.3 = [35 x i8] c"Password update got wrong answer!\0A\00"
define void @verifyGarlic() {
%1 = alloca [32 x i32]
%2 = alloca [32 x i32]
%3 = bitcast [32 x i32]* %1 to i8*
%4 = bitcast [32 x i32]* %2 to i8*
%5 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 0
%6 = call i32 @TigerKDF_HashPassword(i32* %5, i32 32, i32* bitcast ([9 x i8]* @.str to i32*), i32 8, i32* bitcast ([5 x i8]* @.str.1 to i32*), i32 4, i32 1024, i32 4096, i32 0, i32* null, i32 0, i32 16384, i32 1, i32 1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
br label %17
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %32
%15 = add nuw nsw i32 %18, 1
%16 = icmp eq i32 %15, 10
br i1 %16, label %39, label %17
17: ; preds = %8, %14
%18 = phi i32 [ 1, %8 ], [ %15, %14 ]
%19 = call i32 @TigerKDF_HashPassword(i32* %9, i32 32, i32* bitcast ([9 x i8]* @.str to i32*), i32 8, i32* bitcast ([5 x i8]* @.str.1 to i32*), i32 4, i32 1024, i32 4096, i32 %18, i32* null, i32 0, i32 16384, i32 1, i32 1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = call i32 @TigerKDF_UpdatePasswordHash(i32* %5, i32 32, i32 1024, i32 4096, i32 %18, i32 %18, i32 16384, i32 1, i32 1)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %25
%33 = call i64 @memcmp(i32* %5, i32* %9, i32 32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %14, label %35
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %14
ret void
}