#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*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
char *optarg;
size_t optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp;
  char *source = NULL;
  char *name = NULL;
  int first = 1;
  int zero = 0;
  int c;
  int i;
  while ((c = getopt(argc, argv, "n:0")) != -1) {
    switch (c) {
    case 'n':
      name = optarg;
      break;
    case '0':
      zero = 1;
      break;
    }
  }
  source = argv[optind];
  if (!name)
    name = source;
  if (!source) {
    fprintf(stderr, "Usage: %s [-0] [-n <name>] <source>\n", argv[0]);
    return 1;
  }
  if ((fp = fopen(source, "r")) == NULL) {
    perror("Couldn't open source file");
    return 1;
  }
  printf("/* Automatically generated from %s */\n\n"
         "#define %s { \\\n",
         source, name);
  do {
    for (i = 0; i < 16; i++) {
      if ((c = fgetc(fp)) == EOF) {
        if (zero--)
          c = '\0';
        else
          break;
      }
      if (i == 0 && !first)
        printf(", \\\n");
      if (i > 0)
        printf(", ");
      printf("0x%02x", c);
      first = 0;
    }
  } while (c != EOF);
  printf("}\n\n");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4e(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1207 <main+0x97>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x30,%eax
je     11fb <main+0x8b>
jmp    11d7 <main+0x67>
mov    -0x3c(%rbp),%eax
sub    $0x6e,%eax
jne    1202 <main+0x92>
jmp    11e8 <main+0x78>
mov    0x2e09(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1202 <main+0x92>
movl   $0x1,-0x30(%rbp)
jmp    11a4 <main+0x34>
mov    -0x10(%rbp),%rax
mov    0x2dc6(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1230 <main+0xc0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1263 <main+0xf3>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb2(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    139a <main+0x22a>
mov    -0x20(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1299 <main+0x129>
lea    0xda3(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    139a <main+0x22a>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x10,-0x38(%rbp)
jge    1365 <main+0x1f5>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    0x2d0d(%rip),%rcx
cmp    (%rcx),%eax
jne    1305 <main+0x195>
mov    -0x30(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x30(%rbp)
cmp    $0x0,%eax
je     12fb <main+0x18b>
movl   $0x0,-0x34(%rbp)
jmp    1300 <main+0x190>
jmp    1365 <main+0x1f5>
jmp    1305 <main+0x195>
cmpl   $0x0,-0x38(%rbp)
jne    1327 <main+0x1b7>
cmpl   $0x0,-0x2c(%rbp)
jne    1327 <main+0x1b7>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x38(%rbp)
jle    133f <main+0x1cf>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12b6 <main+0x146>
jmp    136a <main+0x1fa>
mov    -0x34(%rbp),%eax
mov    0x2c6c(%rip),%rcx
cmp    (%rcx),%eax
jne    12af <main+0x13f>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
lea    0xe66(%rip),%r15
mov    0x2e57(%rip),%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10a0 <getopt@plt>
cmp    $0xffffffff,%eax
je     11da <main+0x5a>
cmp    $0x30,%eax
je     11d2 <main+0x52>
cmp    $0x6e,%eax
jne    11b0 <main+0x30>
mov    (%r12),%r14
jmp    11b0 <main+0x30>
mov    $0x1,%r13d
jmp    11b0 <main+0x30>
mov    0x2df7(%rip),%rax
mov    (%rax),%rax
mov    (%rbx,%rax,8),%rbp
test   %r14,%r14
cmove  %rbp,%r14
test   %rbp,%rbp
je     12c6 <main+0x146>
lea    0xe2a(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12f2 <main+0x172>
mov    %rax,%rbx
lea    0xe2b(%rip),%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r15d
mov    0x2dac(%rip),%r14
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%eax
jne    1270 <main+0xf0>
xor    %ebp,%ebp
sub    $0x1,%r13d
jb     12ae <main+0x12e>
or     %r12d,%r15d
je     1277 <main+0xf7>
test   %r12d,%r12d
je     1283 <main+0x103>
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1283 <main+0x103>
nop
mov    %eax,%ebp
or     %r12d,%r15d
jne    125a <main+0xda>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
xor    %r15d,%r15d
lea    0xdf2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12d
cmp    $0x10,%r12d
jne    1240 <main+0xc0>
xor    %r12d,%r12d
mov    $0x0,%r15d
cmp    (%r14),%ebp
jne    1240 <main+0xc0>
lea    0xdd1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12e3 <main+0x163>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd2b(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd32(%rip),%rdi
call   1090 <perror@plt>
jmp    12de <main+0x15e>

LLVM IR (-O0):
@.str = [4 x i8] c"n:0\00"
@optarg = global i8* null
@optind = global i64 0
@stderr = global i32 0
@.str.1 = [37 x i8] c"Usage: %s [-0] [-n <name>] <source>\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"Couldn't open source file\00"
@.str.4 = [55 x i8] c"/* Automatically generated from %s */\0A\0A#define %s { \\\0A\00"
@EOF = global i32 0
@.str.5 = [5 x i8] c", \\\0A\00"
@.str.6 = [3 x i8] c", \00"
@.str.7 = [7 x i8] c"0x%02x\00"
@.str.8 = [4 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 i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
store i32 1, i32* %9
store i32 0, i32* %10
br label %13
13: ; preds = %23, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %11
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i32, i32* %11
switch i32 %19, label %23 [
i32 110, label %20
i32 48, label %22
]
20: ; preds = %18
%21 = load i8*, i8** @optarg
store i8* %21, i8** %8
br label %23
22: ; preds = %18
store i32 1, i32* %10
br label %23
23: ; preds = %18, %22, %20
br label %13
24: ; preds = %13
%25 = load i8**, i8*** %5
%26 = load i64, i64* @optind
%27 = getelementptr inbounds i8*, i8** %25, i64 %26
%28 = load i8*, i8** %27
store i8* %28, i8** %7
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %24
%32 = load i8*, i8** %7
store i8* %32, i8** %8
br label %33
33: ; preds = %31, %24
%34 = load i8*, i8** %7
%35 = icmp ne i8* %34, null
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %40)
store i32 1, i32* %3
br label %96
42: ; preds = %33
%43 = load i8*, i8** %7
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %44, i32** %6
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %96
48: ; preds = %42
%49 = load i8*, i8** %7
%50 = load i8*, i8** %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i8* %49, i8* %50)
br label %52
52: ; preds = %88, %48
store i32 0, i32* %12
br label %53
53: ; preds = %84, %52
%54 = load i32, i32* %12
%55 = icmp slt i32 %54, 16
br i1 %55, label %56, label %87
56: ; preds = %53
%57 = load i32*, i32** %6
%58 = call i32 @fgetc(i32* %57)
store i32 %58, i32* %11
%59 = load i32, i32* @EOF
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %68
61: ; preds = %56
%62 = load i32, i32* %10
%63 = add nsw i32 %62, -1
store i32 %63, i32* %10
%64 = icmp ne i32 %62, 0
br i1 %64, label %65, label %66
65: ; preds = %61
store i32 0, i32* %11
br label %67
66: ; preds = %61
br label %87
67: ; preds = %65
br label %68
68: ; preds = %67, %56
%69 = load i32, i32* %12
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %68
%72 = load i32, i32* %9
%73 = icmp ne i32 %72, 0
br i1 %73, label %76, label %74
74: ; preds = %71
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %76
76: ; preds = %74, %71, %68
%77 = load i32, i32* %12
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %81
81: ; preds = %79, %76
%82 = load i32, i32* %11
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %82)
store i32 0, i32* %9
br label %84
84: ; preds = %81
%85 = load i32, i32* %12
%86 = add nsw i32 %85, 1
store i32 %86, i32* %12
br label %53
87: ; preds = %66, %53
br label %88
88: ; preds = %87
%89 = load i32, i32* %11
%90 = load i32, i32* @EOF
%91 = icmp ne i32 %89, %90
br i1 %91, label %52, label %92
92: ; preds = %88
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%94 = load i32*, i32** %6
%95 = call i32 @fclose(i32* %94)
store i32 0, i32* %3
br label %96
96: ; preds = %92, %46, %36
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@.str = [4 x i8] c"n:0\00"
@optarg = global i8* null
@optind = global i64 0
@stderr = global i32 0
@.str.1 = [37 x i8] c"Usage: %s [-0] [-n <name>] <source>\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"Couldn't open source file\00"
@.str.4 = [55 x i8] c"/* Automatically generated from %s */\0A\0A#define %s { \\\0A\00"
@EOF = global i32 0
@.str.6 = [3 x i8] c", \00"
@.str.7 = [7 x i8] c"0x%02x\00"
@str = [3 x i8] c"}\0A\00"
@str.9 = [4 x i8] c", \\\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %10, %2
%4 = phi i8* [ %11, %10 ], [ null, %2 ]
%5 = phi i32 [ %7, %10 ], [ 0, %2 ]
br label %6
6: ; preds = %8, %3
%7 = phi i32 [ %5, %3 ], [ 1, %8 ]
br label %8
8: ; preds = %6, %8
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %8 [
i32 -1, label %12
i32 110, label %10
i32 48, label %6
]
10: ; preds = %8
%11 = load i8*, i8** @optarg
br label %3
12: ; preds = %8
%13 = load i64, i64* @optind
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = icmp eq i8* %4, null
%17 = select i1 %16, i8* %15, i8* %4
%18 = icmp eq i8* %15, null
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %63
23: ; preds = %12
%24 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %63
28: ; preds = %23
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* %17)
br label %30
30: ; preds = %55, %28
%31 = phi i32 [ 0, %28 ], [ %56, %55 ]
%32 = phi i32 [ %7, %28 ], [ %41, %55 ]
%33 = phi i32 [ 1, %28 ], [ 0, %55 ]
%34 = tail call i32 @fgetc(i32* %24)
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = add nsw i32 %32, -1
%39 = icmp eq i32 %32, 0
br i1 %39, label %60, label %40
40: ; preds = %37, %30
%41 = phi i32 [ %32, %30 ], [ %38, %37 ]
%42 = phi i32 [ %34, %30 ], [ 0, %37 ]
%43 = or i32 %31, %33
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.9, i64 0, i64 0))
br label %51
47: ; preds = %40
%48 = icmp eq i32 %31, 0
br i1 %48, label %51, label %49
49: ; preds = %47
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %51
51: ; preds = %45, %49, %47
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%53 = add nuw nsw i32 %31, 1
%54 = icmp eq i32 %53, 16
br i1 %54, label %57, label %55
55: ; preds = %51, %57
%56 = phi i32 [ %53, %51 ], [ 0, %57 ]
br label %30
57: ; preds = %51
%58 = load i32, i32* @EOF
%59 = icmp eq i32 %42, %58
br i1 %59, label %60, label %55
60: ; preds = %57, %37
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%62 = tail call i32 @fclose(i32* %24)
br label %63
63: ; preds = %60, %26, %19
%64 = phi i32 [ 1, %26 ], [ 0, %60 ], [ 1, %19 ]
ret i32 %64
}