#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 padding_size = 0;
  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 output\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. Note that\n");
    fprintf(stderr,
            "\tpadding zeroes will be appended so that the image size\n");
    fprintf(stderr, "\tis a multiple of 4.\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) {
    unsigned int image_size;
    fseek(fd, 0, SEEK_END);
    image_size = ftell(fd);
    fseek(fd, 0, SEEK_SET);
    padding_size = (4 - (image_size % 4)) % 4;
    image_size += padding_size;
    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;
    }
  }
  unsigned j;
  for (j = 0; j < padding_size; ++j) {
    printf("%.2x", 0);
    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)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    12b3 <main+0x123>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    12e7 <main+0x157>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12e2 <main+0x152>
movl   $0x1,-0x24(%rbp)
jmp    12e7 <main+0x157>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8d(%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     132b <main+0x19b>
cmpl   $0x8,-0x2c(%rbp)
jle    1358 <main+0x1c8>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    138c <main+0x1fc>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     1520 <main+0x390>
mov    -0x18(%rbp),%rdi
mov    0x2c47(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2c07(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x38(%rbp),%ecx
and    $0x3,%ecx
mov    $0x4,%eax
sub    %ecx,%eax
and    $0x3,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jae    1413 <main+0x283>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160e <main+0x47e>
movl   $0x0,-0x20(%rbp)
mov    -0x38(%rbp),%esi
shr    $0x18,%esi
and    $0xff,%esi
lea    0xdc6(%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    145b <main+0x2cb>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x38(%rbp),%esi
shr    $0x10,%esi
and    $0xff,%esi
lea    0xd85(%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    149c <main+0x30c>
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x38(%rbp),%esi
shr    $0x8,%esi
and    $0xff,%esi
lea    0xd44(%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    14dd <main+0x34d>
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x38(%rbp),%esi
and    $0xff,%esi
lea    0xd06(%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    151b <main+0x38b>
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    1520 <main+0x390>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    154b <main+0x3bb>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1527 <main+0x397>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2a7b(%rip),%rcx
cmp    (%rcx),%eax
je     15aa <main+0x41a>
mov    -0x1c(%rbp),%esi
lea    0xc7c(%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    15a5 <main+0x415>
lea    0xbe3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    1552 <main+0x3c2>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jae    1607 <main+0x477>
lea    0xc2f(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x2c(%rbp),%eax
jne    15f4 <main+0x464>
lea    0xb94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    15f9 <main+0x469>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    15b1 <main+0x421>
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   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jle    13f0 <main+0x250>
mov    %rsi,%r15
mov    $0x1,%r13b
cmp    $0x4,%edi
jne    11d6 <main+0x36>
mov    0x18(%r15),%rsi
lea    0xfb2(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
setne  %r13b
mov    0x8(%r15),%rdi
lea    0xfa6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    0x10(%r15),%rbx
mov    %rbx,%rdi
call   10b0 <atoi@plt>
test   %eax,%eax
je     1491 <main+0x2f1>
mov    %eax,%r12d
cmp    $0x9,%eax
jge    1491 <main+0x2f1>
test   %r14,%r14
je     14a6 <main+0x306>
xor    %ebp,%ebp
mov    $0x0,%ebx
test   %r13b,%r13b
jne    132b <main+0x18b>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
mov    %eax,%ebx
mov    0x2d82(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %ebx,%eax
neg    %ebx
and    $0x3,%ebx
add    %ebx,%eax
cmp    $0x8,%eax
jae    1281 <main+0xe1>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xf61(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    1399 <main+0x1f9>
mov    %eax,%r13d
shr    $0x18,%eax
lea    0xf65(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%r15d
cmp    $0x1,%r12d
jne    12b3 <main+0x113>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%r15d
mov    %r13d,%eax
shr    $0x10,%eax
movzbl %al,%esi
lea    0xf30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%r15d
jne    12dc <main+0x13c>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r15d,%r15d
mov    %r13d,%eax
movzbl %ah,%esi
lea    0xf0a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
cmp    %r12d,%r15d
jne    1306 <main+0x166>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r15d,%r15d
movzbl %r13b,%esi
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
cmp    %r12d,%r15d
jne    132b <main+0x18b>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    0x2c86(%rip),%r13
cmp    0x0(%r13),%eax
jne    13a8 <main+0x208>
test   %ebx,%ebx
je     1397 <main+0x1f7>
lea    0xe88(%rip),%r14
jmp    1375 <main+0x1d5>
nopl   (%rax)
add    $0xffffffff,%ebx
je     1397 <main+0x1f7>
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
jne    1370 <main+0x1d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1370 <main+0x1d0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe44(%rip),%r15
xor    %ebp,%ebp
jmp    13ce <main+0x22e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%r13),%eax
je     1360 <main+0x1c0>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
jne    13c0 <main+0x220>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    13c0 <main+0x220>
mov    0x2bd9(%rip),%rbx
mov    (%rbx),%edi
lea    0xc00(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc09(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc2b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc4f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc4b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc70(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc96(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xcbc(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xce5(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
mov    %rbx,%rdx
jmp    14ba <main+0x31a>
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xcf8(%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 output\0A\00"
@.str.3 = [12 x i8] c"\09per line.\0A\00"
@.str.4 = [53 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 = [54 x i8] c"\09used by some of the new OR1k bootloaders. Note that\0A\00"
@.str.7 = [57 x i8] c"\09padding zeroes will be appended so that the image size\0A\00"
@.str.8 = [23 x i8] c"\09is a multiple of 4.\0A\0A\00"
@.str.9 = [11 x i8] c"-size_word\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [41 x i8] c"bytes per line incorrect or missing: %s\0A\00"
@.str.12 = [31 x i8] c"failed to open input file: %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.13 = [34 x i8] c"Bad binary image. Size too small\0A\00"
@.str.14 = [5 x i8] c"%.2x\00"
@.str.15 = [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
%14 = alloca i32
%15 = 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
store i32 0, i32* %13
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %38
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %2
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 4
br i1 %40, label %41, label %49
41: ; preds = %38
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 3
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 1, i32* %9
br label %48
48: ; preds = %47, %41
br label %49
49: ; preds = %48, %38
%50 = load i8**, i8*** %5
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %55, i32** %6
%56 = load i8**, i8*** %5
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @atoi(i8* %60)
store i32 %61, i32* %11
%62 = load i32, i32* %11
%63 = icmp eq i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %49
%65 = load i32, i32* %11
%66 = icmp sgt i32 %65, 8
br i1 %66, label %67, label %76
67: ; preds = %64, %49
%68 = load i32, i32* @stderr
%69 = load i8**, i8*** %5
%70 = load i32, i32* %12
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %69, i64 %71
%73 = load i8*, i8** %72
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0), i8* %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %64
%77 = load i32*, i32** %6
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %86
79: ; preds = %76
%80 = load i32, i32* @stderr
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0), i8* %83)
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %76
%87 = load i32, i32* %9
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %154
89: ; preds = %86
%90 = load i32*, i32** %6
%91 = load i32, i32* @SEEK_END
%92 = call i32 @fseek(i32* %90, i32 0, i32 %91)
%93 = load i32*, i32** %6
%94 = call i32 @ftell(i32* %93)
store i32 %94, i32* %14
%95 = load i32*, i32** %6
%96 = load i32, i32* @SEEK_SET
%97 = call i32 @fseek(i32* %95, i32 0, i32 %96)
%98 = load i32, i32* %14
%99 = urem i32 %98, 4
%100 = sub i32 4, %99
%101 = urem i32 %100, 4
store i32 %101, i32* %13
%102 = load i32, i32* %13
%103 = load i32, i32* %14
%104 = add i32 %103, %102
store i32 %104, i32* %14
%105 = load i32, i32* %14
%106 = icmp ult i32 %105, 8
br i1 %106, label %107, label %110
107: ; preds = %89
%108 = load i32, i32* @stderr
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %3
br label %198
110: ; preds = %89
store i32 0, i32* %8
%111 = load i32, i32* %14
%112 = lshr i32 %111, 24
%113 = and i32 %112, 255
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %113)
%115 = load i32, i32* %8
%116 = add nsw i32 %115, 1
store i32 %116, i32* %8
%117 = load i32, i32* %11
%118 = icmp eq i32 %116, %117
br i1 %118, label %119, label %121
119: ; preds = %110
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %8
br label %121
121: ; preds = %119, %110
%122 = load i32, i32* %14
%123 = lshr i32 %122, 16
%124 = and i32 %123, 255
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %8
%127 = add nsw i32 %126, 1
store i32 %127, i32* %8
%128 = load i32, i32* %11
%129 = icmp eq i32 %127, %128
br i1 %129, label %130, label %132
130: ; preds = %121
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %8
br label %132
132: ; preds = %130, %121
%133 = load i32, i32* %14
%134 = lshr i32 %133, 8
%135 = and i32 %134, 255
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %135)
%137 = load i32, i32* %8
%138 = add nsw i32 %137, 1
store i32 %138, i32* %8
%139 = load i32, i32* %11
%140 = icmp eq i32 %138, %139
br i1 %140, label %141, label %143
141: ; preds = %132
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %8
br label %143
143: ; preds = %141, %132
%144 = load i32, i32* %14
%145 = and i32 %144, 255
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %145)
%147 = load i32, i32* %8
%148 = add nsw i32 %147, 1
store i32 %148, i32* %8
%149 = load i32, i32* %11
%150 = icmp eq i32 %148, %149
br i1 %150, label %151, label %153
151: ; preds = %143
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %8
br label %153
153: ; preds = %151, %143
br label %154
154: ; preds = %153, %86
store i32 0, i32* %8
br label %155
155: ; preds = %161, %154
%156 = load i32, i32* %8
%157 = icmp slt i32 %156, 4
br i1 %157, label %158, label %164
158: ; preds = %155
%159 = load i32*, i32** %6
%160 = call i32 @fgetc(i32* %159)
store i32 %160, i32* %7
br label %161
161: ; preds = %158
%162 = load i32, i32* %8
%163 = add nsw i32 %162, 1
store i32 %163, i32* %8
br label %155
164: ; preds = %155
store i32 0, i32* %8
br label %165
165: ; preds = %179, %164
%166 = load i32*, i32** %6
%167 = call i32 @fgetc(i32* %166)
store i32 %167, i32* %7
%168 = load i32, i32* @EOF
%169 = icmp ne i32 %167, %168
br i1 %169, label %170, label %180
170: ; preds = %165
%171 = load i32, i32* %7
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %171)
%173 = load i32, i32* %8
%174 = add nsw i32 %173, 1
store i32 %174, i32* %8
%175 = load i32, i32* %11
%176 = icmp eq i32 %174, %175
br i1 %176, label %177, label %179
177: ; preds = %170
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %8
br label %179
179: ; preds = %177, %170
br label %165
180: ; preds = %165
store i32 0, i32* %15
br label %181
181: ; preds = %194, %180
%182 = load i32, i32* %15
%183 = load i32, i32* %13
%184 = icmp ult i32 %182, %183
br i1 %184, label %185, label %197
185: ; preds = %181
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 0)
%187 = load i32, i32* %8
%188 = add nsw i32 %187, 1
store i32 %188, i32* %8
%189 = load i32, i32* %11
%190 = icmp eq i32 %188, %189
br i1 %190, label %191, label %193
191: ; preds = %185
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %8
br label %193
193: ; preds = %191, %185
br label %194
194: ; preds = %193
%195 = load i32, i32* %15
%196 = add i32 %195, 1
store i32 %196, i32* %15
br label %181
197: ; preds = %181
store i32 0, i32* %3
br label %198
198: ; preds = %197, %107
%199 = load i32, i32* %3
ret i32 %199
}

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 output\0A\00"
@.str.3 = [12 x i8] c"\09per line.\0A\00"
@.str.4 = [53 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 = [54 x i8] c"\09used by some of the new OR1k bootloaders. Note that\0A\00"
@.str.7 = [57 x i8] c"\09padding zeroes will be appended so that the image size\0A\00"
@.str.8 = [23 x i8] c"\09is a multiple of 4.\0A\0A\00"
@.str.9 = [11 x i8] c"-size_word\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [41 x i8] c"bytes per line incorrect or missing: %s\0A\00"
@.str.12 = [31 x i8] c"failed to open input file: %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.13 = [34 x i8] c"Bad binary image. Size too small\0A\00"
@.str.14 = [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 %24
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 ([53 x i8], [53 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 ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = icmp eq i32 %0, 4
br i1 %25, label %26, label %31
26: ; preds = %24
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = tail call i64 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %28)
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %26, %24
%32 = phi i1 [ true, %24 ], [ %30, %26 ]
%33 = getelementptr inbounds i8*, i8** %1, i64 1
%34 = load i8*, i8** %33
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%36 = getelementptr inbounds i8*, i8** %1, i64 2
%37 = load i8*, i8** %36
%38 = tail call i32 @atoi(i8* %37)
%39 = icmp eq i32 %38, 0
%40 = icmp sgt i32 %38, 8
%41 = or i1 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %31
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0), i8* %37)
%45 = tail call i32 @exit(i32 1)
unreachable
46: ; preds = %31
%47 = icmp eq i32* %35, null
br i1 %47, label %48, label %53
48: ; preds = %46
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %33
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0), i8* %50)
%52 = tail call i32 @exit(i32 1)
unreachable
53: ; preds = %46
br i1 %32, label %98, label %54
54: ; preds = %53
%55 = load i32, i32* @SEEK_END
%56 = tail call i32 @fseek(i32* %35, i32 0, i32 %55)
%57 = tail call i32 @ftell(i32* %35)
%58 = load i32, i32* @SEEK_SET
%59 = tail call i32 @fseek(i32* %35, i32 0, i32 %58)
%60 = sub i32 0, %57
%61 = and i32 %60, 3
%62 = add i32 %61, %57
%63 = icmp ult i32 %62, 8
br i1 %63, label %95, label %64
64: ; preds = %54
%65 = lshr i32 %62, 24
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %65)
%67 = icmp eq i32 %38, 1
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = tail call i32 @putchar(i32 10)
br label %70
70: ; preds = %68, %64
%71 = phi i32 [ 1, %68 ], [ 2, %64 ]
%72 = lshr i32 %62, 16
%73 = and i32 %72, 255
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %73)
%75 = icmp eq i32 %71, %38
br i1 %75, label %76, label %78
76: ; preds = %70
%77 = tail call i32 @putchar(i32 10)
br label %78
78: ; preds = %76, %70
%79 = phi i32 [ 0, %76 ], [ %71, %70 ]
%80 = lshr i32 %62, 8
%81 = and i32 %80, 255
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %81)
%83 = add nuw nsw i32 %79, 1
%84 = icmp eq i32 %83, %38
br i1 %84, label %85, label %87
85: ; preds = %78
%86 = tail call i32 @putchar(i32 10)
br label %87
87: ; preds = %85, %78
%88 = phi i32 [ 0, %85 ], [ %83, %78 ]
%89 = and i32 %62, 255
%90 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %89)
%91 = add nuw nsw i32 %88, 1
%92 = icmp eq i32 %91, %38
br i1 %92, label %93, label %98
93: ; preds = %87
%94 = tail call i32 @putchar(i32 10)
br label %98
95: ; preds = %54
%96 = load i32, i32* @stderr
%97 = tail call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
br label %135
98: ; preds = %93, %87, %53
%99 = phi i32 [ 0, %53 ], [ %61, %87 ], [ %61, %93 ]
%100 = tail call i32 @fgetc(i32* %35)
%101 = tail call i32 @fgetc(i32* %35)
%102 = tail call i32 @fgetc(i32* %35)
%103 = tail call i32 @fgetc(i32* %35)
%104 = tail call i32 @fgetc(i32* %35)
%105 = load i32, i32* @EOF
%106 = icmp eq i32 %104, %105
br i1 %106, label %107, label %110
107: ; preds = %118, %98
%108 = phi i32 [ 0, %98 ], [ %119, %118 ]
%109 = icmp eq i32 %99, 0
br i1 %109, label %135, label %123
110: ; preds = %98, %118
%111 = phi i32 [ %120, %118 ], [ %104, %98 ]
%112 = phi i32 [ %119, %118 ], [ 0, %98 ]
%113 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %111)
%114 = add nsw i32 %112, 1
%115 = icmp eq i32 %114, %38
br i1 %115, label %116, label %118
116: ; preds = %110
%117 = tail call i32 @putchar(i32 10)
br label %118
118: ; preds = %116, %110
%119 = phi i32 [ 0, %116 ], [ %114, %110 ]
%120 = tail call i32 @fgetc(i32* %35)
%121 = load i32, i32* @EOF
%122 = icmp eq i32 %120, %121
br i1 %122, label %107, label %110
123: ; preds = %107, %131
%124 = phi i32 [ %133, %131 ], [ 0, %107 ]
%125 = phi i32 [ %132, %131 ], [ %108, %107 ]
%126 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 0)
%127 = add nsw i32 %125, 1
%128 = icmp eq i32 %127, %38
br i1 %128, label %129, label %131
129: ; preds = %123
%130 = tail call i32 @putchar(i32 10)
br label %131
131: ; preds = %123, %129
%132 = phi i32 [ 0, %129 ], [ %127, %123 ]
%133 = add nuw nsw i32 %124, 1
%134 = icmp eq i32 %133, %99
br i1 %134, label %135, label %123
135: ; preds = %131, %107, %95
%136 = phi i32 [ 1, %95 ], [ 0, %107 ], [ 0, %131 ]
ret i32 %136
}