#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strnident(int /*<<< orphan*/, char *);
int strtoul(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  FILE *fin;
  size_t filelen;
  int linelen;
  int arg;
  int alignment = 4;
  if (argc < 2) {
    fputs("bin2s - convert binary files to assembly language\n"
          "typical usage: bin2s foo.bin bar.bin baz.bin > foo.s\n",
          stderr);
    return 1;
  }
  for (arg = 1; arg < argc; arg++) {
    if (argv[arg][0] == '-') {
      switch (argv[arg][1]) {
      case 'a':
        alignment = (argc > arg) ? strtoul(argv[++arg], 0, 0) : 0;
        if (alignment == 0)
          alignment = 4;
        break;
      }
      continue;
    }
    fin = fopen(argv[arg], "rb");
    if (!fin) {
      fputs("bin2s: could not open ", stderr);
      perror(argv[arg]);
      return 1;
    }
    fseek(fin, 0, SEEK_END);
    filelen = ftell(fin);
    rewind(fin);
    if (filelen == 0) {
      fclose(fin);
      fprintf(stderr, "bin2s: warning: skipping empty file %s\n", argv[arg]);
      continue;
    }
    char *ptr = argv[arg];
    char chr;
    char *filename = NULL;
    while ((chr = *ptr)) {
      if (chr == '\\' || chr == '/') {
        filename = ptr;
      }
      ptr++;
    }
    if (NULL != filename) {
      filename++;
    } else {
      filename = argv[arg];
    }
    fprintf(stdout,
            "/* Generated by BIN2S - please don't edit directly */\n"
            "\t.section .rodata\n"
            "\t.balign %d\n"
            "\t.global ",
            alignment);
    strnident(stdout, filename);
    fputs("_size\n", stdout);
    strnident(stdout, filename);
    printf("_size: .int %lu\n\t.global ", (unsigned long)filelen);
    strnident(stdout, filename);
    fputs("\n", stdout);
    strnident(stdout, filename);
    fputs(":\n\t.byte ", stdout);
    linelen = 0;
    while (filelen > 0) {
      unsigned char c = fgetc(fin);
      printf("%3u", (unsigned int)c);
      filelen--;
      if (filelen) {
        if (++linelen >= 16) {
          linelen = 0;
          fputs("\n\t.byte ", stdout);
        } else {
          fputc(',', stdout);
        }
      }
    }
    fputs("\n\n\t.global ", stdout);
    strnident(stdout, filename);
    fputs("_end\n", stdout);
    strnident(stdout, filename);
    fputs("_end:\n\n", stdout);
    fclose(fin);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1218 <main+0x48>
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
lea    0xdf9(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15c5 <main+0x3f5>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12bb <main+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x1(%rax),%al
sub    $0x61,%al
jne    12b6 <main+0xe6>
jmp    125f <main+0x8f>
mov    -0x8(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    1290 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10f0 <strtoul@plt>
mov    %eax,-0x50(%rbp)
jmp    129a <main+0xca>
xor    %eax,%eax
mov    %eax,-0x50(%rbp)
jmp    129a <main+0xca>
mov    -0x50(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    12b1 <main+0xe1>
movl   $0x4,-0x2c(%rbp)
jmp    12b6 <main+0xe6>
jmp    15b7 <main+0x3e7>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd9a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1314 <main+0x144>
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
lea    0xd79(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
mov    -0x18(%rbp),%rdi
mov    0x2cc9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
cmpq   $0x0,-0x20(%rbp)
jne    137a <main+0x1aa>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd14(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x3e7>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x39(%rbp)
cmp    $0x0,%al
je     13d6 <main+0x206>
movsbl -0x39(%rbp),%eax
cmp    $0x5c,%eax
je     13bd <main+0x1ed>
movsbl -0x39(%rbp),%eax
cmp    $0x2f,%eax
jne    13c5 <main+0x1f5>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1392 <main+0x1c2>
xor    %eax,%eax
cmp    -0x48(%rbp),%rax
je     13f3 <main+0x223>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1403 <main+0x233>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1090 <strnident@plt>
mov    0x2b9a(%rip),%rax
mov    (%rax),%esi
lea    0xcc9(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1090 <strnident@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xcac(%rip),%rdi
call   1040 <printf@plt>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1090 <strnident@plt>
mov    0x2b4f(%rip),%rax
mov    (%rax),%esi
lea    0xcc5(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1090 <strnident@plt>
mov    0x2b28(%rip),%rax
mov    (%rax),%esi
lea    0xc78(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    154b <main+0x37b>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x49(%rbp)
movzbl -0x49(%rbp),%esi
lea    0xc54(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1546 <main+0x376>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x10,%eax
jl     152e <main+0x35e>
movl   $0x0,-0x24(%rbp)
mov    0x2ab5(%rip),%rax
mov    (%rax),%esi
lea    0xc06(%rip),%rdi
call   1060 <fputs@plt>
jmp    1541 <main+0x371>
mov    0x2a9b(%rip),%rax
mov    (%rax),%esi
mov    $0x2c,%edi
call   1080 <fputc@plt>
jmp    1546 <main+0x376>
jmp    14bd <main+0x2ed>
mov    0x2a7e(%rip),%rax
mov    (%rax),%esi
lea    0xbdc(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2a69(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1090 <strnident@plt>
mov    0x2a57(%rip),%rax
mov    (%rax),%esi
lea    0xbc1(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2a42(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
call   1090 <strnident@plt>
mov    0x2a30(%rip),%rax
mov    (%rax),%esi
lea    0xba0(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    121f <main+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jge    1202 <main+0x32>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe0d(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%eax
jmp    1474 <main+0x2a4>
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x1,%r12d
mov    0x2dbc(%rip),%r15
movl   $0x4,0xc(%rsp)
mov    %rsi,0x10(%rsp)
mov    %edi,0x8(%rsp)
jmp    1291 <main+0xc1>
nopw   0x0(%rax,%rax,1)
mov    (%r15),%esi
lea    0xefd(%rip),%rdi
call   1060 <fputs@plt>
mov    (%r15),%edi
mov    %r13,%rsi
call   1090 <strnident@plt>
mov    (%r15),%esi
lea    0xeef(%rip),%rdi
call   1060 <fputs@plt>
mov    (%r15),%edi
mov    %r13,%rsi
call   1090 <strnident@plt>
mov    (%r15),%esi
lea    0xedb(%rip),%rdi
call   1060 <fputs@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x10(%rsp),%r13
mov    0x8(%rsp),%ebp
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    1472 <main+0x2a2>
movslq %r12d,%rbx
mov    0x0(%r13,%rbx,8),%rdi
cmpb   $0x2d,(%rdi)
jne    12d0 <main+0x100>
cmpb   $0x61,0x1(%rdi)
jne    1284 <main+0xb4>
lea    0x1(%rbx),%r12d
mov    0x8(%r13,%rbx,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10f0 <strtoul@plt>
mov    %eax,%ecx
test   %eax,%eax
mov    $0x4,%eax
cmove  %eax,%ecx
mov    %ecx,0xc(%rsp)
jmp    1284 <main+0xb4>
nopl   0x0(%rax,%rax,1)
lea    0xd91(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1483 <main+0x2b3>
mov    %rax,%r14
mov    0x2cf9(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r14,%rdi
call   10b0 <ftell@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1050 <rewind@plt>
test   %rbp,%rbp
je     1449 <main+0x279>
mov    0x0(%r13,%rbx,8),%rax
mov    %rax,%rcx
xor    %edx,%edx
jmp    1337 <main+0x167>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rdx
add    $0x1,%rcx
movzbl (%rcx),%ebx
cmp    $0x2f,%bl
je     1330 <main+0x160>
cmp    $0x5c,%bl
je     1330 <main+0x160>
test   %bl,%bl
jne    1333 <main+0x163>
lea    0x1(%rdx),%r13
test   %rdx,%rdx
cmove  %rax,%r13
mov    (%r15),%edi
lea    0xd4d(%rip),%rsi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%r15),%edi
mov    %r13,%rsi
call   1090 <strnident@plt>
mov    (%r15),%esi
lea    0xd8b(%rip),%rdi
call   1060 <fputs@plt>
mov    (%r15),%edi
mov    %r13,%rsi
call   1090 <strnident@plt>
lea    0xd7b(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    (%r15),%edi
mov    %r13,%rsi
call   1090 <strnident@plt>
mov    (%r15),%esi
lea    0xd9f(%rip),%rdi
call   1060 <fputs@plt>
mov    (%r15),%edi
mov    %r13,%rsi
call   1090 <strnident@plt>
mov    (%r15),%esi
lea    0xd5f(%rip),%rdi
call   1060 <fputs@plt>
mov    %r14,%rdi
call   1070 <fgetc@plt>
movzbl %al,%esi
lea    0xd52(%rip),%rdi
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbp
je     1230 <main+0x60>
xor    %ebx,%ebx
jmp    1431 <main+0x261>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
mov    (%r15),%esi
mov    $0x2c,%edi
call   1080 <fputc@plt>
mov    %r14,%rdi
call   1070 <fgetc@plt>
movzbl %al,%esi
lea    0xd11(%rip),%rdi
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbp
je     1230 <main+0x60>
cmp    $0xf,%ebx
jl     1400 <main+0x230>
mov    (%r15),%esi
lea    0xcea(%rip),%rdi
call   1060 <fputs@plt>
xor    %ebx,%ebx
jmp    1410 <main+0x240>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2b80(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%rbx,8),%rdx
lea    0xc1c(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1280 <main+0xb0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b4e(%rip),%rax
mov    (%rax),%esi
lea    0xbd8(%rip),%rdi
call   1060 <fputs@plt>
mov    0x0(%r13,%rbx,8),%rdi
call   10e0 <perror@plt>
mov    $0x1,%eax
jmp    1474 <main+0x2a4>

LLVM IR (-O0):
@.str = [104 x i8] c"bin2s - convert binary files to assembly language\0Atypical usage: bin2s foo.bin bar.bin baz.bin > foo.s\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [23 x i8] c"bin2s: could not open \00"
@SEEK_END = global i32 0
@.str.3 = [40 x i8] c"bin2s: warning: skipping empty file %s\0A\00"
@stdout = global i32 0
@.str.4 = [94 x i8] c"/* Generated by BIN2S - please don't edit directly */\0A\09.section .rodata\0A\09.balign %d\0A\09.global \00"
@.str.5 = [7 x i8] c"_size\0A\00"
@.str.6 = [26 x i8] c"_size: .int %lu\0A\09.global \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [10 x i8] c":\0A\09.byte \00"
@.str.9 = [4 x i8] c"%3u\00"
@.str.10 = [9 x i8] c"\0A\09.byte \00"
@.str.11 = [12 x i8] c"\0A\0A\09.global \00"
@.str.12 = [6 x i8] c"_end\0A\00"
@.str.13 = [8 x i8] c"_end:\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i8*
%14 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 4, i32* %10
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str, i64 0, i64 0), i32 %18)
store i32 1, i32* %3
br label %206
20: ; preds = %2
store i32 1, i32* %9
br label %21
21: ; preds = %202, %20
%22 = load i32, i32* %9
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %205
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 45
br i1 %34, label %35, label %64
35: ; preds = %25
%36 = load i8**, i8*** %5
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
switch i32 %43, label %63 [
i32 97, label %44
]
44: ; preds = %35
%45 = load i32, i32* %4
%46 = load i32, i32* %9
%47 = icmp sgt i32 %45, %46
br i1 %47, label %48, label %56
48: ; preds = %44
%49 = load i8**, i8*** %5
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %49, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @strtoul(i8* %54, i32 0, i32 0)
br label %57
56: ; preds = %44
br label %57
57: ; preds = %56, %48
%58 = phi i32 [ %55, %48 ], [ 0, %56 ]
store i32 %58, i32* %10
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %57
store i32 4, i32* %10
br label %62
62: ; preds = %61, %57
br label %63
63: ; preds = %35, %62
br label %202
64: ; preds = %25
%65 = load i8**, i8*** %5
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %70, i32** %6
%71 = load i32*, i32** %6
%72 = icmp ne i32* %71, null
br i1 %72, label %82, label %73
73: ; preds = %64
%74 = load i32, i32* @stderr
%75 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %74)
%76 = load i8**, i8*** %5
%77 = load i32, i32* %9
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8*, i8** %76, i64 %78
%80 = load i8*, i8** %79
%81 = call i32 @perror(i8* %80)
store i32 1, i32* %3
br label %206
82: ; preds = %64
%83 = load i32*, i32** %6
%84 = load i32, i32* @SEEK_END
%85 = call i32 @fseek(i32* %83, i32 0, i32 %84)
%86 = load i32*, i32** %6
%87 = call i64 @ftell(i32* %86)
store i64 %87, i64* %7
%88 = load i32*, i32** %6
%89 = call i32 @rewind(i32* %88)
%90 = load i64, i64* %7
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %102
92: ; preds = %82
%93 = load i32*, i32** %6
%94 = call i32 @fclose(i32* %93)
%95 = load i32, i32* @stderr
%96 = load i8**, i8*** %5
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8*, i8** %96, i64 %98
%100 = load i8*, i8** %99
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %100)
br label %202
102: ; preds = %82
%103 = load i8**, i8*** %5
%104 = load i32, i32* %9
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %103, i64 %105
%107 = load i8*, i8** %106
store i8* %107, i8** %11
store i8* null, i8** %13
br label %108
108: ; preds = %122, %102
%109 = load i8*, i8** %11
%110 = load i8, i8* %109
store i8 %110, i8* %12
%111 = icmp ne i8 %110, 0
br i1 %111, label %112, label %125
112: ; preds = %108
%113 = load i8, i8* %12
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 92
br i1 %115, label %120, label %116
116: ; preds = %112
%117 = load i8, i8* %12
%118 = sext i8 %117 to i32
%119 = icmp eq i32 %118, 47
br i1 %119, label %120, label %122
120: ; preds = %116, %112
%121 = load i8*, i8** %11
store i8* %121, i8** %13
br label %122
122: ; preds = %120, %116
%123 = load i8*, i8** %11
%124 = getelementptr inbounds i8, i8* %123, i32 1
store i8* %124, i8** %11
br label %108
125: ; preds = %108
%126 = load i8*, i8** %13
%127 = icmp ne i8* null, %126
br i1 %127, label %128, label %131
128: ; preds = %125
%129 = load i8*, i8** %13
%130 = getelementptr inbounds i8, i8* %129, i32 1
store i8* %130, i8** %13
br label %137
131: ; preds = %125
%132 = load i8**, i8*** %5
%133 = load i32, i32* %9
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8*, i8** %132, i64 %134
%136 = load i8*, i8** %135
store i8* %136, i8** %13
br label %137
137: ; preds = %131, %128
%138 = load i32, i32* @stdout
%139 = load i32, i32* %10
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0), i32 %139)
%141 = load i32, i32* @stdout
%142 = load i8*, i8** %13
%143 = call i32 @strnident(i32 %141, i8* %142)
%144 = load i32, i32* @stdout
%145 = call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %144)
%146 = load i32, i32* @stdout
%147 = load i8*, i8** %13
%148 = call i32 @strnident(i32 %146, i8* %147)
%149 = load i64, i64* %7
%150 = trunc i64 %149 to i32
%151 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %150)
%152 = load i32, i32* @stdout
%153 = load i8*, i8** %13
%154 = call i32 @strnident(i32 %152, i8* %153)
%155 = load i32, i32* @stdout
%156 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %155)
%157 = load i32, i32* @stdout
%158 = load i8*, i8** %13
%159 = call i32 @strnident(i32 %157, i8* %158)
%160 = load i32, i32* @stdout
%161 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %160)
store i32 0, i32* %8
br label %162
162: ; preds = %186, %137
%163 = load i64, i64* %7
%164 = icmp ugt i64 %163, 0
br i1 %164, label %165, label %187
165: ; preds = %162
%166 = load i32*, i32** %6
%167 = call zeroext i8 @fgetc(i32* %166)
store i8 %167, i8* %14
%168 = load i8, i8* %14
%169 = zext i8 %168 to i32
%170 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %169)
%171 = load i64, i64* %7
%172 = add i64 %171, -1
store i64 %172, i64* %7
%173 = load i64, i64* %7
%174 = icmp ne i64 %173, 0
br i1 %174, label %175, label %186
175: ; preds = %165
%176 = load i32, i32* %8
%177 = add nsw i32 %176, 1
store i32 %177, i32* %8
%178 = icmp sge i32 %177, 16
br i1 %178, label %179, label %182
179: ; preds = %175
store i32 0, i32* %8
%180 = load i32, i32* @stdout
%181 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %180)
br label %185
182: ; preds = %175
%183 = load i32, i32* @stdout
%184 = call i32 @fputc(i8 signext 44, i32 %183)
br label %185
185: ; preds = %182, %179
br label %186
186: ; preds = %185, %165
br label %162
187: ; preds = %162
%188 = load i32, i32* @stdout
%189 = call i32 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %188)
%190 = load i32, i32* @stdout
%191 = load i8*, i8** %13
%192 = call i32 @strnident(i32 %190, i8* %191)
%193 = load i32, i32* @stdout
%194 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %193)
%195 = load i32, i32* @stdout
%196 = load i8*, i8** %13
%197 = call i32 @strnident(i32 %195, i8* %196)
%198 = load i32, i32* @stdout
%199 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 %198)
%200 = load i32*, i32** %6
%201 = call i32 @fclose(i32* %200)
br label %202
202: ; preds = %187, %92, %63
%203 = load i32, i32* %9
%204 = add nsw i32 %203, 1
store i32 %204, i32* %9
br label %21
205: ; preds = %21
store i32 0, i32* %3
br label %206
206: ; preds = %205, %73, %17
%207 = load i32, i32* %3
ret i32 %207
}

LLVM IR (-O2):
@.str = [104 x i8] c"bin2s - convert binary files to assembly language\0Atypical usage: bin2s foo.bin bar.bin baz.bin > foo.s\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [23 x i8] c"bin2s: could not open \00"
@SEEK_END = global i32 0
@.str.3 = [40 x i8] c"bin2s: warning: skipping empty file %s\0A\00"
@stdout = global i32 0
@.str.4 = [94 x i8] c"/* Generated by BIN2S - please don't edit directly */\0A\09.section .rodata\0A\09.balign %d\0A\09.global \00"
@.str.5 = [7 x i8] c"_size\0A\00"
@.str.6 = [26 x i8] c"_size: .int %lu\0A\09.global \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [10 x i8] c":\0A\09.byte \00"
@.str.9 = [4 x i8] c"%3u\00"
@.str.10 = [9 x i8] c"\0A\09.byte \00"
@.str.11 = [12 x i8] c"\0A\0A\09.global \00"
@.str.12 = [6 x i8] c"_end\0A\00"
@.str.13 = [8 x i8] c"_end:\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %118
7: ; preds = %2, %113
%8 = phi i32 [ %115, %113 ], [ 4, %2 ]
%9 = phi i32 [ %116, %113 ], [ 1, %2 ]
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 45
br i1 %14, label %15, label %27
15: ; preds = %7
%16 = getelementptr inbounds i8, i8* %12, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 97
br i1 %18, label %19, label %113
19: ; preds = %15
%20 = add nsw i32 %9, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i32 @strtoul(i8* %23, i32 0, i32 0)
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 4, i32 %24
br label %113
27: ; preds = %7
%28 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = tail call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i8*, i8** %11
%34 = tail call i32 @perror(i8* %33)
br label %118
35: ; preds = %27
%36 = load i32, i32* @SEEK_END
%37 = tail call i32 @fseek(i32* %28, i32 0, i32 %36)
%38 = tail call i64 @ftell(i32* %28)
%39 = tail call i32 @rewind(i32* %28)
%40 = icmp eq i64 %38, 0
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = tail call i32 @fclose(i32* %28)
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %11
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %44)
br label %113
46: ; preds = %35
%47 = load i8*, i8** %11
br label %48
48: ; preds = %53, %46
%49 = phi i8* [ %47, %46 ], [ %55, %53 ]
%50 = phi i8* [ null, %46 ], [ %54, %53 ]
%51 = load i8, i8* %49
switch i8 %51, label %53 [
i8 0, label %56
i8 92, label %52
i8 47, label %52
]
52: ; preds = %48, %48
br label %53
53: ; preds = %48, %52
%54 = phi i8* [ %49, %52 ], [ %50, %48 ]
%55 = getelementptr inbounds i8, i8* %49, i64 1
br label %48
56: ; preds = %48
%57 = icmp eq i8* %50, null
%58 = getelementptr inbounds i8, i8* %50, i64 1
%59 = select i1 %57, i8* %47, i8* %58
%60 = load i32, i32* @stdout
%61 = tail call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0), i32 %8)
%62 = load i32, i32* @stdout
%63 = tail call i32 @strnident(i32 %62, i8* %59)
%64 = load i32, i32* @stdout
%65 = tail call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %64)
%66 = load i32, i32* @stdout
%67 = tail call i32 @strnident(i32 %66, i8* %59)
%68 = trunc i64 %38 to i32
%69 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %68)
%70 = load i32, i32* @stdout
%71 = tail call i32 @strnident(i32 %70, i8* %59)
%72 = load i32, i32* @stdout
%73 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %72)
%74 = load i32, i32* @stdout
%75 = tail call i32 @strnident(i32 %74, i8* %59)
%76 = load i32, i32* @stdout
%77 = tail call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %76)
%78 = tail call zeroext i8 @fgetc(i32* %28)
%79 = zext i8 %78 to i32
%80 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %79)
%81 = add i64 %38, -1
%82 = icmp eq i64 %81, 0
br i1 %82, label %101, label %83
83: ; preds = %56, %94
%84 = phi i64 [ %99, %94 ], [ %81, %56 ]
%85 = phi i32 [ %95, %94 ], [ 0, %56 ]
%86 = icmp sgt i32 %85, 14
br i1 %86, label %87, label %90
87: ; preds = %83
%88 = load i32, i32* @stdout
%89 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %88)
br label %94
90: ; preds = %83
%91 = add nsw i32 %85, 1
%92 = load i32, i32* @stdout
%93 = tail call i32 @fputc(i8 signext 44, i32 %92)
br label %94
94: ; preds = %87, %90
%95 = phi i32 [ 0, %87 ], [ %91, %90 ]
%96 = tail call zeroext i8 @fgetc(i32* %28)
%97 = zext i8 %96 to i32
%98 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %97)
%99 = add i64 %84, -1
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %83
101: ; preds = %94, %56
%102 = load i32, i32* @stdout
%103 = tail call i32 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %102)
%104 = load i32, i32* @stdout
%105 = tail call i32 @strnident(i32 %104, i8* %59)
%106 = load i32, i32* @stdout
%107 = tail call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %106)
%108 = load i32, i32* @stdout
%109 = tail call i32 @strnident(i32 %108, i8* %59)
%110 = load i32, i32* @stdout
%111 = tail call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 %110)
%112 = tail call i32 @fclose(i32* %28)
br label %113
113: ; preds = %19, %15, %101, %41
%114 = phi i32 [ %20, %19 ], [ %9, %15 ], [ %9, %41 ], [ %9, %101 ]
%115 = phi i32 [ %26, %19 ], [ %8, %15 ], [ %8, %41 ], [ %8, %101 ]
%116 = add nsw i32 %114, 1
%117 = icmp slt i32 %116, %0
br i1 %117, label %7, label %118
118: ; preds = %113, %30, %4
%119 = phi i32 [ 1, %4 ], [ 1, %30 ], [ 0, %113 ]
ret i32 %119
}