#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 */
unsigned int CHAR_BIT;
unsigned int get_bit_length(unsigned int);
unsigned int get_key_size();
unsigned int get_rng_ceil();
int get_rng_input(unsigned int);
char getchar();
scalar_t__ is_power_of_two(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main() {
  unsigned int input;
  unsigned int bit_length;
  unsigned int rng_ceil;
  unsigned int key_size;
  unsigned int bits;
  char generate_keys = 'y';
  while (is_power_of_two(rng_ceil = get_rng_ceil()) == 0) {
    puts("Sorry, I can only use powers of 2!");
  }
  bit_length = get_bit_length(rng_ceil);
  while (generate_keys == 'y' || generate_keys == 'Y') {
    bits = 0;
    key_size = get_key_size();
    char key[((key_size + CHAR_BIT - 1) / CHAR_BIT)];
    while (bits < key_size) {
      input = (get_rng_input(rng_ceil) - 1);
      for (int i = 0; i < bit_length && bits < key_size; i++) {
        if (input % 2 == 1) {
          ((key)[((bits) / CHAR_BIT)] |= (1 << ((bits) % CHAR_BIT)));
        } else {
          ((key)[((bits) / CHAR_BIT)] &= ~(1 << ((bits) % CHAR_BIT)));
        }
        input = input >> 1;
        bits += 1;
      }
      printf("%d of %d bits generated...\n", bits, key_size);
    }
    printf("Your key is:\n0x");
    unsigned int chunk = 0;
    for (int i = 0; i < bits; i++) {
      if (((key)[((i) / CHAR_BIT)] & (1 << ((i) % CHAR_BIT)))) {
        chunk += 1;
      }
      if (i > 0 && ((i + 1) % 4 == 0 || i + 1 == bits)) {
        printf("%X", chunk);
        chunk = 0;
      } else {
        chunk = chunk << 1;
      }
    }
    puts("\nBe sure to run this through newBitcoinKey in bitcoin.sh first if "
         "you are planning on using this to seed a Bitcoin address!");
    puts("Generate another? [y/n]");
    generate_keys = getchar();
    while (generate_keys != 'y' && generate_keys != 'Y' &&
           generate_keys != 'n' && generate_keys != 'N') {
      generate_keys = getchar();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x79,-0x19(%rbp)
mov    $0x0,%al
call   1030 <get_rng_ceil@plt>
mov    %eax,%edi
mov    %edi,-0x10(%rbp)
call   1090 <is_power_of_two@plt>
cmp    $0x0,%rax
jne    11bf <main+0x3f>
lea    0xe4b(%rip),%rdi
call   1040 <puts@plt>
jmp    1193 <main+0x13>
mov    -0x10(%rbp),%edi
call   1050 <get_bit_length@plt>
mov    %eax,-0xc(%rbp)
movsbl -0x19(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x3d(%rbp)
je     11e9 <main+0x69>
movsbl -0x19(%rbp),%eax
cmp    $0x59,%eax
sete   %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    11f9 <main+0x79>
jmp    14c1 <main+0x341>
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,-0x4c(%rbp)
call   1070 <get_key_size@plt>
mov    -0x4c(%rbp),%edx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2dc6(%rip),%rax
mov    (%rax),%ecx
mov    %ecx,%esi
mov    %edi,%eax
lea    -0x1(%rax,%rsi,1),%eax
div    %ecx
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1353 <main+0x1d3>
mov    -0x10(%rbp),%edi
call   10a0 <get_rng_input@plt>
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x4d(%rbp)
jae    1287 <main+0x107>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
setb   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    1297 <main+0x117>
jmp    133a <main+0x1ba>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    12e1 <main+0x161>
mov    -0x18(%rbp),%eax
mov    0x2d30(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
mov    %edx,%ecx
mov    $0x1,%esi
shl    %cl,%esi
mov    -0x18(%rbp),%eax
mov    0x2d19(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edx
or     %esi,%edx
mov    %dl,(%rax,%rcx,1)
jmp    131a <main+0x19a>
mov    -0x18(%rbp),%eax
mov    0x2cf5(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
mov    %edx,%ecx
mov    $0x1,%esi
shl    %cl,%esi
xor    $0xffffffff,%esi
mov    -0x18(%rbp),%eax
mov    0x2cdb(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edx
and    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126a <main+0xea>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1249 <main+0xc9>
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1431 <main+0x2b1>
mov    -0x3c(%rbp),%eax
mov    0x2c5b(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x54(%rbp)
mov    -0x3c(%rbp),%eax
mov    0x2c3e(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
mov    -0x54(%rbp),%eax
mov    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     13c8 <main+0x248>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jle    1415 <main+0x295>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     13f8 <main+0x278>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cmp    -0x18(%rbp),%eax
jne    1415 <main+0x295>
mov    -0x38(%rbp),%esi
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x38(%rbp)
jmp    141e <main+0x29e>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1423 <main+0x2a3>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    136f <main+0x1ef>
lea    0xc1a(%rip),%rdi
call   1040 <puts@plt>
lea    0xc8a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x55(%rbp)
je     1496 <main+0x316>
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x59,%ecx
mov    %al,-0x55(%rbp)
je     1496 <main+0x316>
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6e,%ecx
mov    %al,-0x55(%rbp)
je     1496 <main+0x316>
movsbl -0x19(%rbp),%eax
cmp    $0x4e,%eax
setne  %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    14a6 <main+0x326>
jmp    14b5 <main+0x335>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x19(%rbp)
jmp    1453 <main+0x2d3>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
jmp    11ca <main+0x4a>
xor    %eax,%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    $0x18,%rsp
xor    %eax,%eax
call   1030 <get_rng_ceil@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1090 <is_power_of_two@plt>
test   %rax,%rax
jne    11cd <main+0x4d>
lea    0xe53(%rip),%r14
nopl   (%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <get_rng_ceil@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1090 <is_power_of_two@plt>
test   %rax,%rax
je     11b0 <main+0x30>
mov    %ebx,%edi
call   1050 <get_bit_length@plt>
mov    %eax,%r14d
mov    %ebx,-0x2c(%rbp)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <get_key_size@plt>
mov    %eax,%r12d
mov    %rsp,-0x38(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%ecx
lea    -0x1(%r12),%eax
add    %ecx,%eax
xor    %edx,%edx
div    %ecx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
cmp    $0x1,%r12d
jae    1230 <main+0xb0>
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1304 <main+0x184>
nopl   0x0(%rax)
xor    %r13d,%r13d
jmp    1267 <main+0xe7>
cs nopw 0x0(%rax,%rax,1)
nop
add    %eax,%r13d
add    $0xffffffff,%r13d
mov    -0x2c(%rbp),%ebx
lea    0xdd2(%rip),%rdi
mov    %r13d,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r12d,%r13d
jae    12f0 <main+0x170>
mov    %ebx,%edi
call   10a0 <get_rng_input@plt>
test   %r14d,%r14d
je     124a <main+0xca>
cmp    %r12d,%r13d
jae    124a <main+0xca>
mov    %eax,%esi
add    $0xffffffff,%esi
mov    0x2d5c(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%ebx
nopl   0x0(%rax)
lea    (%rbx,%r13,1),%eax
add    $0xffffffff,%eax
xor    %edx,%edx
div    %r8d
mov    %edx,%ecx
mov    $0x1,%edi
shl    %cl,%edi
movzbl (%r15,%rax,1),%ecx
mov    %edi,%edx
not    %dl
and    %cl,%dl
or     %dil,%cl
test   $0x1,%sil
movzbl %cl,%ecx
movzbl %dl,%edx
cmovne %ecx,%edx
mov    %dl,(%r15,%rax,1)
lea    0x1(%rbx),%eax
cmp    %r14d,%ebx
jae    1240 <main+0xc0>
add    %r13d,%ebx
shr    %esi
cmp    %r12d,%ebx
mov    %eax,%ebx
jb     1290 <main+0x110>
jmp    1240 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd48(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2,%r13d
jae    1360 <main+0x1e0>
lea    0xd47(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb7(%rip),%rdi
call   1040 <puts@plt>
movabs $0x80100000801,%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getchar@plt>
lea    -0x4e(%rax),%ecx
cmp    $0x2b,%cl
ja     1330 <main+0x1b0>
movzbl %cl,%ecx
bt     %rcx,%rbx
jae    1330 <main+0x1b0>
mov    -0x38(%rbp),%rsp
and    $0xdf,%al
cmp    $0x59,%al
mov    -0x2c(%rbp),%ebx
je     11e0 <main+0x60>
jmp    13dd <main+0x25d>
xchg   %ax,%ax
mov    (%r15),%ebx
add    %ebx,%ebx
and    $0x2,%ebx
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
neg    %r13d
mov    $0x2,%r12d
jmp    13b2 <main+0x232>
nopl   0x0(%rax)
xor    %ebx,%ebx
lea    0xcc6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    (%r12,%r13,1),%eax
add    $0x1,%eax
mov    %r12d,%ecx
add    $0x1,%ecx
mov    %ecx,%r12d
cmp    $0x1,%eax
je     1304 <main+0x184>
lea    -0x1(%r12),%eax
xor    %edx,%edx
div    %edi
mov    %edx,%ecx
movsbl (%r15,%rax,1),%esi
shr    %cl,%esi
and    $0x1,%esi
add    %ebx,%esi
test   $0x3,%r12b
je     1380 <main+0x200>
mov    %r13d,%eax
add    %r12d,%eax
je     1380 <main+0x200>
add    %esi,%esi
mov    %esi,%ebx
jmp    1399 <main+0x219>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Sorry, I can only use powers of 2!\00"
@CHAR_BIT = global i32 0
@.str.1 = [28 x i8] c"%d of %d bits generated...\0A\00"
@.str.2 = [16 x i8] c"Your key is:\0A0x\00"
@.str.3 = [3 x i8] c"%X\00"
@.str.4 = [124 x i8] c"\0ABe sure to run this through newBitcoinKey in bitcoin.sh first if you are planning on using this to seed a Bitcoin address!\00"
@.str.5 = [24 x i8] c"Generate another? [y/n]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i8 121, i8* %7
br label %13
13: ; preds = %17, %0
%14 = call i32 (...) @get_rng_ceil()
store i32 %14, i32* %4
%15 = call i64 @is_power_of_two(i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %13
19: ; preds = %13
%20 = load i32, i32* %4
%21 = call i32 @get_bit_length(i32 %20)
store i32 %21, i32* %3
br label %22
22: ; preds = %176, %19
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 121
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8, i8* %7
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 89
br label %30
30: ; preds = %26, %22
%31 = phi i1 [ true, %22 ], [ %29, %26 ]
br i1 %31, label %32, label %178
32: ; preds = %30
store i32 0, i32* %6
%33 = call i32 (...) @get_key_size()
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = load i32, i32* @CHAR_BIT
%36 = add i32 %34, %35
%37 = sub i32 %36, 1
%38 = load i32, i32* @CHAR_BIT
%39 = udiv i32 %37, %38
%40 = zext i32 %39 to i64
%41 = call i8* @llvm.stacksave()
store i8* %41, i8** %8
%42 = alloca i8, i64 %40
store i64 %40, i64* %9
br label %43
43: ; preds = %102, %32
%44 = load i32, i32* %6
%45 = load i32, i32* %5
%46 = icmp ult i32 %44, %45
br i1 %46, label %47, label %106
47: ; preds = %43
%48 = load i32, i32* %4
%49 = call i32 @get_rng_input(i32 %48)
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %2
store i32 0, i32* %10
br label %51
51: ; preds = %99, %47
%52 = load i32, i32* %10
%53 = load i32, i32* %3
%54 = icmp ult i32 %52, %53
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* %6
%57 = load i32, i32* %5
%58 = icmp ult i32 %56, %57
br label %59
59: ; preds = %55, %51
%60 = phi i1 [ false, %51 ], [ %58, %55 ]
br i1 %60, label %61, label %102
61: ; preds = %59
%62 = load i32, i32* %2
%63 = urem i32 %62, 2
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %79
65: ; preds = %61
%66 = load i32, i32* %6
%67 = load i32, i32* @CHAR_BIT
%68 = urem i32 %66, %67
%69 = shl i32 1, %68
%70 = load i32, i32* %6
%71 = load i32, i32* @CHAR_BIT
%72 = udiv i32 %70, %71
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %42, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = or i32 %76, %69
%78 = trunc i32 %77 to i8
store i8 %78, i8* %74
br label %94
79: ; preds = %61
%80 = load i32, i32* %6
%81 = load i32, i32* @CHAR_BIT
%82 = urem i32 %80, %81
%83 = shl i32 1, %82
%84 = xor i32 %83, -1
%85 = load i32, i32* %6
%86 = load i32, i32* @CHAR_BIT
%87 = udiv i32 %85, %86
%88 = zext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %42, i64 %88
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = and i32 %91, %84
%93 = trunc i32 %92 to i8
store i8 %93, i8* %89
br label %94
94: ; preds = %79, %65
%95 = load i32, i32* %2
%96 = lshr i32 %95, 1
store i32 %96, i32* %2
%97 = load i32, i32* %6
%98 = add i32 %97, 1
store i32 %98, i32* %6
br label %99
99: ; preds = %94
%100 = load i32, i32* %10
%101 = add nsw i32 %100, 1
store i32 %101, i32* %10
br label %51
102: ; preds = %59
%103 = load i32, i32* %6
%104 = load i32, i32* %5
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %103, i32 %104)
br label %43
106: ; preds = %43
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %11
store i32 0, i32* %12
br label %108
108: ; preds = %149, %106
%109 = load i32, i32* %12
%110 = load i32, i32* %6
%111 = icmp ult i32 %109, %110
br i1 %111, label %112, label %152
112: ; preds = %108
%113 = load i32, i32* %12
%114 = load i32, i32* @CHAR_BIT
%115 = udiv i32 %113, %114
%116 = zext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %42, i64 %116
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = load i32, i32* %12
%121 = load i32, i32* @CHAR_BIT
%122 = urem i32 %120, %121
%123 = shl i32 1, %122
%124 = and i32 %119, %123
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %112
%127 = load i32, i32* %11
%128 = add i32 %127, 1
store i32 %128, i32* %11
br label %129
129: ; preds = %126, %112
%130 = load i32, i32* %12
%131 = icmp sgt i32 %130, 0
br i1 %131, label %132, label %145
132: ; preds = %129
%133 = load i32, i32* %12
%134 = add nsw i32 %133, 1
%135 = srem i32 %134, 4
%136 = icmp eq i32 %135, 0
br i1 %136, label %142, label %137
137: ; preds = %132
%138 = load i32, i32* %12
%139 = add nsw i32 %138, 1
%140 = load i32, i32* %6
%141 = icmp eq i32 %139, %140
br i1 %141, label %142, label %145
142: ; preds = %137, %132
%143 = load i32, i32* %11
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %143)
store i32 0, i32* %11
br label %148
145: ; preds = %137, %129
%146 = load i32, i32* %11
%147 = shl i32 %146, 1
store i32 %147, i32* %11
br label %148
148: ; preds = %145, %142
br label %149
149: ; preds = %148
%150 = load i32, i32* %12
%151 = add nsw i32 %150, 1
store i32 %151, i32* %12
br label %108
152: ; preds = %108
%153 = call i32 @puts(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.4, i64 0, i64 0))
%154 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%155 = call signext i8 (...) @getchar()
store i8 %155, i8* %7
br label %156
156: ; preds = %174, %152
%157 = load i8, i8* %7
%158 = sext i8 %157 to i32
%159 = icmp ne i32 %158, 121
br i1 %159, label %160, label %172
160: ; preds = %156
%161 = load i8, i8* %7
%162 = sext i8 %161 to i32
%163 = icmp ne i32 %162, 89
br i1 %163, label %164, label %172
164: ; preds = %160
%165 = load i8, i8* %7
%166 = sext i8 %165 to i32
%167 = icmp ne i32 %166, 110
br i1 %167, label %168, label %172
168: ; preds = %164
%169 = load i8, i8* %7
%170 = sext i8 %169 to i32
%171 = icmp ne i32 %170, 78
br label %172
172: ; preds = %168, %164, %160, %156
%173 = phi i1 [ false, %164 ], [ false, %160 ], [ false, %156 ], [ %171, %168 ]
br i1 %173, label %174, label %176
174: ; preds = %172
%175 = call signext i8 (...) @getchar()
store i8 %175, i8* %7
br label %156
176: ; preds = %172
%177 = load i8*, i8** %8
br label %22
178: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Sorry, I can only use powers of 2!\00"
@CHAR_BIT = global i32 0
@.str.1 = [28 x i8] c"%d of %d bits generated...\0A\00"
@.str.2 = [16 x i8] c"Your key is:\0A0x\00"
@.str.3 = [3 x i8] c"%X\00"
@.str.4 = [124 x i8] c"\0ABe sure to run this through newBitcoinKey in bitcoin.sh first if you are planning on using this to seed a Bitcoin address!\00"
@.str.5 = [24 x i8] c"Generate another? [y/n]\00"
define i32 @main() {
%1 = tail call i32 (...) @get_rng_ceil()
%2 = tail call i64 @is_power_of_two(i32 %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %0, %4
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @get_rng_ceil()
%7 = tail call i64 @is_power_of_two(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %4, label %9
9: ; preds = %4, %0
%10 = phi i32 [ %1, %0 ], [ %6, %4 ]
%11 = tail call i32 @get_bit_length(i32 %10)
%12 = icmp ne i32 %11, 0
br label %13
13: ; preds = %9, %101
%14 = tail call i32 (...) @get_key_size()
%15 = load i32, i32* @CHAR_BIT
%16 = add i32 %14, -1
%17 = add i32 %16, %15
%18 = udiv i32 %17, %15
%19 = zext i32 %18 to i64
%20 = tail call i8* @llvm.stacksave()
%21 = alloca i8, i64 %19
%22 = icmp eq i32 %14, 0
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %69
25: ; preds = %13, %33
%26 = phi i32 [ %34, %33 ], [ 0, %13 ]
%27 = tail call i32 @get_rng_input(i32 %10)
%28 = icmp ult i32 %26, %14
%29 = select i1 %12, i1 %28, i1 false
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = add nsw i32 %27, -1
%32 = load i32, i32* @CHAR_BIT
br label %37
33: ; preds = %37, %25
%34 = phi i32 [ %26, %25 ], [ %55, %37 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %14)
%36 = icmp ult i32 %34, %14
br i1 %36, label %25, label %60
37: ; preds = %30, %37
%38 = phi i32 [ 0, %30 ], [ %56, %37 ]
%39 = phi i32 [ %31, %30 ], [ %54, %37 ]
%40 = phi i32 [ %26, %30 ], [ %55, %37 ]
%41 = and i32 %39, 1
%42 = icmp eq i32 %41, 0
%43 = urem i32 %40, %32
%44 = shl nuw i32 1, %43
%45 = udiv i32 %40, %32
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %21, i64 %46
%48 = load i8, i8* %47
%49 = trunc i32 %44 to i8
%50 = xor i8 %49, -1
%51 = and i8 %48, %50
%52 = or i8 %48, %49
%53 = select i1 %42, i8 %51, i8 %52
store i8 %53, i8* %47
%54 = lshr i32 %39, 1
%55 = add nuw i32 %40, 1
%56 = add nuw nsw i32 %38, 1
%57 = icmp ult i32 %56, %11
%58 = icmp ult i32 %55, %14
%59 = select i1 %57, i1 %58, i1 false
br i1 %59, label %37, label %33
60: ; preds = %33
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp ult i32 %34, 2
br i1 %62, label %69, label %63
63: ; preds = %60
%64 = load i8, i8* %21
%65 = shl i8 %64, 1
%66 = and i8 %65, 2
%67 = zext i8 %66 to i32
%68 = load i32, i32* @CHAR_BIT
br label %72
69: ; preds = %95, %60, %23
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @.str.4, i64 0, i64 0))
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %99
72: ; preds = %95, %63
%73 = phi i32 [ %96, %95 ], [ %68, %63 ]
%74 = phi i32 [ %85, %95 ], [ 1, %63 ]
%75 = phi i32 [ %97, %95 ], [ %67, %63 ]
%76 = udiv i32 %74, %73
%77 = zext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %21, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = urem i32 %74, %73
%82 = lshr i32 %80, %81
%83 = and i32 %82, 1
%84 = add i32 %83, %75
%85 = add nuw i32 %74, 1
%86 = and i32 %85, 3
%87 = icmp eq i32 %86, 0
%88 = icmp eq i32 %85, %34
%89 = or i1 %87, %88
br i1 %89, label %90, label %93
90: ; preds = %72
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %84)
%92 = load i32, i32* @CHAR_BIT
br label %95
93: ; preds = %72
%94 = shl i32 %84, 1
br label %95
95: ; preds = %90, %93
%96 = phi i32 [ %92, %90 ], [ %73, %93 ]
%97 = phi i32 [ 0, %90 ], [ %94, %93 ]
%98 = icmp eq i32 %85, %34
br i1 %98, label %69, label %72
99: ; preds = %99, %69
%100 = tail call signext i8 (...) @getchar()
switch i8 %100, label %99 [
i8 121, label %101
i8 110, label %101
i8 89, label %101
i8 78, label %101
]
101: ; preds = %99, %99, %99, %99
tail call void @llvm.stackrestore(i8* %20)
%102 = and i8 %100, -33
%103 = icmp eq i8 %102, 89
br i1 %103, label %13, label %104
104: ; preds = %101
ret i32 0
}