#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 unsigned long uint64_t;

/* Variables and functions */
int /*<<< orphan*/ display_put(char *, double);
void display_printKMG(uint64_t val) {
  if (val >= 1000000000UL) {
    display_put(" [%.2lfG]", (double)val / 1000000000.0);
  } else if (val >= 1000000UL) {
    display_put(" [%.2lfM]", (double)val / 1000000.0);
  } else if (val >= 1000UL) {
    display_put(" [%.2lfk]", (double)val / 1000.0);
  }
}


x86 assembly (clang, -O0):
<display_printKMG>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x3b9aca00,-0x8(%rbp)
3b
jb     116e <display_printKMG+0x5e>
movaps 0xeef(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xeee(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xeb7(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xedc(%rip),%rdi
call   1030 <display_put@plt>
jmp    1217 <display_printKMG+0x107>
cmpq   $0xf4240,-0x8(%rbp)
jb     11c0 <display_printKMG+0xb0>
movaps 0xe9d(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe9c(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe94(%rip),%rdi
call   1030 <display_put@plt>
jmp    1212 <display_printKMG+0x102>
cmpq   $0x3e8,-0x8(%rbp)
jb     120d <display_printKMG+0xfd>
movaps 0xe4b(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe4a(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe03(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe4c(%rip),%rdi
call   1030 <display_put@plt>
jmp    1212 <display_printKMG+0x102>
jmp    1217 <display_printKMG+0x107>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_printKMG>:
cmp    $0x3b9ac9ff,%rdi
jbe    112a <display_printKMG+0x1a>
lea    0xf20(%rip),%rax
movsd  0xed8(%rip),%xmm1
jmp    115c <display_printKMG+0x4c>
cmp    $0xf423f,%rdi
jbe    1144 <display_printKMG+0x34>
lea    0xf10(%rip),%rax
movsd  0xec6(%rip),%xmm1
jmp    115c <display_printKMG+0x4c>
cmp    $0x3e8,%rdi
jb     1189 <display_printKMG+0x79>
lea    0xf00(%rip),%rax
movsd  0xeb4(%rip),%xmm1
movq   %rdi,%xmm2
punpckldq 0xeb7(%rip),%xmm2
subpd  0xebf(%rip),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
mov    %rax,%rdi
jmp    1030 <display_put@plt>
ret

LLVM IR (-O0):
@.str = [10 x i8] c" [%.2lfG]\00"
@.str.1 = [10 x i8] c" [%.2lfM]\00"
@.str.2 = [10 x i8] c" [%.2lfk]\00"
define void @display_printKMG(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp uge i64 %3, 1000000000
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i64, i64* %2
%7 = uitofp i64 %6 to double
%8 = fdiv double %7, 1.000000e+09
%9 = call i32 @display_put(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %8)
br label %28
10: ; preds = %1
%11 = load i64, i64* %2
%12 = icmp uge i64 %11, 1000000
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i64, i64* %2
%15 = uitofp i64 %14 to double
%16 = fdiv double %15, 1.000000e+06
%17 = call i32 @display_put(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %27
18: ; preds = %10
%19 = load i64, i64* %2
%20 = icmp uge i64 %19, 1000
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i64, i64* %2
%23 = uitofp i64 %22 to double
%24 = fdiv double %23, 1.000000e+03
%25 = call i32 @display_put(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %24)
br label %26
26: ; preds = %21, %18
br label %27
27: ; preds = %26, %13
br label %28
28: ; preds = %27, %5
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" [%.2lfG]\00"
@.str.1 = [10 x i8] c" [%.2lfM]\00"
@.str.2 = [10 x i8] c" [%.2lfk]\00"
define void @display_printKMG(i64 %0) {
%2 = icmp ugt i64 %0, 999999999
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = icmp ugt i64 %0, 999999
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = icmp ugt i64 %0, 999
br i1 %6, label %7, label %13
7: ; preds = %5, %3, %1
%8 = phi double [ 1.000000e+09, %1 ], [ 1.000000e+06, %3 ], [ 1.000000e+03, %5 ]
%9 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %5 ]
%10 = uitofp i64 %0 to double
%11 = fdiv double %10, %8
%12 = tail call i32 @display_put(i8* %9, double %11)
br label %13
13: ; preds = %7, %5
ret void
}