int read_test_1(int fd) {
  rewind_tape(fd);
  read_block(fd, 8 * 1024);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  space_forward_filemark(fd, 3);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  read_block(fd, 64 * 1024);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  space_back_block(fd, 1);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  read_block(fd, 32 * 1024);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  return 0;
}


x86 assembly (clang, -O0):
<read_test_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <rewind_tape@plt>
mov    -0x4(%rbp),%edi
mov    $0x2000,%esi
mov    $0x0,%al
call   1080 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe69(%rip),%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x0,%al
call   1070 <space_forward_filemark@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe39(%rip),%rdi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x10000,%esi
mov    $0x0,%al
call   1080 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe09(%rip),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <space_back_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xdd9(%rip),%rdi
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x8000,%esi
mov    $0x0,%al
call   1080 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xda9(%rip),%rdi
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_test_1>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <rewind_tape@plt>
mov    %ebx,%edi
mov    $0x2000,%esi
xor    %eax,%eax
call   1080 <read_block@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
lea    0xe74(%rip),%r14
lea    0xe7b(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x3,%esi
xor    %eax,%eax
call   1070 <space_forward_filemark@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x10000,%esi
xor    %eax,%eax
call   1080 <read_block@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <space_back_block@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x8000,%esi
xor    %eax,%eax
call   1080 <read_block@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%s: Block %d\0A\00"
@__func__.read_test_1 = [12 x i8] c"read_test_1\00"
define i32 @read_test_1(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 (i32, ...) bitcast (i32 (...)* @rewind_tape to i32 (i32, ...)*)(i32 %3)
%5 = load i32, i32* %2
%6 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %5, i32 8192)
%7 = load i32, i32* %2
%8 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %10, i32 3)
%12 = load i32, i32* %2
%13 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %2
%16 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %15, i32 65536)
%17 = load i32, i32* %2
%18 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_back_block to i32 (i32, i32, ...)*)(i32 %20, i32 1)
%22 = load i32, i32* %2
%23 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %2
%26 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %25, i32 32768)
%27 = load i32, i32* %2
%28 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s: Block %d\0A\00"
@__func__.read_test_1 = [12 x i8] c"read_test_1\00"
define i32 @read_test_1(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @rewind_tape to i32 (i32, ...)*)(i32 %0)
%3 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 8192)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %4)
%6 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %0, i32 3)
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %7)
%9 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 65536)
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %10)
%12 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_back_block to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %13)
%15 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 32768)
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_1, i64 0, i64 0), i32 %16)
ret i32 0
}