int read_test_5(int fd) {
  rewind_tape(fd);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  space_forward_filemark(fd, 1);
  printf("*** Should be at block 3 ==> \t");
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  rewind_tape(fd);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  read_block(fd, 8 * 1024);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  space_forward_filemark(fd, 1);
  printf("*** Should be at block 3 ==> \t");
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  printf("Only reading 32k of a 64k block\n");
  read_block(fd, 32 * 1024);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  return 0;
}


x86 assembly (clang, -O0):
<read_test_5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1040 <rewind_tape@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <read_block_position@plt>
mov    %eax,%edx
lea    0xe88(%rip),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <space_forward_filemark@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <read_block_position@plt>
mov    %eax,%edx
lea    0xe4a(%rip),%rdi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1040 <rewind_tape@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <read_block_position@plt>
mov    %eax,%edx
lea    0xe1f(%rip),%rdi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x2000,%esi
mov    $0x0,%al
call   1070 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <read_block_position@plt>
mov    %eax,%edx
lea    0xdef(%rip),%rdi
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <space_forward_filemark@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <read_block_position@plt>
mov    %eax,%edx
lea    0xdb1(%rip),%rdi
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x8000,%esi
mov    $0x0,%al
call   1070 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <read_block_position@plt>
mov    %eax,%edx
lea    0xd73(%rip),%rdi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_test_5>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <rewind_tape@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
lea    0xe7f(%rip),%r14
lea    0xe86(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <space_forward_filemark@plt>
lea    0xe6e(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@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   1040 <printf@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <rewind_tape@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   1040 <printf@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>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <space_forward_filemark@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@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   1040 <printf@plt>
lea    0xded(%rip),%rdi
call   1030 <puts@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   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%s: Block %d\0A\00"
@__func__.read_test_5 = [12 x i8] c"read_test_5\00"
@.str.1 = [31 x i8] c"*** Should be at block 3 ==> \09\00"
@.str.2 = [33 x i8] c"Only reading 32k of a 64k block\0A\00"
define i32 @read_test_5(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, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %5)
%7 = 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_5, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %8, i32 1)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %11)
%13 = 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_5, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = call i32 (i32, ...) bitcast (i32 (...)* @rewind_tape to i32 (i32, ...)*)(i32 %14)
%16 = load i32, i32* %2
%17 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %16)
%18 = 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_5, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %19, i32 8192)
%21 = load i32, i32* %2
%22 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %21)
%23 = 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_5, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %24, i32 1)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%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_5, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %2
%32 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %31, i32 32768)
%33 = load i32, i32* %2
%34 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %33)
%35 = 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_5, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s: Block %d\0A\00"
@__func__.read_test_5 = [12 x i8] c"read_test_5\00"
@.str.1 = [31 x i8] c"*** Should be at block 3 ==> \09\00"
@str = [32 x i8] c"Only reading 32k of a 64k block\00"
define i32 @read_test_5(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @rewind_tape to i32 (i32, ...)*)(i32 %0)
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%4 = 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_5, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%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_5, i64 0, i64 0), i32 %7)
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @rewind_tape to i32 (i32, ...)*)(i32 %0)
%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_5, i64 0, i64 0), i32 %10)
%12 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 8192)
%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_5, i64 0, i64 0), i32 %13)
%15 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%18 = 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_5, i64 0, i64 0), i32 %17)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 32768)
%21 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%22 = 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_5, i64 0, i64 0), i32 %21)
ret i32 0
}