void transformunit(volatile double *size, volatile int *unit) {
  *unit = 0;
  if (*size > 1024) {
    (*size) /= 1024;
    (*unit)++;
  }
  if (*size > 1024) {
    (*size) /= 1024;
    (*unit)++;
  }
}


x86 assembly (clang, -O0):
<transformunit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xeda(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1153 <transformunit+0x53>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xec0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe9d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <transformunit+0x90>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<transformunit>:
movl   $0x0,(%rsi)
movsd  (%rdi),%xmm0
ucomisd 0xeee(%rip),%xmm0
jbe    1127 <transformunit+0x27>
movsd  (%rdi),%xmm0
mulsd  0xee8(%rip),%xmm0
movsd  %xmm0,(%rdi)
addl   $0x1,(%rsi)
movsd  (%rdi),%xmm0
ucomisd 0xecd(%rip),%xmm0
jbe    1148 <transformunit+0x48>
movsd  (%rdi),%xmm0
mulsd  0xec7(%rip),%xmm0
movsd  %xmm0,(%rdi)
addl   $0x1,(%rsi)
ret

LLVM IR (-O0):
define void @transformunit(double* %0, i32* %1) {
%3 = alloca double*
%4 = alloca i32*
store double* %0, double** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
store volatile i32 0, i32* %5
%6 = load double*, double** %3
%7 = load volatile double, double* %6
%8 = fcmp ogt double %7, 1.024000e+03
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load double*, double** %3
%11 = load volatile double, double* %10
%12 = fdiv double %11, 1.024000e+03
store volatile double %12, double* %10
%13 = load i32*, i32** %4
%14 = load volatile i32, i32* %13
%15 = add nsw i32 %14, 1
store volatile i32 %15, i32* %13
br label %16
16: ; preds = %9, %2
%17 = load double*, double** %3
%18 = load volatile double, double* %17
%19 = fcmp ogt double %18, 1.024000e+03
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load double*, double** %3
%22 = load volatile double, double* %21
%23 = fdiv double %22, 1.024000e+03
store volatile double %23, double* %21
%24 = load i32*, i32** %4
%25 = load volatile i32, i32* %24
%26 = add nsw i32 %25, 1
store volatile i32 %26, i32* %24
br label %27
27: ; preds = %20, %16
ret void
}

LLVM IR (-O2):
define void @transformunit(double* %0, i32* %1) {
store volatile i32 0, i32* %1
%3 = load volatile double, double* %0
%4 = fcmp ogt double %3, 1.024000e+03
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load volatile double, double* %0
%7 = fmul double %6, 0x3F50000000000000
store volatile double %7, double* %0
%8 = load volatile i32, i32* %1
%9 = add nsw i32 %8, 1
store volatile i32 %9, i32* %1
br label %10
10: ; preds = %5, %2
%11 = load volatile double, double* %0
%12 = fcmp ogt double %11, 1.024000e+03
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load volatile double, double* %0
%15 = fmul double %14, 0x3F50000000000000
store volatile double %15, double* %0
%16 = load volatile i32, i32* %1
%17 = add nsw i32 %16, 1
store volatile i32 %17, i32* %1
br label %18
18: ; preds = %13, %10
ret void
}