int read_test_3(int 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, 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, 64 * 1024);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  printf("%s: Note: following space_forward_block() should error\n", __func__);
  space_forward_block(fd, 1);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  return 0;
}


x86 assembly (clang, -O0):
<read_test_3>:
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    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe68(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x2000,%esi
mov    $0x0,%al
call   1090 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe38(%rip),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x0,%al
call   1080 <space_forward_filemark@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe08(%rip),%rdi
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x10000,%esi
mov    $0x0,%al
call   1090 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xdd8(%rip),%rdi
lea    0xddf(%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    0xda8(%rip),%rdi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x10000,%esi
mov    $0x0,%al
call   1090 <read_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xd78(%rip),%rdi
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd7d(%rip),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <space_forward_block@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xd33(%rip),%rdi
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_test_3>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <rewind_tape@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read_block_position@plt>
lea    0xe72(%rip),%r14
lea    0xe79(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x2000,%esi
xor    %eax,%eax
call   1090 <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    $0x3,%esi
xor    %eax,%eax
call   1080 <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   1090 <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    $0x10000,%esi
xor    %eax,%eax
call   1090 <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>
lea    0xdb1(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <space_forward_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_3 = [12 x i8] c"read_test_3\00"
@.str.1 = [56 x i8] c"%s: Note: following space_forward_block() should error\0A\00"
define i32 @read_test_3(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_3, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %8, i32 8192)
%10 = load i32, i32* %2
%11 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %10)
%12 = 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_3, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %13, i32 3)
%15 = load i32, i32* %2
%16 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %15)
%17 = 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_3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %18, i32 65536)
%20 = load i32, i32* %2
%21 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %20)
%22 = 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_3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %2
%24 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_back_block to i32 (i32, i32, ...)*)(i32 %23, i32 1)
%25 = load i32, i32* %2
%26 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %25)
%27 = 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_3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %2
%29 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %28, i32 65536)
%30 = load i32, i32* %2
%31 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %30)
%32 = 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_3, i64 0, i64 0), i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_3, i64 0, i64 0))
%34 = load i32, i32* %2
%35 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_block to i32 (i32, i32, ...)*)(i32 %34, i32 1)
%36 = load i32, i32* %2
%37 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %36)
%38 = 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_3, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s: Block %d\0A\00"
@__func__.read_test_3 = [12 x i8] c"read_test_3\00"
@.str.1 = [56 x i8] c"%s: Note: following space_forward_block() should error\0A\00"
define i32 @read_test_3(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_3, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 8192)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%7 = 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_3, i64 0, i64 0), i32 %6)
%8 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %0, i32 3)
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%10 = 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_3, i64 0, i64 0), i32 %9)
%11 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 65536)
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%13 = 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_3, i64 0, i64 0), i32 %12)
%14 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_back_block to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%16 = 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_3, i64 0, i64 0), i32 %15)
%17 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 65536)
%18 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%19 = 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_3, i64 0, i64 0), i32 %18)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__func__.read_test_3, i64 0, i64 0))
%21 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_block to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%22 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%23 = 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_3, i64 0, i64 0), i32 %22)
ret i32 0
}