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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
unsigned int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  FILE *fd;
  int c;
  int i = 0;
  int write_size_word = 0;
  int filename_index = 1;
  int bytes_per_line = 1;
  int bytes_per_line_index = 2;
  unsigned int image_size;
  if (argc < 3) {
    fprintf(stderr, "\n\tInsufficient options.\n");
    fprintf(stderr, "\tPlease specify, in this order: a binary file to\n");
    fprintf(stderr, "\tconvert and the number of bytes of data to putput\n");
    fprintf(stderr, "\tper line.\n");
    fprintf(stderr, "\tOptionally specify the option -size_word to output,\n");
    fprintf(stderr, "\tthe size of the image in the first 4 bytes. This is\n");
    fprintf(stderr, "\tused by some of the new OR1k bootloaders.\n\n");
    exit(1);
  }
  if (argc == 4) {
    if (strcmp("-size_word", argv[3]) == 0)
      write_size_word = 1;
  }
  fd = fopen(argv[filename_index], "r");
  bytes_per_line = atoi(argv[bytes_per_line_index]);
  if ((bytes_per_line == 0) || (bytes_per_line > 8)) {
    fprintf(stderr, "bytes per line incorrect or missing: %s\n",
            argv[bytes_per_line_index]);
    exit(1);
  }
  if (fd == NULL) {
    fprintf(stderr, "failed to open input file: %s\n", argv[1]);
    exit(1);
  }
  if (write_size_word) {
    fseek(fd, 0, SEEK_END);
    image_size = ftell(fd);
    fseek(fd, 0, SEEK_SET);
    image_size += 3;
    image_size &= 0xfffffffc;
    if (image_size < 8) {
      fprintf(stderr, "Bad binary image. Size too small\n");
      return 1;
    }
    i = 0;
    printf("%.2x", (image_size >> 24) & 0xff);
    if (++i == bytes_per_line) {
      printf("\n");
      i = 0;
    }
    printf("%.2x", (image_size >> 16) & 0xff);
    if (++i == bytes_per_line) {
      printf("\n");
      i = 0;
    }
    printf("%.2x", (image_size >> 8) & 0xff);
    if (++i == bytes_per_line) {
      printf("\n");
      i = 0;
    }
    printf("%.2x", (image_size)&0xff);
    if (++i == bytes_per_line) {
      printf("\n");
      i = 0;
    }
  }
  for (i = 0; i < 4; i++)
    c = fgetc(fd);
  i = 0;
  while ((c = fgetc(fd)) != EOF) {
    printf("%.2x", (unsigned int)c);
    if (++i == bytes_per_line) {
      printf("\n");
      i = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    127e <main+0xee>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    12b2 <main+0x122>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe8d(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12ad <main+0x11d>
movl   $0x1,-0x24(%rbp)
jmp    12b2 <main+0x122>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12f6 <main+0x166>
cmpl   $0x8,-0x2c(%rbp)
jle    1323 <main+0x193>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1357 <main+0x1c7>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     14e1 <main+0x351>
mov    -0x18(%rbp),%rdi
mov    0x2c7c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2c3c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x34(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
and    $0xfffffffc,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jae    13d4 <main+0x244>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1572 <main+0x3e2>
movl   $0x0,-0x20(%rbp)
mov    -0x34(%rbp),%esi
shr    $0x18,%esi
and    $0xff,%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x2c(%rbp),%eax
jne    141c <main+0x28c>
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x34(%rbp),%esi
shr    $0x10,%esi
and    $0xff,%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x2c(%rbp),%eax
jne    145d <main+0x2cd>
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x34(%rbp),%esi
shr    $0x8,%esi
and    $0xff,%esi
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x2c(%rbp),%eax
jne    149e <main+0x30e>
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x34(%rbp),%esi
and    $0xff,%esi
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x2c(%rbp),%eax
jne    14dc <main+0x34c>
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    14e1 <main+0x351>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    150c <main+0x37c>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    14e8 <main+0x358>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2aba(%rip),%rcx
cmp    (%rcx),%eax
je     156b <main+0x3db>
mov    -0x1c(%rbp),%esi
lea    0xc63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x2c(%rbp),%eax
jne    1566 <main+0x3d6>
lea    0xbca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    1513 <main+0x383>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jle    139c <main+0x1fc>
mov    %rsi,%r14
mov    $0x1,%bl
cmp    $0x4,%edi
jne    11d1 <main+0x31>
mov    0x18(%r14),%rsi
lea    0xf5e(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
setne  %bl
mov    0x8(%r14),%rdi
lea    0xf53(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
mov    0x10(%r14),%rbp
mov    %rbp,%rdi
call   10b0 <atoi@plt>
test   %eax,%eax
je     141d <main+0x27d>
mov    %eax,%r15d
cmp    $0x9,%eax
jge    141d <main+0x27d>
test   %r12,%r12
je     1432 <main+0x292>
test   %bl,%bl
jne    1311 <main+0x171>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r12,%rdi
call   1080 <ftell@plt>
mov    %eax,%ebx
mov    0x2d8f(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
add    $0x3,%ebx
cmp    $0x7,%ebx
ja     126e <main+0xce>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xf1c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ecx
jmp    1391 <main+0x1f1>
mov    %ebx,%eax
shr    $0x18,%eax
lea    0xf21(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebp
cmp    $0x1,%r15d
jne    129d <main+0xfd>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%esi
lea    0xeef(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r15d,%ebp
jne    12c4 <main+0x124>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
movzbl %bh,%esi
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %r15d,%ebp
jne    12e9 <main+0x149>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
and    $0xfc,%ebx
lea    0xea5(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %r15d,%ebp
jne    1311 <main+0x171>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    0x2ca0(%rip),%r14
xor    %ecx,%ecx
cmp    (%r14),%eax
je     1391 <main+0x1f1>
lea    0xe4d(%rip),%rbp
xor    %ebx,%ebx
jmp    136d <main+0x1cd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%eax
je     138f <main+0x1ef>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    %r15d,%ebx
jne    1360 <main+0x1c0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    1360 <main+0x1c0>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c2d(%rip),%rbx
mov    (%rbx),%edi
lea    0xc54(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc5d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc7f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xca3(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc9f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xcc5(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xceb(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
lea    0xd04(%rip),%rsi
mov    %rbp,%rdx
jmp    1446 <main+0x2a6>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xd14(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"\0A\09Insufficient options.\0A\00"
@.str.1 = [50 x i8] c"\09Please specify, in this order: a binary file to\0A\00"
@.str.2 = [52 x i8] c"\09convert and the number of bytes of data to putput\0A\00"
@.str.3 = [12 x i8] c"\09per line.\0A\00"
@.str.4 = [54 x i8] c"\09Optionally specify the option -size_word to output,\0A\00"
@.str.5 = [54 x i8] c"\09the size of the image in the first 4 bytes. This is\0A\00"
@.str.6 = [45 x i8] c"\09used by some of the new OR1k bootloaders.\0A\0A\00"
@.str.7 = [11 x i8] c"-size_word\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [41 x i8] c"bytes per line incorrect or missing: %s\0A\00"
@.str.10 = [31 x i8] c"failed to open input file: %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.11 = [34 x i8] c"Bad binary image. Size too small\0A\00"
@.str.12 = [5 x i8] c"%.2x\00"
@.str.13 = [2 x i8] c"\0A\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
store i32 1, i32* %11
store i32 2, i32* %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %32
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %2
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %35
store i32 1, i32* %9
br label %42
42: ; preds = %41, %35
br label %43
43: ; preds = %42, %32
%44 = load i8**, i8*** %5
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %49, i32** %6
%50 = load i8**, i8*** %5
%51 = load i32, i32* %12
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %11
%56 = load i32, i32* %11
%57 = icmp eq i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %43
%59 = load i32, i32* %11
%60 = icmp sgt i32 %59, 8
br i1 %60, label %61, label %70
61: ; preds = %58, %43
%62 = load i32, i32* @stderr
%63 = load i8**, i8*** %5
%64 = load i32, i32* %12
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %58
%71 = load i32*, i32** %6
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %80
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %70
%81 = load i32, i32* %9
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %145
83: ; preds = %80
%84 = load i32*, i32** %6
%85 = load i32, i32* @SEEK_END
%86 = call i32 @fseek(i32* %84, i32 0, i32 %85)
%87 = load i32*, i32** %6
%88 = call i32 @ftell(i32* %87)
store i32 %88, i32* %13
%89 = load i32*, i32** %6
%90 = load i32, i32* @SEEK_SET
%91 = call i32 @fseek(i32* %89, i32 0, i32 %90)
%92 = load i32, i32* %13
%93 = add i32 %92, 3
store i32 %93, i32* %13
%94 = load i32, i32* %13
%95 = and i32 %94, -4
store i32 %95, i32* %13
%96 = load i32, i32* %13
%97 = icmp ult i32 %96, 8
br i1 %97, label %98, label %101
98: ; preds = %83
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %172
101: ; preds = %83
store i32 0, i32* %8
%102 = load i32, i32* %13
%103 = lshr i32 %102, 24
%104 = and i32 %103, 255
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %104)
%106 = load i32, i32* %8
%107 = add nsw i32 %106, 1
store i32 %107, i32* %8
%108 = load i32, i32* %11
%109 = icmp eq i32 %107, %108
br i1 %109, label %110, label %112
110: ; preds = %101
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %8
br label %112
112: ; preds = %110, %101
%113 = load i32, i32* %13
%114 = lshr i32 %113, 16
%115 = and i32 %114, 255
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %115)
%117 = load i32, i32* %8
%118 = add nsw i32 %117, 1
store i32 %118, i32* %8
%119 = load i32, i32* %11
%120 = icmp eq i32 %118, %119
br i1 %120, label %121, label %123
121: ; preds = %112
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %8
br label %123
123: ; preds = %121, %112
%124 = load i32, i32* %13
%125 = lshr i32 %124, 8
%126 = and i32 %125, 255
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %126)
%128 = load i32, i32* %8
%129 = add nsw i32 %128, 1
store i32 %129, i32* %8
%130 = load i32, i32* %11
%131 = icmp eq i32 %129, %130
br i1 %131, label %132, label %134
132: ; preds = %123
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %8
br label %134
134: ; preds = %132, %123
%135 = load i32, i32* %13
%136 = and i32 %135, 255
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %136)
%138 = load i32, i32* %8
%139 = add nsw i32 %138, 1
store i32 %139, i32* %8
%140 = load i32, i32* %11
%141 = icmp eq i32 %139, %140
br i1 %141, label %142, label %144
142: ; preds = %134
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %8
br label %144
144: ; preds = %142, %134
br label %145
145: ; preds = %144, %80
store i32 0, i32* %8
br label %146
146: ; preds = %152, %145
%147 = load i32, i32* %8
%148 = icmp slt i32 %147, 4
br i1 %148, label %149, label %155
149: ; preds = %146
%150 = load i32*, i32** %6
%151 = call i32 @fgetc(i32* %150)
store i32 %151, i32* %7
br label %152
152: ; preds = %149
%153 = load i32, i32* %8
%154 = add nsw i32 %153, 1
store i32 %154, i32* %8
br label %146
155: ; preds = %146
store i32 0, i32* %8
br label %156
156: ; preds = %170, %155
%157 = load i32*, i32** %6
%158 = call i32 @fgetc(i32* %157)
store i32 %158, i32* %7
%159 = load i32, i32* @EOF
%160 = icmp ne i32 %158, %159
br i1 %160, label %161, label %171
161: ; preds = %156
%162 = load i32, i32* %7
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %162)
%164 = load i32, i32* %8
%165 = add nsw i32 %164, 1
store i32 %165, i32* %8
%166 = load i32, i32* %11
%167 = icmp eq i32 %165, %166
br i1 %167, label %168, label %170
168: ; preds = %161
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %8
br label %170
170: ; preds = %168, %161
br label %156
171: ; preds = %156
store i32 0, i32* %3
br label %172
172: ; preds = %171, %98
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"\0A\09Insufficient options.\0A\00"
@.str.1 = [50 x i8] c"\09Please specify, in this order: a binary file to\0A\00"
@.str.2 = [52 x i8] c"\09convert and the number of bytes of data to putput\0A\00"
@.str.3 = [12 x i8] c"\09per line.\0A\00"
@.str.4 = [54 x i8] c"\09Optionally specify the option -size_word to output,\0A\00"
@.str.5 = [54 x i8] c"\09the size of the image in the first 4 bytes. This is\0A\00"
@.str.6 = [45 x i8] c"\09used by some of the new OR1k bootloaders.\0A\0A\00"
@.str.7 = [11 x i8] c"-size_word\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [41 x i8] c"bytes per line incorrect or missing: %s\0A\00"
@.str.10 = [31 x i8] c"failed to open input file: %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.11 = [34 x i8] c"Bad binary image. Size too small\0A\00"
@.str.12 = [5 x i8] c"%.2x\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = icmp eq i32 %0, 4
br i1 %21, label %22, label %27
22: ; preds = %20
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = tail call i64 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %24)
%26 = icmp ne i64 %25, 0
br label %27
27: ; preds = %22, %20
%28 = phi i1 [ true, %20 ], [ %26, %22 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32 @atoi(i8* %33)
%35 = icmp eq i32 %34, 0
%36 = icmp sgt i32 %34, 8
%37 = or i1 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %27
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* %33)
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %27
%43 = icmp eq i32* %31, null
br i1 %43, label %44, label %49
44: ; preds = %42
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %29
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %46)
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %42
br i1 %28, label %92, label %50
50: ; preds = %49
%51 = load i32, i32* @SEEK_END
%52 = tail call i32 @fseek(i32* %31, i32 0, i32 %51)
%53 = tail call i32 @ftell(i32* %31)
%54 = load i32, i32* @SEEK_SET
%55 = tail call i32 @fseek(i32* %31, i32 0, i32 %54)
%56 = add i32 %53, 3
%57 = icmp ult i32 %56, 8
br i1 %57, label %58, label %61
58: ; preds = %50
%59 = load i32, i32* @stderr
%60 = tail call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
br label %113
61: ; preds = %50
%62 = lshr i32 %56, 24
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %62)
%64 = icmp eq i32 %34, 1
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = tail call i32 @putchar(i32 10)
br label %67
67: ; preds = %65, %61
%68 = phi i32 [ 1, %65 ], [ 2, %61 ]
%69 = lshr i32 %56, 16
%70 = and i32 %69, 255
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %70)
%72 = icmp eq i32 %68, %34
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = tail call i32 @putchar(i32 10)
br label %75
75: ; preds = %73, %67
%76 = phi i32 [ 0, %73 ], [ %68, %67 ]
%77 = lshr i32 %56, 8
%78 = and i32 %77, 255
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %78)
%80 = add nuw nsw i32 %76, 1
%81 = icmp eq i32 %80, %34
br i1 %81, label %82, label %84
82: ; preds = %75
%83 = tail call i32 @putchar(i32 10)
br label %84
84: ; preds = %82, %75
%85 = phi i32 [ 0, %82 ], [ %80, %75 ]
%86 = and i32 %56, 252
%87 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %86)
%88 = add nuw nsw i32 %85, 1
%89 = icmp eq i32 %88, %34
br i1 %89, label %90, label %92
90: ; preds = %84
%91 = tail call i32 @putchar(i32 10)
br label %92
92: ; preds = %84, %90, %49
%93 = tail call i32 @fgetc(i32* %31)
%94 = tail call i32 @fgetc(i32* %31)
%95 = tail call i32 @fgetc(i32* %31)
%96 = tail call i32 @fgetc(i32* %31)
%97 = tail call i32 @fgetc(i32* %31)
%98 = load i32, i32* @EOF
%99 = icmp eq i32 %97, %98
br i1 %99, label %113, label %100
100: ; preds = %92, %108
%101 = phi i32 [ %110, %108 ], [ %97, %92 ]
%102 = phi i32 [ %109, %108 ], [ 0, %92 ]
%103 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %101)
%104 = add nsw i32 %102, 1
%105 = icmp eq i32 %104, %34
br i1 %105, label %106, label %108
106: ; preds = %100
%107 = tail call i32 @putchar(i32 10)
br label %108
108: ; preds = %106, %100
%109 = phi i32 [ 0, %106 ], [ %104, %100 ]
%110 = tail call i32 @fgetc(i32* %31)
%111 = load i32, i32* @EOF
%112 = icmp eq i32 %110, %111
br i1 %112, label %113, label %100
113: ; preds = %108, %92, %58
%114 = phi i32 [ 1, %58 ], [ 0, %92 ], [ 0, %108 ]
ret i32 %114
}