#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 SHA256_DIGEST_LENGTH;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ hash_until(unsigned char *, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ print_bytes(unsigned char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ randombytes(unsigned char *, int);
int /*<<< orphan*/ stderr;
void generate_pair(size_t iter, unsigned char *private_key_b) {
  unsigned char buf[SHA256_DIGEST_LENGTH];
  fprintf(stderr, "Generating pair with %lu iterations\n", iter);
  if (private_key_b) {
    memcpy(buf, private_key_b, SHA256_DIGEST_LENGTH);
  } else {
    randombytes(buf, SHA256_DIGEST_LENGTH);
  }
  printf("Private:\n\t");
  print_bytes(buf, SHA256_DIGEST_LENGTH);
  hash_until(buf, NULL, iter);
  printf("Public:\n\t");
  print_bytes(buf, SHA256_DIGEST_LENGTH);
}


x86 assembly (clang, -O0):
<generate_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe50(%rip),%rsi
call   1060 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11db <generate_pair+0x7b>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e09(%rip),%rax
mov    (%rax),%edx
call   1070 <memcpy@plt>
jmp    11ed <generate_pair+0x8d>
mov    -0x28(%rbp),%rdi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
call   1050 <randombytes@plt>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
call   1080 <print_bytes@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <hash_until@plt>
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
call   1080 <print_bytes@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_pair>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x2e60(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
test   %r15,%r15
je     11bb <generate_pair+0x5b>
mov    %r15,%rsi
call   1070 <memcpy@plt>
jmp    11c2 <generate_pair+0x62>
mov    %edx,%esi
call   1050 <randombytes@plt>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1080 <print_bytes@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <hash_until@plt>
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1080 <print_bytes@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SHA256_DIGEST_LENGTH = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"Generating pair with %lu iterations\0A\00"
@.str.1 = [11 x i8] c"Private:\0A\09\00"
@.str.2 = [10 x i8] c"Public:\0A\09\00"
define void @generate_pair(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i64 %0, i64* %3
store i8* %1, i8** %4
%7 = load i32, i32* @SHA256_DIGEST_LENGTH
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %5
%10 = alloca i8, i64 %8
store i64 %8, i64* %6
%11 = load i32, i32* @stderr
%12 = load i64, i64* %3
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = load i32, i32* @SHA256_DIGEST_LENGTH
%19 = call i32 @memcpy(i8* %10, i8* %17, i32 %18)
br label %23
20: ; preds = %2
%21 = load i32, i32* @SHA256_DIGEST_LENGTH
%22 = call i32 @randombytes(i8* %10, i32 %21)
br label %23
23: ; preds = %20, %16
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @SHA256_DIGEST_LENGTH
%26 = call i32 @print_bytes(i8* %10, i32 %25)
%27 = load i64, i64* %3
%28 = call i32 @hash_until(i8* %10, i32* null, i64 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @SHA256_DIGEST_LENGTH
%31 = call i32 @print_bytes(i8* %10, i32 %30)
%32 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@SHA256_DIGEST_LENGTH = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"Generating pair with %lu iterations\0A\00"
@.str.1 = [11 x i8] c"Private:\0A\09\00"
@.str.2 = [10 x i8] c"Public:\0A\09\00"
define void @generate_pair(i64 %0, i8* %1) {
%3 = load i32, i32* @SHA256_DIGEST_LENGTH
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 %0)
%8 = icmp eq i8* %1, null
%9 = load i32, i32* @SHA256_DIGEST_LENGTH
br i1 %8, label %12, label %10
10: ; preds = %2
%11 = call i32 @memcpy(i8* %5, i8* %1, i32 %9)
br label %14
12: ; preds = %2
%13 = call i32 @randombytes(i8* %5, i32 %9)
br label %14
14: ; preds = %12, %10
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @SHA256_DIGEST_LENGTH
%17 = call i32 @print_bytes(i8* %5, i32 %16)
%18 = call i32 @hash_until(i8* %5, i32* null, i64 %0)
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @SHA256_DIGEST_LENGTH
%21 = call i32 @print_bytes(i8* %5, i32 %20)
ret void
}