main(argc, argv) int argc;
char *argv[];
{
  int i, n, recno, fd;
  extern struct telescope_tape Tfline;
  if (argc == 0) {
    printf("Filename must be supplied\n\0");
    exit(0);
  }
  if (argc > 0 && (fd = open(argv[1], 0)) == -1) {
    printf("Can't open %s\n", argv[1]);
    exit(0);
  }
  recno = 1;
  n = read(fd, &Tfline, 5120);
  printf("\n\n\t--------          Index of Input Tape           --------\n\n");
  printf("Record  Scan   Off    Source     Observer  RA(1950)  DEC(1950)   "
         "Date     LST\n");
  printf("No      No     Scan   Name          No    hh mm ss  dd mm ss  "
         "mm/dd/yy hh:mm:ss\n\n");
  while (n == 5120) {
    pr_summary(recno);
    recno++;
    n = read(fd, &Tfline, 5120);
  }
  if (n == 0)
    printf("\nEnd of Input\n");
  else
    printf("I/O error reading record number %5d\n", recno);
  recno--;
  printf("Number input records  %6d\n", recno);
  close(fd);
  exit(0);
}


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)
cmpl   $0x0,-0x8(%rbp)
jne    1195 <main+0x35>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11d9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    11d9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2df6(%rip),%rsi
mov    $0x1400,%edx
mov    $0x0,%al
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1400,-0x18(%rbp)
jne    1261 <main+0x101>
mov    -0x1c(%rbp),%edi
mov    $0x0,%al
call   1060 <pr_summary@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2d93(%rip),%rsi
mov    $0x1400,%edx
mov    $0x0,%al
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
jmp    1223 <main+0xc3>
cmpl   $0x0,-0x18(%rbp)
jne    127e <main+0x11e>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x12f>
mov    -0x1c(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%edi
mov    $0x0,%al
call   1040 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jne    118f <main+0x1f>
lea    0xfb6(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jle    11c2 <main+0x52>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1080 <open@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    11c2 <main+0x52>
mov    0x8(%rbx),%rsi
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2e17(%rip),%r14
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1400,%edx
xor    %eax,%eax
call   1060 <read@plt>
mov    %eax,%ebp
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%r12),%ebx
cmp    $0x1400,%ebp
jne    123f <main+0xcf>
mov    %ebx,%edi
xor    %eax,%eax
call   1070 <pr_summary@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1400,%edx
xor    %eax,%eax
call   1060 <read@plt>
mov    %eax,%ebp
mov    %ebx,%r12d
jmp    1210 <main+0xa0>
test   %ebp,%ebp
jne    1251 <main+0xe1>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
jmp    1261 <main+0xf1>
lea    0xdb7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%edi
xor    %eax,%eax
call   1050 <close@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.telescope_tape = type opaque
@.str = [28 x i8] c"Filename must be supplied\0A\00\00"
@.str.1 = [15 x i8] c"Can't open %s\0A\00"
@Tfline = external global %struct.telescope_tape
@.str.2 = [62 x i8] c"\0A\0A\09-------- Index of Input Tape --------\0A\0A\00"
@.str.3 = [79 x i8] c"Record Scan Off Source Observer RA(1950) DEC(1950) Date LST\0A\00"
@.str.4 = [82 x i8] c"No No Scan Name No hh mm ss dd mm ss mm/dd/yy hh:mm:ss\0A\0A\00"
@.str.5 = [15 x i8] c"\0AEnd of Input\0A\00"
@.str.6 = [37 x i8] c"I/O error reading record number %5d\0A\00"
@.str.7 = [27 x i8] c"Number input records %6d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %20, i32 0)
store i32 %21, i32* %9
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %26)
unreachable
28: ; preds = %17, %14
store i32 1, i32* %8
%29 = load i32, i32* %9
%30 = call i32 (i32, %struct.telescope_tape*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, %struct.telescope_tape*, i32, ...)*)(i32 %29, %struct.telescope_tape* @Tfline, i32 5120)
store i32 %30, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %37, %28
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, 5120
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %8
%39 = call i32 (i32, ...) bitcast (i32 (...)* @pr_summary to i32 (i32, ...)*)(i32 %38)
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
%42 = load i32, i32* %9
%43 = call i32 (i32, %struct.telescope_tape*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, %struct.telescope_tape*, i32, ...)*)(i32 %42, %struct.telescope_tape* @Tfline, i32 5120)
store i32 %43, i32* %7
br label %34
44: ; preds = %34
%45 = load i32, i32* %7
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %52
49: ; preds = %44
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %49, %47
%53 = load i32, i32* %8
%54 = add nsw i32 %53, -1
store i32 %54, i32* %8
%55 = load i32, i32* %8
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %9
%58 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %57)
unreachable
}

LLVM IR (-O2):
%struct.telescope_tape = type opaque
@.str.1 = [15 x i8] c"Can't open %s\0A\00"
@Tfline = external global %struct.telescope_tape
@.str.6 = [37 x i8] c"I/O error reading record number %5d\0A\00"
@.str.7 = [27 x i8] c"Number input records %6d\0A\00"
@str = [61 x i8] c"\0A\0A\09-------- Index of Input Tape --------\0A\00"
@str.8 = [78 x i8] c"Record Scan Off Source Observer RA(1950) DEC(1950) Date LST\00"
@str.9 = [81 x i8] c"No No Scan Name No hh mm ss dd mm ss mm/dd/yy hh:mm:ss\0A\00"
@str.10 = [14 x i8] c"\0AEnd of Input\00"
@str.11 = [26 x i8] c"Filename must be supplied\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
6: ; preds = %2
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %16
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %10, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %14)
tail call void @exit(i32 0)
unreachable
16: ; preds = %8, %6
%17 = phi i32 [ %11, %8 ], [ undef, %6 ]
%18 = tail call i32 (i32, %struct.telescope_tape*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, %struct.telescope_tape*, i32, ...)*)(i32 %17, %struct.telescope_tape* @Tfline, i32 5120)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.8, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str.9, i64 0, i64 0))
br label %22
22: ; preds = %25, %16
%23 = phi i32 [ %18, %16 ], [ %28, %25 ]
%24 = phi i32 [ 1, %16 ], [ %27, %25 ]
switch i32 %23, label %31 [
i32 5120, label %25
i32 0, label %29
]
25: ; preds = %22
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @pr_summary to i32 (i32, ...)*)(i32 %24)
%27 = add nuw nsw i32 %24, 1
%28 = tail call i32 (i32, %struct.telescope_tape*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, %struct.telescope_tape*, i32, ...)*)(i32 %17, %struct.telescope_tape* @Tfline, i32 5120)
br label %22
29: ; preds = %22
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0))
br label %33
31: ; preds = %22
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %24)
br label %33
33: ; preds = %31, %29
%34 = add nsw i32 %24, -1
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %34)
%36 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %17)
tail call void @exit(i32 0)
unreachable
}