void cat(void) {
  unsigned short int i;
  unsigned short int j;
  unsigned short int equal;
  unsigned char filename[16 + 2];
  unsigned char str[256];
  char c;
  int rc;
  int line = 0;
  puts0("file ? ");
  for (i = 0; i < 16; i++)
    str[i] = 0;
  getsn(str, 256);
  for (i = 0; i < 16; i++)
    filename[i] = str[i];
  filename[16] = 0;
  rc = open_(filename, 0);
  if (rc != -1) {
  } else {
    puts0("can't open file\r\n");
    return;
  }
  while (readc(0, &c) == 0)
    if (c == '\n') {
      puts0("\r\n");
      if (++line > 23) {
        puts0(" MORE ");
        puts0(filename);
        c = getch();
        if (c == 'q') {
          close_(rc);
          return;
        }
        line = 0;
        putch('\r');
        for (i = 0; i < 70; i++)
          putch(' ');
        putch('\r');
      }
    } else
      putch(c);
  close_(0);
}


x86 assembly (clang, -O0):
<cat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x12c(%rbp)
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1060 <puts0@plt>
movw   $0x0,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
cmp    $0x10,%eax
jge    11c3 <cat+0x53>
movzwl -0x2(%rbp),%eax
movb   $0x0,-0x120(%rbp,%rax,1)
mov    -0x2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x2(%rbp)
jmp    1199 <cat+0x29>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
mov    $0x0,%al
call   1030 <getsn@plt>
movw   $0x0,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
cmp    $0x10,%eax
jge    120d <cat+0x9d>
movzwl -0x2(%rbp),%eax
mov    -0x120(%rbp,%rax,1),%cl
movzwl -0x2(%rbp),%eax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x2(%rbp)
jmp    11dc <cat+0x6c>
movb   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1040 <open_@plt>
mov    %eax,-0x128(%rbp)
cmpl   $0xffffffff,-0x128(%rbp)
je     1236 <cat+0xc6>
jmp    1249 <cat+0xd9>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1060 <puts0@plt>
jmp    1358 <cat+0x1e8>
jmp    124e <cat+0xde>
xor    %edi,%edi
lea    -0x121(%rbp),%rsi
mov    $0x0,%al
call   1070 <readc@plt>
cmp    $0x0,%eax
jne    134f <cat+0x1df>
movsbl -0x121(%rbp),%eax
cmp    $0xa,%eax
jne    133c <cat+0x1cc>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1060 <puts0@plt>
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
cmp    $0x17,%eax
jle    1337 <cat+0x1c7>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1060 <puts0@plt>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1060 <puts0@plt>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x121(%rbp)
movsbl -0x121(%rbp),%eax
cmp    $0x71,%eax
jne    12e5 <cat+0x175>
mov    -0x128(%rbp),%edi
mov    $0x0,%al
call   1090 <close_@plt>
jmp    1358 <cat+0x1e8>
movl   $0x0,-0x12c(%rbp)
mov    $0xd,%edi
mov    $0x0,%al
call   1080 <putch@plt>
movw   $0x0,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
cmp    $0x46,%eax
jge    132b <cat+0x1bb>
mov    $0x20,%edi
mov    $0x0,%al
call   1080 <putch@plt>
mov    -0x2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x2(%rbp)
jmp    1301 <cat+0x191>
mov    $0xd,%edi
mov    $0x0,%al
call   1080 <putch@plt>
jmp    134a <cat+0x1da>
movsbl -0x121(%rbp),%edi
mov    $0x0,%al
call   1080 <putch@plt>
jmp    124e <cat+0xde>
xor    %edi,%edi
mov    $0x0,%al
call   1090 <close_@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1060 <puts0@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1030 <getsn@plt>
movaps 0x30(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <open_@plt>
cmp    $0xffffffff,%eax
je     11ea <cat+0x7a>
mov    %eax,%r13d
lea    0xf(%rsp),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1070 <readc@plt>
test   %eax,%eax
je     120a <cat+0x9a>
xor    %edi,%edi
xor    %eax,%eax
call   1090 <close_@plt>
jmp    11f8 <cat+0x88>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1060 <puts0@plt>
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe06(%rip),%r14
lea    0x10(%rsp),%r12
lea    0xf(%rsp),%rbx
xor    %ebp,%ebp
jmp    1237 <cat+0xc7>
nop
xor    %eax,%eax
call   1080 <putch@plt>
xor    %edi,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <readc@plt>
test   %eax,%eax
jne    11df <cat+0x6f>
movsbl 0xf(%rsp),%edi
cmp    $0xa,%edi
jne    1220 <cat+0xb0>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <puts0@plt>
cmp    $0x17,%ebp
jl     12b0 <cat+0x140>
lea    0xdc3(%rip),%rdi
xor    %eax,%eax
call   1060 <puts0@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <puts0@plt>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %al,0xf(%rsp)
cmp    $0x71,%al
je     12b8 <cat+0x148>
mov    $0xd,%edi
xor    %eax,%eax
call   1080 <putch@plt>
mov    $0x46,%r15w
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    $0x20,%edi
xor    %eax,%eax
call   1080 <putch@plt>
add    $0xffff,%r15w
jne    1290 <cat+0x120>
mov    $0xd,%edi
jmp    1220 <cat+0xb0>
nop
add    $0x1,%ebp
jmp    1227 <cat+0xb7>
mov    %r13d,%edi
jmp    11e1 <cat+0x71>

LLVM IR (-O0):
@.str = [8 x i8] c"file ? \00"
@.str.1 = [18 x i8] c"can't open file\0D\0A\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [7 x i8] c" MORE \00"
define void @cat() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca [18 x i8]
%5 = alloca [256 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %8
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i16 0, i16* %1
br label %10
10: ; preds = %18, %0
%11 = load i16, i16* %1
%12 = zext i16 %11 to i32
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i16, i16* %1
%16 = zext i16 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %14
%19 = load i16, i16* %1
%20 = add i16 %19, 1
store i16 %20, i16* %1
br label %10
21: ; preds = %10
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%23 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @getsn to i32 (i8*, i32, ...)*)(i8* %22, i32 256)
store i16 0, i16* %1
br label %24
24: ; preds = %36, %21
%25 = load i16, i16* %1
%26 = zext i16 %25 to i32
%27 = icmp slt i32 %26, 16
br i1 %27, label %28, label %39
28: ; preds = %24
%29 = load i16, i16* %1
%30 = zext i16 %29 to i64
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i16, i16* %1
%34 = zext i16 %33 to i64
%35 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %28
%37 = load i16, i16* %1
%38 = add i16 %37, 1
store i16 %38, i16* %1
br label %24
39: ; preds = %24
%40 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 16
store i8 0, i8* %40
%41 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%42 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open_ to i32 (i8*, i32, ...)*)(i8* %41, i32 0)
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = icmp ne i32 %43, -1
br i1 %44, label %45, label %46
45: ; preds = %39
br label %48
46: ; preds = %39
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %94
48: ; preds = %45
br label %49
49: ; preds = %91, %48
%50 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @readc to i32 (i32, i8*, ...)*)(i32 0, i8* %6)
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %92
52: ; preds = %49
%53 = load i8, i8* %6
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 10
br i1 %55, label %56, label %87
56: ; preds = %52
%57 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
%60 = icmp sgt i32 %59, 23
br i1 %60, label %61, label %86
61: ; preds = %56
%62 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%63 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%64 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* %63)
%65 = call i32 (...) @getch()
%66 = trunc i32 %65 to i8
store i8 %66, i8* %6
%67 = load i8, i8* %6
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 113
br i1 %69, label %70, label %73
70: ; preds = %61
%71 = load i32, i32* %7
%72 = call i32 (i32, ...) bitcast (i32 (...)* @close_ to i32 (i32, ...)*)(i32 %71)
br label %94
73: ; preds = %61
store i32 0, i32* %8
%74 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 13)
store i16 0, i16* %1
br label %75
75: ; preds = %81, %73
%76 = load i16, i16* %1
%77 = zext i16 %76 to i32
%78 = icmp slt i32 %77, 70
br i1 %78, label %79, label %84
79: ; preds = %75
%80 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 32)
br label %81
81: ; preds = %79
%82 = load i16, i16* %1
%83 = add i16 %82, 1
store i16 %83, i16* %1
br label %75
84: ; preds = %75
%85 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 13)
br label %86
86: ; preds = %84, %56
br label %91
87: ; preds = %52
%88 = load i8, i8* %6
%89 = sext i8 %88 to i32
%90 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 %89)
br label %91
91: ; preds = %87, %86
br label %49
92: ; preds = %49
%93 = call i32 (i32, ...) bitcast (i32 (...)* @close_ to i32 (i32, ...)*)(i32 0)
br label %94
94: ; preds = %92, %70, %46
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"file ? \00"
@.str.1 = [18 x i8] c"can't open file\0D\0A\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [7 x i8] c" MORE \00"
define void @cat() {
%1 = alloca [18 x i8]
%2 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = alloca i8
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @getsn to i32 (i8*, i32, ...)*)(i8* %7, i32 256)
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 16
store i8 0, i8* %10
%11 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open_ to i32 (i8*, i32, ...)*)(i8* %6, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @readc to i32 (i32, i8*, ...)*)(i32 0, i8* %5)
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %52
16: ; preds = %0
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %54
18: ; preds = %13, %48
%19 = phi i32 [ %49, %48 ], [ 0, %13 ]
%20 = load i8, i8* %5
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%24 = add nsw i32 %19, 1
%25 = icmp sgt i32 %19, 22
br i1 %25, label %26, label %48
26: ; preds = %22
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @puts0 to i32 (i8*, ...)*)(i8* %6)
%29 = call i32 (...) @getch()
%30 = trunc i32 %29 to i8
store i8 %30, i8* %5
%31 = and i32 %29, 255
%32 = icmp eq i32 %31, 113
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = call i32 (i32, ...) bitcast (i32 (...)* @close_ to i32 (i32, ...)*)(i32 %11)
br label %54
35: ; preds = %26
%36 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 13)
br label %37
37: ; preds = %35, %37
%38 = phi i16 [ 0, %35 ], [ %40, %37 ]
%39 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 32)
%40 = add nuw nsw i16 %38, 1
%41 = icmp eq i16 %40, 70
br i1 %41, label %44, label %37
42: ; preds = %18
%43 = sext i8 %20 to i32
br label %44
44: ; preds = %37, %42
%45 = phi i32 [ %43, %42 ], [ 13, %37 ]
%46 = phi i32 [ %19, %42 ], [ 0, %37 ]
%47 = call i32 (i32, ...) bitcast (i32 (...)* @putch to i32 (i32, ...)*)(i32 %45)
br label %48
48: ; preds = %44, %22
%49 = phi i32 [ %24, %22 ], [ %46, %44 ]
%50 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @readc to i32 (i32, i8*, ...)*)(i32 0, i8* %5)
%51 = icmp eq i32 %50, 0
br i1 %51, label %18, label %52
52: ; preds = %48, %13
%53 = call i32 (i32, ...) bitcast (i32 (...)* @close_ to i32 (i32, ...)*)(i32 0)
br label %54
54: ; preds = %52, %33, %16
ret void
}