#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 EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("No file was provided.\n");
    return 1;
  }
  FILE *input;
  input = fopen(argv[1], "r");
  if (input != NULL) {
    int ch;
    while ((ch = getc(input)) != EOF) {
      printf("%c", ch);
    }
  } else {
    printf("File does not exist.\n");
  }
  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    116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dd <main+0xad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c8 <main+0x98>
jmp    1192 <main+0x62>
mov    -0x18(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e43(%rip),%rcx
cmp    (%rcx),%eax
je     11c3 <main+0x93>
mov    -0x1c(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1192 <main+0x62>
jmp    11d6 <main+0xa6>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jge    1158 <main+0x18>
mov    $0x1,%r14d
lea    0xec1(%rip),%rdi
jmp    11b0 <main+0x70>
mov    0x8(%rsi),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a6 <main+0x66>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e69(%rip),%rbp
xor    %r14d,%r14d
cmp    0x0(%rbp),%eax
je     11b5 <main+0x75>
nopw   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    0x0(%rbp),%eax
jne    1190 <main+0x50>
jmp    11b5 <main+0x75>
xor    %r14d,%r14d
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"No file was provided.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [22 x i8] c"File does not exist.\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 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %32
12: ; preds = %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 i32*, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %29
19: ; preds = %12
br label %20
20: ; preds = %25, %19
%21 = load i32*, i32** %6
%22 = call i32 @getc(i32* %21)
store i32 %22, i32* %7
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %20
28: ; preds = %20
br label %31
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %28
store i32 0, i32* %3
br label %32
32: ; preds = %31, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@str = [21 x i8] c"File does not exist.\00"
@str.4 = [22 x i8] c"No file was provided.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %19, label %9
9: ; preds = %4
%10 = tail call i32 @getc(i32* %7)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %23, label %13
13: ; preds = %9, %13
%14 = phi i32 [ %16, %13 ], [ %10, %9 ]
%15 = tail call i32 @putchar(i32 %14)
%16 = tail call i32 @getc(i32* %7)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %23, label %13
19: ; preds = %4, %2
%20 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0), %2 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0), %4 ]
%21 = phi i32 [ 1, %2 ], [ 0, %4 ]
%22 = tail call i32 @puts(i8* dereferenceable(1) %20)
br label %23
23: ; preds = %13, %19, %9
%24 = phi i32 [ 0, %9 ], [ %21, %19 ], [ 0, %13 ]
ret i32 %24
}