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

/* Variables and functions */
int /*<<< orphan*/ PHC_test();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ simpletest(char *, char *, char *, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ test_output(int, int /*<<< orphan*/ *, int /*<<< orphan*/,
                               int /*<<< orphan*/ *, int /*<<< orphan*/,
                               int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                               int, int, int, int, int);
int /*<<< orphan*/ verifyClientServer();
int /*<<< orphan*/ verifyGarlic();
int main() {
  printf("****************************************** Basic tests\n");
  verifyGarlic();
  verifyClientServer();
  simpletest("password", "salt", "", 1);
  simpletest("password", "salt", "", 1024);
  simpletest("password", "salt", "data", 1024);
  simpletest("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt",
             "", 1);
  PHC_test();
  printf("****************************************** Misc tests\n");
  test_output(128, (uint8_t *)"password", strlen("password"), (uint8_t *)"salt",
              strlen("salt"), NULL, 0, 1024 * 1024, 4096, 0, 16384, 2, 1);
  test_output(64, (uint8_t *)"password", strlen("password"), (uint8_t *)"salt",
              strlen("salt"), NULL, 0, 10 * 1024, 4096, 0, 64, 1, 64);
  test_output(64, (uint8_t *)"password", strlen("password"), (uint8_t *)"salt",
              strlen("salt"), NULL, 0, 10 * 1024, 4096, 4, 128, 1, 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1090 <verifyGarlic@plt>
mov    $0x0,%al
call   1030 <verifyClientServer@plt>
lea    0xead(%rip),%rdi
lea    0xecf(%rip),%rsi
lea    0xe89(%rip),%rdx
mov    $0x1,%ecx
call   1080 <simpletest@plt>
lea    0xe8e(%rip),%rdi
lea    0xeb0(%rip),%rsi
lea    0xe6a(%rip),%rdx
mov    $0x400,%ecx
call   1080 <simpletest@plt>
lea    0xe6f(%rip),%rdi
lea    0xe91(%rip),%rsi
lea    0xe4c(%rip),%rdx
mov    $0x400,%ecx
call   1080 <simpletest@plt>
lea    0xe40(%rip),%rdi
lea    0xe52(%rip),%rsi
lea    0xe2c(%rip),%rdx
mov    $0x1,%ecx
call   1080 <simpletest@plt>
mov    $0x0,%al
call   1050 <PHC_test@plt>
lea    0xe58(%rip),%rdi
call   1070 <printf@plt>
lea    0xe1e(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10(%rbp)
lea    0xe38(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x10(%rbp),%edx
mov    %eax,%r8d
mov    $0x80,%edi
lea    0xdf8(%rip),%rsi
lea    0xe1a(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
movl   $0x100000,0x8(%rsp)
movl   $0x1000,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x4000,0x20(%rsp)
movl   $0x2,0x28(%rsp)
movl   $0x1,0x30(%rsp)
call   1040 <test_output@plt>
lea    0xda7(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xdc1(%rip),%rdi
call   1060 <strlen@plt>
mov    -0xc(%rbp),%edx
mov    %eax,%r8d
mov    $0x40,%edi
lea    0xd81(%rip),%rsi
lea    0xda3(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
movl   $0x2800,0x8(%rsp)
movl   $0x1000,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x40,0x20(%rsp)
movl   $0x1,0x28(%rsp)
movl   $0x40,0x30(%rsp)
call   1040 <test_output@plt>
lea    0xd30(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x8(%rbp)
lea    0xd4a(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x8(%rbp),%edx
mov    %eax,%r8d
mov    $0x40,%edi
lea    0xd0a(%rip),%rsi
lea    0xd2c(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
movl   $0x2800,0x8(%rsp)
movl   $0x1000,0x10(%rsp)
movl   $0x4,0x18(%rsp)
movl   $0x80,0x20(%rsp)
movl   $0x1,0x28(%rsp)
movl   $0x1,0x30(%rsp)
call   1040 <test_output@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xec7(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1090 <verifyGarlic@plt>
xor    %eax,%eax
call   1030 <verifyClientServer@plt>
lea    0xe7f(%rip),%r15
lea    0xea1(%rip),%r14
lea    0xe60(%rip),%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1080 <simpletest@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x400,%ecx
call   1080 <simpletest@plt>
lea    0xe2f(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x400,%ecx
call   1080 <simpletest@plt>
lea    0xe1d(%rip),%rdi
lea    0xe2f(%rip),%rsi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1080 <simpletest@plt>
xor    %eax,%eax
call   1050 <PHC_test@plt>
lea    0xe70(%rip),%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <strlen@plt>
sub    $0x8,%rsp
mov    $0x80,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
push   $0x1
push   $0x2
push   $0x4000
push   $0x0
push   $0x1000
push   $0x100000
push   $0x0
call   1040 <test_output@plt>
add    $0x40,%rsp
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <strlen@plt>
sub    $0x8,%rsp
mov    $0x40,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
push   $0x40
push   $0x1
push   $0x40
push   $0x0
push   $0x1000
push   $0x2800
push   $0x0
call   1040 <test_output@plt>
add    $0x40,%rsp
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <strlen@plt>
sub    $0x8,%rsp
mov    $0x40,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
push   $0x1
push   $0x1
push   $0x80
push   $0x4
push   $0x1000
push   $0x2800
push   $0x0
call   1040 <test_output@plt>
add    $0x40,%rsp
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [56 x i8] c"****************************************** Basic tests\0A\00"
@.str.1 = [9 x i8] c"password\00"
@.str.2 = [5 x i8] c"salt\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [5 x i8] c"data\00"
@.str.5 = [25 x i8] c"passwordPASSWORDpassword\00"
@.str.6 = [37 x i8] c"saltSALTsaltSALTsaltSALTsaltSALTsalt\00"
@.str.7 = [55 x i8] c"****************************************** Misc tests\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @verifyGarlic()
%4 = call i32 (...) @verifyClientServer()
%5 = call i32 @simpletest(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1)
%6 = call i32 @simpletest(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1024)
%7 = call i32 @simpletest(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 1024)
%8 = call i32 @simpletest(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1)
%9 = call i32 (...) @PHC_test()
%10 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%11 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @test_output(i32 128, i32* bitcast ([9 x i8]* @.str.1 to i32*), i32 %11, i32* bitcast ([5 x i8]* @.str.2 to i32*), i32 %12, i32* null, i32 0, i32 1048576, i32 4096, i32 0, i32 16384, i32 2, i32 1)
%14 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @test_output(i32 64, i32* bitcast ([9 x i8]* @.str.1 to i32*), i32 %14, i32* bitcast ([5 x i8]* @.str.2 to i32*), i32 %15, i32* null, i32 0, i32 10240, i32 4096, i32 0, i32 64, i32 1, i32 64)
%17 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @test_output(i32 64, i32* bitcast ([9 x i8]* @.str.1 to i32*), i32 %17, i32* bitcast ([5 x i8]* @.str.2 to i32*), i32 %18, i32* null, i32 0, i32 10240, i32 4096, i32 4, i32 128, i32 1, i32 1)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"password\00"
@.str.2 = [5 x i8] c"salt\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [5 x i8] c"data\00"
@.str.5 = [25 x i8] c"passwordPASSWORDpassword\00"
@.str.6 = [37 x i8] c"saltSALTsaltSALTsaltSALTsaltSALTsalt\00"
@str = [55 x i8] c"****************************************** Basic tests\00"
@str.8 = [54 x i8] c"****************************************** Misc tests\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @verifyGarlic()
%3 = tail call i32 (...) @verifyClientServer()
%4 = tail call i32 @simpletest(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1)
%5 = tail call i32 @simpletest(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1024)
%6 = tail call i32 @simpletest(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 1024)
%7 = tail call i32 @simpletest(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1)
%8 = tail call i32 (...) @PHC_test()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.8, i64 0, i64 0))
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @test_output(i32 128, i32* bitcast ([9 x i8]* @.str.1 to i32*), i32 %10, i32* bitcast ([5 x i8]* @.str.2 to i32*), i32 %11, i32* null, i32 0, i32 1048576, i32 4096, i32 0, i32 16384, i32 2, i32 1)
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @test_output(i32 64, i32* bitcast ([9 x i8]* @.str.1 to i32*), i32 %13, i32* bitcast ([5 x i8]* @.str.2 to i32*), i32 %14, i32* null, i32 0, i32 10240, i32 4096, i32 0, i32 64, i32 1, i32 64)
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @test_output(i32 64, i32* bitcast ([9 x i8]* @.str.1 to i32*), i32 %16, i32* bitcast ([5 x i8]* @.str.2 to i32*), i32 %17, i32* null, i32 0, i32 10240, i32 4096, i32 4, i32 128, i32 1, i32 1)
ret i32 0
}