int read_test_4(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));
  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));
  space_forward_block(fd, 1);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  space_forward_filemark(fd, 1);
  printf("%s: Block %d\n", __func__, read_block_position(fd));
  return 0;
}


x86 assembly (clang, -O0):
<read_test_4>:
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    $0x1,%esi
mov    $0x0,%al
call   1080 <space_forward_filemark@plt>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xe2a(%rip),%rdi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
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    0xdff(%rip),%rdi
lea    0xe06(%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    0xdcf(%rip),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1080 <space_forward_filemark@plt>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <read_block_position@plt>
mov    %eax,%edx
lea    0xd91(%rip),%rdi
lea    0xd98(%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    0xd61(%rip),%rdi
lea    0xd68(%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    0xd31(%rip),%rdi
lea    0xd38(%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    0xd01(%rip),%rdi
lea    0xd08(%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    0xcd1(%rip),%rdi
lea    0xcd8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%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    0xca1(%rip),%rdi
lea    0xca8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_test_4>:
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    0xe6f(%rip),%r14
lea    0xe76(%rip),%r15
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   1080 <space_forward_filemark@plt>
lea    0xe5e(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <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   1030 <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   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    $0x1,%esi
xor    %eax,%eax
call   1080 <space_forward_filemark@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <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   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>
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>
mov    %ebx,%edi
mov    $0x1,%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>
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_4 = [12 x i8] c"read_test_4\00"
@.str.1 = [31 x i8] c"*** Should be at block 3 ==> \09\00"
define i32 @read_test_4(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_4, 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_4, 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_4, 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_4, 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_4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
%31 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %30, i32 65536)
%32 = load i32, i32* %2
%33 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %32)
%34 = 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_4, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_back_block to i32 (i32, i32, ...)*)(i32 %35, i32 1)
%37 = load i32, i32* %2
%38 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %37)
%39 = 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_4, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %2
%41 = call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %40, i32 65536)
%42 = load i32, i32* %2
%43 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %42)
%44 = 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_4, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %2
%46 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_block to i32 (i32, i32, ...)*)(i32 %45, i32 1)
%47 = load i32, i32* %2
%48 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %47)
%49 = 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_4, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %2
%51 = call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %50, i32 1)
%52 = load i32, i32* %2
%53 = call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %52)
%54 = 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_4, i64 0, i64 0), i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s: Block %d\0A\00"
@__func__.read_test_4 = [12 x i8] c"read_test_4\00"
@.str.1 = [31 x i8] c"*** Should be at block 3 ==> \09\00"
define i32 @read_test_4(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_4, 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_4, 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_4, 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_4, 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_4, i64 0, i64 0), i32 %17)
%19 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 65536)
%20 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%21 = 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_4, i64 0, i64 0), i32 %20)
%22 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_back_block to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%24 = 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_4, i64 0, i64 0), i32 %23)
%25 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @read_block to i32 (i32, i32, ...)*)(i32 %0, i32 65536)
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%27 = 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_4, i64 0, i64 0), i32 %26)
%28 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_block to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%29 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%30 = 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_4, i64 0, i64 0), i32 %29)
%31 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @space_forward_filemark to i32 (i32, i32, ...)*)(i32 %0, i32 1)
%32 = tail call i32 (i32, ...) bitcast (i32 (...)* @read_block_position to i32 (i32, ...)*)(i32 %0)
%33 = 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_4, i64 0, i64 0), i32 %32)
ret i32 0
}