#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*/ safef(char *, int, char *, double, char *);
void sprintWithGreekByte(char *s, int slength, long long size) {
  char *greek[] = {"B", "KB", "MB", "GB", "TB", "PB"};
  int i = 0;
  long long d = 1;
  while ((size / d) >= 1024) {
    ++i;
    d *= 1024;
  }
  double result = ((double)size) / d;
  if (result < 10)
    safef(s, slength, "%3.1f %s", ((double)size) / d, greek[i]);
  else
    safef(s, slength, "%3.0f %s", ((double)size) / d, greek[i]);
}


x86 assembly (clang, -O0):
<sprintWithGreekByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xec5(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe9b(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe93(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x54(%rbp)
movq   $0x1,-0x60(%rbp)
mov    -0x18(%rbp),%rax
cqto
idivq  -0x60(%rbp)
cmp    $0x400,%rax
jl     11c4 <sprintWithGreekByte+0xa4>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x60(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x60(%rbp)
jmp    1194 <sprintWithGreekByte+0x74>
cvtsi2sdq -0x18(%rbp),%xmm0
cvtsi2sdq -0x60(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe1f(%rip),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    121d <sprintWithGreekByte+0xfd>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
cvtsi2sdq -0x18(%rbp),%xmm0
cvtsi2sdq -0x60(%rbp),%xmm1
divsd  %xmm1,%xmm0
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
lea    0xe04(%rip),%rdx
call   1040 <safef@plt>
jmp    1249 <sprintWithGreekByte+0x129>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
cvtsi2sdq -0x18(%rbp),%xmm0
cvtsi2sdq -0x60(%rbp),%xmm1
divsd  %xmm1,%xmm0
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
lea    0xddc(%rip),%rdx
call   1040 <safef@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprintWithGreekByte>:
mov    %rdx,%r8
lea    0xefd(%rip),%rax
mov    %rax,-0x38(%rsp)
lea    0xeea(%rip),%rax
mov    %rax,-0x30(%rsp)
lea    0xee1(%rip),%rax
mov    %rax,-0x28(%rsp)
lea    0xed8(%rip),%rax
mov    %rax,-0x20(%rsp)
lea    0xecf(%rip),%rax
mov    %rax,-0x18(%rsp)
lea    0xec6(%rip),%rax
mov    %rax,-0x10(%rsp)
xor    %ecx,%ecx
cmp    $0x400,%rdx
jl     119e <sprintWithGreekByte+0x8e>
mov    $0x1,%r9d
jmp    1184 <sprintWithGreekByte+0x74>
xchg   %ax,%ax
mov    %r8,%rax
cqto
idiv   %r9
add    $0x1,%rcx
cmp    $0x3ff,%rax
jle    11a8 <sprintWithGreekByte+0x98>
shl    $0xa,%r9
mov    %r8,%rax
or     %r9,%rax
shr    $0x20,%rax
jne    1170 <sprintWithGreekByte+0x60>
mov    %r8d,%eax
xor    %edx,%edx
div    %r9d
jmp    1178 <sprintWithGreekByte+0x68>
movsd  0xe5a(%rip),%xmm1
jmp    11ad <sprintWithGreekByte+0x9d>
cvtsi2sd %r9,%xmm1
cvtsi2sd %r8,%xmm0
divsd  %xmm1,%xmm0
movsd  0xe4a(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    -0x38(%rsp,%rcx,8),%rcx
lea    0xe51(%rip),%rax
lea    0xe53(%rip),%rdx
cmova  %rax,%rdx
jmp    1030 <safef@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"B\00"
@.str.1 = [3 x i8] c"KB\00"
@.str.2 = [3 x i8] c"MB\00"
@.str.3 = [3 x i8] c"GB\00"
@.str.4 = [3 x i8] c"TB\00"
@.str.5 = [3 x i8] c"PB\00"
@.str.6 = [9 x i8] c"%3.1f %s\00"
@.str.7 = [9 x i8] c"%3.0f %s\00"
define void @sprintWithGreekByte(i8* %0, i32 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca [6 x i8*]
%8 = alloca i32
%9 = alloca i64
%10 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%11 = bitcast [6 x i8*]* %7 to i8*
%12 = bitcast i8* %11 to [6 x i8*]*
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i32 0, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i32 0, i32 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i32 0, i32 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8** %18
store i32 0, i32* %8
store i64 1, i64* %9
br label %19
19: ; preds = %24, %3
%20 = load i64, i64* %6
%21 = load i64, i64* %9
%22 = sdiv i64 %20, %21
%23 = icmp sge i64 %22, 1024
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
%27 = load i64, i64* %9
%28 = mul nsw i64 %27, 1024
store i64 %28, i64* %9
br label %19
29: ; preds = %19
%30 = load i64, i64* %6
%31 = sitofp i64 %30 to double
%32 = load i64, i64* %9
%33 = sitofp i64 %32 to double
%34 = fdiv double %31, %33
store double %34, double* %10
%35 = load double, double* %10
%36 = fcmp olt double %35, 1.000000e+01
br i1 %36, label %37, label %50
37: ; preds = %29
%38 = load i8*, i8** %4
%39 = load i32, i32* %5
%40 = load i64, i64* %6
%41 = sitofp i64 %40 to double
%42 = load i64, i64* %9
%43 = sitofp i64 %42 to double
%44 = fdiv double %41, %43
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @safef(i8* %38, i32 %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), double %44, i8* %48)
br label %63
50: ; preds = %29
%51 = load i8*, i8** %4
%52 = load i32, i32* %5
%53 = load i64, i64* %6
%54 = sitofp i64 %53 to double
%55 = load i64, i64* %9
%56 = sitofp i64 %55 to double
%57 = fdiv double %54, %56
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 @safef(i8* %51, i32 %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %57, i8* %61)
br label %63
63: ; preds = %50, %37
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"B\00"
@.str.1 = [3 x i8] c"KB\00"
@.str.2 = [3 x i8] c"MB\00"
@.str.3 = [3 x i8] c"GB\00"
@.str.4 = [3 x i8] c"TB\00"
@.str.5 = [3 x i8] c"PB\00"
@.str.6 = [9 x i8] c"%3.1f %s\00"
@.str.7 = [9 x i8] c"%3.0f %s\00"
define void @sprintWithGreekByte(i8* %0, i32 %1, i64 %2) {
%4 = alloca [6 x i8*]
%5 = bitcast [6 x i8*]* %4 to i8*
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %11
%12 = icmp sgt i64 %2, 1023
br i1 %12, label %13, label %23
13: ; preds = %3, %13
%14 = phi i32 [ %16, %13 ], [ 0, %3 ]
%15 = phi i64 [ %17, %13 ], [ 1, %3 ]
%16 = add nuw nsw i32 %14, 1
%17 = shl nsw i64 %15, 10
%18 = sdiv i64 %2, %17
%19 = icmp sgt i64 %18, 1023
br i1 %19, label %13, label %20
20: ; preds = %13
%21 = sitofp i64 %17 to double
%22 = zext i32 %16 to i64
br label %23
23: ; preds = %20, %3
%24 = phi double [ 1.000000e+00, %3 ], [ %21, %20 ]
%25 = phi i64 [ 0, %3 ], [ %22, %20 ]
%26 = sitofp i64 %2 to double
%27 = fdiv double %26, %24
%28 = fcmp olt double %27, 1.000000e+01
%29 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 %25
%30 = load i8*, i8** %29
%31 = select i1 %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0)
%32 = tail call i32 @safef(i8* %0, i32 %1, i8* %31, double %27, i8* %30)
ret void
}