#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 /*<<< orphan*/ earworm_PBKDF2_SHA256(int const *, int, int const *, int,
                                         int, int *, int);
scalar_t__ memcmp(int const *, int *, int);
int test_PBKDF2_SHA256() {
  static const uint8_t secret1[] = {0x70, 0x61, 0x73, 0x73, 0x77, 0x64};
  static const uint8_t salt1[] = {0x73, 0x61, 0x6c, 0x74};
  static const uint8_t result1[] = {
      0x55, 0xac, 0x04, 0x6e, 0x56, 0xe3, 0x08, 0x9f, 0xec, 0x16, 0x91,
      0xc2, 0x25, 0x44, 0xb6, 0x05, 0xf9, 0x41, 0x85, 0x21, 0x6d, 0xde,
      0x04, 0x65, 0xe6, 0x8b, 0x9d, 0x57, 0xc2, 0x0d, 0xac, 0xbc, 0x49,
      0xca, 0x9c, 0xcc, 0xf1, 0x79, 0xb6, 0x45, 0x99, 0x16, 0x64, 0xb3,
      0x9d, 0x77, 0xef, 0x31, 0x7c, 0x71, 0xb8, 0x45, 0xb1, 0xe3, 0x0b,
      0xd5, 0x09, 0x11, 0x20, 0x41, 0xd3, 0xa1, 0x97, 0x83};
  static const uint8_t secret2[] = {0x50, 0x61, 0x73, 0x73,
                                    0x77, 0x6f, 0x72, 0x64};
  static const uint8_t salt2[] = {0x4e, 0x61, 0x43, 0x6c};
  static const uint8_t result2[] = {
      0x4d, 0xdc, 0xd8, 0xf6, 0x0b, 0x98, 0xbe, 0x21, 0x83, 0x0c, 0xee,
      0x5e, 0xf2, 0x27, 0x01, 0xf9, 0x64, 0x1a, 0x44, 0x18, 0xd0, 0x4c,
      0x04, 0x14, 0xae, 0xff, 0x08, 0x87, 0x6b, 0x34, 0xab, 0x56, 0xa1,
      0xd4, 0x25, 0xa1, 0x22, 0x58, 0x33, 0x54, 0x9a, 0xdb, 0x84, 0x1b,
      0x51, 0xc9, 0xb3, 0x17, 0x6a, 0x27, 0x2b, 0xde, 0xbb, 0xa1, 0xd0,
      0x78, 0x47, 0x8f, 0x62, 0xb3, 0x97, 0xf3, 0x3c, 0x8d};
  uint8_t result[64];
  earworm_PBKDF2_SHA256(secret1, sizeof secret1, salt1, sizeof salt1, 1, result,
                        sizeof result);
  if (memcmp(result1, result, sizeof result))
    return -1;
  earworm_PBKDF2_SHA256(secret2, sizeof secret2, salt2, sizeof salt2, 80000,
                        result, sizeof result);
  if (memcmp(result2, result, sizeof result))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<test_PBKDF2_SHA256>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x110(%rbp),%r9
lea    0xec7(%rip),%rdi
mov    $0x18,%esi
lea    0xedb(%rip),%rdx
mov    $0x10,%ecx
mov    $0x1,%r8d
movl   $0x100,(%rsp)
call   1040 <earworm_PBKDF2_SHA256@plt>
lea    -0x110(%rbp),%rsi
lea    0xec6(%rip),%rdi
mov    $0x100,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     118a <test_PBKDF2_SHA256+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <test_PBKDF2_SHA256+0xd0>
lea    -0x110(%rbp),%r9
lea    0xf98(%rip),%rdi
mov    $0x20,%esi
lea    0xfac(%rip),%rdx
mov    $0x10,%ecx
mov    $0x13880,%r8d
movl   $0x100,(%rsp)
call   1040 <earworm_PBKDF2_SHA256@plt>
lea    -0x110(%rbp),%rsi
lea    0xf97(%rip),%rdi
mov    $0x100,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     11e9 <test_PBKDF2_SHA256+0xc9>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <test_PBKDF2_SHA256+0xd0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_PBKDF2_SHA256>:
push   %rbx
sub    $0x110,%rsp
movl   $0x100,(%rsp)
lea    0xeca(%rip),%rdi
lea    0xee3(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    $0x18,%esi
mov    $0x10,%ecx
mov    $0x1,%r8d
mov    %rbx,%r9
call   1040 <earworm_PBKDF2_SHA256@plt>
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11c6 <test_PBKDF2_SHA256+0xa6>
movl   $0x100,(%rsp)
lea    0xfa7(%rip),%rdi
lea    0xfc0(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    $0x20,%esi
mov    $0x10,%ecx
mov    $0x13880,%r8d
mov    %rbx,%r9
call   1040 <earworm_PBKDF2_SHA256@plt>
lea    0xfac(%rip),%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <memcmp@plt>
neg    %rax
sbb    %eax,%eax
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@test_PBKDF2_SHA256.secret1 = internal constant [6 x i32] [i32 112, i32 97, i32 115, i32 115, i32 119, i32 100]
@test_PBKDF2_SHA256.salt1 = internal constant [4 x i32] [i32 115, i32 97, i32 108, i32 116]
@test_PBKDF2_SHA256.result1 = internal constant [64 x i32] [i32 85, i32 172, i32 4, i32 110, i32 86, i32 227, i32 8, i32 159, i32 236, i32 22, i32 145, i32 194, i32 37, i32 68, i32 182, i32 5, i32 249, i32 65, i32 133, i32 33, i32 109, i32 222, i32 4, i32 101, i32 230, i32 139, i32 157, i32 87, i32 194, i32 13, i32 172, i32 188, i32 73, i32 202, i32 156, i32 204, i32 241, i32 121, i32 182, i32 69, i32 153, i32 22, i32 100, i32 179, i32 157, i32 119, i32 239, i32 49, i32 124, i32 113, i32 184, i32 69, i32 177, i32 227, i32 11, i32 213, i32 9, i32 17, i32 32, i32 65, i32 211, i32 161, i32 151, i32 131]
@test_PBKDF2_SHA256.secret2 = internal constant [8 x i32] [i32 80, i32 97, i32 115, i32 115, i32 119, i32 111, i32 114, i32 100]
@test_PBKDF2_SHA256.salt2 = internal constant [4 x i32] [i32 78, i32 97, i32 67, i32 108]
@test_PBKDF2_SHA256.result2 = internal constant [64 x i32] [i32 77, i32 220, i32 216, i32 246, i32 11, i32 152, i32 190, i32 33, i32 131, i32 12, i32 238, i32 94, i32 242, i32 39, i32 1, i32 249, i32 100, i32 26, i32 68, i32 24, i32 208, i32 76, i32 4, i32 20, i32 174, i32 255, i32 8, i32 135, i32 107, i32 52, i32 171, i32 86, i32 161, i32 212, i32 37, i32 161, i32 34, i32 88, i32 51, i32 84, i32 154, i32 219, i32 132, i32 27, i32 81, i32 201, i32 179, i32 23, i32 106, i32 39, i32 43, i32 222, i32 187, i32 161, i32 208, i32 120, i32 71, i32 143, i32 98, i32 179, i32 151, i32 243, i32 60, i32 141]
define i32 @test_PBKDF2_SHA256() {
%1 = alloca i32
%2 = alloca [64 x i32]
%3 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 0
%4 = call i32 @earworm_PBKDF2_SHA256(i32* getelementptr inbounds ([6 x i32], [6 x i32]* @test_PBKDF2_SHA256.secret1, i64 0, i64 0), i32 24, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @test_PBKDF2_SHA256.salt1, i64 0, i64 0), i32 16, i32 1, i32* %3, i32 256)
%5 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 0
%6 = call i64 @memcmp(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @test_PBKDF2_SHA256.result1, i64 0, i64 0), i32* %5, i32 256)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %17
9: ; preds = %0
%10 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 0
%11 = call i32 @earworm_PBKDF2_SHA256(i32* getelementptr inbounds ([8 x i32], [8 x i32]* @test_PBKDF2_SHA256.secret2, i64 0, i64 0), i32 32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @test_PBKDF2_SHA256.salt2, i64 0, i64 0), i32 16, i32 80000, i32* %10, i32 256)
%12 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 0
%13 = call i64 @memcmp(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @test_PBKDF2_SHA256.result2, i64 0, i64 0), i32* %12, i32 256)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 -1, i32* %1
br label %17
16: ; preds = %9
store i32 0, i32* %1
br label %17
17: ; preds = %16, %15, %8
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@test_PBKDF2_SHA256.secret1 = internal constant [6 x i32] [i32 112, i32 97, i32 115, i32 115, i32 119, i32 100]
@test_PBKDF2_SHA256.salt1 = internal constant [4 x i32] [i32 115, i32 97, i32 108, i32 116]
@test_PBKDF2_SHA256.result1 = internal constant [64 x i32] [i32 85, i32 172, i32 4, i32 110, i32 86, i32 227, i32 8, i32 159, i32 236, i32 22, i32 145, i32 194, i32 37, i32 68, i32 182, i32 5, i32 249, i32 65, i32 133, i32 33, i32 109, i32 222, i32 4, i32 101, i32 230, i32 139, i32 157, i32 87, i32 194, i32 13, i32 172, i32 188, i32 73, i32 202, i32 156, i32 204, i32 241, i32 121, i32 182, i32 69, i32 153, i32 22, i32 100, i32 179, i32 157, i32 119, i32 239, i32 49, i32 124, i32 113, i32 184, i32 69, i32 177, i32 227, i32 11, i32 213, i32 9, i32 17, i32 32, i32 65, i32 211, i32 161, i32 151, i32 131]
@test_PBKDF2_SHA256.secret2 = internal constant [8 x i32] [i32 80, i32 97, i32 115, i32 115, i32 119, i32 111, i32 114, i32 100]
@test_PBKDF2_SHA256.salt2 = internal constant [4 x i32] [i32 78, i32 97, i32 67, i32 108]
@test_PBKDF2_SHA256.result2 = internal constant [64 x i32] [i32 77, i32 220, i32 216, i32 246, i32 11, i32 152, i32 190, i32 33, i32 131, i32 12, i32 238, i32 94, i32 242, i32 39, i32 1, i32 249, i32 100, i32 26, i32 68, i32 24, i32 208, i32 76, i32 4, i32 20, i32 174, i32 255, i32 8, i32 135, i32 107, i32 52, i32 171, i32 86, i32 161, i32 212, i32 37, i32 161, i32 34, i32 88, i32 51, i32 84, i32 154, i32 219, i32 132, i32 27, i32 81, i32 201, i32 179, i32 23, i32 106, i32 39, i32 43, i32 222, i32 187, i32 161, i32 208, i32 120, i32 71, i32 143, i32 98, i32 179, i32 151, i32 243, i32 60, i32 141]
define i32 @test_PBKDF2_SHA256() {
%1 = alloca [64 x i32]
%2 = bitcast [64 x i32]* %1 to i8*
%3 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 0
%4 = call i32 @earworm_PBKDF2_SHA256(i32* getelementptr inbounds ([6 x i32], [6 x i32]* @test_PBKDF2_SHA256.secret1, i64 0, i64 0), i32 24, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @test_PBKDF2_SHA256.salt1, i64 0, i64 0), i32 16, i32 1, i32* %3, i32 256)
%5 = call i64 @memcmp(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @test_PBKDF2_SHA256.result1, i64 0, i64 0), i32* %3, i32 256)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = call i32 @earworm_PBKDF2_SHA256(i32* getelementptr inbounds ([8 x i32], [8 x i32]* @test_PBKDF2_SHA256.secret2, i64 0, i64 0), i32 32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @test_PBKDF2_SHA256.salt2, i64 0, i64 0), i32 16, i32 80000, i32* %3, i32 256)
%9 = call i64 @memcmp(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @test_PBKDF2_SHA256.result2, i64 0, i64 0), i32* %3, i32 256)
%10 = icmp ne i64 %9, 0
%11 = sext i1 %10 to i32
br label %12
12: ; preds = %7, %0
%13 = phi i32 [ -1, %0 ], [ %11, %7 ]
ret i32 %13
}