#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 */
typedef int /*<<< orphan*/ daddr_t;

/* Variables and functions */
long int st_blocks(long int size) {
  long int datablks = (size + 512 - 1) / 512;
  long int indrblks = 0;
  if (datablks > 10) {
    indrblks = (datablks - 10 - 1) / (1024 / sizeof(daddr_t)) + 1;
    if (datablks > 10 + (1024 / sizeof(daddr_t))) {
      indrblks += (datablks - 10 - (1024 / sizeof(daddr_t)) - 1) /
                      ((1024 / sizeof(daddr_t)) * (1024 / sizeof(daddr_t))) +
                  1;
      if (datablks > 10 + (1024 / sizeof(daddr_t)) +
                         (1024 / sizeof(daddr_t)) * (1024 / sizeof(daddr_t)))
        indrblks++;
    }
  }
  return datablks + indrblks;
}


x86 assembly (clang, -O0):
<st_blocks>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x200,%rax
sub    $0x1,%rax
mov    $0x200,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0xa,-0x10(%rbp)
jle    11a3 <st_blocks+0xa3>
mov    -0x10(%rbp),%rax
sub    $0xa,%rax
sub    $0x1,%rax
shr    $0x8,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x10a,-0x10(%rbp)
jbe    119e <st_blocks+0x9e>
mov    -0x10(%rbp),%rax
sub    $0xa,%rax
sub    $0x100,%rax
sub    $0x1,%rax
shr    $0x10,%rax
add    $0x1,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x1010a,-0x10(%rbp)
jbe    1199 <st_blocks+0x99>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119e <st_blocks+0x9e>
jmp    11a3 <st_blocks+0xa3>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<st_blocks>:
lea    0x1ff(%rdi),%rax
lea    0x3fe(%rdi),%rcx
test   %rax,%rax
cmovns %rax,%rcx
sar    $0x9,%rcx
cmp    $0x1401,%rdi
jl     1158 <st_blocks+0x58>
lea    -0xb(%rcx),%rax
shr    $0x8,%rax
add    $0x1,%rax
cmp    $0x10b,%rcx
jb     1154 <st_blocks+0x54>
lea    -0x10b(%rcx),%rdx
shr    $0x10,%rdx
cmp    $0x1010b,%rcx
sbb    $0xffffffffffffffff,%rdx
add    %rdx,%rax
add    $0x1,%rax
add    %rcx,%rax
ret
xor    %eax,%eax
add    %rcx,%rax
ret

LLVM IR (-O0):
define i64 @st_blocks(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = add nsw i64 %5, 512
%7 = sub nsw i64 %6, 1
%8 = sdiv i64 %7, 512
store i64 %8, i64* %3
store i64 0, i64* %4
%9 = load i64, i64* %3
%10 = icmp sgt i64 %9, 10
br i1 %10, label %11, label %35
11: ; preds = %1
%12 = load i64, i64* %3
%13 = sub nsw i64 %12, 10
%14 = sub nsw i64 %13, 1
%15 = udiv i64 %14, 256
%16 = add i64 %15, 1
store i64 %16, i64* %4
%17 = load i64, i64* %3
%18 = icmp ugt i64 %17, 266
br i1 %18, label %19, label %34
19: ; preds = %11
%20 = load i64, i64* %3
%21 = sub nsw i64 %20, 10
%22 = sub i64 %21, 256
%23 = sub i64 %22, 1
%24 = udiv i64 %23, 65536
%25 = add i64 %24, 1
%26 = load i64, i64* %4
%27 = add i64 %26, %25
store i64 %27, i64* %4
%28 = load i64, i64* %3
%29 = icmp ugt i64 %28, 65802
br i1 %29, label %30, label %33
30: ; preds = %19
%31 = load i64, i64* %4
%32 = add nsw i64 %31, 1
store i64 %32, i64* %4
br label %33
33: ; preds = %30, %19
br label %34
34: ; preds = %33, %11
br label %35
35: ; preds = %34, %1
%36 = load i64, i64* %3
%37 = load i64, i64* %4
%38 = add nsw i64 %36, %37
ret i64 %38
}

LLVM IR (-O2):
define i64 @st_blocks(i64 %0) {
%2 = add nsw i64 %0, 511
%3 = sdiv i64 %2, 512
%4 = icmp sgt i64 %0, 5120
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = add nsw i64 %3, -11
%7 = lshr i64 %6, 8
%8 = add nuw nsw i64 %7, 1
%9 = icmp ugt i64 %3, 266
br i1 %9, label %10, label %18
10: ; preds = %5
%11 = add nsw i64 %3, -267
%12 = lshr i64 %11, 16
%13 = add nuw nsw i64 %12, 1
%14 = icmp ugt i64 %3, 65802
%15 = zext i1 %14 to i64
%16 = add nuw nsw i64 %13, %15
%17 = add nuw nsw i64 %16, %8
br label %18
18: ; preds = %10, %5, %1
%19 = phi i64 [ %8, %5 ], [ 0, %1 ], [ %17, %10 ]
%20 = add nsw i64 %19, %3
ret i64 %20
}