#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *stderr;
int main(int argc, char *argv[]) {
  const char *srcfile, *dstfile, *varname, *type;
  FILE *src, *dst;
  unsigned char *buffer;
  int bytes, offs;
  int terminate = 1;
  if (argc < 4) {
    fprintf(stderr,
            "Usage:\n"
            "  laytostr <source.lay> <output.h> <varname> [<type>]\n"
            "\n"
            "The default <type> is char, with an assumed NULL terminator\n");
    return 0;
  }
  srcfile = argv[1];
  dstfile = argv[2];
  varname = argv[3];
  type = (argc >= 5) ? argv[4] : "char";
  if (argc >= 5)
    terminate = 0;
  src = fopen(srcfile, "rb");
  if (src == NULL) {
    fprintf(stderr, "Unable to open source file '%s'\n", srcfile);
    return 1;
  }
  fseek(src, 0, SEEK_END);
  bytes = ftell(src);
  fseek(src, 0, SEEK_SET);
  buffer = (unsigned char *)malloc(bytes + 1);
  if (buffer == NULL) {
    fclose(src);
    fprintf(stderr, "Out of memory allocating %d byte buffer\n", bytes);
    return 1;
  }
  fread(buffer, 1, bytes, src);
  buffer[bytes] = 0;
  fclose(src);
  dst = fopen(dstfile, "w");
  if (dst == NULL) {
    free(buffer);
    fprintf(stderr, "Unable to open output file '%s'\n", dstfile);
    return 1;
  }
  fprintf(dst, "extern const %s %s[];\n", type, varname);
  fprintf(dst, "const %s %s[] =\n{\n\t", type, varname);
  for (offs = 0; offs < bytes + terminate; offs++) {
    fprintf(dst, "0x%02x%s", buffer[offs],
            (offs != bytes + terminate - 1) ? "," : "");
    if (offs % 16 == 15)
      fprintf(dst, "\n\t");
  }
  fprintf(dst, "\n};\n");
  free(buffer);
  fclose(dst);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x54(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11cb <main+0x4b>
mov    0x2e2a(%rip),%rax
mov    (%rax),%rdi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1464 <main+0x2e4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     120a <main+0x8a>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    121a <main+0x9a>
lea    0xe6a(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    121a <main+0x9a>
mov    -0x60(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     1233 <main+0xb3>
movl   $0x0,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    127a <main+0xfa>
mov    0x2d7f(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1464 <main+0x2e4>
mov    -0x38(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2d2b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x4c(%rbp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12f8 <main+0x178>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%rdi
mov    -0x4c(%rbp),%edx
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1464 <main+0x2e4>
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1372 <main+0x1f2>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd70(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1464 <main+0x2e4>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd6b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x4c(%rbp),%ecx
add    -0x54(%rbp),%ecx
cmp    %ecx,%eax
jge    1439 <main+0x2b9>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
movslq -0x50(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0x50(%rbp),%esi
mov    -0x4c(%rbp),%r8d
add    -0x54(%rbp),%r8d
sub    $0x1,%r8d
lea    0xd36(%rip),%rcx
lea    0xd39(%rip),%rax
cmp    %r8d,%esi
cmovne %rax,%rcx
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x50(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    1426 <main+0x2a6>
mov    -0x40(%rbp),%rdi
lea    0xcf9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    142b <main+0x2ab>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    13ad <main+0x22d>
mov    -0x40(%rbp),%rdi
lea    0xce2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%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    $0x3,%edi
jg     11c8 <main+0x38>
mov    0x2e2e(%rip),%rax
mov    (%rax),%rcx
lea    0xe4c(%rip),%rdi
mov    $0x7a,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
jmp    139f <main+0x20f>
mov    0x8(%rsi),%r13
cmp    $0x4,%edi
jne    11da <main+0x4a>
lea    0xea3(%rip),%r15
jmp    11de <main+0x4e>
mov    0x20(%rsi),%r15
mov    0x10(%rsi),%r14
mov    0x18(%rsi),%rbx
xor    %r12d,%r12d
cmp    $0x4,%edi
sete   0x7(%rsp)
lea    0xe88(%rip),%rsi
mov    %r13,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1354 <main+0x1c4>
mov    %rax,%rbp
mov    %rbx,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    0x2dcb(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1070 <ftell@plt>
mov    %eax,%r13d
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0x1(%r13),%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     13b2 <main+0x222>
mov    %rax,%r15
mov    $0x1,%ebx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
movslq %r13d,%rax
movb   $0x0,(%r15,%rax,1)
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xe42(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     13dc <main+0x24c>
mov    %rax,%rbp
mov    0x7(%rsp),%al
mov    %al,%r12b
lea    0xe43(%rip),%rsi
mov    %rbp,%rdi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdx
mov    0x8(%rsp),%r14
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe39(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    %r12d,%r13d
test   %r13d,%r13d
jle    1376 <main+0x1e6>
lea    -0x1(%r13),%r12d
mov    %r13d,%r13d
lea    0xe23(%rip),%rbx
xor    %r14d,%r14d
jmp    1309 <main+0x179>
nopl   (%rax)
add    $0x1,%r14
cmp    %r14,%r13
je     1376 <main+0x1e6>
movzbl (%r15,%r14,1),%edx
cmp    %r14,%r12
lea    0xe0c(%rip),%rcx
lea    0xdfb(%rip),%rax
cmove  %rax,%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14d,%eax
not    %eax
test   $0xf,%al
jne    1300 <main+0x170>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xdce(%rip),%rdi
mov    %rbp,%rcx
call   10b0 <fwrite@plt>
jmp    1300 <main+0x170>
mov    0x2c7d(%rip),%rax
mov    (%rax),%rdi
lea    0xd1e(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
jmp    13a1 <main+0x211>
lea    0xda9(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   10b0 <fwrite@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    0x2c17(%rip),%rax
mov    (%rax),%rdi
lea    0xcd9(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
jmp    13a1 <main+0x211>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2bed(%rip),%rax
mov    (%rax),%rdi
lea    0xcda(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    13a1 <main+0x211>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [123 x i8] c"Usage:\0A laytostr <source.lay> <output.h> <varname> [<type>]\0A\0AThe default <type> is char, with an assumed NULL terminator\0A\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [33 x i8] c"Unable to open source file '%s'\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [41 x i8] c"Out of memory allocating %d byte buffer\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [33 x i8] c"Unable to open output file '%s'\0A\00"
@.str.7 = [23 x i8] c"extern const %s %s[];\0A\00"
@.str.8 = [20 x i8] c"const %s %s[] =\0A{\0A\09\00"
@.str.9 = [9 x i8] c"0x%02x%s\00"
@.str.10 = [2 x i8] c",\00"
@.str.11 = [1 x i8] zeroinitializer
@.str.12 = [3 x i8] c"\0A\09\00"
@.str.13 = [5 x i8] c"\0A};\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%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 1, i32* %15
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32*, i32** @stderr
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %143
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
store i8* %30, i8** %8
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 5
br i1 %32, label %33, label %37
33: ; preds = %21
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
br label %38
37: ; preds = %21
br label %38
38: ; preds = %37, %33
%39 = phi i8* [ %36, %33 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %37 ]
store i8* %39, i8** %9
%40 = load i32, i32* %4
%41 = icmp sge i32 %40, 5
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 0, i32* %15
br label %43
43: ; preds = %42, %38
%44 = load i8*, i8** %6
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %45, i32** %10
%46 = load i32*, i32** %10
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load i32*, i32** @stderr
%50 = load i8*, i8** %6
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %50)
store i32 1, i32* %3
br label %143
52: ; preds = %43
%53 = load i32*, i32** %10
%54 = load i32, i32* @SEEK_END
%55 = call i32 @fseek(i32* %53, i32 0, i32 %54)
%56 = load i32*, i32** %10
%57 = call i32 @ftell(i32* %56)
store i32 %57, i32* %13
%58 = load i32*, i32** %10
%59 = load i32, i32* @SEEK_SET
%60 = call i32 @fseek(i32* %58, i32 0, i32 %59)
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 1
%63 = call i64 @malloc(i32 %62)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %12
%65 = load i8*, i8** %12
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %73
67: ; preds = %52
%68 = load i32*, i32** %10
%69 = call i32 @fclose(i32* %68)
%70 = load i32*, i32** @stderr
%71 = load i32, i32* %13
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %71)
store i32 1, i32* %3
br label %143
73: ; preds = %52
%74 = load i8*, i8** %12
%75 = load i32, i32* %13
%76 = load i32*, i32** %10
%77 = call i32 @fread(i8* %74, i32 1, i32 %75, i32* %76)
%78 = load i8*, i8** %12
%79 = load i32, i32* %13
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
store i8 0, i8* %81
%82 = load i32*, i32** %10
%83 = call i32 @fclose(i32* %82)
%84 = load i8*, i8** %7
%85 = call i32* @fopen(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %85, i32** %11
%86 = load i32*, i32** %11
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %94
88: ; preds = %73
%89 = load i8*, i8** %12
%90 = call i32 @free(i8* %89)
%91 = load i32*, i32** @stderr
%92 = load i8*, i8** %7
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %92)
store i32 1, i32* %3
br label %143
94: ; preds = %73
%95 = load i32*, i32** %11
%96 = load i8*, i8** %9
%97 = load i8*, i8** %8
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %95, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %96, i8* %97)
%99 = load i32*, i32** %11
%100 = load i8*, i8** %9
%101 = load i8*, i8** %8
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %100, i8* %101)
store i32 0, i32* %14
br label %103
103: ; preds = %133, %94
%104 = load i32, i32* %14
%105 = load i32, i32* %13
%106 = load i32, i32* %15
%107 = add nsw i32 %105, %106
%108 = icmp slt i32 %104, %107
br i1 %108, label %109, label %136
109: ; preds = %103
%110 = load i32*, i32** %11
%111 = load i8*, i8** %12
%112 = load i32, i32* %14
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %111, i64 %113
%115 = load i8, i8* %114
%116 = zext i8 %115 to i32
%117 = load i32, i32* %14
%118 = load i32, i32* %13
%119 = load i32, i32* %15
%120 = add nsw i32 %118, %119
%121 = sub nsw i32 %120, 1
%122 = icmp ne i32 %117, %121
%123 = zext i1 %122 to i64
%124 = select i1 %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.11, i64 0, i64 0)
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %110, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %116, i8* %124)
%126 = load i32, i32* %14
%127 = srem i32 %126, 16
%128 = icmp eq i32 %127, 15
br i1 %128, label %129, label %132
129: ; preds = %109
%130 = load i32*, i32** %11
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %132
132: ; preds = %129, %109
br label %133
133: ; preds = %132
%134 = load i32, i32* %14
%135 = add nsw i32 %134, 1
store i32 %135, i32* %14
br label %103
136: ; preds = %103
%137 = load i32*, i32** %11
%138 = call i32 (i32*, i8*, ...) @fprintf(i32* %137, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%139 = load i8*, i8** %12
%140 = call i32 @free(i8* %139)
%141 = load i32*, i32** %11
%142 = call i32 @fclose(i32* %141)
store i32 0, i32* %3
br label %143
143: ; preds = %136, %88, %67, %48, %18
%144 = load i32, i32* %3
ret i32 %144
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [123 x i8] c"Usage:\0A laytostr <source.lay> <output.h> <varname> [<type>]\0A\0AThe default <type> is char, with an assumed NULL terminator\0A\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [33 x i8] c"Unable to open source file '%s'\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [41 x i8] c"Out of memory allocating %d byte buffer\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [33 x i8] c"Unable to open output file '%s'\0A\00"
@.str.7 = [23 x i8] c"extern const %s %s[];\0A\00"
@.str.8 = [20 x i8] c"const %s %s[] =\0A{\0A\09\00"
@.str.9 = [9 x i8] c"0x%02x%s\00"
@.str.10 = [2 x i8] c",\00"
@.str.11 = [1 x i8] zeroinitializer
@.str.12 = [3 x i8] c"\0A\09\00"
@.str.13 = [5 x i8] c"\0A};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32*, i32** @stderr
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str, i64 0, i64 0), i64 122, i64 1, i32* %5)
br label %79
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = icmp eq i32 %0, 4
br i1 %14, label %18, label %15
15: ; preds = %7
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
br label %18
18: ; preds = %7, %15
%19 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %7 ]
%20 = zext i1 %14 to i32
%21 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32*, i32** @stderr
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %79
26: ; preds = %18
%27 = load i32, i32* @SEEK_END
%28 = tail call i32 @fseek(i32* %21, i32 0, i32 %27)
%29 = tail call i32 @ftell(i32* %21)
%30 = load i32, i32* @SEEK_SET
%31 = tail call i32 @fseek(i32* %21, i32 0, i32 %30)
%32 = add nsw i32 %29, 1
%33 = tail call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i8*
%35 = icmp eq i64 %33, 0
br i1 %35, label %36, label %40
36: ; preds = %26
%37 = tail call i32 @fclose(i32* %21)
%38 = load i32*, i32** @stderr
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %79
40: ; preds = %26
%41 = tail call i32 @fread(i8* %34, i32 1, i32 %29, i32* %21)
%42 = sext i32 %29 to i64
%43 = getelementptr inbounds i8, i8* %34, i64 %42
store i8 0, i8* %43
%44 = tail call i32 @fclose(i32* %21)
%45 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = tail call i32 @free(i8* %34)
%49 = load i32*, i32** @stderr
%50 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %11)
br label %79
51: ; preds = %40
%52 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %19, i8* %13)
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %19, i8* %13)
%54 = add i32 %29, %20
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %75
56: ; preds = %51
%57 = add nsw i32 %54, -1
%58 = zext i32 %57 to i64
%59 = zext i32 %54 to i64
br label %60
60: ; preds = %56, %72
%61 = phi i64 [ 0, %56 ], [ %73, %72 ]
%62 = getelementptr inbounds i8, i8* %34, i64 %61
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = icmp eq i64 %61, %58
%66 = select i1 %65, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0)
%67 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %64, i8* %66)
%68 = and i64 %61, 15
%69 = icmp eq i64 %68, 15
br i1 %69, label %70, label %72
70: ; preds = %60
%71 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i64 2, i64 1, i32* %45)
br label %72
72: ; preds = %60, %70
%73 = add nuw nsw i64 %61, 1
%74 = icmp eq i64 %73, %59
br i1 %74, label %75, label %60
75: ; preds = %72, %51
%76 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i64 4, i64 1, i32* %45)
%77 = tail call i32 @free(i8* %34)
%78 = tail call i32 @fclose(i32* %45)
br label %79
79: ; preds = %75, %47, %36, %23, %4
%80 = phi i32 [ 0, %4 ], [ 1, %23 ], [ 1, %36 ], [ 1, %47 ], [ 0, %75 ]
ret i32 %80
}