#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*/ errorDump(char *);
int /*<<< orphan*/ f2v(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    errorDump("Too less args!");
  }
  FILE *inputFile, *outputFile;
  inputFile = fopen(argv[1], "r");
  outputFile = fopen(argv[2], "w");
  if (inputFile == NULL || outputFile == NULL) {
    errorDump("Cannot open the input or output file");
  }
  f2v(inputFile, outputFile);
  fclose(inputFile);
  fclose(outputFile);
  printf("Translate %s to %s done.\n", argv[1], argv[2]);
  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   $0x2,-0x8(%rbp)
jge    117c <main+0x2c>
lea    0xe89(%rip),%rdi
call   1070 <errorDump@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe84(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c2 <main+0x72>
cmpq   $0x0,-0x20(%rbp)
jne    11ce <main+0x7e>
lea    0xe4a(%rip),%rdi
call   1070 <errorDump@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <f2v@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x1,%edi
jg     1169 <main+0x19>
lea    0xe9c(%rip),%rdi
call   1070 <errorDump@plt>
mov    0x8(%r14),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    0x10(%r14),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %r15,%r15
je     1199 <main+0x49>
test   %rbx,%rbx
jne    11a5 <main+0x55>
lea    0xe73(%rip),%rdi
call   1070 <errorDump@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <f2v@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x8(%r14),%rsi
mov    0x10(%r14),%rdx
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Too less args!\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [37 x i8] c"Cannot open the input or output file\00"
@.str.4 = [26 x i8] c"Translate %s to %s done.\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 slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @errorDump(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%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 i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %12
%24 = load i32*, i32** %7
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23, %12
%27 = call i32 @errorDump(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = load i32*, i32** %6
%30 = load i32*, i32** %7
%31 = call i32 @f2v(i32* %29, i32* %30)
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
%34 = load i32*, i32** %7
%35 = call i32 @fclose(i32* %34)
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %38, i8* %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Too less args!\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [37 x i8] c"Cannot open the input or output file\00"
@.str.4 = [26 x i8] c"Translate %s to %s done.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @errorDump(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%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 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %9, null
%14 = icmp eq i32* %12, null
%15 = or i1 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %6
%17 = tail call i32 @errorDump(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %6, %16
%19 = tail call i32 @f2v(i32* %9, i32* %12)
%20 = tail call i32 @fclose(i32* %9)
%21 = tail call i32 @fclose(i32* %12)
%22 = load i8*, i8** %7
%23 = load i8*, i8** %10
%24 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %22, i8* %23)
ret i32 0
}