#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 */

/* Variables and functions */
int /*<<< orphan*/ EVP_sha1();
int /*<<< orphan*/ HMAC(int /*<<< orphan*/, unsigned char const *, unsigned int,
                        unsigned char *, int, unsigned char *, unsigned int *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int pbkdf2(const unsigned char *pw, unsigned int pwlen, unsigned int ic,
           unsigned char *dk, unsigned long long dklen) {
  unsigned long l, r, i, j;
  unsigned char txt[4], hash[(20) * 2], tmp[(20)], *p = dk, *lhix, *hix, *swap;
  unsigned short k;
  unsigned int outlen;
  if (dklen > ((((unsigned long long)1) << 32) - 1) * (20)) {
    return 1;
  }
  l = dklen / (20);
  r = dklen % (20);
  for (i = 1; i <= l; i++) {
    sprintf((char *)txt, "%04u", (unsigned int)i);
    HMAC(EVP_sha1(), pw, pwlen, txt, 4, hash, &outlen);
    lhix = hash;
    hix = hash + (20);
    for (k = 0; k < (20); k++) {
      tmp[k] = hash[k];
    }
    for (j = 1; j < ic; j++) {
      HMAC(EVP_sha1(), pw, pwlen, lhix, (20), hix, &outlen);
      for (k = 0; k < (20); k++) {
        tmp[k] ^= hix[k];
      }
      swap = hix;
      hix = lhix;
      lhix = swap;
    }
    for (k = 0; k < (20); k++) {
      *p++ = tmp[k];
    }
  }
  if (r) {
    sprintf((char *)txt, "%04u", (unsigned int)i);
    HMAC(EVP_sha1(), pw, pwlen, txt, 4, hash, &outlen);
    lhix = hash;
    hix = hash + (20);
    for (k = 0; k < (20); k++) {
      tmp[k] = hash[k];
    }
    for (j = 1; j < ic; j++) {
      HMAC(EVP_sha1(), pw, pwlen, lhix, (20), hix, &outlen);
      for (k = 0; k < (20); k++) {
        tmp[k] ^= hix[k];
      }
      swap = hix;
      hix = lhix;
      lhix = swap;
    }
    for (k = 0; k < r; k++) {
      *p++ = tmp[k];
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<pbkdf2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa8(%rbp)
movabs $0x13ffffffec,%rax
cmp    %rax,-0x28(%rbp)
jbe    1178 <pbkdf2+0x48>
movl   $0x1,-0x4(%rbp)
jmp    159a <pbkdf2+0x46a>
mov    -0x28(%rbp),%rax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x38(%rbp)
movq   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
ja     13a5 <pbkdf2+0x275>
lea    -0x4c(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
lea    0xe3d(%rip),%rsi
call   1050 <sprintf@plt>
mov    $0x0,%al
call   1030 <EVP_sha1@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x4c(%rbp),%rcx
lea    -0x80(%rbp),%r9
mov    $0x4,%r8d
lea    -0xc8(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <HMAC@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x80(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0xb8(%rbp)
movw   $0x0,-0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
cmp    $0x14,%eax
jge    1259 <pbkdf2+0x129>
movzwl -0xc2(%rbp),%eax
mov    -0x80(%rbp,%rax,1),%cl
movzwl -0xc2(%rbp),%eax
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xc2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc2(%rbp)
jmp    1219 <pbkdf2+0xe9>
movq   $0x1,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x18(%rbp),%ecx
cmp    %rcx,%rax
jae    133a <pbkdf2+0x20a>
mov    $0x0,%al
call   1030 <EVP_sha1@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0xb0(%rbp),%rcx
mov    -0xb8(%rbp),%r9
mov    $0x14,%r8d
lea    -0xc8(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <HMAC@plt>
movw   $0x0,-0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
cmp    $0x14,%eax
jge    12ff <pbkdf2+0x1cf>
mov    -0xb8(%rbp),%rax
movzwl -0xc2(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
movzwl -0xc2(%rbp),%eax
movzbl -0xa0(%rbp,%rax,1),%ecx
ff
xor    %edx,%ecx
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xc2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc2(%rbp)
jmp    12ae <pbkdf2+0x17e>
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xc0(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1261 <pbkdf2+0x131>
movw   $0x0,-0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
cmp    $0x14,%eax
jge    138f <pbkdf2+0x25f>
movzwl -0xc2(%rbp),%eax
mov    -0xa0(%rbp,%rax,1),%cl
mov    -0xa8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xa8(%rbp)
mov    %cl,(%rax)
mov    -0xc2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc2(%rbp)
jmp    1343 <pbkdf2+0x213>
jmp    1394 <pbkdf2+0x264>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11a4 <pbkdf2+0x74>
cmpq   $0x0,-0x38(%rbp)
je     1593 <pbkdf2+0x463>
lea    -0x4c(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
lea    0xc3f(%rip),%rsi
call   1050 <sprintf@plt>
mov    $0x0,%al
call   1030 <EVP_sha1@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x4c(%rbp),%rcx
lea    -0x80(%rbp),%r9
mov    $0x4,%r8d
lea    -0xc8(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <HMAC@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x80(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0xb8(%rbp)
movw   $0x0,-0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
cmp    $0x14,%eax
jge    1457 <pbkdf2+0x327>
movzwl -0xc2(%rbp),%eax
mov    -0x80(%rbp,%rax,1),%cl
movzwl -0xc2(%rbp),%eax
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xc2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc2(%rbp)
jmp    1417 <pbkdf2+0x2e7>
movq   $0x1,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x18(%rbp),%ecx
cmp    %rcx,%rax
jae    1538 <pbkdf2+0x408>
mov    $0x0,%al
call   1030 <EVP_sha1@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0xb0(%rbp),%rcx
mov    -0xb8(%rbp),%r9
mov    $0x14,%r8d
lea    -0xc8(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <HMAC@plt>
movw   $0x0,-0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
cmp    $0x14,%eax
jge    14fd <pbkdf2+0x3cd>
mov    -0xb8(%rbp),%rax
movzwl -0xc2(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
movzwl -0xc2(%rbp),%eax
movzbl -0xa0(%rbp,%rax,1),%ecx
ff
xor    %edx,%ecx
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xc2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc2(%rbp)
jmp    14ac <pbkdf2+0x37c>
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xc0(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    145f <pbkdf2+0x32f>
movw   $0x0,-0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
cmp    -0x38(%rbp),%rax
jae    158e <pbkdf2+0x45e>
movzwl -0xc2(%rbp),%eax
mov    -0xa0(%rbp,%rax,1),%cl
mov    -0xa8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xa8(%rbp)
mov    %cl,(%rax)
mov    -0xc2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc2(%rbp)
jmp    1541 <pbkdf2+0x411>
jmp    1593 <pbkdf2+0x463>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbkdf2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %edx,%r12d
mov    $0x1,%eax
movabs $0x13ffffffec,%rdx
cmp    %rdx,%r8
ja     1469 <pbkdf2+0x339>
mov    %esi,%r14d
mov    %rdi,%rbx
movabs $0xcccccccccccccccd,%rdx
cc cc cc
mov    %r8,%rax
mul    %rdx
shr    $0x4,%rdx
mov    %rdx,0x38(%rsp)
lea    0x0(,%rdx,4),%rax
lea    (%rax,%rax,4),%rax
mov    %r8,%r13
sub    %rax,%r13
mov    $0x1,%edx
mov    %r12d,%eax
cmp    $0x14,%r8
mov    %rax,0x48(%rsp)
jb     130a <pbkdf2+0x1da>
mov    %r13,0x40(%rsp)
add    $0xffffffffffffffff,%rax
mov    %rax,0x50(%rsp)
mov    $0x1,%eax
lea    0x24(%rsp),%rbp
mov    %r12d,0x30(%rsp)
jmp    1216 <pbkdf2+0xe6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movaps 0x10(%rsp),%xmm0
mov    0x28(%rsp),%rcx
movups %xmm0,(%rcx)
mov    0x20(%rsp),%al
mov    %al,0x10(%rcx)
mov    0x21(%rsp),%al
mov    %al,0x11(%rcx)
mov    0x22(%rsp),%al
mov    %al,0x12(%rcx)
mov    0x23(%rsp),%al
mov    %al,0x13(%rcx)
add    $0x14,%rcx
mov    0x58(%rsp),%rdx
lea    0x1(%rdx),%rax
cmp    0x38(%rsp),%rdx
mov    0x30(%rsp),%r12d
je     12fb <pbkdf2+0x1cb>
mov    %rcx,0x28(%rsp)
lea    0x34(%rsp),%r15
mov    %r15,%rdi
lea    0xdd6(%rip),%rsi
mov    %rax,0x58(%rsp)
mov    %rax,%rdx
call   1050 <sprintf@plt>
xor    %eax,%eax
call   1030 <EVP_sha1@plt>
mov    %rbp,(%rsp)
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    %r15,%rcx
mov    $0x4,%r8d
lea    0x60(%rsp),%r9
call   1040 <HMAC@plt>
movaps 0x60(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x70(%rsp),%eax
mov    %eax,0x20(%rsp)
cmp    $0x2,%r12d
jb     11d0 <pbkdf2+0xa0>
mov    0x50(%rsp),%r15
lea    0x74(%rsp),%rax
lea    0x60(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %rax,%r13
xor    %eax,%eax
call   1030 <EVP_sha1@plt>
mov    %rbp,(%rsp)
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    %r12,%rcx
mov    $0x14,%r8d
mov    %r13,%r9
call   1040 <HMAC@plt>
movups 0x0(%r13),%xmm0
xorps  0x10(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movzbl 0x10(%r13),%eax
xor    %al,0x20(%rsp)
movzbl 0x11(%r13),%eax
xor    %al,0x21(%rsp)
movzbl 0x12(%r13),%eax
xor    %al,0x22(%rsp)
movzbl 0x13(%r13),%eax
xor    %al,0x23(%rsp)
mov    %r12,%rax
mov    %r13,%r12
add    $0xffffffffffffffff,%r15
jne    1290 <pbkdf2+0x160>
jmp    11d0 <pbkdf2+0xa0>
mov    0x38(%rsp),%rax
add    $0x1,%eax
mov    %eax,%edx
mov    0x40(%rsp),%r13
test   %r13,%r13
je     1467 <pbkdf2+0x337>
mov    %rcx,0x28(%rsp)
lea    0xce1(%rip),%rsi
lea    0x34(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <sprintf@plt>
xor    %eax,%eax
call   1030 <EVP_sha1@plt>
lea    0x24(%rsp),%rcx
mov    %rcx,(%rsp)
lea    0x60(%rsp),%r15
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    %rbp,%rcx
mov    $0x4,%r8d
mov    %r15,%r9
call   1040 <HMAC@plt>
movaps 0x60(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x70(%rsp),%eax
mov    %eax,0x20(%rsp)
cmp    $0x2,%r12d
mov    0x48(%rsp),%r12
jb     13e6 <pbkdf2+0x2b6>
lea    0x74(%rsp),%rax
add    $0xffffffffffffffff,%r12
mov    %rax,%rbp
xor    %eax,%eax
call   1030 <EVP_sha1@plt>
lea    0x24(%rsp),%rcx
mov    %rcx,(%rsp)
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    %r15,%rcx
mov    $0x14,%r8d
mov    %rbp,%r9
call   1040 <HMAC@plt>
movups 0x0(%rbp),%xmm0
xorps  0x10(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movzbl 0x10(%rbp),%eax
xor    %al,0x20(%rsp)
movzbl 0x11(%rbp),%eax
xor    %al,0x21(%rsp)
movzbl 0x12(%rbp),%eax
xor    %al,0x22(%rsp)
movzbl 0x13(%rbp),%eax
xor    %al,0x23(%rsp)
mov    %r15,%rax
mov    %rbp,%r15
add    $0xffffffffffffffff,%r12
jne    1380 <pbkdf2+0x250>
cmp    $0x8,%r13
jae    13f5 <pbkdf2+0x2c5>
xor    %ecx,%ecx
mov    0x28(%rsp),%rdx
jmp    143f <pbkdf2+0x30f>
lea    -0x1(%r13),%rax
xor    %ecx,%ecx
cmp    $0xffff,%ax
mov    0x28(%rsp),%rbp
je     143c <pbkdf2+0x30c>
cmp    $0xffff,%rax
ja     143c <pbkdf2+0x30c>
cmp    $0x2,%r13
mov    $0x1,%esi
mov    $0x1,%eax
cmovae %r13,%rax
lea    (%rsp,%rax,1),%rcx
add    $0x10,%rcx
cmp    %rcx,%rbp
jae    147b <pbkdf2+0x34b>
add    %rbp,%rax
lea    0x10(%rsp),%rcx
cmp    %rax,%rcx
jae    147b <pbkdf2+0x34b>
xor    %ecx,%ecx
mov    %rbp,%rdx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0xf(%rsp,%rcx,1),%eax
mov    %al,(%rdx)
add    $0x1,%rdx
movzwl %cx,%eax
add    $0x1,%rcx
cmp    %rax,%r13
ja     1450 <pbkdf2+0x320>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x2,%r13
cmovae %r13,%rsi
mov    %esi,%ecx
and    $0x18,%ecx
lea    (%rcx,%rbp,1),%rdx
xor    %eax,%eax
xchg   %ax,%ax
mov    0x10(%rsp,%rax,1),%rdi
mov    %rdi,0x0(%rbp,%rax,1)
add    $0x8,%rax
cmp    %rax,%rcx
jne    1490 <pbkdf2+0x360>
xor    %eax,%eax
cmp    %rcx,%rsi
je     1469 <pbkdf2+0x339>
jmp    143f <pbkdf2+0x30f>

LLVM IR (-O0):
@.str = [5 x i8] c"%04u\00"
define i32 @pbkdf2(i8* %0, i32 %1, i32 %2, i8* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca [4 x i8]
%17 = alloca [40 x i8]
%18 = alloca [20 x i8]
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i16
%24 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%25 = load i8*, i8** %10
store i8* %25, i8** %19
%26 = load i64, i64* %11
%27 = icmp ugt i64 %26, 85899345900
br i1 %27, label %28, label %29
28: ; preds = %5
store i32 1, i32* %6
br label %218
29: ; preds = %5
%30 = load i64, i64* %11
%31 = udiv i64 %30, 20
store i64 %31, i64* %12
%32 = load i64, i64* %11
%33 = urem i64 %32, 20
store i64 %33, i64* %13
store i64 1, i64* %14
br label %34
34: ; preds = %124, %29
%35 = load i64, i64* %14
%36 = load i64, i64* %12
%37 = icmp ule i64 %35, %36
br i1 %37, label %38, label %127
38: ; preds = %34
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%40 = load i64, i64* %14
%41 = trunc i64 %40 to i32
%42 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = call i32 (...) @EVP_sha1()
%44 = load i8*, i8** %7
%45 = load i32, i32* %8
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%47 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
%48 = call i32 @HMAC(i32 %43, i8* %44, i32 %45, i8* %46, i32 4, i8* %47, i32* %24)
%49 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
store i8* %49, i8** %20
%50 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 20
store i8* %51, i8** %21
store i16 0, i16* %23
br label %52
52: ; preds = %64, %38
%53 = load i16, i16* %23
%54 = zext i16 %53 to i32
%55 = icmp slt i32 %54, 20
br i1 %55, label %56, label %67
56: ; preds = %52
%57 = load i16, i16* %23
%58 = zext i16 %57 to i64
%59 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = load i16, i16* %23
%62 = zext i16 %61 to i64
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 %62
store i8 %60, i8* %63
br label %64
64: ; preds = %56
%65 = load i16, i16* %23
%66 = add i16 %65, 1
store i16 %66, i16* %23
br label %52
67: ; preds = %52
store i64 1, i64* %15
br label %68
68: ; preds = %105, %67
%69 = load i64, i64* %15
%70 = load i32, i32* %9
%71 = zext i32 %70 to i64
%72 = icmp ult i64 %69, %71
br i1 %72, label %73, label %108
73: ; preds = %68
%74 = call i32 (...) @EVP_sha1()
%75 = load i8*, i8** %7
%76 = load i32, i32* %8
%77 = load i8*, i8** %20
%78 = load i8*, i8** %21
%79 = call i32 @HMAC(i32 %74, i8* %75, i32 %76, i8* %77, i32 20, i8* %78, i32* %24)
store i16 0, i16* %23
br label %80
80: ; preds = %98, %73
%81 = load i16, i16* %23
%82 = zext i16 %81 to i32
%83 = icmp slt i32 %82, 20
br i1 %83, label %84, label %101
84: ; preds = %80
%85 = load i8*, i8** %21
%86 = load i16, i16* %23
%87 = zext i16 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = load i16, i16* %23
%92 = zext i16 %91 to i64
%93 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = xor i32 %95, %90
%97 = trunc i32 %96 to i8
store i8 %97, i8* %93
br label %98
98: ; preds = %84
%99 = load i16, i16* %23
%100 = add i16 %99, 1
store i16 %100, i16* %23
br label %80
101: ; preds = %80
%102 = load i8*, i8** %21
store i8* %102, i8** %22
%103 = load i8*, i8** %20
store i8* %103, i8** %21
%104 = load i8*, i8** %22
store i8* %104, i8** %20
br label %105
105: ; preds = %101
%106 = load i64, i64* %15
%107 = add i64 %106, 1
store i64 %107, i64* %15
br label %68
108: ; preds = %68
store i16 0, i16* %23
br label %109
109: ; preds = %120, %108
%110 = load i16, i16* %23
%111 = zext i16 %110 to i32
%112 = icmp slt i32 %111, 20
br i1 %112, label %113, label %123
113: ; preds = %109
%114 = load i16, i16* %23
%115 = zext i16 %114 to i64
%116 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 %115
%117 = load i8, i8* %116
%118 = load i8*, i8** %19
%119 = getelementptr inbounds i8, i8* %118, i32 1
store i8* %119, i8** %19
store i8 %117, i8* %118
br label %120
120: ; preds = %113
%121 = load i16, i16* %23
%122 = add i16 %121, 1
store i16 %122, i16* %23
br label %109
123: ; preds = %109
br label %124
124: ; preds = %123
%125 = load i64, i64* %14
%126 = add i64 %125, 1
store i64 %126, i64* %14
br label %34
127: ; preds = %34
%128 = load i64, i64* %13
%129 = icmp ne i64 %128, 0
br i1 %129, label %130, label %217
130: ; preds = %127
%131 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%132 = load i64, i64* %14
%133 = trunc i64 %132 to i32
%134 = call i32 @sprintf(i8* %131, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %133)
%135 = call i32 (...) @EVP_sha1()
%136 = load i8*, i8** %7
%137 = load i32, i32* %8
%138 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%139 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
%140 = call i32 @HMAC(i32 %135, i8* %136, i32 %137, i8* %138, i32 4, i8* %139, i32* %24)
%141 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
store i8* %141, i8** %20
%142 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
%143 = getelementptr inbounds i8, i8* %142, i64 20
store i8* %143, i8** %21
store i16 0, i16* %23
br label %144
144: ; preds = %156, %130
%145 = load i16, i16* %23
%146 = zext i16 %145 to i32
%147 = icmp slt i32 %146, 20
br i1 %147, label %148, label %159
148: ; preds = %144
%149 = load i16, i16* %23
%150 = zext i16 %149 to i64
%151 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 %150
%152 = load i8, i8* %151
%153 = load i16, i16* %23
%154 = zext i16 %153 to i64
%155 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 %154
store i8 %152, i8* %155
br label %156
156: ; preds = %148
%157 = load i16, i16* %23
%158 = add i16 %157, 1
store i16 %158, i16* %23
br label %144
159: ; preds = %144
store i64 1, i64* %15
br label %160
160: ; preds = %197, %159
%161 = load i64, i64* %15
%162 = load i32, i32* %9
%163 = zext i32 %162 to i64
%164 = icmp ult i64 %161, %163
br i1 %164, label %165, label %200
165: ; preds = %160
%166 = call i32 (...) @EVP_sha1()
%167 = load i8*, i8** %7
%168 = load i32, i32* %8
%169 = load i8*, i8** %20
%170 = load i8*, i8** %21
%171 = call i32 @HMAC(i32 %166, i8* %167, i32 %168, i8* %169, i32 20, i8* %170, i32* %24)
store i16 0, i16* %23
br label %172
172: ; preds = %190, %165
%173 = load i16, i16* %23
%174 = zext i16 %173 to i32
%175 = icmp slt i32 %174, 20
br i1 %175, label %176, label %193
176: ; preds = %172
%177 = load i8*, i8** %21
%178 = load i16, i16* %23
%179 = zext i16 %178 to i64
%180 = getelementptr inbounds i8, i8* %177, i64 %179
%181 = load i8, i8* %180
%182 = zext i8 %181 to i32
%183 = load i16, i16* %23
%184 = zext i16 %183 to i64
%185 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 %184
%186 = load i8, i8* %185
%187 = zext i8 %186 to i32
%188 = xor i32 %187, %182
%189 = trunc i32 %188 to i8
store i8 %189, i8* %185
br label %190
190: ; preds = %176
%191 = load i16, i16* %23
%192 = add i16 %191, 1
store i16 %192, i16* %23
br label %172
193: ; preds = %172
%194 = load i8*, i8** %21
store i8* %194, i8** %22
%195 = load i8*, i8** %20
store i8* %195, i8** %21
%196 = load i8*, i8** %22
store i8* %196, i8** %20
br label %197
197: ; preds = %193
%198 = load i64, i64* %15
%199 = add i64 %198, 1
store i64 %199, i64* %15
br label %160
200: ; preds = %160
store i16 0, i16* %23
br label %201
201: ; preds = %213, %200
%202 = load i16, i16* %23
%203 = zext i16 %202 to i64
%204 = load i64, i64* %13
%205 = icmp ult i64 %203, %204
br i1 %205, label %206, label %216
206: ; preds = %201
%207 = load i16, i16* %23
%208 = zext i16 %207 to i64
%209 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 %208
%210 = load i8, i8* %209
%211 = load i8*, i8** %19
%212 = getelementptr inbounds i8, i8* %211, i32 1
store i8* %212, i8** %19
store i8 %210, i8* %211
br label %213
213: ; preds = %206
%214 = load i16, i16* %23
%215 = add i16 %214, 1
store i16 %215, i16* %23
br label %201
216: ; preds = %201
br label %217
217: ; preds = %216, %127
store i32 0, i32* %6
br label %218
218: ; preds = %217, %28
%219 = load i32, i32* %6
ret i32 %219
}

LLVM IR (-O2):
@.str = [5 x i8] c"%04u\00"
define i32 @pbkdf2(i8* %0, i32 %1, i32 %2, i8* nocapture writeonly %3, i64 %4) {
%6 = alloca [4 x i8]
%7 = alloca [40 x i8]
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%9 = alloca [20 x i8]
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%12 = alloca i32
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%16 = bitcast i32* %12 to i8*
%17 = icmp ugt i64 %4, 85899345900
br i1 %17, label %177, label %18
18: ; preds = %5
%19 = urem i64 %4, 20
%20 = udiv i64 %4, 20
%21 = icmp ult i64 %4, 20
br i1 %21, label %89, label %22
22: ; preds = %18
%23 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 20
%24 = zext i32 %2 to i64
%25 = icmp ugt i32 %2, 1
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 16
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 17
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 18
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 19
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 16
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 17
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 18
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 19
%34 = bitcast [20 x i8]* %9 to <16 x i8>*
%35 = bitcast [20 x i8]* %9 to <16 x i8>*
%36 = bitcast [20 x i8]* %9 to <16 x i8>*
br label %37
37: ; preds = %22, %44
%38 = phi i8* [ %3, %22 ], [ %55, %44 ]
%39 = phi i64 [ 1, %22 ], [ %56, %44 ]
%40 = trunc i64 %39 to i32
%41 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = call i32 (...) @EVP_sha1()
%43 = call i32 @HMAC(i32 %42, i8* %0, i32 %1, i8* %13, i32 4, i8* %14, i32* %12)
br i1 %25, label %58, label %44
44: ; preds = %58, %37
%45 = load <16 x i8>, <16 x i8>* %36
%46 = getelementptr inbounds i8, i8* %38, i64 16
%47 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> %45, <16 x i8>* %47
%48 = load i8, i8* %30
%49 = getelementptr inbounds i8, i8* %38, i64 17
store i8 %48, i8* %46
%50 = load i8, i8* %31
%51 = getelementptr inbounds i8, i8* %38, i64 18
store i8 %50, i8* %49
%52 = load i8, i8* %32
%53 = getelementptr inbounds i8, i8* %38, i64 19
store i8 %52, i8* %51
%54 = load i8, i8* %33
%55 = getelementptr inbounds i8, i8* %38, i64 20
store i8 %54, i8* %53
%56 = add nuw nsw i64 %39, 1
%57 = icmp eq i64 %39, %20
br i1 %57, label %86, label %37
58: ; preds = %37, %58
%59 = phi i8* [ %60, %58 ], [ %23, %37 ]
%60 = phi i8* [ %59, %58 ], [ %14, %37 ]
%61 = phi i64 [ %84, %58 ], [ 1, %37 ]
%62 = call i32 (...) @EVP_sha1()
%63 = call i32 @HMAC(i32 %62, i8* %0, i32 %1, i8* %60, i32 20, i8* %59, i32* %12)
%64 = bitcast i8* %59 to <16 x i8>*
%65 = load <16 x i8>, <16 x i8>* %64
%66 = load <16 x i8>, <16 x i8>* %34
%67 = xor <16 x i8> %66, %65
store <16 x i8> %67, <16 x i8>* %35
%68 = getelementptr inbounds i8, i8* %59, i64 16
%69 = load i8, i8* %68
%70 = load i8, i8* %26
%71 = xor i8 %70, %69
store i8 %71, i8* %26
%72 = getelementptr inbounds i8, i8* %59, i64 17
%73 = load i8, i8* %72
%74 = load i8, i8* %27
%75 = xor i8 %74, %73
store i8 %75, i8* %27
%76 = getelementptr inbounds i8, i8* %59, i64 18
%77 = load i8, i8* %76
%78 = load i8, i8* %28
%79 = xor i8 %78, %77
store i8 %79, i8* %28
%80 = getelementptr inbounds i8, i8* %59, i64 19
%81 = load i8, i8* %80
%82 = load i8, i8* %29
%83 = xor i8 %82, %81
store i8 %83, i8* %29
%84 = add nuw nsw i64 %61, 1
%85 = icmp eq i64 %84, %24
br i1 %85, label %44, label %58
86: ; preds = %44
%87 = trunc i64 %20 to i32
%88 = add i32 %87, 1
br label %89
89: ; preds = %86, %18
%90 = phi i32 [ 1, %18 ], [ %88, %86 ]
%91 = phi i8* [ %3, %18 ], [ %55, %86 ]
%92 = icmp eq i64 %19, 0
br i1 %92, label %177, label %93
93: ; preds = %89
%94 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %90)
%95 = call i32 (...) @EVP_sha1()
%96 = call i32 @HMAC(i32 %95, i8* %0, i32 %1, i8* %13, i32 4, i8* %14, i32* %12)
%97 = zext i32 %2 to i64
%98 = icmp ugt i32 %2, 1
br i1 %98, label %99, label %107
99: ; preds = %93
%100 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 20
%101 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 16
%102 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 17
%103 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 18
%104 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 19
%105 = bitcast [20 x i8]* %9 to <16 x i8>*
%106 = bitcast [20 x i8]* %9 to <16 x i8>*
br label %140
107: ; preds = %140, %93
%108 = icmp ult i64 %19, 8
br i1 %108, label %137, label %109
109: ; preds = %107
%110 = add nsw i64 %19, -1
%111 = trunc i64 %110 to i16
%112 = icmp eq i16 %111, -1
%113 = icmp ugt i64 %110, 65535
%114 = or i1 %112, %113
br i1 %114, label %137, label %115
115: ; preds = %109
%116 = call i64 @llvm.umax.i64(i64 %19, i64 1)
%117 = getelementptr i8, i8* %91, i64 %116
%118 = getelementptr [20 x i8], [20 x i8]* %9, i64 0, i64 %116
%119 = icmp ult i8* %91, %118
%120 = icmp ult i8* %10, %117
%121 = and i1 %119, %120
br i1 %121, label %137, label %122
122: ; preds = %115
%123 = call i64 @llvm.umax.i64(i64 %19, i64 1)
%124 = and i64 %123, 24
%125 = getelementptr i8, i8* %91, i64 %124
br label %126
126: ; preds = %126, %122
%127 = phi i64 [ 0, %122 ], [ %133, %126 ]
%128 = getelementptr i8, i8* %91, i64 %127
%129 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 %127
%130 = bitcast i8* %129 to <8 x i8>*
%131 = load <8 x i8>, <8 x i8>* %130
%132 = bitcast i8* %128 to <8 x i8>*
store <8 x i8> %131, <8 x i8>* %132
%133 = add nuw i64 %127, 8
%134 = icmp eq i64 %133, %124
br i1 %134, label %135, label %126
135: ; preds = %126
%136 = icmp eq i64 %123, %124
br i1 %136, label %177, label %137
137: ; preds = %115, %109, %107, %135
%138 = phi i64 [ 0, %107 ], [ 0, %115 ], [ 0, %109 ], [ %124, %135 ]
%139 = phi i8* [ %91, %107 ], [ %91, %115 ], [ %91, %109 ], [ %125, %135 ]
br label %168
140: ; preds = %99, %140
%141 = phi i8* [ %142, %140 ], [ %100, %99 ]
%142 = phi i8* [ %141, %140 ], [ %14, %99 ]
%143 = phi i64 [ %166, %140 ], [ 1, %99 ]
%144 = call i32 (...) @EVP_sha1()
%145 = call i32 @HMAC(i32 %144, i8* %0, i32 %1, i8* %142, i32 20, i8* %141, i32* %12)
%146 = bitcast i8* %141 to <16 x i8>*
%147 = load <16 x i8>, <16 x i8>* %146
%148 = load <16 x i8>, <16 x i8>* %105
%149 = xor <16 x i8> %148, %147
store <16 x i8> %149, <16 x i8>* %106
%150 = getelementptr inbounds i8, i8* %141, i64 16
%151 = load i8, i8* %150
%152 = load i8, i8* %101
%153 = xor i8 %152, %151
store i8 %153, i8* %101
%154 = getelementptr inbounds i8, i8* %141, i64 17
%155 = load i8, i8* %154
%156 = load i8, i8* %102
%157 = xor i8 %156, %155
store i8 %157, i8* %102
%158 = getelementptr inbounds i8, i8* %141, i64 18
%159 = load i8, i8* %158
%160 = load i8, i8* %103
%161 = xor i8 %160, %159
store i8 %161, i8* %103
%162 = getelementptr inbounds i8, i8* %141, i64 19
%163 = load i8, i8* %162
%164 = load i8, i8* %104
%165 = xor i8 %164, %163
store i8 %165, i8* %104
%166 = add nuw nsw i64 %143, 1
%167 = icmp eq i64 %166, %97
br i1 %167, label %107, label %140
168: ; preds = %137, %168
%169 = phi i64 [ %174, %168 ], [ %138, %137 ]
%170 = phi i8* [ %173, %168 ], [ %139, %137 ]
%171 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 %169
%172 = load i8, i8* %171
%173 = getelementptr inbounds i8, i8* %170, i64 1
store i8 %172, i8* %170
%174 = add i64 %169, 1
%175 = and i64 %174, 65535
%176 = icmp ugt i64 %19, %175
br i1 %176, label %168, label %177
177: ; preds = %168, %135, %89, %5
%178 = phi i32 [ 1, %5 ], [ 0, %89 ], [ 0, %135 ], [ 0, %168 ]
ret i32 %178
}