#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 FILENAME_MAX;
int /*<<< orphan*/ exit(int);
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*/ putchar(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  FILE *fp;
  int c, x = 0, i;
  char filename[FILENAME_MAX], varname[FILENAME_MAX];
  if (argc != 3 && argc != 2) {
    fprintf(stderr, "Usage: %s /path/to/infile.dat [name_of_variable]\n",
            argv[0]);
    exit(1);
  }
  strcpy(filename, argv[1]);
  if (argc == 2) {
    strcpy(varname, argv[1]);
    for (i = 0; i < strlen(varname); i++) {
      if (varname[i] == '.')
        varname[i] = '\0';
      if (varname[i] == '-')
        varname[i] = '_';
    }
  } else {
    strcpy(varname, argv[2]);
  }
  fp = fopen(filename, "rb");
  if (fp == NULL) {
    fprintf(stderr, "Cannot open file: %s\n", argv[1]);
    exit(1);
  }
  printf("/**\n * Automatically generated from \"%s\" by %s.\n **/\n", filename,
         argv[0]);
  printf("const char %s[] = {", varname);
  while ((c = fgetc(fp)) != EOF) {
    if (x > 0)
      putchar(',');
    if (x++ % 20 == 0)
      putchar('\n');
    printf("%d", c);
  }
  printf("\n};\n\n");
  fclose(fp);
  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   $0x0,-0x20(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1231 <main+0xa1>
cmpl   $0x2,-0x8(%rbp)
je     1231 <main+0xa1>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdde(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jne    12da <main+0x14a>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    %eax,-0x54(%rbp)
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    12d5 <main+0x145>
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    12a1 <main+0x111>
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    12c2 <main+0x132>
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    12c7 <main+0x137>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1264 <main+0xd4>
jmp    12eb <main+0x15b>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x50(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1331 <main+0x1a1>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd13(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x50(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2c79(%rip),%rcx
cmp    (%rcx),%eax
je     13c7 <main+0x237>
cmpl   $0x0,-0x20(%rbp)
jle    138b <main+0x1fb>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
mov    $0x14,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13b1 <main+0x221>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%esi
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    135c <main+0x1cc>
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    1331 <main+0x191>
mov    %edi,%r12d
mov    0x8(%r14),%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
cmp    $0x2,%r12d
jne    124c <main+0xac>
mov    0x8(%r14),%rsi
mov    %r13,%rdi
call   1040 <strcpy@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    1258 <main+0xb8>
xor    %ebx,%ebx
jmp    123a <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
mov    %r13,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1258 <main+0xb8>
movzbl 0x0(%r13,%rbx,1),%eax
cmp    $0x2e,%al
je     1220 <main+0x80>
cmp    $0x2d,%al
jne    1227 <main+0x87>
mov    $0x5f,%al
jmp    1222 <main+0x82>
mov    0x10(%r14),%rsi
mov    %r13,%rdi
call   1040 <strcpy@plt>
lea    0xdd3(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1346 <main+0x1a6>
mov    %rax,%r12
mov    (%r14),%rdx
lea    0xdce(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdf3(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12,%rdi
call   1090 <fgetc@plt>
mov    0x2d41(%rip),%r15
cmp    (%r15),%eax
jne    12d1 <main+0x131>
lea    0xde5(%rip),%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
lea    0xdbb(%rip),%r14
xor    %r13d,%r13d
jmp    130b <main+0x16b>
nop
mov    $0x1,%r13d
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12,%rdi
call   1090 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r15),%eax
je     12ac <main+0x10c>
test   %r13d,%r13d
je     12e0 <main+0x140>
mov    $0x2c,%edi
call   1030 <putchar@plt>
imul   $0xcccccccd,%r13d,%eax
add    $0x1,%r13d
ror    $0x2,%eax
cmp    $0xccccccc,%eax
ja     12f0 <main+0x150>
jmp    12e6 <main+0x146>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcbc(%rip),%rsi
jmp    135a <main+0x1ba>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xcdb(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@stderr = global i32 0
@.str = [50 x i8] c"Usage: %s /path/to/infile.dat [name_of_variable]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.3 = [54 x i8] c"/**\0A * Automatically generated from \22%s\22 by %s.\0A **/\0A\00"
@.str.4 = [20 x i8] c"const char %s[] = {\00"
@EOF = global i32 0
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [6 x i8] c"\0A};\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 i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%13 = load i32, i32* @FILENAME_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %10
%16 = alloca i8, i64 %14
store i64 %14, i64* %11
%17 = load i32, i32* @FILENAME_MAX
%18 = zext i32 %17 to i64
%19 = alloca i8, i64 %18
store i64 %18, i64* %12
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %32
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 2
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %22, %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %16, i8* %35)
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 2
br i1 %38, label %39, label %75
39: ; preds = %32
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @strcpy(i8* %19, i8* %42)
store i32 0, i32* %9
br label %44
44: ; preds = %71, %39
%45 = load i32, i32* %9
%46 = call i32 @strlen(i8* %19)
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %74
48: ; preds = %44
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %19, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 46
br i1 %54, label %55, label %59
55: ; preds = %48
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %19, i64 %57
store i8 0, i8* %58
br label %59
59: ; preds = %55, %48
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %19, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 45
br i1 %65, label %66, label %70
66: ; preds = %59
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %19, i64 %68
store i8 95, i8* %69
br label %70
70: ; preds = %66, %59
br label %71
71: ; preds = %70
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
br label %44
74: ; preds = %44
br label %80
75: ; preds = %32
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 2
%78 = load i8*, i8** %77
%79 = call i32 @strcpy(i8* %19, i8* %78)
br label %80
80: ; preds = %75, %74
%81 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %81, i32** %6
%82 = load i32*, i32** %6
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %91
84: ; preds = %80
%85 = load i32, i32* @stderr
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 1
%88 = load i8*, i8** %87
%89 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %88)
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %80
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 0
%94 = load i8*, i8** %93
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %19)
br label %97
97: ; preds = %114, %91
%98 = load i32*, i32** %6
%99 = call i32 @fgetc(i32* %98)
store i32 %99, i32* %7
%100 = load i32, i32* @EOF
%101 = icmp ne i32 %99, %100
br i1 %101, label %102, label %117
102: ; preds = %97
%103 = load i32, i32* %8
%104 = icmp sgt i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %102
%106 = call i32 @putchar(i8 signext 44)
br label %107
107: ; preds = %105, %102
%108 = load i32, i32* %8
%109 = add nsw i32 %108, 1
store i32 %109, i32* %8
%110 = srem i32 %108, 20
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %107
%113 = call i32 @putchar(i8 signext 10)
br label %114
114: ; preds = %112, %107
%115 = load i32, i32* %7
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %115)
br label %97
117: ; preds = %97
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%119 = load i32*, i32** %6
%120 = call i32 @fclose(i32* %119)
store i32 0, i32* %3
%121 = load i8*, i8** %10
%122 = load i32, i32* %3
ret i32 %122
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
@stderr = global i32 0
@.str = [50 x i8] c"Usage: %s /path/to/infile.dat [name_of_variable]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.3 = [54 x i8] c"/**\0A * Automatically generated from \22%s\22 by %s.\0A **/\0A\00"
@.str.4 = [20 x i8] c"const char %s[] = {\00"
@EOF = global i32 0
@.str.5 = [3 x i8] c"%d\00"
@str = [5 x i8] c"\0A};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @FILENAME_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = alloca i8, i64 %4
%7 = and i32 %0, -2
%8 = icmp eq i32 %7, 2
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %5, i8* %16)
%18 = icmp eq i32 %0, 2
br i1 %18, label %19, label %36
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = call i32 @strcpy(i8* %6, i8* %20)
%22 = call i32 @strlen(i8* %6)
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %19, %31
%25 = phi i64 [ %32, %31 ], [ 0, %19 ]
%26 = getelementptr inbounds i8, i8* %6, i64 %25
%27 = load i8, i8* %26
switch i8 %27, label %31 [
i8 46, label %29
i8 45, label %28
]
28: ; preds = %24
br label %29
29: ; preds = %24, %28
%30 = phi i8 [ 95, %28 ], [ 0, %24 ]
store i8 %30, i8* %26
br label %31
31: ; preds = %29, %24
%32 = add nuw nsw i64 %25, 1
%33 = call i32 @strlen(i8* %6)
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %24, label %40
36: ; preds = %14
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @strcpy(i8* %6, i8* %38)
br label %40
40: ; preds = %31, %19, %36
%41 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %15
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %40
%49 = load i8*, i8** %1
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %49)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%52 = call i32 @fgetc(i32* %41)
%53 = load i32, i32* @EOF
%54 = icmp eq i32 %52, %53
br i1 %54, label %73, label %55
55: ; preds = %48, %67
%56 = phi i32 [ %70, %67 ], [ %52, %48 ]
%57 = phi i32 [ %68, %67 ], [ 0, %48 ]
%58 = icmp eq i32 %57, 0
br i1 %58, label %64, label %59
59: ; preds = %55
%60 = call i32 @putchar(i8 signext 44)
%61 = add nuw nsw i32 %57, 1
%62 = urem i32 %57, 20
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %55, %59
%65 = phi i32 [ %61, %59 ], [ 1, %55 ]
%66 = call i32 @putchar(i8 signext 10)
br label %67
67: ; preds = %64, %59
%68 = phi i32 [ %65, %64 ], [ %61, %59 ]
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %56)
%70 = call i32 @fgetc(i32* %41)
%71 = load i32, i32* @EOF
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %55
73: ; preds = %67, %48
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%75 = call i32 @fclose(i32* %41)
ret i32 0
}