#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ print_escaped_path(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  int i;
  char *path;
  FILE *in = NULL;
  int ch;
  unsigned int len = 0;
  for (i = 1; i < argc && argv[i][0] == '-'; ++i)
    ;
  if (i == argc) {
    fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
    return EXIT_FAILURE;
  }
  path = argv[i];
  errno = 0;
  if ((in = fopen(path, "r")) == NULL) {
    fprintf(stderr, "Unable to open '%s': %s\n", path, strerror(errno));
    return EXIT_FAILURE;
  }
  printf("static const unsigned char ");
  print_escaped_path(path);
  printf("[] = {");
  for (;;) {
    ch = fgetc(in);
    if (len != 0) {
      printf(",");
    }
    if (len % 12 == 0) {
      printf("\n ");
    }
    printf(" 0x%.2x", (ch == EOF ? 0 : ch));
    if (ch == EOF) {
      break;
    }
    ++len;
  }
  printf("\n};\nstatic const unsigned int ");
  print_escaped_path(path);
  printf("_len = %i;\n", len);
  fclose(in);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x31(%rbp)
jge    11c5 <main+0x55>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11d5 <main+0x65>
jmp    11e8 <main+0x78>
jmp    11da <main+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x2c>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1223 <main+0xb3>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13ac <main+0x23c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    0x2d96(%rip),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12ab <main+0x13b>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d56(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13ac <main+0x23c>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <print_escaped_path@plt>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     12f4 <main+0x184>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
mov    $0xc,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    1317 <main+0x1a7>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    0x2cc7(%rip),%rcx
cmp    (%rcx),%eax
jne    1333 <main+0x1c3>
xor    %eax,%eax
mov    %eax,-0x48(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%esi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    0x2c94(%rip),%rcx
cmp    (%rcx),%eax
jne    1361 <main+0x1f1>
jmp    136f <main+0x1ff>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12d0 <main+0x160>
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <print_escaped_path@plt>
mov    -0x30(%rbp),%esi
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%eax
cmp    $0x2,%edi
jl     11b4 <main+0x34>
mov    %edi,%ecx
mov    $0x1,%eax
nopl   0x0(%rax)
mov    (%rsi,%rax,8),%rdx
cmpb   $0x2d,(%rdx)
jne    11b4 <main+0x34>
add    $0x1,%rax
cmp    %rax,%rcx
jne    11a0 <main+0x20>
jmp    11b8 <main+0x38>
cmp    %edi,%eax
jne    11de <main+0x5e>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe35(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2def(%rip),%rax
jmp    1306 <main+0x186>
mov    %eax,%eax
mov    (%rsi,%rax,8),%rbx
mov    0x2de5(%rip),%rbp
movq   $0x0,0x0(%rbp)
lea    0xe1c(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1317 <main+0x197>
mov    %rax,%r13
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,(%rsp)
mov    %rbx,%rdi
call   1080 <print_escaped_path@plt>
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
mov    0x2da6(%rip),%r14
lea    0xe0e(%rip),%r12
xor    %r15d,%r15d
jmp    1266 <main+0xe6>
xchg   %ax,%ax
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
add    $0xffffffff,%ebp
cmp    (%r14),%ebx
je     12ce <main+0x14e>
mov    %r13,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
cmp    $0x1,%ebp
je     12b2 <main+0x132>
mov    %r15d,%eax
mov    $0xaaaaaaab,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
shl    $0x2,%eax
mov    %r13,%r14
mov    %r12,%r13
lea    (%rax,%rax,2),%r12d
mov    $0x2c,%edi
call   1030 <putchar@plt>
add    %ebp,%r12d
cmp    $0x1,%r12d
mov    %r13,%r12
mov    %r14,%r13
mov    0x2d38(%rip),%r14
jne    12c0 <main+0x140>
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x0,%esi
cmp    (%r14),%ebx
je     1250 <main+0xd0>
mov    %ebx,%esi
jmp    1250 <main+0xd0>
lea    0xd8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1080 <print_escaped_path@plt>
neg    %ebp
lea    0xd90(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cba(%rip),%rax
mov    (%rax),%r14d
mov    0x0(%rbp),%rdi
call   10a0 <strerror@plt>
lea    0xce7(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11d2 <main+0x52>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Unable to open '%s': %s\0A\00"
@.str.3 = [28 x i8] c"static const unsigned char \00"
@.str.4 = [7 x i8] c"[] = {\00"
@.str.5 = [2 x i8] c",\00"
@.str.6 = [3 x i8] c"\0A \00"
@.str.7 = [8 x i8] c" 0x%.2x\00"
@EOF = global i32 0
@.str.8 = [31 x i8] c"\0A};\0Astatic const unsigned int \00"
@.str.9 = [12 x i8] c"_len = %i;\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 i8*
%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* null, i32** %8
store i32 0, i32* %10
store i32 1, i32* %6
br label %11
11: ; preds = %28, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br label %25
25: ; preds = %15, %11
%26 = phi i1 [ false, %11 ], [ %24, %15 ]
br i1 %26, label %27, label %31
27: ; preds = %25
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %11
31: ; preds = %25
%32 = load i32, i32* %6
%33 = load i32, i32* %4
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %3
br label %102
42: ; preds = %31
%43 = load i8**, i8*** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
store i8* %47, i8** %7
store i64 0, i64* @errno
%48 = load i8*, i8** %7
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %49, i32** %8
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %58
51: ; preds = %42
%52 = load i32, i32* @stderr
%53 = load i8*, i8** %7
%54 = load i64, i64* @errno
%55 = call i8* @strerror(i64 %54)
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %53, i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
store i32 %57, i32* %3
br label %102
58: ; preds = %42
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%60 = load i8*, i8** %7
%61 = call i32 @print_escaped_path(i8* %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %90, %58
%64 = load i32*, i32** %8
%65 = call i32 @fgetc(i32* %64)
store i32 %65, i32* %9
%66 = load i32, i32* %10
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %68, %63
%71 = load i32, i32* %10
%72 = urem i32 %71, 12
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %76
76: ; preds = %74, %70
%77 = load i32, i32* %9
%78 = load i32, i32* @EOF
%79 = icmp eq i32 %77, %78
br i1 %79, label %80, label %81
80: ; preds = %76
br label %83
81: ; preds = %76
%82 = load i32, i32* %9
br label %83
83: ; preds = %81, %80
%84 = phi i32 [ 0, %80 ], [ %82, %81 ]
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %84)
%86 = load i32, i32* %9
%87 = load i32, i32* @EOF
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %90
89: ; preds = %83
br label %93
90: ; preds = %83
%91 = load i32, i32* %10
%92 = add i32 %91, 1
store i32 %92, i32* %10
br label %63
93: ; preds = %89
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
%95 = load i8*, i8** %7
%96 = call i32 @print_escaped_path(i8* %95)
%97 = load i32, i32* %10
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %97)
%99 = load i32*, i32** %8
%100 = call i32 @fclose(i32* %99)
%101 = load i32, i32* @EXIT_SUCCESS
store i32 %101, i32* %3
br label %102
102: ; preds = %93, %51, %35
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Unable to open '%s': %s\0A\00"
@.str.3 = [28 x i8] c"static const unsigned char \00"
@.str.4 = [7 x i8] c"[] = {\00"
@.str.6 = [3 x i8] c"\0A \00"
@.str.7 = [8 x i8] c" 0x%.2x\00"
@EOF = global i32 0
@.str.8 = [31 x i8] c"\0A};\0Astatic const unsigned int \00"
@.str.9 = [12 x i8] c"_len = %i;\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %12
%7 = phi i64 [ 1, %4 ], [ %13, %12 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 45
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %20, label %6
15: ; preds = %6
%16 = trunc i64 %7 to i32
br label %17
17: ; preds = %15, %2
%18 = phi i32 [ 1, %2 ], [ %16, %15 ]
%19 = icmp eq i32 %18, %0
br i1 %19, label %20, label %24
20: ; preds = %12, %17
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %1
%23 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %62
24: ; preds = %17
%25 = zext i32 %18 to i64
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
store i64 0, i64* @errno
%28 = tail call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = load i64, i64* @errno
%33 = tail call i8* @strerror(i64 %32)
%34 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %33)
br label %62
35: ; preds = %24
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%37 = tail call i32 @print_escaped_path(i8* %27)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %49, %35
%40 = phi i32 [ 0, %35 ], [ %56, %49 ]
%41 = tail call i32 @fgetc(i32* %28)
%42 = icmp eq i32 %40, 0
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = tail call i32 @putchar(i32 44)
%45 = urem i32 %40, 12
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %39, %43
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = load i32, i32* @EOF
%51 = icmp eq i32 %41, %50
%52 = select i1 %51, i32 0, i32 %41
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %52)
%54 = load i32, i32* @EOF
%55 = icmp eq i32 %41, %54
%56 = add i32 %40, 1
br i1 %55, label %57, label %39
57: ; preds = %49
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
%59 = tail call i32 @print_escaped_path(i8* %27)
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %40)
%61 = tail call i32 @fclose(i32* %28)
br label %62
62: ; preds = %57, %30, %20
%63 = phi i32* [ @EXIT_FAILURE, %20 ], [ @EXIT_FAILURE, %30 ], [ @EXIT_SUCCESS, %57 ]
%64 = load i32, i32* %63
ret i32 %64
}