#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 */
char EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void main(int argc, char *argv[]) {
  FILE *fp;
  char ch;
  if (argc != 1) {
    if ((fp = fopen(argv[1], "r")) == NULL) {
      printf("File can't be open!\n");
      exit(1);
    }
    ch = getc(fp);
    do {
      putchar(ch);
      ch = getc(fp);
    } while (ch != EOF);
    printf("\n\n\nHere is end of file!\n");
  }
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     11e4 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe88(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a1 <main+0x51>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2e1b(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11ad <main+0x5d>
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
je     11c1 <main+0x71>
mov    0x8(%rsi),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
jne    1184 <main+0x34>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <getc@plt>
mov    0x2e52(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r14),%al
jne    11a0 <main+0x50>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"File can't be open!\0A\00"
@EOF = global i8 0
@.str.2 = [25 x i8] c"\0A\0A\0AHere is end of file!\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %34
9: ; preds = %2
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %5
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = load i32*, i32** %5
%20 = call signext i8 @getc(i32* %19)
store i8 %20, i8* %6
br label %21
21: ; preds = %26, %18
%22 = load i8, i8* %6
%23 = call i32 @putchar(i8 signext %22)
%24 = load i32*, i32** %5
%25 = call signext i8 @getc(i32* %24)
store i8 %25, i8* %6
br label %26
26: ; preds = %21
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br i1 %31, label %21, label %32
32: ; preds = %26
%33 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %2
%35 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@str = [24 x i8] c"\0A\0A\0AHere is end of file!\00"
@str.3 = [20 x i8] c"File can't be open!\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %22, 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, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %4
%13 = tail call signext i8 @getc(i32* %7)
br label %14
14: ; preds = %14, %12
%15 = phi i8 [ %13, %12 ], [ %17, %14 ]
%16 = tail call i32 @putchar(i8 signext %15)
%17 = tail call signext i8 @getc(i32* %7)
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %14
20: ; preds = %14
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
%23 = tail call i32 @exit(i32 1)
unreachable
}