#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 EXIT_FAILURE;
int /*<<< orphan*/ displayHeader();
int /*<<< orphan*/ displayHelp(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ perror(char *);
int tiCalcToText(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  const char *inFileName = argv[1];
  const char *outFileName = argv[2];
  FILE *inFile;
  FILE *outFile;
  displayHeader();
  if (argc != 3) {
    displayHelp(*argv);
    return EXIT_FAILURE;
  }
  if (!(inFile = fopen(inFileName, "r"))) {
    perror("Error opening input file");
    return EXIT_FAILURE;
  }
  if (!(outFile = fopen(outFileName, "w"))) {
  }
  int exit_code = tiCalcToText(inFile, outFile);
  fclose(inFile);
  fclose(outFile);
  return exit_code;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <displayHeader@plt>
cmpl   $0x3,-0x8(%rbp)
je     11bc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <displayHelp@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1242 <main+0xe2>
mov    -0x18(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11f7 <main+0x97>
lea    0xe21(%rip),%rdi
call   1070 <perror@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1242 <main+0xe2>
mov    -0x20(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    121a <main+0xba>
jmp    121a <main+0xba>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <tiCalcToText@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%r14
xor    %eax,%eax
call   1080 <displayHeader@plt>
cmp    $0x3,%ebp
jne    11cc <main+0x6c>
lea    0xe79(%rip),%rsi
mov    %r15,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e8 <main+0x88>
mov    %rax,%rbx
lea    0xe7d(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <tiCalcToText@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
jmp    11dd <main+0x7d>
mov    (%rbx),%rdi
call   1040 <displayHelp@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe13(%rip),%rdi
call   1070 <perror@plt>
jmp    11d4 <main+0x74>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Error opening input file\00"
@.str.2 = [2 x i8] c"w\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*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = call i32 (...) @displayHeader()
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 3
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32 @displayHelp(i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
br label %46
25: ; preds = %2
%26 = load i8*, i8** %6
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %8
%28 = icmp ne i32* %27, null
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %46
32: ; preds = %25
%33 = load i8*, i8** %7
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %9
%35 = icmp ne i32* %34, null
br i1 %35, label %37, label %36
36: ; preds = %32
br label %37
37: ; preds = %36, %32
%38 = load i32*, i32** %8
%39 = load i32*, i32** %9
%40 = call i32 @tiCalcToText(i32* %38, i32* %39)
store i32 %40, i32* %10
%41 = load i32*, i32** %8
%42 = call i32 @fclose(i32* %41)
%43 = load i32*, i32** %9
%44 = call i32 @fclose(i32* %43)
%45 = load i32, i32* %10
store i32 %45, i32* %3
br label %46
46: ; preds = %37, %29, %20
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Error opening input file\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 (...) @displayHeader()
%8 = icmp eq i32 %0, 3
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @displayHelp(i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
br label %24
13: ; preds = %2
%14 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
br label %24
19: ; preds = %13
%20 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @tiCalcToText(i32* %14, i32* %20)
%22 = tail call i32 @fclose(i32* %14)
%23 = tail call i32 @fclose(i32* %20)
br label %24
24: ; preds = %19, %16, %9
%25 = phi i32 [ %12, %9 ], [ %21, %19 ], [ %18, %16 ]
ret i32 %25
}