#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_SUCCESS;
int /*<<< orphan*/ exit_error_input_file_opening(char *, char *);
int /*<<< orphan*/ exit_error_invalid_arguments(int, char *);
int /*<<< orphan*/ exit_error_output_file_opening(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int main(int argc, char **argv) {
  if (argc != 4)
    exit_error_invalid_arguments(argc, argv[0]);
  FILE *input = fopen(argv[1], "r");
  if (!input)
    exit_error_input_file_opening(argv[1], argv[0]);
  FILE *output = fopen(argv[2], "w");
  if (!output)
    exit_error_output_file_opening(argv[2], argv[0]);
  fprintf(output, "#ifndef %s_H\n", argv[3]);
  fprintf(output, "#define %s_H\n\n\n", argv[3]);
  fprintf(output, "const char *%s =\n", argv[3]);
  int counter = 0;
  int ch;
  while ((ch = fgetc(input)) != EOF) {
    ++counter;
    if (counter == 1)
      fprintf(output, "    \"");
    else if (counter % 10 == 1)
      fprintf(output, "\"\n    \"");
    fprintf(output, "\\x%02x", ch);
  }
  fprintf(output, "\";\n\n\n");
  fprintf(output, "const size_t %s_LEN = %d;\n\n\n", argv[3], counter);
  fprintf(output, "#endif // %s_H\n", argv[3]);
  fclose(input);
  fclose(output);
  return 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)
cmpl   $0x4,-0x8(%rbp)
je     119f <main+0x2f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1070 <exit_error_invalid_arguments@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d6 <main+0x66>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <exit_error_input_file_opening@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe1d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120d <main+0x9d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1090 <exit_error_output_file_opening@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d73(%rip),%rcx
cmp    (%rcx),%eax
je     12ec <main+0x17c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    12a7 <main+0x137>
mov    -0x20(%rbp),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d2 <main+0x162>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    12cd <main+0x15d>
mov    -0x20(%rbp),%rdi
lea    0xd6e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d2 <main+0x162>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1262 <main+0xf2>
mov    -0x20(%rbp),%rdi
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
mov    -0x24(%rbp),%ecx
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c8a(%rip),%rax
mov    (%rax),%eax
add    $0x30,%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
cmp    $0x4,%edi
je     119b <main+0x1b>
mov    (%rbx),%rsi
call   1070 <exit_error_invalid_arguments@plt>
mov    0x8(%rbx),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11bf <main+0x3f>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdi
call   1040 <exit_error_input_file_opening@plt>
mov    0x10(%rbx),%rdi
lea    0xe38(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11e3 <main+0x63>
mov    (%rbx),%rsi
mov    0x10(%rbx),%rdi
call   10a0 <exit_error_output_file_opening@plt>
mov    0x18(%rbx),%rdx
lea    0xe16(%rip),%rsi
xor    %ebp,%ebp
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x18(%rbx),%rdx
lea    0xe0d(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,(%rsp)
mov    0x18(%rbx),%rdx
lea    0xe04(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    0x2daf(%rip),%rax
cmp    (%rax),%ebx
je     1283 <main+0x103>
lea    0xdf2(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
lea    0xddf(%rip),%rsi
mov    %r12,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    $0x1,%ebp
mov    0x2d69(%rip),%rax
cmp    (%rax),%ebx
jne    12f4 <main+0x174>
lea    0xdb9(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
mov    (%rsp),%rbx
mov    0x18(%rbx),%rdx
lea    0xd9e(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x18(%rbx),%rdx
lea    0xda4(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
mov    $0x2,%r14d
lea    0xd36(%rip),%r13
jmp    133f <main+0x1bf>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
add    $0x1,%r14d
add    $0x1,%ebp
mov    0x2cb1(%rip),%rax
cmp    (%rax),%ebx
je     1283 <main+0x103>
mov    %r14d,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
cmp    %eax,%ebp
jne    1310 <main+0x190>
mov    $0x7,%esi
mov    $0x1,%edx
lea    0xccb(%rip),%rdi
mov    %r12,%rcx
call   1090 <fwrite@plt>
jmp    1310 <main+0x190>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [14 x i8] c"#ifndef %s_H\0A\00"
@.str.3 = [16 x i8] c"#define %s_H\0A\0A\0A\00"
@.str.4 = [18 x i8] c"const char *%s =\0A\00"
@EOF = global i32 0
@.str.5 = [6 x i8] c" \22\00"
@.str.6 = [8 x i8] c"\22\0A \22\00"
@.str.7 = [7 x i8] c"\\x%02x\00"
@.str.8 = [6 x i8] c"\22;\0A\0A\0A\00"
@.str.9 = [29 x i8] c"const size_t %s_LEN = %d;\0A\0A\0A\00"
@.str.10 = [16 x i8] c"#endif // %s_H\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @exit_error_invalid_arguments(i32 %13, i8* %16)
br label %18
18: ; preds = %12, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp ne i32* %23, null
br i1 %24, label %33, label %25
25: ; preds = %18
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @exit_error_input_file_opening(i8* %28, i8* %31)
br label %33
33: ; preds = %25, %18
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %7
%38 = load i32*, i32** %7
%39 = icmp ne i32* %38, null
br i1 %39, label %48, label %40
40: ; preds = %33
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 @exit_error_output_file_opening(i8* %43, i8* %46)
br label %48
48: ; preds = %40, %33
%49 = load i32*, i32** %7
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %52)
%54 = load i32*, i32** %7
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 3
%57 = load i8*, i8** %56
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %57)
%59 = load i32*, i32** %7
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 3
%62 = load i8*, i8** %61
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %62)
store i32 0, i32* %8
br label %64
64: ; preds = %85, %48
%65 = load i32*, i32** %6
%66 = call i32 @fgetc(i32* %65)
store i32 %66, i32* %9
%67 = load i32, i32* @EOF
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %89
69: ; preds = %64
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
%72 = load i32, i32* %8
%73 = icmp eq i32 %72, 1
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i32*, i32** %7
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %85
77: ; preds = %69
%78 = load i32, i32* %8
%79 = srem i32 %78, 10
%80 = icmp eq i32 %79, 1
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = load i32*, i32** %7
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %84
84: ; preds = %81, %77
br label %85
85: ; preds = %84, %74
%86 = load i32*, i32** %7
%87 = load i32, i32* %9
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %87)
br label %64
89: ; preds = %64
%90 = load i32*, i32** %7
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%92 = load i32*, i32** %7
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 3
%95 = load i8*, i8** %94
%96 = load i32, i32* %8
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %95, i32 %96)
%98 = load i32*, i32** %7
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 3
%101 = load i8*, i8** %100
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %101)
%103 = load i32*, i32** %6
%104 = call i32 @fclose(i32* %103)
%105 = load i32*, i32** %7
%106 = call i32 @fclose(i32* %105)
%107 = load i32, i32* @EXIT_SUCCESS
ret i32 %107
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [14 x i8] c"#ifndef %s_H\0A\00"
@.str.3 = [16 x i8] c"#define %s_H\0A\0A\0A\00"
@.str.4 = [18 x i8] c"const char *%s =\0A\00"
@EOF = global i32 0
@.str.5 = [6 x i8] c" \22\00"
@.str.6 = [8 x i8] c"\22\0A \22\00"
@.str.7 = [7 x i8] c"\\x%02x\00"
@.str.8 = [6 x i8] c"\22;\0A\0A\0A\00"
@.str.9 = [29 x i8] c"const size_t %s_LEN = %d;\0A\0A\0A\00"
@.str.10 = [16 x i8] c"#endif // %s_H\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @exit_error_invalid_arguments(i32 %0, i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = load i8*, i8** %1
%15 = tail call i32 @exit_error_input_file_opening(i8* %13, i8* %14)
br label %16
16: ; preds = %12, %7
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i8*, i8** %17
%23 = load i8*, i8** %1
%24 = tail call i32 @exit_error_output_file_opening(i8* %22, i8* %23)
br label %25
25: ; preds = %21, %16
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %26
%30 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %26
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = tail call i32 @fgetc(i32* %10)
%34 = load i32, i32* @EOF
%35 = icmp eq i32 %33, %34
br i1 %35, label %55, label %36
36: ; preds = %25
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 5, i64 1, i32* %19)
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %33)
%39 = tail call i32 @fgetc(i32* %10)
%40 = load i32, i32* @EOF
%41 = icmp eq i32 %39, %40
br i1 %41, label %55, label %42
42: ; preds = %36, %50
%43 = phi i32 [ %52, %50 ], [ %39, %36 ]
%44 = phi i32 [ %45, %50 ], [ 1, %36 ]
%45 = add nuw nsw i32 %44, 1
%46 = urem i32 %45, 10
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %19)
br label %50
50: ; preds = %42, %48
%51 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %43)
%52 = tail call i32 @fgetc(i32* %10)
%53 = load i32, i32* @EOF
%54 = icmp eq i32 %52, %53
br i1 %54, label %55, label %42
55: ; preds = %50, %36, %25
%56 = phi i32 [ 0, %25 ], [ 1, %36 ], [ %45, %50 ]
%57 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i64 5, i64 1, i32* %19)
%58 = load i8*, i8** %26
%59 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %58, i32 %56)
%60 = load i8*, i8** %26
%61 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %60)
%62 = tail call i32 @fclose(i32* %10)
%63 = tail call i32 @fclose(i32* %19)
%64 = load i32, i32* @EXIT_SUCCESS
ret i32 %64
}