#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int /*<<< orphan*/ write_file_content_list(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ write_file_length_list(int /*<<< orphan*/ *, int *, int);
int /*<<< orphan*/ write_file_name_list(int /*<<< orphan*/ *, char const **,
                                        int);
int /*<<< orphan*/ write_header(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_main(int /*<<< orphan*/ *, int);
int main(int argc, const char **argv) {
  int i;
  int lineret;
  int number_of_files;
  size_t j;
  size_t read_bytes;
  unsigned char buffer[2048];
  int *filelength;
  FILE *f, *out;
  if (argc < 2) {
    usage();
    return 0;
  }
  number_of_files = argc - 1;
  if (!(out = fopen("out.c", "w"))) {
    fprintf(stderr, "unable to open output file %s for writing\n", "out.c");
    return 1;
  }
  if (!(filelength = malloc(argc * sizeof(int)))) {
    perror("malloc");
    return 3;
  }
  for (i = 1; i < argc; i++) {
    filelength[i] = 0;
  }
  write_header(out);
  for (i = 1; i < argc; ++i) {
    if (!(f = fopen(argv[i], "rb"))) {
      fprintf(stderr, "unable to open input file %s for reading\n", argv[i]);
      fclose(out);
      free(filelength);
      return 2;
    }
    fprintf(out, "\nconst unsigned char f%d[] = {\n    ", i);
    lineret = 0;
    while ((read_bytes = fread(buffer, 1, 2048, f))) {
      filelength[i] += read_bytes;
      for (j = 0; j < read_bytes; ++j) {
        fprintf(out, "0x%.2x,", buffer[j]);
        if (++lineret == 12) {
          fprintf(out, "\n    ");
          lineret = 0;
        } else {
          fprintf(out, " ");
        }
      }
    }
    fprintf(out, "};\n\n");
    fclose(f);
  }
  write_file_content_list(out, argc - 1);
  write_file_length_list(out, filelength, argc - 1);
  write_file_name_list(out, argv + 1, argc - 1);
  write_main(out, argc - 1);
  fclose(out);
  free(filelength);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1206 <main+0x36>
mov    $0x0,%al
call   10a0 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    14fb <main+0x32b>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xdea(%rip),%rdi
lea    0xde9(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x848(%rbp)
cmp    $0x0,%rax
jne    125e <main+0x8e>
mov    0x2da6(%rip),%rax
movslq (%rax),%rdi
lea    0xdc4(%rip),%rsi
lea    0xdb5(%rip),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14fb <main+0x32b>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x838(%rbp)
cmp    $0x0,%rax
jne    1296 <main+0xc6>
lea    0xdae(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x3,-0x4(%rbp)
jmp    14fb <main+0x32b>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c9 <main+0xf9>
mov    -0x838(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    129d <main+0xcd>
mov    -0x848(%rbp),%rdi
call   10f0 <write_header@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1485 <main+0x2b5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd3f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x840(%rbp)
cmp    $0x0,%rax
jne    1359 <main+0x189>
mov    0x2cc8(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd0f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x848(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x838(%rbp),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
jmp    14fb <main+0x32b>
mov    -0x848(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xcfd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
lea    -0x830(%rbp),%rdi
mov    -0x840(%rbp),%rcx
mov    $0x1,%esi
mov    $0x800,%edx
call   1040 <fread@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1456 <main+0x286>
mov    -0x30(%rbp),%rsi
mov    -0x838(%rbp),%rax
movslq -0x14(%rbp),%rcx
movslq (%rax,%rcx,4),%rdx
add    %rsi,%rdx
mov    %edx,(%rax,%rcx,4)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1451 <main+0x281>
mov    -0x848(%rbp),%rdi
mov    -0x28(%rbp),%rax
movzbl -0x830(%rbp,%rax,1),%edx
ff
lea    0xc9f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0xc,%eax
jne    1426 <main+0x256>
mov    -0x848(%rbp),%rdi
lea    0xc72(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
jmp    143b <main+0x26b>
mov    -0x848(%rbp),%rdi
lea    0xc55(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1440 <main+0x270>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    13c4 <main+0x1f4>
jmp    1378 <main+0x1a8>
mov    -0x848(%rbp),%rdi
lea    0xc2f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x840(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12dc <main+0x10c>
mov    -0x848(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1050 <write_file_content_list@plt>
mov    -0x848(%rbp),%rdi
mov    -0x838(%rbp),%rsi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1080 <write_file_length_list@plt>
mov    -0x848(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   10e0 <write_file_name_list@plt>
mov    -0x848(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   10b0 <write_main@plt>
mov    -0x848(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x838(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x848,%rsp
cmp    $0x1,%edi
jg     1224 <main+0x24>
xor    %ebx,%ebx
xor    %eax,%eax
call   10c0 <usage@plt>
jmp    14a2 <main+0x2a2>
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xdd0(%rip),%rdi
lea    0xdcf(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     13fd <main+0x1fd>
mov    %rax,%rbx
lea    0x0(,%rbp,4),%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     14b6 <main+0x2b6>
mov    %rax,%r13
mov    %rax,%rdi
add    $0x4,%rdi
lea    -0x1(%rbp),%eax
mov    %rax,0x18(%rsp)
lea    0x0(,%rax,4),%rdx
xor    %esi,%esi
call   1070 <memset@plt>
mov    %rbx,%rdi
call   1120 <write_header@plt>
mov    %ebp,%eax
mov    %rax,0x20(%rsp)
mov    $0x1,%r12d
lea    0xdf1(%rip),%rbp
lea    0xde4(%rip),%r15
mov    %r13,0x30(%rsp)
mov    %r14,0x28(%rsp)
jmp    12ec <main+0xec>
nopl   (%rax)
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xdd2(%rip),%rdi
mov    %rbx,%rcx
call   1110 <fwrite@plt>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%r12
add    $0x1,%r12
cmp    0x20(%rsp),%r12
mov    0x28(%rsp),%r14
je     1459 <main+0x259>
mov    (%r14,%r12,8),%rdi
lea    0xd43(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1423 <main+0x223>
mov    %rax,%rcx
mov    %rbx,%rdi
lea    0xd55(%rip),%rsi
mov    %r12,0x8(%rsp)
mov    %r12d,%edx
xor    %eax,%eax
mov    %rcx,%r14
call   1090 <fprintf@plt>
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    %r14,0x10(%rsp)
mov    %r14,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     12b0 <main+0xb0>
mov    %rax,%r14
mov    0x8(%rsp),%rax
mov    0x0(%r13,%rax,4),%ecx
xor    %r12d,%r12d
jmp    138f <main+0x18f>
nopl   0x0(%rax,%rax,1)
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    0x10(%rsp),%rcx
call   1040 <fread@plt>
mov    %rax,%r14
test   %rax,%rax
mov    0x30(%rsp),%r13
mov    0x38(%rsp),%rcx
je     12b0 <main+0xb0>
add    %r14d,%ecx
mov    0x8(%rsp),%rax
mov    %rcx,0x38(%rsp)
mov    %ecx,0x0(%r13,%rax,4)
xor    %r13d,%r13d
jmp    13c6 <main+0x1c6>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
add    $0x1,%r13
cmp    %r13,%r14
je     1360 <main+0x160>
movzbl 0x40(%rsp,%r13,1),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
add    $0x1,%r12d
cmp    $0xc,%r12d
jne    13b0 <main+0x1b0>
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1110 <fwrite@plt>
xor    %r12d,%r12d
jmp    13bd <main+0x1bd>
mov    0x2bdc(%rip),%rax
movslq (%rax),%rdi
lea    0xbfa(%rip),%rsi
lea    0xbeb(%rip),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebx
jmp    14a2 <main+0x2a2>
mov    %r12d,%eax
mov    0x2bb3(%rip),%rcx
movslq (%rcx),%rdi
mov    (%r14,%rax,8),%rdx
lea    0xc02(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0x2,%ebx
jmp    14a2 <main+0x2a2>
mov    %rbx,%rdi
mov    0x18(%rsp),%rbp
mov    %ebp,%esi
call   1050 <write_file_content_list@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   10a0 <write_file_length_list@plt>
add    $0x8,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1100 <write_file_name_list@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10d0 <write_main@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x848,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb76(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%ebx
jmp    14a2 <main+0x2a2>

LLVM IR (-O0):
@.str = [6 x i8] c"out.c\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [43 x i8] c"unable to open output file %s for writing\0A\00"
@.str.3 = [7 x i8] c"malloc\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [42 x i8] c"unable to open input file %s for reading\0A\00"
@.str.6 = [36 x i8] c"\0Aconst unsigned char f%d[] = {\0A \00"
@.str.7 = [8 x i8] c"0x%.2x,\00"
@.str.8 = [6 x i8] c"\0A \00"
@.str.9 = [2 x i8] c" \00"
@.str.10 = [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 i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca [2048 x i8]
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (...) @usage()
store i32 0, i32* %3
br label %156
19: ; preds = %2
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %8
%22 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %14
%23 = icmp ne i32* %22, null
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %156
29: ; preds = %19
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 4
%33 = trunc i64 %32 to i32
%34 = call i32* @malloc(i32 %33)
store i32* %34, i32** %12
%35 = icmp ne i32* %34, null
br i1 %35, label %38, label %36
36: ; preds = %29
%37 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %3
br label %156
38: ; preds = %29
store i32 1, i32* %6
br label %39
39: ; preds = %48, %38
%40 = load i32, i32* %6
%41 = load i32, i32* %4
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %51
43: ; preds = %39
%44 = load i32*, i32** %12
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
store i32 0, i32* %47
br label %48
48: ; preds = %43
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %39
51: ; preds = %39
%52 = load i32*, i32** %14
%53 = call i32 @write_header(i32* %52)
store i32 1, i32* %6
br label %54
54: ; preds = %129, %51
%55 = load i32, i32* %6
%56 = load i32, i32* %4
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %132
58: ; preds = %54
%59 = load i8**, i8*** %5
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32* @fopen(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %64, i32** %13
%65 = icmp ne i32* %64, null
br i1 %65, label %80, label %66
66: ; preds = %58
%67 = load i32, i32* @stderr
%68 = sext i32 %67 to i64
%69 = inttoptr i64 %68 to i32*
%70 = load i8**, i8*** %5
%71 = load i32, i32* %6
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %74)
%76 = load i32*, i32** %14
%77 = call i32 @fclose(i32* %76)
%78 = load i32*, i32** %12
%79 = call i32 @free(i32* %78)
store i32 2, i32* %3
br label %156
80: ; preds = %58
%81 = load i32*, i32** %14
%82 = load i32, i32* %6
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %82)
store i32 0, i32* %7
br label %84
84: ; preds = %123, %80
%85 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%86 = load i32*, i32** %13
%87 = call i64 @fread(i8* %85, i32 1, i32 2048, i32* %86)
store i64 %87, i64* %10
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %124
89: ; preds = %84
%90 = load i64, i64* %10
%91 = load i32*, i32** %12
%92 = load i32, i32* %6
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32, i32* %91, i64 %93
%95 = load i32, i32* %94
%96 = sext i32 %95 to i64
%97 = add i64 %96, %90
%98 = trunc i64 %97 to i32
store i32 %98, i32* %94
store i64 0, i64* %9
br label %99
99: ; preds = %120, %89
%100 = load i64, i64* %9
%101 = load i64, i64* %10
%102 = icmp ult i64 %100, %101
br i1 %102, label %103, label %123
103: ; preds = %99
%104 = load i32*, i32** %14
%105 = load i64, i64* %9
%106 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 %105
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %108)
%110 = load i32, i32* %7
%111 = add nsw i32 %110, 1
store i32 %111, i32* %7
%112 = icmp eq i32 %111, 12
br i1 %112, label %113, label %116
113: ; preds = %103
%114 = load i32*, i32** %14
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %7
br label %119
116: ; preds = %103
%117 = load i32*, i32** %14
%118 = call i32 (i32*, i8*, ...) @fprintf(i32* %117, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %119
119: ; preds = %116, %113
br label %120
120: ; preds = %119
%121 = load i64, i64* %9
%122 = add i64 %121, 1
store i64 %122, i64* %9
br label %99
123: ; preds = %99
br label %84
124: ; preds = %84
%125 = load i32*, i32** %14
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %125, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%127 = load i32*, i32** %13
%128 = call i32 @fclose(i32* %127)
br label %129
129: ; preds = %124
%130 = load i32, i32* %6
%131 = add nsw i32 %130, 1
store i32 %131, i32* %6
br label %54
132: ; preds = %54
%133 = load i32*, i32** %14
%134 = load i32, i32* %4
%135 = sub nsw i32 %134, 1
%136 = call i32 @write_file_content_list(i32* %133, i32 %135)
%137 = load i32*, i32** %14
%138 = load i32*, i32** %12
%139 = load i32, i32* %4
%140 = sub nsw i32 %139, 1
%141 = call i32 @write_file_length_list(i32* %137, i32* %138, i32 %140)
%142 = load i32*, i32** %14
%143 = load i8**, i8*** %5
%144 = getelementptr inbounds i8*, i8** %143, i64 1
%145 = load i32, i32* %4
%146 = sub nsw i32 %145, 1
%147 = call i32 @write_file_name_list(i32* %142, i8** %144, i32 %146)
%148 = load i32*, i32** %14
%149 = load i32, i32* %4
%150 = sub nsw i32 %149, 1
%151 = call i32 @write_main(i32* %148, i32 %150)
%152 = load i32*, i32** %14
%153 = call i32 @fclose(i32* %152)
%154 = load i32*, i32** %12
%155 = call i32 @free(i32* %154)
store i32 0, i32* %3
br label %156
156: ; preds = %132, %66, %36, %24, %17
%157 = load i32, i32* %3
ret i32 %157
}

LLVM IR (-O2):
@.str = [6 x i8] c"out.c\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [43 x i8] c"unable to open output file %s for writing\0A\00"
@.str.3 = [7 x i8] c"malloc\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [42 x i8] c"unable to open input file %s for reading\0A\00"
@.str.6 = [36 x i8] c"\0Aconst unsigned char f%d[] = {\0A \00"
@.str.7 = [8 x i8] c"0x%.2x,\00"
@.str.8 = [6 x i8] c"\0A \00"
@.str.10 = [5 x i8] c"};\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @usage()
br label %94
8: ; preds = %2
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %94
16: ; preds = %8
%17 = shl i32 %0, 2
%18 = tail call i32* @malloc(i32 %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %94
22: ; preds = %16
%23 = getelementptr i32, i32* %18, i64 1
%24 = bitcast i32* %23 to i8*
%25 = add nsw i32 %0, -1
%26 = zext i32 %25 to i64
%27 = shl nuw nsw i64 %26, 2
%28 = tail call i32 @write_header(i32* %9)
%29 = zext i32 %0 to i64
br label %30
30: ; preds = %22, %80
%31 = phi i64 [ 1, %22 ], [ %83, %80 ]
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %46
36: ; preds = %30
%37 = and i64 %31, 4294967295
%38 = getelementptr inbounds i8*, i8** %1, i64 %37
%39 = load i32, i32* @stderr
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to i32*
%42 = load i8*, i8** %38
%43 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = tail call i32 @fclose(i32* %9)
%45 = tail call i32 @free(i32* %18)
br label %94
46: ; preds = %30
%47 = trunc i64 %31 to i32
%48 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = call i64 @fread(i8* %4, i32 1, i32 2048, i32* %34)
%50 = icmp eq i64 %49, 0
br i1 %50, label %80, label %51
51: ; preds = %46
%52 = getelementptr inbounds i32, i32* %18, i64 %31
%53 = load i32, i32* %52
br label %57
54: ; preds = %76
%55 = call i64 @fread(i8* %4, i32 1, i32 2048, i32* %34)
%56 = icmp eq i64 %55, 0
br i1 %56, label %80, label %57
57: ; preds = %51, %54
%58 = phi i32 [ %53, %51 ], [ %62, %54 ]
%59 = phi i64 [ %49, %51 ], [ %55, %54 ]
%60 = phi i32 [ 0, %51 ], [ %77, %54 ]
%61 = trunc i64 %59 to i32
%62 = add i32 %58, %61
store i32 %62, i32* %52
br label %63
63: ; preds = %57, %76
%64 = phi i32 [ %60, %57 ], [ %77, %76 ]
%65 = phi i64 [ 0, %57 ], [ %78, %76 ]
%66 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %68)
%70 = add nsw i32 %64, 1
%71 = icmp eq i32 %70, 12
br i1 %71, label %72, label %74
72: ; preds = %63
%73 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i64 5, i64 1, i32* %9)
br label %76
74: ; preds = %63
%75 = tail call i32 @fputc(i32 32, i32* %9)
br label %76
76: ; preds = %72, %74
%77 = phi i32 [ 0, %72 ], [ %70, %74 ]
%78 = add nuw i64 %65, 1
%79 = icmp eq i64 %78, %59
br i1 %79, label %54, label %63
80: ; preds = %54, %46
%81 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i64 4, i64 1, i32* %9)
%82 = tail call i32 @fclose(i32* %34)
%83 = add nuw nsw i64 %31, 1
%84 = icmp eq i64 %83, %29
br i1 %84, label %85, label %30
85: ; preds = %80
%86 = add nsw i32 %0, -1
%87 = tail call i32 @write_file_content_list(i32* %9, i32 %86)
%88 = tail call i32 @write_file_length_list(i32* %9, i32* %18, i32 %86)
%89 = getelementptr inbounds i8*, i8** %1, i64 1
%90 = tail call i32 @write_file_name_list(i32* %9, i8** %89, i32 %86)
%91 = tail call i32 @write_main(i32* %9, i32 %86)
%92 = tail call i32 @fclose(i32* %9)
%93 = tail call i32 @free(i32* %18)
br label %94
94: ; preds = %85, %36, %20, %11, %6
%95 = phi i32 [ 0, %6 ], [ 2, %36 ], [ 0, %85 ], [ 3, %20 ], [ 1, %11 ]
ret i32 %95
}