#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int lseek(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int cal_inode_tblock(int fd, long int seek_pos) {
  int pos, end_pos, nr_blocks, inode_table_blocks;
  pos = lseek(fd, 0, SEEK_CUR);
  end_pos = lseek(fd, 0, SEEK_END);
  pos = lseek(fd, pos, SEEK_SET);
  nr_blocks = (end_pos - pos) / 4096;
  inode_table_blocks = (nr_blocks * 10) / 100;
  printf("inode table blocks == %d\n", inode_table_blocks);
  return inode_table_blocks;
}


x86 assembly (clang, -O0):
<cal_inode_tblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2e68(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
imul   $0xa,-0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_inode_tblock>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    0x2eb3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %eax,%r14d
mov    0x2ea8(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %eax,%ebp
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r14d,%esi
call   1040 <lseek@plt>
sub    %eax,%ebp
movslq %ebp,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x2e,%rbx
add    %eax,%ebx
lea    0xe80(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str = [26 x i8] c"inode table blocks == %d\0A\00"
define i32 @cal_inode_tblock(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i64 %1, i64* %4
%9 = load i32, i32* %3
%10 = load i32, i32* @SEEK_CUR
%11 = call i32 @lseek(i32 %9, i32 0, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %3
%13 = load i32, i32* @SEEK_END
%14 = call i32 @lseek(i32 %12, i32 0, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @lseek(i32 %15, i32 %16, i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
%22 = sdiv i32 %21, 4096
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = mul nsw i32 %23, 10
%25 = sdiv i32 %24, 100
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %8
ret i32 %28
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str = [26 x i8] c"inode table blocks == %d\0A\00"
define i32 @cal_inode_tblock(i32 %0, i64 %1) {
%3 = load i32, i32* @SEEK_CUR
%4 = tail call i32 @lseek(i32 %0, i32 0, i32 %3)
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @lseek(i32 %0, i32 0, i32 %5)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @lseek(i32 %0, i32 %4, i32 %7)
%9 = sub nsw i32 %6, %8
%10 = sdiv i32 %9, 40960
%11 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 %10
}