#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int SHA256_DIGEST_LENGTH;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, size_t);
int /*<<< orphan*/ generate_pair(int, unsigned char *);
char getopt(int, char **, char *);
size_t hash_until(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ help();
int /*<<< orphan*/ load_bytes(char *, unsigned char *, int, char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
size_t verify_pair(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ version();
int main(int argc, char *argv[]) {
  char choice;
  char *public_key = NULL;
  char *private_key = NULL;
  unsigned char public_key_b[SHA256_DIGEST_LENGTH];
  unsigned char private_key_b[SHA256_DIGEST_LENGTH];
  int mode_create = 0;
  int mode_verify = 0;
  int mode_prove = 0;
  int iterations = 4194304;
  int offset = 1;
  while ((choice = getopt(argc, argv, "Vhcvpi:a:b:o:")) != -1) {
    switch (choice) {
    case 'c':
      mode_create = 1;
      break;
    case 'v':
      mode_verify = 1;
      break;
    case 'p':
      mode_prove = 1;
      break;
    case 'i':
      iterations = atoi(optarg);
      break;
    case 'o':
      offset = atoi(optarg);
      break;
    case 'a':
      public_key = optarg;
      break;
    case 'b':
      private_key = optarg;
      break;
    case 'V':
      version();
      break;
    case 'h':
      help();
      break;
    default:
      help();
    }
  }
  if (mode_create) {
    if (private_key) {
      load_bytes(private_key, private_key_b, SHA256_DIGEST_LENGTH,
                 "Please enter your private key: ");
      generate_pair(iterations, private_key_b);
    } else {
      generate_pair(iterations, NULL);
    }
    exit(EXIT_SUCCESS);
  }
  if (mode_prove) {
    size_t current_iterations;
    int verification_iterations;
    unsigned char private_tmp[SHA256_DIGEST_LENGTH];
    load_bytes(private_key, private_key_b, SHA256_DIGEST_LENGTH,
               "Please enter your private key: ");
    load_bytes(public_key, public_key_b, SHA256_DIGEST_LENGTH,
               "Please enter known public key: ");
    memcpy(private_tmp, private_key_b, SHA256_DIGEST_LENGTH);
    current_iterations = hash_until(private_tmp, public_key_b, iterations);
    verification_iterations = current_iterations - offset;
    if (verification_iterations <= 0 ||
        verification_iterations >= current_iterations) {
      fprintf(stderr,
              "Invalid offset: %d. Public/private key are only %lu "
              "iterations apart.\n",
              offset, current_iterations);
      exit(EXIT_FAILURE);
    }
    memcpy(private_tmp, private_key_b, SHA256_DIGEST_LENGTH);
    hash_until(private_tmp, NULL, verification_iterations);
    if (verify_pair(private_tmp, public_key_b, offset)) {
      printf("Success!\n");
      exit(EXIT_SUCCESS);
    } else {
      printf("Fail.\n");
      exit(EXIT_FAILURE);
    }
  }
  if (mode_verify) {
    size_t result = 0;
    load_bytes(public_key, public_key_b, SHA256_DIGEST_LENGTH,
               "Please enter known public key: ");
    load_bytes(private_key, private_key_b, SHA256_DIGEST_LENGTH,
               "Please enter verification key: ");
    result = verify_pair(private_key_b, public_key_b, iterations);
    if (result) {
      printf("Success, %lu iterations!\n", result);
      exit(EXIT_SUCCESS);
    } else {
      printf("Could not verify pair after %d iterations\n", iterations);
      exit(EXIT_FAILURE);
    }
  }
  help();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x400000,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1a(%rip),%rdx
call   10b0 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     134a <main+0x18a>
movsbl -0x11(%rbp),%eax
add    $0xffffffaa,%eax
mov    %eax,%ecx
mov    %rcx,-0x98(%rbp)
sub    $0x20,%eax
ja     133e <main+0x17e>
mov    -0x98(%rbp),%rax
lea    0xd5b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x44(%rbp)
jmp    1345 <main+0x185>
movl   $0x1,-0x48(%rbp)
jmp    1345 <main+0x185>
movl   $0x1,-0x4c(%rbp)
jmp    1345 <main+0x185>
mov    0x2d1f(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x50(%rbp)
jmp    1345 <main+0x185>
mov    0x2d08(%rip),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x54(%rbp)
jmp    1345 <main+0x185>
mov    0x2cf1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1345 <main+0x185>
mov    0x2cde(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1345 <main+0x185>
mov    $0x0,%al
call   1090 <version@plt>
jmp    1345 <main+0x185>
mov    $0x0,%al
call   10c0 <help@plt>
jmp    1345 <main+0x185>
mov    $0x0,%al
call   10c0 <help@plt>
jmp    125c <main+0x9c>
cmpl   $0x0,-0x44(%rbp)
je     13ad <main+0x1ed>
cmpq   $0x0,-0x28(%rbp)
je     1393 <main+0x1d3>
mov    -0x88(%rbp),%rsi
mov    -0x28(%rbp),%rdi
mov    0x2c5f(%rip),%rax
mov    (%rax),%edx
lea    0xd18(%rip),%rcx
call   1060 <load_bytes@plt>
mov    -0x88(%rbp),%rsi
mov    -0x50(%rbp),%edi
call   1050 <generate_pair@plt>
jmp    139f <main+0x1df>
mov    -0x50(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <generate_pair@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x4c(%rbp)
je     1533 <main+0x373>
mov    -0x88(%rbp),%rsi
mov    0x2c0b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2bd8(%rip),%rax
mov    (%rax),%edx
lea    0xc91(%rip),%rcx
call   1060 <load_bytes@plt>
mov    -0x90(%rbp),%rsi
mov    -0x20(%rbp),%rdi
mov    0x2bb8(%rip),%rax
mov    (%rax),%edx
lea    0xc91(%rip),%rcx
call   1060 <load_bytes@plt>
mov    -0x88(%rbp),%rsi
mov    -0xa0(%rbp),%rdi
mov    0x2b95(%rip),%rax
mov    (%rax),%edx
call   1080 <memcpy@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    -0x50(%rbp),%edx
call   1040 <hash_until@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    1482 <main+0x2c2>
movslq -0x64(%rbp),%rax
cmp    -0x60(%rbp),%rax
jb     14ac <main+0x2ec>
mov    0x2b4f(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%edx
mov    -0x60(%rbp),%rcx
lea    0xc39(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    0x2b0f(%rip),%rax
mov    (%rax),%edx
call   1080 <memcpy@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x64(%rbp),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <hash_until@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   10a0 <verify_pair@plt>
cmp    $0x0,%rax
je     1517 <main+0x357>
lea    0xc17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ab0(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xc05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2a9c(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x48(%rbp)
je     15e9 <main+0x429>
mov    -0x90(%rbp),%rsi
movq   $0x0,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2a79(%rip),%rax
mov    (%rax),%edx
lea    0xb52(%rip),%rcx
call   1060 <load_bytes@plt>
mov    -0x88(%rbp),%rsi
mov    -0x28(%rbp),%rdi
mov    0x2a59(%rip),%rax
mov    (%rax),%edx
lea    0xbaa(%rip),%rcx
call   1060 <load_bytes@plt>
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    -0x50(%rbp),%edx
call   10a0 <verify_pair@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
je     15ca <main+0x40a>
mov    -0x80(%rbp),%rsi
lea    0xb95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x29fd(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x50(%rbp),%esi
lea    0xb90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x29e6(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   10c0 <help@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
lea    0xe6b(%rip),%rdx
call   10c0 <getopt@plt>
cmp    $0xff,%al
je     1320 <main+0x150>
movl   $0x400000,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
lea    0xdc5(%rip),%r14
xor    %ecx,%ecx
mov    %rcx,-0x58(%rbp)
xor    %ecx,%ecx
mov    %rcx,-0x38(%rbp)
xor    %ebx,%ebx
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    1284 <main+0xb4>
nopl   0x0(%rax)
xor    %eax,%eax
call   10d0 <help@plt>
mov    %r13d,%ebx
mov    %r12d,%edi
mov    %r15,%rsi
lea    0xe0d(%rip),%rdx
call   10c0 <getopt@plt>
cmp    $0xff,%al
je     130c <main+0x13c>
mov    %ebx,%r13d
movsbl %al,%eax
add    $0xffffffaa,%eax
cmp    $0x20,%eax
ja     1260 <main+0x90>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
mov    $0x1,%ebx
jmp    *%rax
xor    %eax,%eax
call   10a0 <version@plt>
jmp    1267 <main+0x97>
mov    0x2d48(%rip),%rax
mov    (%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    1267 <main+0x97>
mov    0x2d34(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1267 <main+0x97>
mov    0x2d24(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1267 <main+0x97>
mov    0x2d14(%rip),%rax
mov    (%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    1267 <main+0x97>
movl   $0x1,-0x40(%rbp)
jmp    1267 <main+0x97>
movl   $0x1,-0x3c(%rbp)
jmp    1267 <main+0x97>
test   %ebx,%ebx
jne    1338 <main+0x168>
cmpl   $0x0,-0x40(%rbp)
jne    134d <main+0x17d>
cmpl   $0x0,-0x3c(%rbp)
jne    1422 <main+0x252>
xor    %eax,%eax
call   10d0 <help@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmpq   $0x0,-0x38(%rbp)
jne    1481 <main+0x2b1>
mov    -0x2c(%rbp),%edi
xor    %esi,%esi
jmp    14a7 <main+0x2d7>
mov    0x2c7c(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%r15
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xd1f(%rip),%rcx
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%r14
mov    %r14,%rsi
call   1070 <load_bytes@plt>
mov    (%r12),%edx
lea    0xd24(%rip),%rcx
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rbx
mov    %rbx,%rsi
call   1070 <load_bytes@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <memcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    -0x2c(%rbp),%edx
call   1050 <hash_until@plt>
mov    %eax,%r12d
sub    -0x30(%rbp),%r12d
test   %r12d,%r12d
jle    14ae <main+0x2de>
movslq %r12d,%rcx
cmp    %rcx,%rax
jbe    14ae <main+0x2de>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    -0x48(%rbp),%rsi
call   1090 <memcpy@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1050 <hash_until@plt>
mov    %r15,%rdi
mov    -0x50(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   10b0 <verify_pair@plt>
test   %rax,%rax
jne    14ea <main+0x31a>
lea    0xd66(%rip),%rdi
call   1030 <puts@plt>
jmp    14c9 <main+0x2f9>
mov    0x2ba7(%rip),%rbx
mov    (%rbx),%edx
lea    0xc80(%rip),%rcx
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%r14
mov    %r14,%rsi
call   1070 <load_bytes@plt>
mov    (%rbx),%edx
lea    0xcce(%rip),%rcx
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rsi
call   1070 <load_bytes@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    -0x2c(%rbp),%edx
call   10b0 <verify_pair@plt>
test   %rax,%rax
jne    14d7 <main+0x307>
lea    0xcde(%rip),%rdi
mov    -0x2c(%rbp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    14c9 <main+0x2f9>
mov    0x2b48(%rip),%rax
mov    (%rax),%edx
lea    0xc01(%rip),%rcx
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rsi
call   1070 <load_bytes@plt>
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
call   1060 <generate_pair@plt>
jmp    14f6 <main+0x326>
mov    0x2b23(%rip),%rcx
mov    (%rcx),%edi
lea    0xc14(%rip),%rsi
mov    -0x30(%rbp),%edx
mov    %rax,%rcx
call   1080 <fprintf@plt>
mov    0x2af8(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0xc5b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    14f6 <main+0x326>
lea    0xc93(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ac3(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@SHA256_DIGEST_LENGTH = global i32 0
@.str = [14 x i8] c"Vhcvpi:a:b:o:\00"
@optarg = global i8* null
@.str.1 = [32 x i8] c"Please enter your private key: \00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [32 x i8] c"Please enter known public key: \00"
@stderr = global i32 0
@.str.3 = [71 x i8] c"Invalid offset: %d. Public/private key are only %lu iterations apart.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [10 x i8] c"Success!\0A\00"
@.str.5 = [7 x i8] c"Fail.\0A\00"
@.str.6 = [32 x i8] c"Please enter verification key: \00"
@.str.7 = [26 x i8] c"Success, %lu iterations!\0A\00"
@.str.8 = [43 x i8] c"Could not verify pair after %d iterations\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
%22 = load i32, i32* @SHA256_DIGEST_LENGTH
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %9
%25 = alloca i8, i64 %23
store i64 %23, i64* %10
%26 = load i32, i32* @SHA256_DIGEST_LENGTH
%27 = zext i32 %26 to i64
%28 = alloca i8, i64 %27
store i64 %27, i64* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 4194304, i32* %15
store i32 1, i32* %16
br label %29
29: ; preds = %57, %2
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call signext i8 @getopt(i32 %30, i8** %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8 %32, i8* %6
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, -1
br i1 %34, label %35, label %58
35: ; preds = %29
%36 = load i8, i8* %6
%37 = sext i8 %36 to i32
switch i32 %37, label %55 [
i32 99, label %38
i32 118, label %39
i32 112, label %40
i32 105, label %41
i32 111, label %44
i32 97, label %47
i32 98, label %49
i32 86, label %51
i32 104, label %53
]
38: ; preds = %35
store i32 1, i32* %12
br label %57
39: ; preds = %35
store i32 1, i32* %13
br label %57
40: ; preds = %35
store i32 1, i32* %14
br label %57
41: ; preds = %35
%42 = load i8*, i8** @optarg
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %15
br label %57
44: ; preds = %35
%45 = load i8*, i8** @optarg
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %16
br label %57
47: ; preds = %35
%48 = load i8*, i8** @optarg
store i8* %48, i8** %7
br label %57
49: ; preds = %35
%50 = load i8*, i8** @optarg
store i8* %50, i8** %8
br label %57
51: ; preds = %35
%52 = call i32 (...) @version()
br label %57
53: ; preds = %35
%54 = call i32 (...) @help()
br label %57
55: ; preds = %35
%56 = call i32 (...) @help()
br label %57
57: ; preds = %55, %53, %51, %49, %47, %44, %41, %40, %39, %38
br label %29
58: ; preds = %29
%59 = load i32, i32* %12
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %76
61: ; preds = %58
%62 = load i8*, i8** %8
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i8*, i8** %8
%66 = load i32, i32* @SHA256_DIGEST_LENGTH
%67 = call i32 @load_bytes(i8* %65, i8* %28, i32 %66, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%68 = load i32, i32* %15
%69 = call i32 @generate_pair(i32 %68, i8* %28)
br label %73
70: ; preds = %61
%71 = load i32, i32* %15
%72 = call i32 @generate_pair(i32 %71, i8* null)
br label %73
73: ; preds = %70, %64
%74 = load i32, i32* @EXIT_SUCCESS
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %58
%77 = load i32, i32* %14
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %129
79: ; preds = %76
%80 = load i32, i32* @SHA256_DIGEST_LENGTH
%81 = zext i32 %80 to i64
%82 = call i8* @llvm.stacksave()
store i8* %82, i8** %19
%83 = alloca i8, i64 %81
store i64 %81, i64* %20
%84 = load i8*, i8** %8
%85 = load i32, i32* @SHA256_DIGEST_LENGTH
%86 = call i32 @load_bytes(i8* %84, i8* %28, i32 %85, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%87 = load i8*, i8** %7
%88 = load i32, i32* @SHA256_DIGEST_LENGTH
%89 = call i32 @load_bytes(i8* %87, i8* %25, i32 %88, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%90 = load i32, i32* @SHA256_DIGEST_LENGTH
%91 = call i32 @memcpy(i8* %83, i8* %28, i32 %90)
%92 = load i32, i32* %15
%93 = call i64 @hash_until(i8* %83, i8* %25, i32 %92)
store i64 %93, i64* %17
%94 = load i64, i64* %17
%95 = load i32, i32* %16
%96 = sext i32 %95 to i64
%97 = sub i64 %94, %96
%98 = trunc i64 %97 to i32
store i32 %98, i32* %18
%99 = load i32, i32* %18
%100 = icmp sle i32 %99, 0
br i1 %100, label %106, label %101
101: ; preds = %79
%102 = load i32, i32* %18
%103 = sext i32 %102 to i64
%104 = load i64, i64* %17
%105 = icmp uge i64 %103, %104
br i1 %105, label %106, label %113
106: ; preds = %101, %79
%107 = load i32, i32* @stderr
%108 = load i32, i32* %16
%109 = load i64, i64* %17
%110 = call i32 @fprintf(i32 %107, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %108, i64 %109)
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %101
%114 = load i32, i32* @SHA256_DIGEST_LENGTH
%115 = call i32 @memcpy(i8* %83, i8* %28, i32 %114)
%116 = load i32, i32* %18
%117 = call i64 @hash_until(i8* %83, i8* null, i32 %116)
%118 = load i32, i32* %16
%119 = call i64 @verify_pair(i8* %83, i8* %25, i32 %118)
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %125
121: ; preds = %113
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%123 = load i32, i32* @EXIT_SUCCESS
%124 = call i32 @exit(i32 %123)
unreachable
125: ; preds = %113
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%127 = load i32, i32* @EXIT_FAILURE
%128 = call i32 @exit(i32 %127)
unreachable
129: ; preds = %76
%130 = load i32, i32* %13
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %153
132: ; preds = %129
store i64 0, i64* %21
%133 = load i8*, i8** %7
%134 = load i32, i32* @SHA256_DIGEST_LENGTH
%135 = call i32 @load_bytes(i8* %133, i8* %25, i32 %134, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%136 = load i8*, i8** %8
%137 = load i32, i32* @SHA256_DIGEST_LENGTH
%138 = call i32 @load_bytes(i8* %136, i8* %28, i32 %137, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%139 = load i32, i32* %15
%140 = call i64 @verify_pair(i8* %28, i8* %25, i32 %139)
store i64 %140, i64* %21
%141 = load i64, i64* %21
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %148
143: ; preds = %132
%144 = load i64, i64* %21
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i64 %144)
%146 = load i32, i32* @EXIT_SUCCESS
%147 = call i32 @exit(i32 %146)
unreachable
148: ; preds = %132
%149 = load i32, i32* %15
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i32 %149)
%151 = load i32, i32* @EXIT_FAILURE
%152 = call i32 @exit(i32 %151)
unreachable
153: ; preds = %129
%154 = call i32 (...) @help()
store i32 0, i32* %3
%155 = load i8*, i8** %9
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
@SHA256_DIGEST_LENGTH = global i32 0
@.str = [14 x i8] c"Vhcvpi:a:b:o:\00"
@optarg = global i8* null
@.str.1 = [32 x i8] c"Please enter your private key: \00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [32 x i8] c"Please enter known public key: \00"
@stderr = global i32 0
@.str.3 = [71 x i8] c"Invalid offset: %d. Public/private key are only %lu iterations apart.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [32 x i8] c"Please enter verification key: \00"
@.str.7 = [26 x i8] c"Success, %lu iterations!\0A\00"
@.str.8 = [43 x i8] c"Could not verify pair after %d iterations\0A\00"
@str = [6 x i8] c"Fail.\00"
@str.9 = [9 x i8] c"Success!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @SHA256_DIGEST_LENGTH
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = alloca i8, i64 %4
%7 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8 %7, -1
br i1 %8, label %114, label %9
9: ; preds = %2, %37
%10 = phi i8 [ %45, %37 ], [ %7, %2 ]
%11 = phi i8* [ %44, %37 ], [ null, %2 ]
%12 = phi i8* [ %43, %37 ], [ null, %2 ]
%13 = phi i32 [ %42, %37 ], [ 0, %2 ]
%14 = phi i32 [ %41, %37 ], [ 1, %2 ]
%15 = phi i32 [ %40, %37 ], [ 4194304, %2 ]
%16 = phi i32 [ %39, %37 ], [ 0, %2 ]
%17 = phi i32 [ %38, %37 ], [ 0, %2 ]
%18 = sext i8 %10 to i32
switch i32 %18, label %35 [
i32 99, label %37
i32 118, label %19
i32 112, label %20
i32 105, label %21
i32 111, label %24
i32 97, label %27
i32 98, label %29
i32 86, label %31
i32 104, label %33
]
19: ; preds = %9
br label %37
20: ; preds = %9
br label %37
21: ; preds = %9
%22 = load i8*, i8** @optarg
%23 = tail call i32 @atoi(i8* %22)
br label %37
24: ; preds = %9
%25 = load i8*, i8** @optarg
%26 = tail call i32 @atoi(i8* %25)
br label %37
27: ; preds = %9
%28 = load i8*, i8** @optarg
br label %37
29: ; preds = %9
%30 = load i8*, i8** @optarg
br label %37
31: ; preds = %9
%32 = tail call i32 (...) @version()
br label %37
33: ; preds = %9
%34 = tail call i32 (...) @help()
br label %37
35: ; preds = %9
%36 = tail call i32 (...) @help()
br label %37
37: ; preds = %9, %35, %33, %31, %29, %27, %24, %21, %20, %19
%38 = phi i32 [ %17, %35 ], [ %17, %33 ], [ %17, %31 ], [ %17, %29 ], [ %17, %27 ], [ %17, %24 ], [ %17, %21 ], [ %17, %20 ], [ 1, %19 ], [ %17, %9 ]
%39 = phi i32 [ %16, %35 ], [ %16, %33 ], [ %16, %31 ], [ %16, %29 ], [ %16, %27 ], [ %16, %24 ], [ %16, %21 ], [ 1, %20 ], [ %16, %19 ], [ %16, %9 ]
%40 = phi i32 [ %15, %35 ], [ %15, %33 ], [ %15, %31 ], [ %15, %29 ], [ %15, %27 ], [ %15, %24 ], [ %23, %21 ], [ %15, %20 ], [ %15, %19 ], [ %15, %9 ]
%41 = phi i32 [ %14, %35 ], [ %14, %33 ], [ %14, %31 ], [ %14, %29 ], [ %14, %27 ], [ %26, %24 ], [ %14, %21 ], [ %14, %20 ], [ %14, %19 ], [ %14, %9 ]
%42 = phi i32 [ %13, %35 ], [ %13, %33 ], [ %13, %31 ], [ %13, %29 ], [ %13, %27 ], [ %13, %24 ], [ %13, %21 ], [ %13, %20 ], [ %13, %19 ], [ 1, %9 ]
%43 = phi i8* [ %12, %35 ], [ %12, %33 ], [ %12, %31 ], [ %30, %29 ], [ %12, %27 ], [ %12, %24 ], [ %12, %21 ], [ %12, %20 ], [ %12, %19 ], [ %12, %9 ]
%44 = phi i8* [ %11, %35 ], [ %11, %33 ], [ %11, %31 ], [ %11, %29 ], [ %28, %27 ], [ %11, %24 ], [ %11, %21 ], [ %11, %20 ], [ %11, %19 ], [ %11, %9 ]
%45 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%46 = icmp eq i8 %45, -1
br i1 %46, label %47, label %9
47: ; preds = %37
%48 = icmp eq i32 %42, 0
br i1 %48, label %60, label %49
49: ; preds = %47
%50 = icmp eq i8* %43, null
br i1 %50, label %55, label %51
51: ; preds = %49
%52 = load i32, i32* @SHA256_DIGEST_LENGTH
%53 = call i32 @load_bytes(i8* %43, i8* %6, i32 %52, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%54 = call i32 @generate_pair(i32 %40, i8* %6)
br label %57
55: ; preds = %49
%56 = tail call i32 @generate_pair(i32 %40, i8* null)
br label %57
57: ; preds = %55, %51
%58 = load i32, i32* @EXIT_SUCCESS
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %47
%61 = icmp eq i32 %39, 0
br i1 %61, label %97, label %62
62: ; preds = %60
%63 = load i32, i32* @SHA256_DIGEST_LENGTH
%64 = zext i32 %63 to i64
%65 = alloca i8, i64 %64
%66 = call i32 @load_bytes(i8* %43, i8* %6, i32 %63, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%67 = load i32, i32* @SHA256_DIGEST_LENGTH
%68 = call i32 @load_bytes(i8* %44, i8* %5, i32 %67, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%69 = load i32, i32* @SHA256_DIGEST_LENGTH
%70 = call i32 @memcpy(i8* %65, i8* %6, i32 %69)
%71 = call i64 @hash_until(i8* %65, i8* %5, i32 %40)
%72 = trunc i64 %71 to i32
%73 = sub i32 %72, %41
%74 = icmp sgt i32 %73, 0
%75 = sext i32 %73 to i64
%76 = icmp ugt i64 %71, %75
%77 = select i1 %74, i1 %76, i1 false
br i1 %77, label %83, label %78
78: ; preds = %62
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %41, i64 %71)
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %62
%84 = load i32, i32* @SHA256_DIGEST_LENGTH
%85 = call i32 @memcpy(i8* %65, i8* %6, i32 %84)
%86 = call i64 @hash_until(i8* %65, i8* null, i32 %73)
%87 = call i64 @verify_pair(i8* %65, i8* %5, i32 %41)
%88 = icmp eq i64 %87, 0
br i1 %88, label %93, label %89
89: ; preds = %83
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%91 = load i32, i32* @EXIT_SUCCESS
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %83
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = call i32 @exit(i32 %95)
unreachable
97: ; preds = %60
%98 = icmp eq i32 %38, 0
br i1 %98, label %114, label %99
99: ; preds = %97
%100 = load i32, i32* @SHA256_DIGEST_LENGTH
%101 = call i32 @load_bytes(i8* %44, i8* %5, i32 %100, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%102 = load i32, i32* @SHA256_DIGEST_LENGTH
%103 = call i32 @load_bytes(i8* %43, i8* %6, i32 %102, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%104 = call i64 @verify_pair(i8* %6, i8* %5, i32 %40)
%105 = icmp eq i64 %104, 0
br i1 %105, label %110, label %106
106: ; preds = %99
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i64 %104)
%108 = load i32, i32* @EXIT_SUCCESS
%109 = call i32 @exit(i32 %108)
unreachable
110: ; preds = %99
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i32 %40)
%112 = load i32, i32* @EXIT_FAILURE
%113 = call i32 @exit(i32 %112)
unreachable
114: ; preds = %2, %97
%115 = tail call i32 (...) @help()
ret i32 0
}