#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 */
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char hex(int);
scalar_t__ isprint(char);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int read(int, char *, int);
int /*<<< orphan*/ stdout;
int write(int, char *, int);
int main(int argc, char **argv) {
  char table[(26 * 26)] = {};
  int i;
  int fd;
  ssize_t rc;
  char *datfile = "pwtable.dat";
  static char bubble[] = ".oO";
  if (argc == 1) {
    fd = open("/dev/random", O_RDONLY);
    if (fd < 0) {
      perror("/dev/random");
      exit(EXIT_FAILURE);
    }
    printf("Generating tabula recta data. This can take several minutes. |");
    i = 0;
    while (i < 26 * 26) {
      char c;
      rc = read(fd, &c, 1);
      if (rc == 1) {
        if (isprint(c)) {
          putchar(0x8);
          putchar(bubble[i % 3]);
          fflush(stdout);
          table[i++] = c;
        }
      } else if (rc < 0) {
        perror("reading from /dev/random");
        exit(EXIT_FAILURE);
      } else {
        perror("failed to read from /dev/random");
      }
    }
    rc = close(fd);
    if (rc < 0) {
      perror("closing /dev/random");
      exit(EXIT_FAILURE);
    }
    puts("done");
    fd = open(datfile, O_WRONLY | O_CREAT, 0644);
    if (fd < 0) {
      perror(datfile);
      exit(EXIT_FAILURE);
    }
    rc = write(fd, table, (26 * 26));
    if (rc != 26 * 26) {
      perror("writing pwtable.dat");
      exit(EXIT_FAILURE);
    }
    close(fd);
  } else if (argc == 2) {
    datfile = argv[1];
  } else {
    puts("\n"
         "Usage: pwtable [datfile]\n"
         "\n"
         "If no datfile is specified then one will be generated\n"
         "and stored in pwtable.dat.\n"
         "A tabula recta will then be printed out in ASCII.\n"
         "\n"
         "http://blog.jgc.org/2010/12/write-your-passwords-down.html\n");
    exit(EXIT_FAILURE);
  }
  fd = open(datfile, O_RDONLY);
  if (fd < 0) {
    perror(datfile);
    exit(EXIT_FAILURE);
  }
  rc = read(fd, table, (26 * 26));
  if (rc != (26 * 26)) {
    perror("reading pwtable.dat");
    exit(EXIT_FAILURE);
  }
  close(fd);
  printf("    ");
  for (i = 0; i < 26; i++) {
    putchar(hex(i % 13));
    putchar(' ');
  }
  printf("\n    ");
  for (i = 0; i < 26; i++) {
    putchar('A' + i);
    putchar(' ');
  }
  printf("\n   +---------------------------------------------------");
  for (i = 0; i < 26 * 26; i++) {
    if (i % 26 == 0) {
      putchar('\n');
      putchar(hex((i / 26) % 13));
      putchar(' ');
      putchar('A' + (i / 26));
      putchar('|');
    }
    putchar(table[i]);
    putchar(' ');
  }
  putchar('\n');
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x2a4,%edx
call   1070 <memset@plt>
lea    0xf85(%rip),%rax
mov    %rax,-0x2d8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1446 <main+0x276>
mov    0x2dc5(%rip),%rax
mov    (%rax),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x2c8(%rbp)
cmpl   $0x0,-0x2c8(%rbp)
jge    1258 <main+0x88>
lea    0xe3b(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xda1(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x2c4(%rbp)
cmpl   $0x2a4,-0x2c4(%rbp)
jge    1359 <main+0x189>
mov    -0x2c8(%rbp),%edi
lea    -0x2d9(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x2cc(%rbp)
cmpl   $0x1,-0x2cc(%rbp)
jne    131c <main+0x14c>
movsbl -0x2d9(%rbp),%edi
call   10b0 <isprint@plt>
cmp    $0x0,%rax
je     1317 <main+0x147>
mov    $0x8,%edi
call   1030 <putchar@plt>
mov    -0x2c4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2da8(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    -0x2d9(%rbp),%cl
mov    -0x2c4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2c4(%rbp)
cltq
mov    %cl,-0x2c0(%rbp,%rax,1)
jmp    1354 <main+0x184>
cmpl   $0x0,-0x2cc(%rbp)
jge    1343 <main+0x173>
lea    0xd0f(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xd0e(%rip),%rdi
call   10d0 <perror@plt>
jmp    1354 <main+0x184>
jmp    126e <main+0x9e>
mov    -0x2c8(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x2cc(%rbp)
cmpl   $0x0,-0x2cc(%rbp)
jge    1391 <main+0x1c1>
lea    0xcfa(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xcf4(%rip),%rdi
call   1040 <puts@plt>
mov    -0x2d8(%rbp),%rdi
mov    0x2c05(%rip),%rax
mov    (%rax),%esi
mov    0x2c44(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x2c8(%rbp)
cmpl   $0x0,-0x2c8(%rbp)
jge    13ef <main+0x21f>
mov    -0x2d8(%rbp),%rdi
call   10d0 <perror@plt>
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x2c8(%rbp),%edi
lea    -0x2c0(%rbp),%rsi
mov    $0x2a4,%edx
call   1050 <write@plt>
mov    %eax,-0x2cc(%rbp)
cmpl   $0x2a4,-0x2cc(%rbp)
je     1436 <main+0x266>
lea    0xc6e(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x2c8(%rbp),%edi
call   1080 <close@plt>
jmp    1483 <main+0x2b3>
cmpl   $0x2,-0x8(%rbp)
jne    1464 <main+0x294>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x2d8(%rbp)
jmp    147e <main+0x2ae>
lea    0xc3a(%rip),%rdi
call   1040 <puts@plt>
mov    0x2b59(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1483 <main+0x2b3>
mov    -0x2d8(%rbp),%rdi
mov    0x2b4f(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x2c8(%rbp)
cmpl   $0x0,-0x2c8(%rbp)
jge    14c7 <main+0x2f7>
mov    -0x2d8(%rbp),%rdi
call   10d0 <perror@plt>
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x2c8(%rbp),%edi
lea    -0x2c0(%rbp),%rsi
mov    $0x2a4,%edx
call   1090 <read@plt>
mov    %eax,-0x2cc(%rbp)
cmpl   $0x2a4,-0x2cc(%rbp)
je     150e <main+0x33e>
lea    0xc85(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2ac9(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x2c8(%rbp),%edi
call   1080 <close@plt>
lea    0xc75(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x2c4(%rbp)
cmpl   $0x1a,-0x2c4(%rbp)
jge    1577 <main+0x3a7>
mov    -0x2c4(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   10f0 <hex@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x2c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c4(%rbp)
jmp    152f <main+0x35f>
lea    0xc16(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x2c4(%rbp)
cmpl   $0x1a,-0x2c4(%rbp)
jge    15c9 <main+0x3f9>
mov    -0x2c4(%rbp),%eax
add    $0x41,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x2c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c4(%rbp)
jmp    158d <main+0x3bd>
lea    0xbca(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x2c4(%rbp)
cmpl   $0x2a4,-0x2c4(%rbp)
jge    1694 <main+0x4c4>
mov    -0x2c4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1662 <main+0x492>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x2c4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   10f0 <hex@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x2c4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movslq -0x2c4(%rbp),%rax
movsbl -0x2c0(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x2c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c4(%rbp)
jmp    15df <main+0x40f>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x291b(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2b8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
mov    $0x2a4,%edx
xor    %esi,%esi
call   1070 <memset@plt>
cmp    $0x2,%ebp
je     122e <main+0x5e>
cmp    $0x1,%ebp
jne    1251 <main+0x81>
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
jns    13b7 <main+0x1e7>
lea    0xe5b(%rip),%rdi
jmp    1527 <main+0x357>
mov    0x8(%rbx),%rbx
mov    0x2da7(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
jns    1262 <main+0x92>
mov    %rbx,%rdi
jmp    1527 <main+0x357>
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
jmp    152c <main+0x35c>
mov    %eax,%ebp
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x2a4,%edx
call   1090 <read@plt>
cmp    $0x2a4,%eax
jne    1478 <main+0x2a8>
mov    %ebp,%edi
call   1080 <close@plt>
lea    0xf0b(%rip),%rdi
call   1060 <printf@plt>
xor    %ebx,%ebx
mov    $0x1a,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
imul   $0x4ec4ec4f,%rax,%rax
shr    $0x22,%rax
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   10f0 <hex@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    12a0 <main+0xd0>
lea    0xebb(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffe6,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x5b(%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    12f0 <main+0x120>
lea    0xe8e(%rip),%rdi
call   1060 <printf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1349 <main+0x179>
nopl   0x0(%rax)
movsbl 0x10(%rsp,%rbp,1),%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    $0xffffffff,%r14d
cmp    $0x2a4,%rbp
je     1484 <main+0x2b4>
movzwl %bp,%eax
imul   $0x4ec5,%eax,%ebx
shr    $0x13,%ebx
lea    (%rbx,%rbx,4),%eax
lea    (%rax,%rax,4),%eax
add    %ebx,%eax
add    %r14w,%ax
jne    1320 <main+0x150>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzwl %bx,%eax
movzbl %al,%eax
imul   $0x4f,%eax,%eax
shr    $0xa,%eax
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%eax
mov    %ebx,%ecx
sub    %al,%cl
movzbl %cl,%edi
call   10f0 <hex@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0x41(%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    1320 <main+0x150>
mov    %eax,%ebx
lea    0xc44(%rip),%rdi
call   1060 <printf@plt>
lea    0xf(%rsp),%r14
mov    0x2bf7(%rip),%r13
jmp    13fc <main+0x22c>
test   %eax,%eax
js     14b0 <main+0x2e0>
lea    0xc7a(%rip),%rdi
call   10d0 <perror@plt>
nopw   0x0(%rax,%rax,1)
cmp    $0x2a4,%ebp
jge    149c <main+0x2cc>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
jne    13d3 <main+0x203>
movzbl 0xf(%rsp),%r15d
movsbl %r15b,%edi
call   10b0 <isprint@plt>
test   %rax,%rax
je     13f0 <main+0x220>
mov    $0x8,%edi
call   1030 <putchar@plt>
movslq %ebp,%r12
imul   $0x55555556,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %r12d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
lea    0xba9(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   10a0 <fflush@plt>
lea    0x1(%r12),%ebp
mov    %r15b,0x10(%rsp,%r12,1)
jmp    13f0 <main+0x220>
lea    0xd05(%rip),%rdi
jmp    1527 <main+0x357>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2b2b(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    %ebx,%edi
call   1080 <close@plt>
test   %eax,%eax
jns    14b9 <main+0x2e9>
lea    0xbce(%rip),%rdi
jmp    1527 <main+0x357>
lea    0xb8c(%rip),%rdi
jmp    1527 <main+0x357>
lea    0xbd0(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ae4(%rip),%rax
mov    0x2b25(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xcae(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
jns    14fa <main+0x32a>
lea    0xc94(%rip),%rdi
jmp    1527 <main+0x357>
mov    %eax,%ebp
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x2a4,%edx
call   1050 <write@plt>
cmp    $0x2a4,%eax
jne    1520 <main+0x350>
mov    %ebp,%edi
call   1080 <close@plt>
jmp    1232 <main+0x62>
lea    0xb6e(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"pwtable.dat\00"
@main.bubble = internal global [4 x i8] c".oO\00"
@.str.1 = [12 x i8] c"/dev/random\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [63 x i8] c"Generating tabula recta data. This can take several minutes. |\00"
@stdout = global i32 0
@.str.3 = [25 x i8] c"reading from /dev/random\00"
@.str.4 = [32 x i8] c"failed to read from /dev/random\00"
@.str.5 = [20 x i8] c"closing /dev/random\00"
@.str.6 = [5 x i8] c"done\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.7 = [20 x i8] c"writing pwtable.dat\00"
@.str.8 = [219 x i8] c"\0AUsage: pwtable [datfile]\0A\0AIf no datfile is specified then one will be generated\0Aand stored in pwtable.dat.\0AA tabula recta will then be printed out in ASCII.\0A\0Ahttp://blog.jgc.org/2010/12/write-your-passwords-down.html\0A\00"
@.str.9 = [20 x i8] c"reading pwtable.dat\00"
@.str.10 = [5 x i8] c" \00"
@.str.11 = [6 x i8] c"\0A \00"
@.str.12 = [57 x i8] c"\0A +---------------------------------------------------\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [676 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [676 x i8]* %6 to i8*
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %10
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %101
15: ; preds = %2
%16 = load i32, i32* @O_RDONLY
%17 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
%25 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %26
26: ; preds = %64, %24
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 676
br i1 %28, label %29, label %65
29: ; preds = %26
%30 = load i32, i32* %8
%31 = call i32 @read(i32 %30, i8* %11, i32 1)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %54
34: ; preds = %29
%35 = load i8, i8* %11
%36 = call i64 @isprint(i8 signext %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %53
38: ; preds = %34
%39 = call i32 @putchar(i8 signext 8)
%40 = load i32, i32* %7
%41 = srem i32 %40, 3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i8], [4 x i8]* @main.bubble, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @putchar(i8 signext %44)
%46 = load i32, i32* @stdout
%47 = call i32 @fflush(i32 %46)
%48 = load i8, i8* %11
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds [676 x i8], [676 x i8]* %6, i64 0, i64 %51
store i8 %48, i8* %52
br label %53
53: ; preds = %38, %34
br label %64
54: ; preds = %29
%55 = load i32, i32* %9
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %54
%62 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %61
br label %64
64: ; preds = %63, %53
br label %26
65: ; preds = %26
%66 = load i32, i32* %8
%67 = call i32 @close(i32 %66)
store i32 %67, i32* %9
%68 = load i32, i32* %9
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %65
%71 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %65
%75 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%76 = load i8*, i8** %10
%77 = load i32, i32* @O_WRONLY
%78 = load i32, i32* @O_CREAT
%79 = or i32 %77, %78
%80 = call i32 (i8*, i32, ...) @open(i8* %76, i32 %79, i32 420)
store i32 %80, i32* %8
%81 = load i32, i32* %8
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %88
83: ; preds = %74
%84 = load i8*, i8** %10
%85 = call i32 @perror(i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %74
%89 = load i32, i32* %8
%90 = getelementptr inbounds [676 x i8], [676 x i8]* %6, i64 0, i64 0
%91 = call i32 @write(i32 %89, i8* %90, i32 676)
store i32 %91, i32* %9
%92 = load i32, i32* %9
%93 = icmp ne i32 %92, 676
br i1 %93, label %94, label %98
94: ; preds = %88
%95 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %88
%99 = load i32, i32* %8
%100 = call i32 @close(i32 %99)
br label %113
101: ; preds = %2
%102 = load i32, i32* %4
%103 = icmp eq i32 %102, 2
br i1 %103, label %104, label %108
104: ; preds = %101
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 1
%107 = load i8*, i8** %106
store i8* %107, i8** %10
br label %112
108: ; preds = %101
%109 = call i32 @puts(i8* getelementptr inbounds ([219 x i8], [219 x i8]* @.str.8, i64 0, i64 0))
%110 = load i32, i32* @EXIT_FAILURE
%111 = call i32 @exit(i32 %110)
unreachable
112: ; preds = %104
br label %113
113: ; preds = %112, %98
%114 = load i8*, i8** %10
%115 = load i32, i32* @O_RDONLY
%116 = call i32 (i8*, i32, ...) @open(i8* %114, i32 %115)
store i32 %116, i32* %8
%117 = load i32, i32* %8
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %124
119: ; preds = %113
%120 = load i8*, i8** %10
%121 = call i32 @perror(i8* %120)
%122 = load i32, i32* @EXIT_FAILURE
%123 = call i32 @exit(i32 %122)
unreachable
124: ; preds = %113
%125 = load i32, i32* %8
%126 = getelementptr inbounds [676 x i8], [676 x i8]* %6, i64 0, i64 0
%127 = call i32 @read(i32 %125, i8* %126, i32 676)
store i32 %127, i32* %9
%128 = load i32, i32* %9
%129 = icmp ne i32 %128, 676
br i1 %129, label %130, label %134
130: ; preds = %124
%131 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%132 = load i32, i32* @EXIT_FAILURE
%133 = call i32 @exit(i32 %132)
unreachable
134: ; preds = %124
%135 = load i32, i32* %8
%136 = call i32 @close(i32 %135)
%137 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %7
br label %138
138: ; preds = %147, %134
%139 = load i32, i32* %7
%140 = icmp slt i32 %139, 26
br i1 %140, label %141, label %150
141: ; preds = %138
%142 = load i32, i32* %7
%143 = srem i32 %142, 13
%144 = call signext i8 @hex(i32 %143)
%145 = call i32 @putchar(i8 signext %144)
%146 = call i32 @putchar(i8 signext 32)
br label %147
147: ; preds = %141
%148 = load i32, i32* %7
%149 = add nsw i32 %148, 1
store i32 %149, i32* %7
br label %138
150: ; preds = %138
%151 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %7
br label %152
152: ; preds = %161, %150
%153 = load i32, i32* %7
%154 = icmp slt i32 %153, 26
br i1 %154, label %155, label %164
155: ; preds = %152
%156 = load i32, i32* %7
%157 = add nsw i32 65, %156
%158 = trunc i32 %157 to i8
%159 = call i32 @putchar(i8 signext %158)
%160 = call i32 @putchar(i8 signext 32)
br label %161
161: ; preds = %155
%162 = load i32, i32* %7
%163 = add nsw i32 %162, 1
store i32 %163, i32* %7
br label %152
164: ; preds = %152
%165 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %7
br label %166
166: ; preds = %194, %164
%167 = load i32, i32* %7
%168 = icmp slt i32 %167, 676
br i1 %168, label %169, label %197
169: ; preds = %166
%170 = load i32, i32* %7
%171 = srem i32 %170, 26
%172 = icmp eq i32 %171, 0
br i1 %172, label %173, label %187
173: ; preds = %169
%174 = call i32 @putchar(i8 signext 10)
%175 = load i32, i32* %7
%176 = sdiv i32 %175, 26
%177 = srem i32 %176, 13
%178 = call signext i8 @hex(i32 %177)
%179 = call i32 @putchar(i8 signext %178)
%180 = call i32 @putchar(i8 signext 32)
%181 = load i32, i32* %7
%182 = sdiv i32 %181, 26
%183 = add nsw i32 65, %182
%184 = trunc i32 %183 to i8
%185 = call i32 @putchar(i8 signext %184)
%186 = call i32 @putchar(i8 signext 124)
br label %187
187: ; preds = %173, %169
%188 = load i32, i32* %7
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [676 x i8], [676 x i8]* %6, i64 0, i64 %189
%191 = load i8, i8* %190
%192 = call i32 @putchar(i8 signext %191)
%193 = call i32 @putchar(i8 signext 32)
br label %194
194: ; preds = %187
%195 = load i32, i32* %7
%196 = add nsw i32 %195, 1
store i32 %196, i32* %7
br label %166
197: ; preds = %166
%198 = call i32 @putchar(i8 signext 10)
%199 = load i32, i32* @EXIT_SUCCESS
%200 = call i32 @exit(i32 %199)
unreachable
}

LLVM IR (-O2):
@.str = [12 x i8] c"pwtable.dat\00"
@main.bubble = internal unnamed_addr constant [4 x i8] c".oO\00"
@.str.1 = [12 x i8] c"/dev/random\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [63 x i8] c"Generating tabula recta data. This can take several minutes. |\00"
@stdout = global i32 0
@.str.3 = [25 x i8] c"reading from /dev/random\00"
@.str.4 = [32 x i8] c"failed to read from /dev/random\00"
@.str.5 = [20 x i8] c"closing /dev/random\00"
@.str.6 = [5 x i8] c"done\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.7 = [20 x i8] c"writing pwtable.dat\00"
@.str.8 = [219 x i8] c"\0AUsage: pwtable [datfile]\0A\0AIf no datfile is specified then one will be generated\0Aand stored in pwtable.dat.\0AA tabula recta will then be printed out in ASCII.\0A\0Ahttp://blog.jgc.org/2010/12/write-your-passwords-down.html\0A\00"
@.str.9 = [20 x i8] c"reading pwtable.dat\00"
@.str.10 = [5 x i8] c" \00"
@.str.11 = [6 x i8] c"\0A \00"
@.str.12 = [57 x i8] c"\0A +---------------------------------------------------\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [676 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [676 x i8], [676 x i8]* %3, i64 0, i64 0
switch i32 %0, label %77 [
i32 1, label %6
i32 2, label %74
]
6: ; preds = %2
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %6
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %44
%17 = phi i32 [ 0, %14 ], [ %45, %44 ]
%18 = call i32 @read(i32 %8, i8* %4, i32 1)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load i8, i8* %4
%22 = tail call i64 @isprint(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %44, label %24
24: ; preds = %20
%25 = tail call i32 @putchar(i8 signext 8)
%26 = srem i32 %17, 3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x i8], [4 x i8]* @main.bubble, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = tail call i32 @putchar(i8 signext %29)
%31 = load i32, i32* @stdout
%32 = tail call i32 @fflush(i32 %31)
%33 = add nsw i32 %17, 1
%34 = sext i32 %17 to i64
%35 = getelementptr inbounds [676 x i8], [676 x i8]* %3, i64 0, i64 %34
store i8 %21, i8* %35
br label %44
36: ; preds = %16
%37 = icmp slt i32 %18, 0
br i1 %37, label %38, label %42
38: ; preds = %36
%39 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %36
%43 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %20, %24, %42
%45 = phi i32 [ %33, %24 ], [ %17, %20 ], [ %17, %42 ]
%46 = icmp slt i32 %45, 676
br i1 %46, label %16, label %47
47: ; preds = %44
%48 = tail call i32 @close(i32 %8)
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %47
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%56 = load i32, i32* @O_WRONLY
%57 = load i32, i32* @O_CREAT
%58 = or i32 %57, %56
%59 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %58, i32 420)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %54
%62 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = tail call i32 @exit(i32 %63)
unreachable
65: ; preds = %54
%66 = call i32 @write(i32 %59, i8* %5, i32 676)
%67 = icmp eq i32 %66, 676
br i1 %67, label %72, label %68
68: ; preds = %65
%69 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = tail call i32 @exit(i32 %70)
unreachable
72: ; preds = %65
%73 = tail call i32 @close(i32 %59)
br label %81
74: ; preds = %2
%75 = getelementptr inbounds i8*, i8** %1, i64 1
%76 = load i8*, i8** %75
br label %81
77: ; preds = %2
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([219 x i8], [219 x i8]* @.str.8, i64 0, i64 0))
%79 = load i32, i32* @EXIT_FAILURE
%80 = tail call i32 @exit(i32 %79)
unreachable
81: ; preds = %74, %72
%82 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %72 ], [ %76, %74 ]
%83 = load i32, i32* @O_RDONLY
%84 = tail call i32 (i8*, i32, ...) @open(i8* %82, i32 %83)
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %81
%87 = tail call i32 @perror(i8* %82)
%88 = load i32, i32* @EXIT_FAILURE
%89 = tail call i32 @exit(i32 %88)
unreachable
90: ; preds = %81
%91 = call i32 @read(i32 %84, i8* %5, i32 676)
%92 = icmp eq i32 %91, 676
br i1 %92, label %97, label %93
93: ; preds = %90
%94 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = tail call i32 @exit(i32 %95)
unreachable
97: ; preds = %90
%98 = tail call i32 @close(i32 %84)
%99 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %100
100: ; preds = %97, %100
%101 = phi i32 [ 0, %97 ], [ %108, %100 ]
%102 = trunc i32 %101 to i8
%103 = urem i8 %102, 13
%104 = zext i8 %103 to i32
%105 = tail call signext i8 @hex(i32 %104)
%106 = tail call i32 @putchar(i8 signext %105)
%107 = tail call i32 @putchar(i8 signext 32)
%108 = add nuw nsw i32 %101, 1
%109 = icmp eq i32 %108, 26
br i1 %109, label %110, label %100
110: ; preds = %100
%111 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %112
112: ; preds = %110, %112
%113 = phi i32 [ 0, %110 ], [ %118, %112 ]
%114 = trunc i32 %113 to i8
%115 = add nuw nsw i8 %114, 65
%116 = tail call i32 @putchar(i8 signext %115)
%117 = tail call i32 @putchar(i8 signext 32)
%118 = add nuw nsw i32 %113, 1
%119 = icmp eq i32 %118, 26
br i1 %119, label %120, label %112
120: ; preds = %112
%121 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0))
br label %122
122: ; preds = %120, %139
%123 = phi i64 [ 0, %120 ], [ %144, %139 ]
%124 = trunc i64 %123 to i16
%125 = urem i16 %124, 26
%126 = udiv i16 %124, 26
%127 = icmp eq i16 %125, 0
br i1 %127, label %128, label %139
128: ; preds = %122
%129 = tail call i32 @putchar(i8 signext 10)
%130 = trunc i16 %126 to i8
%131 = urem i8 %130, 13
%132 = zext i8 %131 to i32
%133 = tail call signext i8 @hex(i32 %132)
%134 = tail call i32 @putchar(i8 signext %133)
%135 = tail call i32 @putchar(i8 signext 32)
%136 = add nuw nsw i8 %130, 65
%137 = tail call i32 @putchar(i8 signext %136)
%138 = tail call i32 @putchar(i8 signext 124)
br label %139
139: ; preds = %128, %122
%140 = getelementptr inbounds [676 x i8], [676 x i8]* %3, i64 0, i64 %123
%141 = load i8, i8* %140
%142 = tail call i32 @putchar(i8 signext %141)
%143 = tail call i32 @putchar(i8 signext 32)
%144 = add nuw nsw i64 %123, 1
%145 = icmp eq i64 %144, 676
br i1 %145, label %146, label %122
146: ; preds = %139
%147 = tail call i32 @putchar(i8 signext 10)
%148 = load i32, i32* @EXIT_SUCCESS
%149 = tail call i32 @exit(i32 %148)
unreachable
}