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

/* Variables and functions */
int PKCS5_PBKDF2_HMAC_SHA1(char *, int, unsigned char *, int, int, int, int *);
int /*<<< orphan*/ abort();
scalar_t__ clEqual(int *, int, int const *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
void testPBKDF2() {
  uint8_t key[20];
  static const uint8_t kExpected[] = {0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48,
                                      0x9a, 0xbe, 0xad, 0x49, 0xd9, 0x26, 0xf7,
                                      0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1};
  do {
    if (!(PKCS5_PBKDF2_HMAC_SHA1("password", 8, (unsigned char *)"salt", 4,
                                 4096, sizeof key, key) == 1)) {
      fprintf(stderr, "FAIL %s(%d) : %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/hkjn/greygoo/refs/heads/master/"
              "ucryptolib/test.c",
              430,
              "PKCS5_PBKDF2_HMAC_SHA1(\"password\", 8, (unsigned "
              "char*)\"salt\", 4, 4096, sizeof key, key) == 1");
      abort();
    }
  } while (0);
  do {
    if (!(clEqual(key, sizeof key, kExpected, sizeof kExpected) == 0)) {
      fprintf(stderr, "FAIL %s(%d) : %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/hkjn/greygoo/refs/heads/master/"
              "ucryptolib/test.c",
              433,
              "clEqual(key, sizeof key, kExpected, sizeof kExpected) == 0");
      abort();
    }
  } while (0);
}


x86 assembly (clang, -O0):
<testPBKDF2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x50(%rbp),%rax
lea    0xefd(%rip),%rdi
mov    $0x8,%esi
lea    0xefa(%rip),%rdx
mov    $0x4,%ecx
mov    $0x1000,%r8d
mov    $0x50,%r9d
mov    %rax,(%rsp)
call   1060 <PKCS5_PBKDF2_HMAC_SHA1@plt>
cmp    $0x1,%eax
je     11b1 <testPBKDF2+0x71>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
lea    0xed7(%rip),%rdx
mov    $0x1ae,%ecx
lea    0xf56(%rip),%r8
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    11b6 <testPBKDF2+0x76>
jmp    11bb <testPBKDF2+0x7b>
lea    -0x50(%rbp),%rdi
mov    $0x50,%ecx
lea    0xe35(%rip),%rdx
mov    %ecx,%esi
call   1030 <clEqual@plt>
cmp    $0x0,%rax
je     120b <testPBKDF2+0xcb>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
lea    0xe7d(%rip),%rdx
mov    $0x1b1,%ecx
lea    0xf59(%rip),%r8
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    1210 <testPBKDF2+0xd0>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testPBKDF2>:
sub    $0x68,%rsp
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0xefc(%rip),%rdi
lea    0xefe(%rip),%rdx
mov    $0x8,%esi
mov    $0x4,%ecx
mov    $0x1000,%r8d
mov    $0x50,%r9d
call   1060 <PKCS5_PBKDF2_HMAC_SHA1@plt>
cmp    $0x1,%eax
jne    11a0 <testPBKDF2+0x60>
lea    0xe7e(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    $0x50,%ecx
call   1030 <clEqual@plt>
test   %rax,%rax
jne    11c5 <testPBKDF2+0x85>
add    $0x68,%rsp
ret
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
lea    0xeb9(%rip),%rdx
lea    0xf3d(%rip),%r8
mov    $0x1ae,%ecx
jmp    11e8 <testPBKDF2+0xa8>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
lea    0xe94(%rip),%rdx
lea    0xf75(%rip),%r8
mov    $0x1b1,%ecx
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@testPBKDF2.kExpected = internal constant [20 x i32] [i32 75, i32 0, i32 121, i32 1, i32 183, i32 101, i32 72, i32 154, i32 190, i32 173, i32 73, i32 217, i32 38, i32 247, i32 33, i32 208, i32 101, i32 164, i32 41, i32 193]
@.str = [9 x i8] c"password\00"
@.str.1 = [5 x i8] c"salt\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"FAIL %s(%d) : %s\0A\00"
@.str.3 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hkjn/greygoo/refs/heads/master/ucryptolib/test.c\00"
@.str.4 = [93 x i8] c"PKCS5_PBKDF2_HMAC_SHA1(\22password\22, 8, (unsigned char*)\22salt\22, 4, 4096, sizeof key, key) == 1\00"
@.str.5 = [59 x i8] c"clEqual(key, sizeof key, kExpected, sizeof kExpected) == 0\00"
define void @testPBKDF2() {
%1 = alloca [20 x i32]
br label %2
2: ; preds = %0
%3 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%4 = call i32 @PKCS5_PBKDF2_HMAC_SHA1(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 4096, i32 80, i32* %3)
%5 = icmp eq i32 %4, 1
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.3, i64 0, i64 0), i32 430, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %2
br label %11
11: ; preds = %10
br label %12
12: ; preds = %11
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%14 = call i64 @clEqual(i32* %13, i32 80, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @testPBKDF2.kExpected, i64 0, i64 0), i32 80)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.3, i64 0, i64 0), i32 433, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %12
br label %21
21: ; preds = %20
ret void
}

LLVM IR (-O2):
@testPBKDF2.kExpected = internal constant [20 x i32] [i32 75, i32 0, i32 121, i32 1, i32 183, i32 101, i32 72, i32 154, i32 190, i32 173, i32 73, i32 217, i32 38, i32 247, i32 33, i32 208, i32 101, i32 164, i32 41, i32 193]
@.str = [9 x i8] c"password\00"
@.str.1 = [5 x i8] c"salt\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"FAIL %s(%d) : %s\0A\00"
@.str.3 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hkjn/greygoo/refs/heads/master/ucryptolib/test.c\00"
@.str.4 = [93 x i8] c"PKCS5_PBKDF2_HMAC_SHA1(\22password\22, 8, (unsigned char*)\22salt\22, 4, 4096, sizeof key, key) == 1\00"
@.str.5 = [59 x i8] c"clEqual(key, sizeof key, kExpected, sizeof kExpected) == 0\00"
define void @testPBKDF2() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%4 = call i32 @PKCS5_PBKDF2_HMAC_SHA1(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 4096, i32 80, i32* %3)
%5 = icmp eq i32 %4, 1
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.3, i64 0, i64 0), i32 430, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = call i64 @clEqual(i32* %3, i32 80, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @testPBKDF2.kExpected, i64 0, i64 0), i32 80)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.3, i64 0, i64 0), i32 433, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %10
ret void
}