#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 EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  for (int i = 1; i < argc; i++) {
    printf("const unsigned char RESOURCE%d_[] = {\n", i);
    FILE *f = fopen(argv[i], "rb");
    if (f == NULL) {
      fprintf(stderr, "cannot open file %s\n", argv[i]);
      exit(EXIT_FAILURE);
    }
    int c;
    int j = 0;
    while ((c = fgetc(f)) != EOF) {
      if (j % 16 == 0) {
        printf("\n  ");
      }
      printf("0x%02x,", c);
      j++;
    }
    fclose(f);
    printf("\n};\n");
  }
  printf("const struct Resource RESOURCES[] = {\n");
  for (int i = 1; i < argc; i++) {
    printf("  {\n");
    printf("    \"%s\",\n", argv[i]);
    printf("    RESOURCE%d_,\n", i);
    printf("    sizeof(RESOURCE%d_)\n", i);
    printf("  },\n");
  }
  printf("};\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1278 <main+0x118>
mov    -0x14(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f0 <main+0x90>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2dde(%rip),%rcx
cmp    (%rcx),%eax
je     1253 <main+0xf3>
mov    -0x28(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1234 <main+0xd4>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f7 <main+0x97>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x1d>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ff <main+0x19f>
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    128d <main+0x12d>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jle    126b <main+0xfb>
mov    %rsi,(%rsp)
mov    %edi,0xc(%rsp)
mov    %edi,%ebx
mov    $0x1,%ebp
mov    0x2e4b(%rip),%r15
mov    %rbx,0x10(%rsp)
jmp    11d6 <main+0x66>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%rbp
mov    0x10(%rsp),%rbx
cmp    %rbx,%rbp
je     12be <main+0x14e>
lea    0xe23(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rax
mov    (%rax,%rbp,8),%rdi
lea    0xe32(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1291 <main+0x121>
mov    %rax,%r12
mov    %rax,%rdi
call   1060 <fgetc@plt>
cmp    (%r15),%eax
lea    0xe27(%rip),%rbx
je     11b0 <main+0x40>
mov    %eax,%r13d
xor    %r14d,%r14d
jmp    1259 <main+0xe9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe0c(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14d
mov    %r12,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r13d
cmp    (%r15),%eax
je     11b0 <main+0x40>
test   $0xf,%r14b
jne    1230 <main+0xc0>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1230 <main+0xc0>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %ebp,%eax
mov    0x2d3e(%rip),%rcx
mov    (%rcx),%edi
mov    (%rsp),%rcx
mov    (%rcx,%rax,8),%rdx
lea    0xd7f(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    0xdbc(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x2,0xc(%rsp)
mov    (%rsp),%r12
jl     1277 <main+0x107>
mov    %rbx,%r15
mov    $0x1,%ebp
lea    0xd72(%rip),%rbx
lea    0xd7d(%rip),%r13
lea    0xdb9(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xda0(%rip),%rdi
call   1030 <puts@plt>
mov    (%r12,%rbp,8),%rsi
lea    0xd34(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1300 <main+0x190>
jmp    1277 <main+0x107>

LLVM IR (-O0):
@.str = [39 x i8] c"const unsigned char RESOURCE%d_[] = {\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"cannot open file %s\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@.str.3 = [4 x i8] c"\0A \00"
@.str.4 = [8 x i8] c"0x%02x,\00"
@.str.5 = [5 x i8] c"\0A};\0A\00"
@.str.6 = [39 x i8] c"const struct Resource RESOURCES[] = {\0A\00"
@.str.7 = [5 x i8] c" {\0A\00"
@.str.8 = [11 x i8] c" \22%s\22,\0A\00"
@.str.9 = [18 x i8] c" RESOURCE%d_,\0A\00"
@.str.10 = [25 x i8] c" sizeof(RESOURCE%d_)\0A\00"
@.str.11 = [6 x i8] c" },\0A\00"
@.str.12 = [4 x i8] c"};\0A\00"
@EXIT_SUCCESS = 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %11
11: ; preds = %57, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %60
15: ; preds = %11
%16 = load i32, i32* %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %36
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %15
store i32 0, i32* %9
br label %37
37: ; preds = %48, %36
%38 = load i32*, i32** %7
%39 = call i32 @fgetc(i32* %38)
store i32 %39, i32* %8
%40 = load i32, i32* @EOF
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %53
42: ; preds = %37
%43 = load i32, i32* %9
%44 = srem i32 %43, 16
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %46, %42
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %37
53: ; preds = %37
%54 = load i32*, i32** %7
%55 = call i32 @fclose(i32* %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %53
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %11
60: ; preds = %11
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %10
br label %62
62: ; preds = %79, %60
%63 = load i32, i32* %10
%64 = load i32, i32* %4
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %82
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%68 = load i8**, i8*** %5
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %72)
%74 = load i32, i32* %10
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %10
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %76)
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %79
79: ; preds = %66
%80 = load i32, i32* %10
%81 = add nsw i32 %80, 1
store i32 %81, i32* %10
br label %62
82: ; preds = %62
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%84 = load i32, i32* @EXIT_SUCCESS
%85 = call i32 @exit(i32 %84)
unreachable
}

LLVM IR (-O2):
@.str = [39 x i8] c"const unsigned char RESOURCE%d_[] = {\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"cannot open file %s\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@.str.3 = [4 x i8] c"\0A \00"
@.str.4 = [8 x i8] c"0x%02x,\00"
@.str.8 = [11 x i8] c" \22%s\22,\0A\00"
@.str.9 = [18 x i8] c" RESOURCE%d_,\0A\00"
@.str.10 = [25 x i8] c" sizeof(RESOURCE%d_)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [38 x i8] c"const struct Resource RESOURCES[] = {\00"
@str.13 = [3 x i8] c"};\00"
@str.14 = [4 x i8] c" {\00"
@str.15 = [5 x i8] c" },\00"
@str.16 = [4 x i8] c"\0A};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %50
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %12
8: ; preds = %45
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br i1 %3, label %10, label %50
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %54
12: ; preds = %6, %45
%13 = phi i64 [ 1, %6 ], [ %48, %45 ]
%14 = trunc i64 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 %13
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %24, label %20
20: ; preds = %12
%21 = tail call i32 @fgetc(i32* %18)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %45, label %32
24: ; preds = %12
%25 = and i64 %13, 4294967295
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %26
%29 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %20, %39
%33 = phi i32 [ %42, %39 ], [ %21, %20 ]
%34 = phi i32 [ %41, %39 ], [ 0, %20 ]
%35 = and i32 %34, 15
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%41 = add nuw nsw i32 %34, 1
%42 = tail call i32 @fgetc(i32* %18)
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %32
45: ; preds = %39, %20
%46 = tail call i32 @fclose(i32* %18)
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.16, i64 0, i64 0))
%48 = add nuw nsw i64 %13, 1
%49 = icmp eq i64 %48, %7
br i1 %49, label %8, label %12
50: ; preds = %54, %4, %8
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.13, i64 0, i64 0))
%52 = load i32, i32* @EXIT_SUCCESS
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %10, %54
%55 = phi i64 [ 1, %10 ], [ %64, %54 ]
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.14, i64 0, i64 0))
%57 = getelementptr inbounds i8*, i8** %1, i64 %55
%58 = load i8*, i8** %57
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %58)
%60 = trunc i64 %55 to i32
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %60)
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %60)
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.15, i64 0, i64 0))
%64 = add nuw nsw i64 %55, 1
%65 = icmp eq i64 %64, %11
br i1 %65, label %50, label %54
}