#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i, c;
  FILE *rfp, *wfp;
  if (argc < 3) {
    fprintf(stderr, "Usage: %s inputfilename outputfilename\n\n", argv[0]);
    exit(1);
  }
  rfp = fopen(argv[1], "rb");
  if (rfp == NULL) {
    fprintf(stderr, "cannot open \"%s\"\n", argv[1]);
    exit(1);
  }
  wfp = fopen(argv[2], "wb");
  if (wfp == NULL) {
    fprintf(stderr, "cannot create  \"%s\"e\n", argv[2]);
    exit(1);
  }
  for (;;) {
    fprintf(wfp, "             \"");
    for (i = 0; i < 24; i++) {
      c = fgetc(rfp);
      if (c == EOF)
        break;
      c = fprintf(wfp, "\\x%02x", c);
      if (c < 0)
        goto end;
    }
    fprintf(wfp, "\"\n");
    if (c == EOF)
      break;
  }
end:
  fclose(rfp);
  fclose(wfp);
  exit(0);
}


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   $0x3,-0x8(%rbp)
jge    1199 <main+0x49>
mov    0x2e61(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e6 <main+0x96>
mov    0x2e15(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1233 <main+0xe3>
mov    0x2dc8(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1238 <main+0xe8>
mov    -0x28(%rbp),%rdi
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x18,-0x14(%rbp)
jge    12b8 <main+0x168>
mov    -0x20(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2d77(%rip),%rcx
cmp    (%rcx),%eax
jne    127e <main+0x12e>
jmp    12b8 <main+0x168>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12a5 <main+0x155>
jmp    12eb <main+0x19b>
jmp    12aa <main+0x15a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1251 <main+0x101>
mov    -0x28(%rbp),%rdi
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    0x2d14(%rip),%rcx
cmp    (%rcx),%eax
jne    12e1 <main+0x191>
jmp    12e6 <main+0x196>
jmp    1238 <main+0xe8>
jmp    12eb <main+0x19b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x2,%edi
jg     1189 <main+0x29>
mov    0x2e5e(%rip),%rax
movslq (%rax),%rdi
mov    (%r15),%rdx
lea    0xe79(%rip),%rsi
jmp    11e2 <main+0x82>
mov    0x8(%r15),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
jne    11b5 <main+0x55>
mov    0x2e33(%rip),%rax
movslq (%rax),%rdi
mov    0x8(%r15),%rdx
lea    0xe79(%rip),%rsi
jmp    11e2 <main+0x82>
mov    %rax,%r14
mov    0x10(%r15),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
jne    11f3 <main+0x93>
mov    0x2e04(%rip),%rax
movslq (%rax),%rdi
mov    0x10(%r15),%rdx
lea    0xe5f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%rbx
mov    0x2deb(%rip),%r15
lea    0xe62(%rip),%r13
jmp    122e <main+0xce>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe1a(%rip),%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
cmp    (%r15),%ebp
je     127c <main+0x11c>
mov    $0xe,%esi
mov    $0x1,%edx
lea    0xe18(%rip),%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    $0x18,%r12d
nopl   (%rax)
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     1210 <main+0xb0>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %eax,%eax
js     127c <main+0x11c>
mov    %eax,%ebp
add    $0xffffffff,%r12d
jne    1250 <main+0xf0>
jmp    1210 <main+0xb0>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Usage: %s inputfilename outputfilename\0A\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [18 x i8] c"cannot open \22%s\22\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [22 x i8] c"cannot create \22%s\22e\0A\00"
@.str.5 = [15 x i8] c" \22\00"
@EOF = global i32 0
@.str.6 = [7 x i8] c"\\x%02x\00"
@.str.7 = [3 x i8] c"\22\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = load i8*, i8** %1
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load i8*, i8** %12
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %11
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
%32 = load i8*, i8** %24
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %23, %48
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 14, i64 1, i32* %26)
br label %40
37: ; preds = %45
%38 = add nuw nsw i32 %41, 1
%39 = icmp eq i32 %38, 24
br i1 %39, label %48, label %40
40: ; preds = %35, %37
%41 = phi i32 [ 0, %35 ], [ %38, %37 ]
%42 = tail call i32 @fgetc(i32* %14)
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %48, label %45
45: ; preds = %40
%46 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %42)
%47 = icmp slt i32 %46, 0
br i1 %47, label %53, label %37
48: ; preds = %40, %37
%49 = phi i32 [ %42, %40 ], [ %46, %37 ]
%50 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 2, i64 1, i32* %26)
%51 = load i32, i32* @EOF
%52 = icmp eq i32 %49, %51
br i1 %52, label %53, label %35
53: ; preds = %48, %45
%54 = tail call i32 @fclose(i32* %14)
%55 = tail call i32 @fclose(i32* %26)
%56 = tail call i32 @exit(i32 0)
unreachable
}