#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 *, float, char);
char *stringify_cpu_hz(long long cpu_hz) {
  static char cpu_string[20], suffix;
  float hz;
  if (cpu_hz > 1000000000LL) {
    hz = (float)cpu_hz / 1000000000LL;
    suffix = 'G';
  } else if (cpu_hz > 1000000LL) {
    hz = (float)cpu_hz / 1000000LL;
    suffix = 'M';
  } else if (cpu_hz > 1000LL) {
    hz = (float)cpu_hz / 1000LL;
    suffix = 'k';
  } else {
    hz = cpu_hz;
    suffix = ' ';
  }
  snprintf(cpu_string, 20, "%1.2lf %cHz", hz, suffix);
  return cpu_string;
}


x86 assembly (clang, -O0):
<stringify_cpu_hz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x3b9aca00,-0x8(%rbp)
3b
jle    114d <stringify_cpu_hz+0x3d>
cvtsi2ssq -0x8(%rbp),%xmm0
movss  0xed0(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movb   $0x47,0x2f0c(%rip)
jmp    11cb <stringify_cpu_hz+0xbb>
cmpq   $0xf4240,-0x8(%rbp)
jle    117e <stringify_cpu_hz+0x6e>
cvtsi2ssq -0x8(%rbp),%xmm0
movss  0xe9b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movb   $0x4d,0x2edb(%rip)
jmp    11c6 <stringify_cpu_hz+0xb6>
cmpq   $0x3e8,-0x8(%rbp)
jle    11af <stringify_cpu_hz+0x9f>
cvtsi2ssq -0x8(%rbp),%xmm0
movss  0xe66(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movb   $0x6b,0x2eaa(%rip)
jmp    11c1 <stringify_cpu_hz+0xb1>
cvtsi2ssq -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movb   $0x20,0x2e93(%rip)
jmp    11c6 <stringify_cpu_hz+0xb6>
jmp    11cb <stringify_cpu_hz+0xbb>
movss  -0xc(%rbp),%xmm0
lea    0x2e69(%rip),%rdi
mov    $0x14,%esi
lea    0xe29(%rip),%rdx
movsbl 0x2e6a(%rip),%ecx
call   1030 <snprintf@plt>
lea    0x2e4a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringify_cpu_hz>:
push   %rbx
cmp    $0x3b9aca01,%rdi
jl     112b <stringify_cpu_hz+0x1b>
cvtsi2ss %rdi,%xmm0
divss  0xee1(%rip),%xmm0
mov    $0x47,%al
jmp    115f <stringify_cpu_hz+0x4f>
cmp    $0xf4241,%rdi
jl     1145 <stringify_cpu_hz+0x35>
cvtsi2ss %rdi,%xmm0
divss  0xec3(%rip),%xmm0
mov    $0x4d,%al
jmp    115f <stringify_cpu_hz+0x4f>
cvtsi2ss %rdi,%xmm0
mov    $0x20,%al
cmp    $0x3e9,%rdi
jl     115f <stringify_cpu_hz+0x4f>
divss  0xea3(%rip),%xmm0
mov    $0x6b,%al
movzbl %al,%ecx
lea    0x2ed7(%rip),%rbx
lea    0xe9c(%rip),%rdx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stringify_cpu_hz.cpu_string = internal global [20 x i8] zeroinitializer
@stringify_cpu_hz.suffix = internal global i8 0
@.str = [12 x i8] c"%1.2lf %cHz\00"
define i8* @stringify_cpu_hz(i64 %0) {
%2 = alloca i64
%3 = alloca float
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp sgt i64 %4, 1000000000
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i64, i64* %2
%8 = sitofp i64 %7 to float
%9 = fdiv float %8, 1.000000e+09
store float %9, float* %3
store i8 71, i8* @stringify_cpu_hz.suffix
br label %29
10: ; preds = %1
%11 = load i64, i64* %2
%12 = icmp sgt i64 %11, 1000000
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* %2
%15 = sitofp i64 %14 to float
%16 = fdiv float %15, 1.000000e+06
store float %16, float* %3
store i8 77, i8* @stringify_cpu_hz.suffix
br label %28
17: ; preds = %10
%18 = load i64, i64* %2
%19 = icmp sgt i64 %18, 1000
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i64, i64* %2
%22 = sitofp i64 %21 to float
%23 = fdiv float %22, 1.000000e+03
store float %23, float* %3
store i8 107, i8* @stringify_cpu_hz.suffix
br label %27
24: ; preds = %17
%25 = load i64, i64* %2
%26 = sitofp i64 %25 to float
store float %26, float* %3
store i8 32, i8* @stringify_cpu_hz.suffix
br label %27
27: ; preds = %24, %20
br label %28
28: ; preds = %27, %13
br label %29
29: ; preds = %28, %6
%30 = load float, float* %3
%31 = load i8, i8* @stringify_cpu_hz.suffix
%32 = call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @stringify_cpu_hz.cpu_string, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %30, i8 signext %31)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @stringify_cpu_hz.cpu_string, i64 0, i64 0)
}

LLVM IR (-O2):
@stringify_cpu_hz.cpu_string = internal global [20 x i8] zeroinitializer
@.str = [12 x i8] c"%1.2lf %cHz\00"
define i8* @stringify_cpu_hz(i64 %0) {
%2 = icmp sgt i64 %0, 1000000000
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = sitofp i64 %0 to float
%5 = fdiv float %4, 1.000000e+09
br label %16
6: ; preds = %1
%7 = icmp sgt i64 %0, 1000000
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = sitofp i64 %0 to float
%10 = fdiv float %9, 1.000000e+06
br label %16
11: ; preds = %6
%12 = icmp sgt i64 %0, 1000
%13 = sitofp i64 %0 to float
br i1 %12, label %14, label %16
14: ; preds = %11
%15 = fdiv float %13, 1.000000e+03
br label %16
16: ; preds = %11, %8, %14, %3
%17 = phi i8 [ 77, %8 ], [ 107, %14 ], [ 71, %3 ], [ 32, %11 ]
%18 = phi float [ %10, %8 ], [ %15, %14 ], [ %5, %3 ], [ %13, %11 ]
%19 = tail call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @stringify_cpu_hz.cpu_string, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %18, i8 signext %17)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @stringify_cpu_hz.cpu_string, i64 0, i64 0)
}