#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ processFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr,
            "%s: program expected 1 argument, but instead recieved %i \n",
            argv[0], argc - 1);
    exit(EXIT_FAILURE);
  } else {
    FILE *filename;
    filename = fopen(argv[1], "r");
    if (filename == NULL) {
      printf("\n");
      printf("Could not open file or file not found! \n");
      fclose(filename);
      exit(EXIT_FAILURE);
    } else {
      printf("\n");
      processFile(filename);
      fclose(filename);
      exit(EXIT_SUCCESS);
    }
  }
  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)
je     11b0 <main+0x50>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
lea    0xe63(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1202 <main+0xa2>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <processFile@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11ad <main+0x3d>
mov    0x8(%rsi),%rdi
lea    0xeba(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
jne    11d8 <main+0x68>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <fclose@plt>
jmp    11ca <main+0x5a>
mov    %edi,%ecx
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
add    $0xffffffff,%ecx
lea    0xe3b(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rbx,%rdi
call   1060 <processFile@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"%s: program expected 1 argument, but instead recieved %i \0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [41 x i8] c"Could not open file or file not found! \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32*, i32** %6
%30 = call i32 @fclose(i32* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %19
%34 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32*, i32** %6
%36 = call i32 @processFile(i32* %35)
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
%39 = load i32, i32* @EXIT_SUCCESS
%40 = call i32 @exit(i32 %39)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"%s: program expected 1 argument, but instead recieved %i \0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@EXIT_SUCCESS = global i32 0
@str = [40 x i8] c"Could not open file or file not found! \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = add nsw i32 %0, -1
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
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 ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
%16 = tail call i32 @putchar(i32 10)
br i1 %15, label %17, label %22
17: ; preds = %11
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @fclose(i32* null)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %11
%23 = tail call i32 @processFile(i32* %14)
%24 = tail call i32 @fclose(i32* %14)
%25 = load i32, i32* @EXIT_SUCCESS
%26 = tail call i32 @exit(i32 %25)
unreachable
}