#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*/ snprintf(char *, int, char *, double);
void conv_unit_size(char *str, int len, double num) {
  if (num >= 1024.0 * 1024.0 * 1024.0)
    snprintf(str, len, "%.3f(Gbyte)", num / (1024.0 * 1024.0 * 1024.0));
  else if (num >= 1024.0 * 1024.0)
    snprintf(str, len, "%.3f(Mbyte)", num / (1024.0 * 1024.0));
  else if (num >= 1024.0)
    snprintf(str, len, "%.3f(Kbyte)", num / 1024.0);
  else
    snprintf(str, len, "%.3f(byte)", num);
}


x86 assembly (clang, -O0):
<conv_unit_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xecf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1164 <conv_unit_size+0x54>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xebe(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1206 <conv_unit_size+0xf6>
movsd  -0x18(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11a4 <conv_unit_size+0x94>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe8a(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1201 <conv_unit_size+0xf1>
movsd  -0x18(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11e4 <conv_unit_size+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  0xe41(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe56(%rip),%rdx
call   1030 <snprintf@plt>
jmp    11fc <conv_unit_size+0xec>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
lea    0xe45(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1201 <conv_unit_size+0xf1>
jmp    1206 <conv_unit_size+0xf6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_unit_size>:
ucomisd 0xee8(%rip),%xmm0
jae    113a <conv_unit_size+0x2a>
ucomisd 0xeee(%rip),%xmm0
jae    114e <conv_unit_size+0x3e>
ucomisd 0xef4(%rip),%xmm0
jae    1162 <conv_unit_size+0x52>
lea    0xf1f(%rip),%rdx
jmp    1030 <snprintf@plt>
mulsd  0xec6(%rip),%xmm0
lea    0xee7(%rip),%rdx
jmp    1030 <snprintf@plt>
mulsd  0xec2(%rip),%xmm0
lea    0xedf(%rip),%rdx
jmp    1030 <snprintf@plt>
mulsd  0xebe(%rip),%xmm0
lea    0xed7(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%.3f(Gbyte)\00"
@.str.1 = [12 x i8] c"%.3f(Mbyte)\00"
@.str.2 = [12 x i8] c"%.3f(Kbyte)\00"
@.str.3 = [11 x i8] c"%.3f(byte)\00"
define void @conv_unit_size(i8* %0, i32 %1, double %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
store double %2, double* %6
%7 = load double, double* %6
%8 = fcmp oge double %7, 0x41D0000000000000
br i1 %8, label %9, label %15
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = load double, double* %6
%13 = fdiv double %12, 0x41D0000000000000
%14 = call i32 @snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %13)
br label %40
15: ; preds = %3
%16 = load double, double* %6
%17 = fcmp oge double %16, 0x4130000000000000
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = load double, double* %6
%22 = fdiv double %21, 0x4130000000000000
%23 = call i32 @snprintf(i8* %19, i32 %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %22)
br label %39
24: ; preds = %15
%25 = load double, double* %6
%26 = fcmp oge double %25, 1.024000e+03
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = load double, double* %6
%31 = fdiv double %30, 1.024000e+03
%32 = call i32 @snprintf(i8* %28, i32 %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %31)
br label %38
33: ; preds = %24
%34 = load i8*, i8** %4
%35 = load i32, i32* %5
%36 = load double, double* %6
%37 = call i32 @snprintf(i8* %34, i32 %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %36)
br label %38
38: ; preds = %33, %27
br label %39
39: ; preds = %38, %18
br label %40
40: ; preds = %39, %9
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%.3f(Gbyte)\00"
@.str.1 = [12 x i8] c"%.3f(Mbyte)\00"
@.str.2 = [12 x i8] c"%.3f(Kbyte)\00"
@.str.3 = [11 x i8] c"%.3f(byte)\00"
define void @conv_unit_size(i8* %0, i32 %1, double %2) {
%4 = fcmp ult double %2, 0x41D0000000000000
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = fmul double %2, 0x3E10000000000000
%7 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %6)
br label %20
8: ; preds = %3
%9 = fcmp ult double %2, 0x4130000000000000
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = fmul double %2, 0x3EB0000000000000
%12 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %11)
br label %20
13: ; preds = %8
%14 = fcmp ult double %2, 1.024000e+03
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = fmul double %2, 0x3F50000000000000
%17 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %16)
br label %20
18: ; preds = %13
%19 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %2)
br label %20
20: ; preds = %10, %18, %15, %5
ret void
}