#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 */

/* Variables and functions */
int EOF;
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ freopen(char *, char *, int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char *in, *out;
  int c;
  const int eof = EOF;
  if (argc < 4)
    return 1;
  in = argv[2];
  out = argv[3];
  if (freopen(in, "r", stdin) == 0)
    return 1;
  if (freopen(out, "w", stdout) == 0)
    return 1;
  printf("{-# LINE 1 \"%s\" #-}\n", in);
  while ((c = getchar()) != eof)
    if (c <= 127)
      putchar(c);
    else
      printf("\\x%02x", c);
  fflush(stdout);
  return (!feof(stdin));
}


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)
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1198 <main+0x38>
movl   $0x1,-0x4(%rbp)
jmp    128c <main+0x12c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
lea    0xe3c(%rip),%rsi
call   1050 <freopen@plt>
cmp    $0x0,%rax
jne    11df <main+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    128c <main+0x12c>
mov    -0x20(%rbp),%rdi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
lea    0xe0f(%rip),%rsi
call   1050 <freopen@plt>
cmp    $0x0,%rax
jne    120e <main+0xae>
movl   $0x1,-0x4(%rbp)
jmp    128c <main+0x12c>
mov    -0x18(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x24(%rbp)
cmp    -0x28(%rbp),%eax
je     1260 <main+0x100>
cmpl   $0x7f,-0x24(%rbp)
jg     124a <main+0xea>
mov    -0x24(%rbp),%edi
call   1030 <putchar@plt>
jmp    125b <main+0xfb>
mov    -0x24(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1220 <main+0xc0>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%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    $0x1,%ebx
cmp    $0x4,%edi
jl     11fd <main+0x9d>
mov    0x2e60(%rip),%rax
mov    (%rax),%ebp
mov    0x10(%rsi),%r14
mov    0x18(%rsi),%r15
mov    0x2e57(%rip),%r12
mov    (%r12),%edx
lea    0xe64(%rip),%rsi
mov    %r14,%rdi
call   1050 <freopen@plt>
test   %rax,%rax
je     11fd <main+0x9d>
mov    0x2e20(%rip),%r13
mov    0x0(%r13),%edx
lea    0xe47(%rip),%rsi
mov    %r15,%rdi
call   1050 <freopen@plt>
test   %rax,%rax
je     11fd <main+0x9d>
lea    0xe35(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    %ebp,%eax
jne    120e <main+0xae>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    (%r12),%edi
call   1070 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe04(%rip),%rbx
jmp    1237 <main+0xd7>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    %ebp,%eax
je     11e4 <main+0x84>
cmp    $0x7f,%eax
jg     1220 <main+0xc0>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    122c <main+0xcc>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [21 x i8] c"{-# LINE 1 \22%s\22 #-}\0A\00"
@.str.3 = [7 x i8] c"\\x%02x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%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* @EOF
store i32 %10, i32* %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %57
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8*, i8** %6
%22 = load i32, i32* @stdin
%23 = call i64 @freopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %14
store i32 1, i32* %3
br label %57
26: ; preds = %14
%27 = load i8*, i8** %7
%28 = load i32, i32* @stdout
%29 = call i64 @freopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 1, i32* %3
br label %57
32: ; preds = %26
%33 = load i8*, i8** %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %48, %32
%36 = call i32 (...) @getchar()
store i32 %36, i32* %8
%37 = load i32, i32* %9
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = load i32, i32* %8
%41 = icmp sle i32 %40, 127
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %8
%44 = call i32 @putchar(i32 %43)
br label %48
45: ; preds = %39
%46 = load i32, i32* %8
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %42
br label %35
49: ; preds = %35
%50 = load i32, i32* @stdout
%51 = call i32 @fflush(i32 %50)
%52 = load i32, i32* @stdin
%53 = call i32 @feof(i32 %52)
%54 = icmp ne i32 %53, 0
%55 = xor i1 %54, true
%56 = zext i1 %55 to i32
store i32 %56, i32* %3
br label %57
57: ; preds = %49, %31, %25, %13
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [21 x i8] c"{-# LINE 1 \22%s\22 #-}\0A\00"
@.str.3 = [7 x i8] c"\\x%02x\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @EOF
%4 = icmp slt i32 %0, 4
br i1 %4, label %38, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8*, i8** %1, i64 3
%9 = load i8*, i8** %8
%10 = load i32, i32* @stdin
%11 = tail call i64 @freopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %38, label %13
13: ; preds = %5
%14 = load i32, i32* @stdout
%15 = tail call i64 @freopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %38, label %17
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%19 = tail call i32 (...) @getchar()
%20 = icmp eq i32 %19, %3
br i1 %20, label %31, label %21
21: ; preds = %17, %28
%22 = phi i32 [ %29, %28 ], [ %19, %17 ]
%23 = icmp slt i32 %22, 128
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @putchar(i32 %22)
br label %28
26: ; preds = %21
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %28
28: ; preds = %26, %24
%29 = tail call i32 (...) @getchar()
%30 = icmp eq i32 %29, %3
br i1 %30, label %31, label %21
31: ; preds = %28, %17
%32 = load i32, i32* @stdout
%33 = tail call i32 @fflush(i32 %32)
%34 = load i32, i32* @stdin
%35 = tail call i32 @feof(i32 %34)
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %13, %5, %2, %31
%39 = phi i32 [ %37, %31 ], [ 1, %2 ], [ 1, %5 ], [ 1, %13 ]
ret i32 %39
}