#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 *, size_t, char *, size_t);
void snprintsize(char *buf, size_t n, size_t size) {
  double dsize = size;
  if (dsize > 1024 * 1024 * 1024) {
    dsize /= 1024 * 1024 * 1024;
    snprintf(buf, n, "%.1f GB", dsize);
  } else {
    snprintf(buf, n, "%ld bytes", size);
  }
}


x86 assembly (clang, -O0):
<snprintsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movaps 0xee5(%rip),%xmm1
movq   -0x18(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xee4(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c1 <snprintsize+0xb1>
movsd  -0x20(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
movsd  0xe76(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
and    %rdx,%rax
or     %rax,%rcx
lea    0xe79(%rip),%rdx
call   1030 <snprintf@plt>
jmp    11d9 <snprintsize+0xc9>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rcx
lea    0xe64(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snprintsize>:
mov    %rdx,%rcx
cmp    $0x40000001,%rdx
jb     1170 <snprintsize+0x60>
movq   %rcx,%xmm0
punpckldq 0xed7(%rip),%xmm0
subpd  0xedf(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xedb(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
subsd  0xed3(%rip),%xmm1
cvttsd2si %xmm1,%rcx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rax,%rcx
lea    0xec5(%rip),%rdx
jmp    1030 <snprintf@plt>
lea    0xec1(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%.1f GB\00"
@.str.1 = [10 x i8] c"%ld bytes\00"
define void @snprintsize(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca double
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = uitofp i64 %8 to double
store double %9, double* %7
%10 = load double, double* %7
%11 = fcmp ogt double %10, 0x41D0000000000000
br i1 %11, label %12, label %20
12: ; preds = %3
%13 = load double, double* %7
%14 = fdiv double %13, 0x41D0000000000000
store double %14, double* %7
%15 = load i8*, i8** %4
%16 = load i64, i64* %5
%17 = load double, double* %7
%18 = fptoui double %17 to i64
%19 = call i32 @snprintf(i8* %15, i64 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %18)
br label %25
20: ; preds = %3
%21 = load i8*, i8** %4
%22 = load i64, i64* %5
%23 = load i64, i64* %6
%24 = call i32 @snprintf(i8* %21, i64 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %20, %12
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%.1f GB\00"
@.str.1 = [10 x i8] c"%ld bytes\00"
define void @snprintsize(i8* %0, i64 %1, i64 %2) {
%4 = icmp ugt i64 %2, 1073741824
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = uitofp i64 %2 to double
%7 = fmul double %6, 0x3E10000000000000
%8 = fptoui double %7 to i64
%9 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %8)
br label %12
10: ; preds = %3
%11 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %2)
br label %12
12: ; preds = %10, %5
ret void
}