#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  const char hex[] = "0123456789ABCDEF";
  char buf[16];
  char line[80];
  int i, j, k;
  unsigned addr = 0;
  FILE *fi = stdin, *fo = stdout;
  errno = 0;
  for (i = 0; i < 80; i++)
    line[i] = ' ';
  if (argc > 1 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-h") ||
                   !strcmp(argv[1], "--help"))) {
    fprintf(stderr, "Usage: tobit [infile [outfile]]\n\n"
                    "  'infile' and 'outfile' default to stdin and stdout.\n\n"
                    "  Use 'tobit - outfile' to use stdin for infile while\n"
                    "  still specifying an output file.\n\n");
    exit(1);
  }
  if (argc > 1 && argv[1][0] != '-') {
    fi = fopen(argv[1], "rb");
    if (!fi) {
      perror("fopen()");
      fprintf(stderr, "Couldn't open '%s' for reading.\n", argv[1]);
      exit(1);
    }
  }
  if (argc > 2) {
    fo = fopen(argv[2], "wb");
    if (!fo) {
      perror("fopen()");
      fprintf(stderr, "Couldn't open '%s' for reading.\n", argv[2]);
      exit(1);
    }
  }
  while (!feof(fi)) {
    if (!(i = fread(buf, 1, 1, fi)))
      break;
    memset(line, ' ', 79);
    line[52] = '#';
    line[79] = '\n';
    for (j = 0; j < i; j++) {
      for (k = 0; k < 8; k++)
        line[2 + j * 12 + k] = '0' + ((buf[j] >> (7 - k)) & 1);
      line[54 + j * 3] = hex[0xF & (buf[j] >> 4)];
      line[55 + j * 3] = hex[0xF & (buf[j])];
      line[66 + j] = (buf[j] >= 32) && (buf[j] < 127) ? buf[j] : '.';
    }
    for (j = 0; j < 8; j++)
      line[78 - j] = hex[(addr >> (j * 4)) & 0xF];
    fwrite(line, 1, 80, fo);
    addr++;
    if ((addr & 7) == 0)
      fputc('\n', fo);
  }
  return errno;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe40(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe3d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe3b(%rip),%al
mov    %al,-0x20(%rbp)
movl   $0x0,-0xa0(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2dc5(%rip),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x94(%rbp)
cmpl   $0x50,-0x94(%rbp)
jge    124b <main+0xab>
movslq -0x94(%rbp),%rax
movb   $0x20,-0x90(%rbp,%rax,1)
20
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    121b <main+0x7b>
cmpl   $0x1,-0x8(%rbp)
jle    12cd <main+0x12d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdad(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     12ac <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd93(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     12ac <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd79(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12cd <main+0x12d>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jle    134e <main+0x1ae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     134e <main+0x1ae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd7(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    1349 <main+0x1a9>
lea    0xdb9(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xda4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    134e <main+0x1ae>
cmpl   $0x2,-0x8(%rbp)
jle    13bb <main+0x21b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd96(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
jne    13b6 <main+0x216>
lea    0xd4c(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd37(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    13bb <main+0x21b>
jmp    13c0 <main+0x220>
mov    -0xa8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13e1 <main+0x241>
jmp    162a <main+0x48a>
lea    -0x40(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x94(%rbp)
cmp    $0x0,%eax
jne    140c <main+0x26c>
jmp    162a <main+0x48a>
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
mov    $0x4f,%edx
call   1040 <memset@plt>
movb   $0x23,-0x5c(%rbp)
movb   $0xa,-0x41(%rbp)
movl   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    157d <main+0x3dd>
movl   $0x0,-0x9c(%rbp)
cmpl   $0x8,-0x9c(%rbp)
jge    14ab <main+0x30b>
movslq -0x98(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
mov    $0x7,%ecx
sub    -0x9c(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
add    $0x30,%eax
mov    %al,%cl
imul   $0xc,-0x98(%rbp),%eax
add    $0x2,%eax
add    -0x9c(%rbp),%eax
cltq
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1450 <main+0x2b0>
movslq -0x98(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
sar    $0x4,%eax
and    $0xf,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
imul   $0x3,-0x98(%rbp),%eax
add    $0x36,%eax
cltq
mov    %cl,-0x90(%rbp,%rax,1)
movslq -0x98(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
and    $0xf,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
imul   $0x3,-0x98(%rbp),%eax
add    $0x37,%eax
cltq
mov    %cl,-0x90(%rbp,%rax,1)
movslq -0x98(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jl     153f <main+0x39f>
movslq -0x98(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x7f,%eax
jge    153f <main+0x39f>
movslq -0x98(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
mov    %eax,-0xb4(%rbp)
jmp    154f <main+0x3af>
mov    $0x2e,%eax
mov    %eax,-0xb4(%rbp)
jmp    154f <main+0x3af>
mov    -0xb4(%rbp),%eax
mov    %al,%cl
mov    -0x98(%rbp),%eax
add    $0x42,%eax
cltq
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1434 <main+0x294>
movl   $0x0,-0x98(%rbp)
cmpl   $0x8,-0x98(%rbp)
jge    15d6 <main+0x436>
mov    -0xa0(%rbp),%eax
mov    -0x98(%rbp),%ecx
shl    $0x2,%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    -0x30(%rbp,%rax,1),%cl
mov    $0x4e,%eax
sub    -0x98(%rbp),%eax
cltq
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1587 <main+0x3e7>
lea    -0x90(%rbp),%rdi
mov    -0xb0(%rbp),%rcx
mov    $0x1,%esi
mov    $0x50,%edx
call   10c0 <fwrite@plt>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
mov    -0xa0(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1625 <main+0x485>
mov    -0xb0(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
jmp    13c0 <main+0x220>
mov    0x299f(%rip),%rax
mov    (%rax),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0x2e30(%rip),%rax
mov    (%rax),%r14
mov    0x2e06(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
mov    0x2dff(%rip),%rax
movl   $0x0,(%rax)
movaps 0xe22(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
cmp    $0x2,%edi
jl     1294 <main+0xf4>
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x8(%rsi),%rbp
lea    0xe10(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     14cb <main+0x32b>
lea    0xdfc(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     14cb <main+0x32b>
lea    0xde8(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     14cb <main+0x32b>
cmpb   $0x2d,0x0(%rbp)
je     1270 <main+0xd0>
lea    0xe85(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     14ec <main+0x34c>
cmp    $0x3,%r12d
jb     1294 <main+0xf4>
mov    0x10(%r15),%rdi
lea    0xe8c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1507 <main+0x367>
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     12bb <main+0x11b>
mov    0x2d29(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
lea    0x10(%rsp),%rbx
lea    0xd46(%rip),%r15
mov    $0x2e,%r12d
mov    %r14,0x68(%rsp)
jmp    12f1 <main+0x151>
nopw   0x0(%rax,%rax,1)
mov    0x68(%rsp),%r14
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    12a0 <main+0x100>
lea    0x70(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     12a0 <main+0x100>
mov    %eax,%ebp
mov    %rbx,%r14
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x4f,%edx
call   1040 <memset@plt>
movb   $0x23,0x44(%rsp)
movb   $0xa,0x5f(%rsp)
test   %ebp,%ebp
jle    140d <main+0x26d>
mov    %ebp,%eax
mov    $0x37,%ecx
mov    $0x9,%edx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x70(%rsp,%rsi,1),%ebp
mov    %ebp,%ebx
shr    $0x7,%bl
or     $0x30,%bl
mov    %bl,0x9(%rsp,%rdx,1)
mov    %ebp,%ebx
shr    $0x6,%bl
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0xa(%rsp,%rdx,1)
mov    %ebp,%ebx
shr    $0x5,%bl
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0xb(%rsp,%rdx,1)
mov    %ebp,%ebx
shr    $0x4,%bl
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0xc(%rsp,%rdx,1)
mov    %ebp,%ebx
shr    $0x3,%bl
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0xd(%rsp,%rdx,1)
mov    %ebp,%ebx
shr    $0x2,%bl
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0xe(%rsp,%rdx,1)
mov    %ebp,%ebx
shr    %bl
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0xf(%rsp,%rdx,1)
mov    %ebp,%ebx
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0x10(%rsp,%rdx,1)
mov    %rbp,%rdi
shr    $0x4,%rdi
movzbl (%rdi,%r15,1),%ebx
lea    -0x1(%rcx),%edi
mov    %bl,0x10(%rsp,%rdi,1)
mov    %ebp,%edi
and    $0xf,%edi
movzbl (%rdi,%r15,1),%ebx
mov    %ecx,%edi
mov    %bl,0x10(%rsp,%rdi,1)
lea    -0x7f(%rbp),%edi
cmp    $0xa1,%dil
cmovb  %r12d,%ebp
mov    %bpl,0x52(%rsp,%rsi,1)
add    $0x1,%rsi
add    $0x3,%ecx
add    $0xc,%rdx
cmp    %rsi,%rax
jne    1350 <main+0x1b0>
mov    %r13d,%eax
mov    %eax,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x5e(%rsp)
mov    %r13d,%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x5d(%rsp)
mov    %r13d,%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x5c(%rsp)
mov    %r13d,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x5b(%rsp)
mov    %r13d,%ecx
shr    $0x10,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x5a(%rsp)
mov    %r13d,%ecx
shr    $0x14,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x59(%rsp)
mov    %r13d,%ecx
shr    $0x18,%ecx
and    $0xf,%ecx
mov    (%rcx,%r15,1),%cl
mov    %cl,0x58(%rsp)
shr    $0x1c,%rax
mov    (%rax,%r15,1),%al
mov    %al,0x57(%rsp)
mov    %r14,%rbx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x50,%edx
mov    0x8(%rsp),%rcx
call   10c0 <fwrite@plt>
add    $0x1,%r13d
test   $0x7,%r13b
jne    12e0 <main+0x140>
mov    $0xa,%edi
mov    0x8(%rsp),%rsi
call   1050 <fputc@plt>
jmp    12e0 <main+0x140>
mov    0x2b06(%rip),%rax
mov    (%rax),%edi
lea    0xb53(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xbf1(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2ad9(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
jmp    1520 <main+0x380>
lea    0xbd6(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r15),%rdx
lea    0xbc5(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@__const.main.hex = [17 x i8] c"0123456789ABCDEF\00"
@stdin = global i32* null
@stdout = global i32* null
@errno = global i32 0
@.str = [3 x i8] c"-?\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.3 = [179 x i8] c"Usage: tobit [infile [outfile]]\0A\0A 'infile' and 'outfile' default to stdin and stdout.\0A\0A Use 'tobit - outfile' to use stdin for infile while\0A still specifying an output file.\0A\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [8 x i8] c"fopen()\00"
@.str.6 = [33 x i8] c"Couldn't open '%s' for reading.\0A\00"
@.str.7 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [17 x i8]
%7 = alloca [16 x i8]
%8 = alloca [80 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [17 x i8]* %6 to i8*
store i32 0, i32* %12
%16 = load i32*, i32** @stdin
store i32* %16, i32** %13
%17 = load i32*, i32** @stdout
store i32* %17, i32** %14
store i32 0, i32* @errno
store i32 0, i32* %9
br label %18
18: ; preds = %25, %2
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 80
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %23
store i8 32, i8* %24
br label %25
25: ; preds = %21
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %18
28: ; preds = %18
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 1
br i1 %30, label %31, label %53
31: ; preds = %28
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %31
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %37
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 @strcmp(i8* %46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %43, %37, %31
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.3, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %43, %28
%54 = load i32, i32* %4
%55 = icmp sgt i32 %54, 1
br i1 %55, label %56, label %80
56: ; preds = %53
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = getelementptr inbounds i8, i8* %59, i64 0
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 45
br i1 %63, label %64, label %80
64: ; preds = %56
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %68, i32** %13
%69 = load i32*, i32** %13
%70 = icmp ne i32* %69, null
br i1 %70, label %79, label %71
71: ; preds = %64
%72 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %76)
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %64
br label %80
80: ; preds = %79, %56, %53
%81 = load i32, i32* %4
%82 = icmp sgt i32 %81, 2
br i1 %82, label %83, label %99
83: ; preds = %80
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 2
%86 = load i8*, i8** %85
%87 = call i32* @fopen(i8* %86, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %87, i32** %14
%88 = load i32*, i32** %14
%89 = icmp ne i32* %88, null
br i1 %89, label %98, label %90
90: ; preds = %83
%91 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%92 = load i32, i32* @stderr
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 2
%95 = load i8*, i8** %94
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %95)
%97 = call i32 @exit(i32 1)
unreachable
98: ; preds = %83
br label %99
99: ; preds = %98, %80
br label %100
100: ; preds = %238, %99
%101 = load i32*, i32** %13
%102 = call i32 @feof(i32* %101)
%103 = icmp ne i32 %102, 0
%104 = xor i1 %103, true
br i1 %104, label %105, label %239
105: ; preds = %100
%106 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%107 = load i32*, i32** %13
%108 = call i32 @fread(i8* %106, i32 1, i32 1, i32* %107)
store i32 %108, i32* %9
%109 = icmp ne i32 %108, 0
br i1 %109, label %111, label %110
110: ; preds = %105
br label %239
111: ; preds = %105
%112 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%113 = call i32 @memset(i8* %112, i8 signext 32, i32 79)
%114 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 52
store i8 35, i8* %114
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 79
store i8 10, i8* %115
store i32 0, i32* %10
br label %116
116: ; preds = %203, %111
%117 = load i32, i32* %10
%118 = load i32, i32* %9
%119 = icmp slt i32 %117, %118
br i1 %119, label %120, label %206
120: ; preds = %116
store i32 0, i32* %11
br label %121
121: ; preds = %143, %120
%122 = load i32, i32* %11
%123 = icmp slt i32 %122, 8
br i1 %123, label %124, label %146
124: ; preds = %121
%125 = load i32, i32* %10
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %126
%128 = load i8, i8* %127
%129 = sext i8 %128 to i32
%130 = load i32, i32* %11
%131 = sub nsw i32 7, %130
%132 = ashr i32 %129, %131
%133 = and i32 %132, 1
%134 = add nsw i32 48, %133
%135 = trunc i32 %134 to i8
%136 = load i32, i32* %10
%137 = mul nsw i32 %136, 12
%138 = add nsw i32 2, %137
%139 = load i32, i32* %11
%140 = add nsw i32 %138, %139
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %141
store i8 %135, i8* %142
br label %143
143: ; preds = %124
%144 = load i32, i32* %11
%145 = add nsw i32 %144, 1
store i32 %145, i32* %11
br label %121
146: ; preds = %121
%147 = load i32, i32* %10
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %148
%150 = load i8, i8* %149
%151 = sext i8 %150 to i32
%152 = ashr i32 %151, 4
%153 = and i32 15, %152
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %154
%156 = load i8, i8* %155
%157 = load i32, i32* %10
%158 = mul nsw i32 %157, 3
%159 = add nsw i32 54, %158
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %160
store i8 %156, i8* %161
%162 = load i32, i32* %10
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %163
%165 = load i8, i8* %164
%166 = sext i8 %165 to i32
%167 = and i32 15, %166
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %168
%170 = load i8, i8* %169
%171 = load i32, i32* %10
%172 = mul nsw i32 %171, 3
%173 = add nsw i32 55, %172
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %174
store i8 %170, i8* %175
%176 = load i32, i32* %10
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %177
%179 = load i8, i8* %178
%180 = sext i8 %179 to i32
%181 = icmp sge i32 %180, 32
br i1 %181, label %182, label %195
182: ; preds = %146
%183 = load i32, i32* %10
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %184
%186 = load i8, i8* %185
%187 = sext i8 %186 to i32
%188 = icmp slt i32 %187, 127
br i1 %188, label %189, label %195
189: ; preds = %182
%190 = load i32, i32* %10
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %191
%193 = load i8, i8* %192
%194 = sext i8 %193 to i32
br label %196
195: ; preds = %182, %146
br label %196
196: ; preds = %195, %189
%197 = phi i32 [ %194, %189 ], [ 46, %195 ]
%198 = trunc i32 %197 to i8
%199 = load i32, i32* %10
%200 = add nsw i32 66, %199
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %201
store i8 %198, i8* %202
br label %203
203: ; preds = %196
%204 = load i32, i32* %10
%205 = add nsw i32 %204, 1
store i32 %205, i32* %10
br label %116
206: ; preds = %116
store i32 0, i32* %10
br label %207
207: ; preds = %223, %206
%208 = load i32, i32* %10
%209 = icmp slt i32 %208, 8
br i1 %209, label %210, label %226
210: ; preds = %207
%211 = load i32, i32* %12
%212 = load i32, i32* %10
%213 = mul nsw i32 %212, 4
%214 = lshr i32 %211, %213
%215 = and i32 %214, 15
%216 = zext i32 %215 to i64
%217 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %216
%218 = load i8, i8* %217
%219 = load i32, i32* %10
%220 = sub nsw i32 78, %219
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %221
store i8 %218, i8* %222
br label %223
223: ; preds = %210
%224 = load i32, i32* %10
%225 = add nsw i32 %224, 1
store i32 %225, i32* %10
br label %207
226: ; preds = %207
%227 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%228 = load i32*, i32** %14
%229 = call i32 @fwrite(i8* %227, i32 1, i32 80, i32* %228)
%230 = load i32, i32* %12
%231 = add i32 %230, 1
store i32 %231, i32* %12
%232 = load i32, i32* %12
%233 = and i32 %232, 7
%234 = icmp eq i32 %233, 0
br i1 %234, label %235, label %238
235: ; preds = %226
%236 = load i32*, i32** %14
%237 = call i32 @fputc(i8 signext 10, i32* %236)
br label %238
238: ; preds = %235, %226
br label %100
239: ; preds = %110, %100
%240 = load i32, i32* @errno
ret i32 %240
}

LLVM IR (-O2):
@__const.main.hex = [17 x i8] c"0123456789ABCDEF\00"
@stdin = global i32* null
@stdout = global i32* null
@errno = global i32 0
@.str = [3 x i8] c"-?\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.3 = [179 x i8] c"Usage: tobit [infile [outfile]]\0A\0A 'infile' and 'outfile' default to stdin and stdout.\0A\0A Use 'tobit - outfile' to use stdin for infile while\0A still specifying an output file.\0A\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [8 x i8] c"fopen()\00"
@.str.6 = [33 x i8] c"Couldn't open '%s' for reading.\0A\00"
@.str.7 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%8 = load i32*, i32** @stdin
%9 = load i32*, i32** @stdout
store i32 0, i32* @errno
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %52
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %11
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19, %16, %11
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = load i8, i8* %13
%28 = icmp eq i8 %27, 45
br i1 %28, label %38, label %29
29: ; preds = %26
%30 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %12
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %35)
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %29, %26
%39 = phi i32* [ %30, %29 ], [ %8, %26 ]
%40 = icmp ugt i32 %0, 2
br i1 %40, label %41, label %52
41: ; preds = %38
%42 = getelementptr inbounds i8*, i8** %1, i64 2
%43 = load i8*, i8** %42
%44 = tail call i32* @fopen(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %52
46: ; preds = %41
%47 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %42
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %49)
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %2, %41, %38
%53 = phi i32* [ %39, %41 ], [ %39, %38 ], [ %8, %2 ]
%54 = phi i32* [ %44, %41 ], [ %9, %38 ], [ %9, %2 ]
%55 = call i32 @feof(i32* %53)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %191
57: ; preds = %52
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 52
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 79
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 78
%61 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 77
%62 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 76
%63 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 75
%64 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 74
%65 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 73
%66 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 72
%67 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 71
br label %68
68: ; preds = %57, %188
%69 = phi i32 [ 0, %57 ], [ %117, %188 ]
%70 = call i32 @fread(i8* %6, i32 1, i32 1, i32* %53)
%71 = icmp eq i32 %70, 0
br i1 %71, label %191, label %72
72: ; preds = %68
%73 = call i32 @memset(i8* %7, i8 signext 32, i32 79)
store i8 35, i8* %58
store i8 10, i8* %59
%74 = icmp sgt i32 %70, 0
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = zext i32 %70 to i64
br label %120
77: ; preds = %120, %72
%78 = and i32 %69, 15
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %79
%81 = load i8, i8* %80
store i8 %81, i8* %60
%82 = lshr i32 %69, 4
%83 = and i32 %82, 15
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %84
%86 = load i8, i8* %85
store i8 %86, i8* %61
%87 = lshr i32 %69, 8
%88 = and i32 %87, 15
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %89
%91 = load i8, i8* %90
store i8 %91, i8* %62
%92 = lshr i32 %69, 12
%93 = and i32 %92, 15
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %94
%96 = load i8, i8* %95
store i8 %96, i8* %63
%97 = lshr i32 %69, 16
%98 = and i32 %97, 15
%99 = zext i32 %98 to i64
%100 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %99
%101 = load i8, i8* %100
store i8 %101, i8* %64
%102 = lshr i32 %69, 20
%103 = and i32 %102, 15
%104 = zext i32 %103 to i64
%105 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %104
%106 = load i8, i8* %105
store i8 %106, i8* %65
%107 = lshr i32 %69, 24
%108 = and i32 %107, 15
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %109
%111 = load i8, i8* %110
store i8 %111, i8* %66
%112 = lshr i32 %69, 28
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %113
%115 = load i8, i8* %114
store i8 %115, i8* %67
%116 = call i32 @fwrite(i8* %7, i32 1, i32 80, i32* %54)
%117 = add i32 %69, 1
%118 = and i32 %117, 7
%119 = icmp eq i32 %118, 0
br i1 %119, label %186, label %188
120: ; preds = %75, %120
%121 = phi i64 [ 0, %75 ], [ %184, %120 ]
%122 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %121
%123 = load i8, i8* %122
%124 = mul nuw nsw i64 %121, 12
%125 = or i64 %124, 2
%126 = lshr i8 %123, 7
%127 = or i8 %126, 48
%128 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %125
store i8 %127, i8* %128
%129 = lshr i8 %123, 6
%130 = and i8 %129, 1
%131 = or i8 %130, 48
%132 = or i64 %124, 3
%133 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %132
store i8 %131, i8* %133
%134 = lshr i8 %123, 5
%135 = and i8 %134, 1
%136 = or i8 %135, 48
%137 = add nuw i64 %124, 4
%138 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %137
store i8 %136, i8* %138
%139 = lshr i8 %123, 4
%140 = and i8 %139, 1
%141 = or i8 %140, 48
%142 = add nuw i64 %124, 5
%143 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %142
store i8 %141, i8* %143
%144 = lshr i8 %123, 3
%145 = and i8 %144, 1
%146 = or i8 %145, 48
%147 = add nuw i64 %124, 6
%148 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %147
store i8 %146, i8* %148
%149 = lshr i8 %123, 2
%150 = and i8 %149, 1
%151 = or i8 %150, 48
%152 = add nuw i64 %124, 7
%153 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %152
store i8 %151, i8* %153
%154 = lshr i8 %123, 1
%155 = and i8 %154, 1
%156 = or i8 %155, 48
%157 = add nuw i64 %124, 8
%158 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %157
store i8 %156, i8* %158
%159 = and i8 %123, 1
%160 = or i8 %159, 48
%161 = add nuw i64 %124, 9
%162 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %161
store i8 %160, i8* %162
%163 = lshr i8 %123, 4
%164 = zext i8 %163 to i64
%165 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %164
%166 = load i8, i8* %165
%167 = trunc i64 %121 to i32
%168 = mul nsw i32 %167, 3
%169 = add nuw nsw i32 %168, 54
%170 = zext i32 %169 to i64
%171 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %170
store i8 %166, i8* %171
%172 = and i8 %123, 15
%173 = zext i8 %172 to i64
%174 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.main.hex, i64 0, i64 %173
%175 = load i8, i8* %174
%176 = add nuw nsw i32 %168, 55
%177 = zext i32 %176 to i64
%178 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %177
store i8 %175, i8* %178
%179 = add i8 %123, -127
%180 = icmp ult i8 %179, -95
%181 = select i1 %180, i8 46, i8 %123
%182 = add nuw nsw i64 %121, 66
%183 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %182
store i8 %181, i8* %183
%184 = add nuw nsw i64 %121, 1
%185 = icmp eq i64 %184, %76
br i1 %185, label %77, label %120
186: ; preds = %77
%187 = call i32 @fputc(i8 signext 10, i32* %54)
br label %188
188: ; preds = %186, %77
%189 = call i32 @feof(i32* %53)
%190 = icmp eq i32 %189, 0
br i1 %190, label %68, label %191
191: ; preds = %188, %68, %52
%192 = load i32, i32* @errno
ret i32 %192
}