#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 size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
size_t read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int fd;
  ssize_t read_bites;
  char buffer[64 + 1];
  if (argc < 2) {
    fprintf(stderr, "Too few arguments\n");
    exit(1);
  }
  fd = open(argv[1], O_RDONLY);
  if (fd < 0) {
    fprintf(stderr, "Cannot open file\n");
    exit(1);
  }
  while ((read_bites = read(fd, buffer, 64)) > 0) {
    buffer[read_bites] = 0;
    fputs(buffer, stdout);
  }
  close(fd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119f <main+0x3f>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11e1 <main+0x81>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11e6 <main+0x86>
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x40,%edx
call   1050 <read@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jbe    1225 <main+0xc5>
mov    -0x20(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
jmp    11e6 <main+0x86>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
cmp    $0x1,%edi
jg     117f <main+0x1f>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
jmp    11a5 <main+0x45>
mov    0x8(%rsi),%rdi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
test   %eax,%eax
jns    11b4 <main+0x54>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x40,%edx
call   1050 <read@plt>
test   %rax,%rax
je     1203 <main+0xa3>
mov    0x2dff(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,(%rsp,%rax,1)
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <fputs@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1050 <read@plt>
test   %rax,%rax
jne    11e0 <main+0x80>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Too few arguments\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [18 x i8] c"Cannot open file\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca [65 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @O_RDONLY
%20 = call i32 @open(i8* %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %15
br label %28
28: ; preds = %33, %27
%29 = load i32, i32* %6
%30 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%31 = call i64 @read(i32 %29, i8* %30, i32 64)
store i64 %31, i64* %7
%32 = icmp ugt i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %28
%34 = load i64, i64* %7
%35 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 %34
store i8 0, i8* %35
%36 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%37 = load i32, i32* @stdout
%38 = call i32 @fputs(i8* %36, i32 %37)
br label %28
39: ; preds = %28
%40 = load i32, i32* %6
%41 = call i32 @close(i32 %40)
%42 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Too few arguments\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [18 x i8] c"Cannot open file\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = call i64 @read(i32 %14, i8* %4, i32 64)
%18 = icmp eq i64 %17, 0
br i1 %18, label %30, label %23
19: ; preds = %10
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %16, %23
%24 = phi i64 [ %28, %23 ], [ %17, %16 ]
%25 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i32, i32* @stdout
%27 = call i32 @fputs(i8* %4, i32 %26)
%28 = call i64 @read(i32 %14, i8* %4, i32 64)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %23
30: ; preds = %23, %16
%31 = call i32 @close(i32 %14)
%32 = call i32 @exit(i32 0)
unreachable
}