#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*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stderr;
main(int argc, char *argv[]) {
  FILE *fd;
  int c;
  if ((fd = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Can't open %s\n", argv[1]);
    return 1;
  }
  while ((c = fgetc(fd)) != EOF) {
    if (c != 13)
      putchar(c);
  }
  fclose(fd);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b1 <main+0x61>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe62(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f1 <main+0xa1>
jmp    11b6 <main+0x66>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%eax
je     11e8 <main+0x98>
cmpl   $0xd,-0x1c(%rbp)
je     11e3 <main+0x93>
mov    -0x1c(%rbp),%edi
call   1030 <putchar@plt>
jmp    11b6 <main+0x66>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11a7 <main+0x57>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e6a(%rip),%r14
jmp    1188 <main+0x38>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%eax
je     119b <main+0x4b>
cmp    $0xd,%eax
je     1180 <main+0x30>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x30>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11c5 <main+0x75>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xe47(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"Can't open %s\0A\00"
@EOF = global i32 0
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 i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %35
19: ; preds = %2
br label %20
20: ; preds = %31, %19
%21 = load i32*, i32** %6
%22 = call i32 @fgetc(i32* %21)
store i32 %22, i32* %7
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 13
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %7
%30 = call i32 @putchar(i32 %29)
br label %31
31: ; preds = %28, %25
br label %20
32: ; preds = %20
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
br label %35
35: ; preds = %32, %13
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"Can't open %s\0A\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = tail call i32 @fgetc(i32* %5)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %24, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %3
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %26
15: ; preds = %7, %20
%16 = phi i32 [ %21, %20 ], [ %8, %7 ]
%17 = icmp eq i32 %16, 13
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @putchar(i32 %16)
br label %20
20: ; preds = %18, %15
%21 = tail call i32 @fgetc(i32* %5)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %15
24: ; preds = %20, %7
%25 = tail call i32 @fclose(i32* %5)
br label %26
26: ; preds = %24, %11
%27 = phi i32 [ 1, %11 ], [ 0, %24 ]
ret i32 %27
}