#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ transformInfile(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fin;
  FILE *fout;
  if (argc != 3) {
    printf("Usage: a.out outputFileName inputFileName \n");
    return -1;
  }
  fin = fopen(argv[2], "r");
  if (fin == NULL) {
    printf("\nUnable to open file: %s!\n", argv[2]);
    return -1;
  }
  fout = fopen(argv[1], "w");
  if (fout == NULL) {
    printf("\nUnable to open output file: %s!\n", argv[1]);
    return -1;
  }
  transformInfile(fin, fout);
  fclose(fin);
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <main+0xea>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11bf <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <main+0xea>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1204 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <main+0xea>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <transformInfile@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    11ac <main+0x5c>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ba <main+0x6a>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c7 <main+0x77>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <transformInfile@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    11de <main+0x8e>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
jmp    11d9 <main+0x89>
mov    0x10(%rbx),%rsi
lea    0xe3d(%rip),%rdi
jmp    11d2 <main+0x82>
mov    0x8(%rbx),%rsi
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Usage: a.out outputFileName inputFileName \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"\0AUnable to open file: %s!\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [34 x i8] c"\0AUnable to open output file: %s!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %44
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %22)
store i32 -1, i32* %3
br label %44
24: ; preds = %12
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %28, i32** %7
%29 = load i32*, i32** %7
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %36
31: ; preds = %24
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %34)
store i32 -1, i32* %3
br label %44
36: ; preds = %24
%37 = load i32*, i32** %6
%38 = load i32*, i32** %7
%39 = call i32 @transformInfile(i32* %37, i32* %38)
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
store i32 0, i32* %3
br label %44
44: ; preds = %36, %31, %19, %10
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"\0AUnable to open file: %s!\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [34 x i8] c"\0AUnable to open output file: %s!\0A\00"
@str = [43 x i8] c"Usage: a.out outputFileName inputFileName \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %26
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %26
14: ; preds = %6
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %20)
br label %26
22: ; preds = %14
%23 = tail call i32 @transformInfile(i32* %9, i32* %17)
%24 = tail call i32 @fclose(i32* %9)
%25 = tail call i32 @fclose(i32* %17)
br label %26
26: ; preds = %22, %19, %11, %4
%27 = phi i32 [ -1, %4 ], [ -1, %11 ], [ -1, %19 ], [ 0, %22 ]
ret i32 %27
}