showfile(file) {
  register int i, cnt;
  char buf[512];
  type(1, "\n");
  if ((i = open(file, 0)) == -1) {
    printf("Can't open %s\n", file);
    return 1;
  }
  do
    if ((cnt = read(i, buf, sizeof buf)) > 0)
      write(1, buf, cnt);
  while (cnt == sizeof buf);
  close(i);
  type(1, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<showfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x1,%edi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <type@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    11b6 <showfile+0x56>
mov    -0x8(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122c <showfile+0xcc>
jmp    11bb <showfile+0x5b>
mov    -0xc(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    11f3 <showfile+0x93>
lea    -0x210(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <write@plt>
jmp    11f8 <showfile+0x98>
movslq -0x10(%rbp),%rax
cmp    $0x200,%rax
je     11bb <showfile+0x5b>
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1060 <close@plt>
mov    $0x1,%edi
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1030 <type@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showfile>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %edi,%ebx
lea    0xe99(%rip),%rsi
mov    $0x1,%r14d
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <type@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     11f1 <showfile+0x91>
mov    %eax,%ebp
mov    %rsp,%r14
nopl   0x0(%rax,%rax,1)
mov    $0x200,%edx
mov    %ebp,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <read@plt>
test   %eax,%eax
jle    11d0 <showfile+0x70>
mov    %eax,%ebx
mov    $0x1,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <write@plt>
cmp    $0x200,%ebx
je     11a0 <showfile+0x40>
xor    %r14d,%r14d
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <close@plt>
lea    0xe2a(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <type@plt>
jmp    1201 <showfile+0xa1>
lea    0xe08(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [15 x i8] c"Can't open %s\0A\00"
define i32 @showfile(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [512 x i8]
store i32 %0, i32* %3
%7 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @type to i32 (i32, i8*, ...)*)(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = call i32 (i32, i32, ...) bitcast (i32 (...)* @open to i32 (i32, i32, ...)*)(i32 %8, i32 0)
store i32 %9, i32* %4
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i32 1, i32* %2
br label %33
14: ; preds = %1
br label %15
15: ; preds = %25, %14
%16 = load i32, i32* %4
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%18 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i64, ...)*)(i32 %16, i8* %17, i64 512)
store i32 %18, i32* %5
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* %21, i32 %22)
br label %24
24: ; preds = %20, %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = icmp eq i64 %27, 512
br i1 %28, label %15, label %29
29: ; preds = %25
%30 = load i32, i32* %4
%31 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %30)
%32 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @type to i32 (i32, i8*, ...)*)(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %33
33: ; preds = %29, %11
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [15 x i8] c"Can't open %s\0A\00"
define i32 @showfile(i32 %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i32, i8*, ...) bitcast (i32 (...)* @type to i32 (i32, i8*, ...)*)(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @open to i32 (i32, i32, ...)*)(i32 %0, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %18
9: ; preds = %1, %12
%10 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i64, ...)*)(i32 %5, i8* %3, i64 512)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* %3, i32 %10)
%14 = icmp eq i32 %10, 512
br i1 %14, label %9, label %15
15: ; preds = %9, %12
%16 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %5)
%17 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @type to i32 (i32, i8*, ...)*)(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %7
%19 = phi i32 [ 1, %7 ], [ 0, %15 ]
ret i32 %19
}