#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 EOF;
int /*<<< orphan*/ EVP_sha256();
int /*<<< orphan*/ PKCS5_PBKDF2_HMAC(char *, int, unsigned char *, int, int,
                                     int /*<<< orphan*/, int, unsigned char *);
int RAND_bytes(unsigned char *, int);
int atoi(char *);
int base64_encode(unsigned char *, int, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
char *getpass(char *);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, char *, int, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int strlen(char *);
int main(int argc, char **argv) {
  int iterations = 901, rc, saltlen, blen;
  unsigned char saltbytes[12];
  char *salt, *b64;
  unsigned char key[128];
  char *pw1, *pw2, *password;
  char *progname = argv[0];
  int c;
  int prompt;
  prompt = 1;
  while ((c = getopt(argc, argv, "ip:")) != EOF) {
    switch (c) {
    case 'i':
      iterations = atoi(optarg);
      break;
    case 'p':
      pw1 = strdup(optarg);
      pw2 = strdup(optarg);
      prompt = 0;
      break;
    default:
      exit(fprintf(stderr, "Usage: %s [-i iterations] [-p password]\n",
                   progname));
    }
  }
  argc -= optind - 1;
  argv += optind - 1;
  if (argc != 1) {
    exit(
        fprintf(stderr, "Usage: %s [-i iterations] [-p password]\n", progname));
  }
  if (prompt) {
    pw1 = strdup(getpass("Enter password: "));
    pw2 = getpass("Re-enter same password: ");
  }
  if (strcmp(pw1, pw2) != 0) {
    fprintf(stderr, "Passwords don't match!\n");
    return (1);
  }
  password = pw1;
  rc = RAND_bytes(saltbytes, 12);
  if (rc == 0) {
    fprintf(stderr, "Cannot get random bytes for salt!\n");
    return 2;
  }
  base64_encode(saltbytes, 12, &salt);
  saltlen = strlen(salt);
  PKCS5_PBKDF2_HMAC(password, strlen(password), (unsigned char *)salt, saltlen,
                    iterations, EVP_sha256(), 24, key);
  blen = base64_encode(key, 24, &b64);
  if (blen > 0) {
    printf("PBKDF2$%s$%d$%s$%s\n", "sha256", iterations, salt, b64);
    free(b64);
  }
  free(password);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x385,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xe0(%rbp)
movl   $0x1,-0xe8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdda(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0xe4(%rbp)
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%eax
je     12ea <main+0x10a>
mov    -0xe4(%rbp),%eax
mov    %eax,-0xec(%rbp)
sub    $0x69,%eax
je     126e <main+0x8e>
jmp    125a <main+0x7a>
mov    -0xec(%rbp),%eax
sub    $0x70,%eax
je     1285 <main+0xa5>
jmp    12c0 <main+0xe0>
mov    0x2d83(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    12e5 <main+0x105>
mov    0x2d6c(%rip),%rax
mov    (%rax),%rdi
call   10f0 <strdup@plt>
mov    %rax,-0xc8(%rbp)
mov    0x2d56(%rip),%rax
mov    (%rax),%rdi
call   10f0 <strdup@plt>
mov    %rax,-0xd0(%rbp)
movl   $0x0,-0xe8(%rbp)
jmp    12e5 <main+0x105>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
mov    -0xe0(%rbp),%rdx
lea    0xd2d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    %eax,%edi
call   10e0 <exit@plt>
jmp    1218 <main+0x38>
mov    0x2ce7(%rip),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    0x2cd3(%rip),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     134b <main+0x16b>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
mov    -0xe0(%rbp),%rdx
lea    0xcc7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    %eax,%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0xe8(%rbp)
je     1386 <main+0x1a6>
lea    0xcce(%rip),%rdi
call   10b0 <getpass@plt>
mov    %rax,%rdi
call   10f0 <strdup@plt>
mov    %rax,-0xc8(%rbp)
lea    0xcc4(%rip),%rdi
call   10b0 <getpass@plt>
mov    %rax,-0xd0(%rbp)
mov    -0xc8(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     13c6 <main+0x1e6>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
lea    0xca4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150c <main+0x32c>
mov    -0xc8(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0x2c(%rbp),%rdi
mov    $0xc,%esi
call   1060 <RAND_bytes@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1412 <main+0x232>
mov    0x2bd2(%rip),%rax
mov    (%rax),%edi
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    150c <main+0x32c>
lea    -0x2c(%rbp),%rdi
mov    $0xc,%esi
lea    -0x38(%rbp),%rdx
call   10a0 <base64_encode@plt>
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xd8(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0xd8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x104(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xf4(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xf0(%rbp)
mov    $0x0,%al
call   1100 <EVP_sha256@plt>
mov    -0x110(%rbp),%rdi
mov    -0x104(%rbp),%esi
mov    -0x100(%rbp),%rdx
mov    -0xf4(%rbp),%ecx
mov    -0xf0(%rbp),%r8d
mov    %eax,%r9d
lea    -0xc0(%rbp),%rax
movl   $0x18,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <PKCS5_PBKDF2_HMAC@plt>
lea    -0xc0(%rbp),%rdi
mov    $0x18,%esi
lea    -0x40(%rbp),%rdx
call   10a0 <base64_encode@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    14f9 <main+0x319>
mov    -0x14(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
lea    0xbae(%rip),%rdi
lea    0xbbb(%rip),%rsi
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0xd8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    (%rsi),%rax
mov    %rax,0x8(%rsp)
lea    0xdfa(%rip),%rdx
call   10c0 <getopt@plt>
mov    0x2dce(%rip),%rcx
cmp    (%rcx),%eax
jne    1231 <main+0x51>
mov    0x2dbb(%rip),%rax
mov    $0x385,%r12d
cmp    (%rax),%r15d
je     12b8 <main+0xd8>
jmp    1409 <main+0x229>
mov    $0x385,%r12d
mov    $0x1,%ebp
jmp    127f <main+0x9f>
xchg   %ax,%ax
mov    0x2db1(%rip),%rax
mov    (%rax),%rbp
mov    %rbp,%rdi
call   10f0 <strdup@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   10f0 <strdup@plt>
mov    %rax,%r13
xor    %ebp,%ebp
mov    %r15d,%edi
mov    %rbx,%rsi
lea    0xd91(%rip),%rdx
call   10c0 <getopt@plt>
mov    0x2d65(%rip),%rcx
cmp    (%rcx),%eax
je     12a1 <main+0xc1>
cmp    $0x70,%eax
je     1240 <main+0x60>
cmp    $0x69,%eax
jne    1409 <main+0x229>
mov    0x2d64(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r12d
jmp    1262 <main+0x82>
mov    0x2d30(%rip),%rax
cmp    (%rax),%r15d
jne    1409 <main+0x229>
mov    %r14,%rbx
test   %ebp,%ebp
je     12de <main+0xfe>
lea    0xd6e(%rip),%rdi
call   10b0 <getpass@plt>
mov    %rax,%rdi
call   10f0 <strdup@plt>
mov    %rax,%rbx
lea    0xd68(%rip),%rdi
call   10b0 <getpass@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     130f <main+0x12f>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebx
jmp    13f5 <main+0x215>
lea    0x24(%rsp),%rdi
mov    $0xc,%esi
call   1060 <RAND_bytes@plt>
test   %eax,%eax
je     13d9 <main+0x1f9>
lea    0x24(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    $0xc,%esi
call   10a0 <base64_encode@plt>
mov    0x10(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%r15
mov    %rbx,%r13
xor    %ebx,%ebx
xor    %eax,%eax
call   1100 <EVP_sha256@plt>
lea    0x30(%rsp),%r10
mov    %r13,0x8(%rsp)
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %r12d,%r8d
mov    %eax,%r9d
push   %r10
mov    %r10,%rbp
push   $0x18
call   1040 <PKCS5_PBKDF2_HMAC@plt>
add    $0x10,%rsp
lea    0x18(%rsp),%rdx
mov    %rbp,%rdi
mov    $0x18,%esi
call   10a0 <base64_encode@plt>
test   %eax,%eax
jle    13cd <main+0x1ed>
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
lea    0xcde(%rip),%rdi
lea    0xceb(%rip),%rsi
mov    %r12d,%edx
call   1070 <printf@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    13f5 <main+0x215>
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
lea    0xc86(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
lea    0xbeb(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %eax,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"ip:\00"
@EOF = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [41 x i8] c"Usage: %s [-i iterations] [-p password]\0A\00"
@optind = global i32 0
@.str.2 = [17 x i8] c"Enter password: \00"
@.str.3 = [25 x i8] c"Re-enter same password: \00"
@.str.4 = [24 x i8] c"Passwords don't match!\0A\00"
@.str.5 = [35 x i8] c"Cannot get random bytes for salt!\0A\00"
@.str.6 = [20 x i8] c"PBKDF2$%s$%d$%s$%s\0A\00"
@.str.7 = [7 x i8] c"sha256\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [12 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [128 x i8]
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 901, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
store i8* %22, i8** %17
store i32 1, i32* %19
br label %23
23: ; preds = %44, %2
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
%26 = call i32 @getopt(i32 %24, i8** %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %26, i32* %18
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %45
29: ; preds = %23
%30 = load i32, i32* %18
switch i32 %30, label %39 [
i32 105, label %31
i32 112, label %34
]
31: ; preds = %29
%32 = load i8*, i8** @optarg
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %6
br label %44
34: ; preds = %29
%35 = load i8*, i8** @optarg
%36 = call i8* @strdup(i8* %35)
store i8* %36, i8** %14
%37 = load i8*, i8** @optarg
%38 = call i8* @strdup(i8* %37)
store i8* %38, i8** %15
store i32 0, i32* %19
br label %44
39: ; preds = %29
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %17
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %34, %31
br label %23
45: ; preds = %23
%46 = load i32, i32* @optind
%47 = sub nsw i32 %46, 1
%48 = load i32, i32* %4
%49 = sub nsw i32 %48, %47
store i32 %49, i32* %4
%50 = load i32, i32* @optind
%51 = sub nsw i32 %50, 1
%52 = load i8**, i8*** %5
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds i8*, i8** %52, i64 %53
store i8** %54, i8*** %5
%55 = load i32, i32* %4
%56 = icmp ne i32 %55, 1
br i1 %56, label %57, label %62
57: ; preds = %45
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %17
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %59)
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %45
%63 = load i32, i32* %19
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = call i8* @getpass(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%67 = call i8* @strdup(i8* %66)
store i8* %67, i8** %14
%68 = call i8* @getpass(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i8* %68, i8** %15
br label %69
69: ; preds = %65, %62
%70 = load i8*, i8** %14
%71 = load i8*, i8** %15
%72 = call i64 @strcmp(i8* %70, i8* %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %114
77: ; preds = %69
%78 = load i8*, i8** %14
store i8* %78, i8** %16
%79 = getelementptr inbounds [12 x i8], [12 x i8]* %10, i64 0, i64 0
%80 = call i32 @RAND_bytes(i8* %79, i32 12)
store i32 %80, i32* %7
%81 = load i32, i32* %7
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %77
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %114
86: ; preds = %77
%87 = getelementptr inbounds [12 x i8], [12 x i8]* %10, i64 0, i64 0
%88 = call i32 @base64_encode(i8* %87, i32 12, i8** %11)
%89 = load i8*, i8** %11
%90 = call i32 @strlen(i8* %89)
store i32 %90, i32* %8
%91 = load i8*, i8** %16
%92 = load i8*, i8** %16
%93 = call i32 @strlen(i8* %92)
%94 = load i8*, i8** %11
%95 = load i32, i32* %8
%96 = load i32, i32* %6
%97 = call i32 (...) @EVP_sha256()
%98 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%99 = call i32 @PKCS5_PBKDF2_HMAC(i8* %91, i32 %93, i8* %94, i32 %95, i32 %96, i32 %97, i32 24, i8* %98)
%100 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%101 = call i32 @base64_encode(i8* %100, i32 24, i8** %12)
store i32 %101, i32* %9
%102 = load i32, i32* %9
%103 = icmp sgt i32 %102, 0
br i1 %103, label %104, label %111
104: ; preds = %86
%105 = load i32, i32* %6
%106 = load i8*, i8** %11
%107 = load i8*, i8** %12
%108 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %105, i8* %106, i8* %107)
%109 = load i8*, i8** %12
%110 = call i32 @free(i8* %109)
br label %111
111: ; preds = %104, %86
%112 = load i8*, i8** %16
%113 = call i32 @free(i8* %112)
store i32 0, i32* %3
br label %114
114: ; preds = %111, %83, %74
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
@.str = [4 x i8] c"ip:\00"
@EOF = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [41 x i8] c"Usage: %s [-i iterations] [-p password]\0A\00"
@optind = global i32 0
@.str.2 = [17 x i8] c"Enter password: \00"
@.str.3 = [25 x i8] c"Re-enter same password: \00"
@.str.4 = [24 x i8] c"Passwords don't match!\0A\00"
@.str.5 = [35 x i8] c"Cannot get random bytes for salt!\0A\00"
@.str.6 = [20 x i8] c"PBKDF2$%s$%d$%s$%s\0A\00"
@.str.7 = [7 x i8] c"sha256\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [12 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [128 x i8]
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%8 = bitcast i8** %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %1
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %45, label %15
15: ; preds = %2, %32
%16 = phi i32 [ %37, %32 ], [ %12, %2 ]
%17 = phi i32 [ %36, %32 ], [ 1, %2 ]
%18 = phi i8* [ %35, %32 ], [ undef, %2 ]
%19 = phi i8* [ %34, %32 ], [ undef, %2 ]
%20 = phi i32 [ %33, %32 ], [ 901, %2 ]
switch i32 %16, label %28 [
i32 105, label %21
i32 112, label %24
]
21: ; preds = %15
%22 = load i8*, i8** @optarg
%23 = tail call i32 @atoi(i8* %22)
br label %32
24: ; preds = %15
%25 = load i8*, i8** @optarg
%26 = tail call i8* @strdup(i8* %25)
%27 = tail call i8* @strdup(i8* %25)
br label %32
28: ; preds = %15
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %24, %21
%33 = phi i32 [ %20, %24 ], [ %23, %21 ]
%34 = phi i8* [ %26, %24 ], [ %19, %21 ]
%35 = phi i8* [ %27, %24 ], [ %18, %21 ]
%36 = phi i32 [ 0, %24 ], [ %17, %21 ]
%37 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %15
40: ; preds = %32
%41 = load i32, i32* @optind
%42 = add i32 %0, 1
%43 = sub i32 %42, %41
%44 = icmp eq i32 %43, 1
br i1 %44, label %54, label %50
45: ; preds = %2
%46 = load i32, i32* @optind
%47 = add i32 %0, 1
%48 = sub i32 %47, %46
%49 = icmp eq i32 %48, 1
br i1 %49, label %56, label %50
50: ; preds = %45, %40
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %40
%55 = icmp eq i32 %36, 0
br i1 %55, label %61, label %56
56: ; preds = %45, %54
%57 = phi i32 [ %33, %54 ], [ 901, %45 ]
%58 = tail call i8* @getpass(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%59 = tail call i8* @strdup(i8* %58)
%60 = tail call i8* @getpass(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %56, %54
%62 = phi i32 [ %57, %56 ], [ %33, %54 ]
%63 = phi i8* [ %59, %56 ], [ %34, %54 ]
%64 = phi i8* [ %60, %56 ], [ %35, %54 ]
%65 = tail call i64 @strcmp(i8* %63, i8* %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %61
%68 = load i32, i32* @stderr
%69 = tail call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %94
70: ; preds = %61
%71 = call i32 @RAND_bytes(i8* %7, i32 12)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %94
76: ; preds = %70
%77 = call i32 @base64_encode(i8* %7, i32 12, i8** %4)
%78 = load i8*, i8** %4
%79 = call i32 @strlen(i8* %78)
%80 = call i32 @strlen(i8* %63)
%81 = load i8*, i8** %4
%82 = call i32 (...) @EVP_sha256()
%83 = call i32 @PKCS5_PBKDF2_HMAC(i8* %63, i32 %80, i8* %81, i32 %79, i32 %62, i32 %82, i32 24, i8* %10)
%84 = call i32 @base64_encode(i8* %10, i32 24, i8** %5)
%85 = icmp sgt i32 %84, 0
br i1 %85, label %86, label %92
86: ; preds = %76
%87 = load i8*, i8** %4
%88 = load i8*, i8** %5
%89 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %62, i8* %87, i8* %88)
%90 = load i8*, i8** %5
%91 = call i32 @free(i8* %90)
br label %92
92: ; preds = %86, %76
%93 = call i32 @free(i8* %63)
br label %94
94: ; preds = %92, %73, %67
%95 = phi i32 [ 1, %67 ], [ 2, %73 ], [ 0, %92 ]
ret i32 %95
}