#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 */
char *gettext(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long long);
char *HzToHuman(unsigned long hz) {
  static char buffer[1024];
  memset(buffer, 0, 1024);
  unsigned long long Hz;
  Hz = hz;
  sprintf(buffer, gettext("%9lli"), Hz);
  if (Hz > 1000)
    sprintf(buffer, gettext("%6lli Mhz"), (Hz + 500) / 1000);
  if (Hz > 1500000)
    sprintf(buffer, gettext("%6.2f Ghz"), (Hz + 5000.0) / 1000000);
  return buffer;
}


x86 assembly (clang, -O0):
<HzToHuman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rdx
lea    0x2edf(%rip),%rdi
call   1050 <sprintf@plt>
cmpq   $0x3e8,-0x10(%rbp)
jbe    11b6 <HzToHuman+0x86>
lea    0xeb3(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rax
add    $0x1f4,%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0x2e9f(%rip),%rdi
call   1050 <sprintf@plt>
cmpq   $0x16e360,-0x10(%rbp)
jbe    1244 <HzToHuman+0x114>
lea    0xe7d(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rsi
movaps 0xe26(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe25(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdx
mov    %rdx,%rcx
sar    $0x3f,%rcx
movsd  0xe07(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdx
lea    0x2e11(%rip),%rdi
call   1050 <sprintf@plt>
lea    0x2e05(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HzToHuman>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f12(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
lea    0xee4(%rip),%rdi
call   1030 <gettext@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
cmp    $0x3e9,%rbx
jb     121f <HzToHuman+0xef>
lea    0xec3(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rsi
lea    0x1f4(%rbx),%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
lea    0x2eaa(%rip),%rdi
call   1050 <sprintf@plt>
cmp    $0x16e361,%rbx
jb     121f <HzToHuman+0xef>
lea    0xe8d(%rip),%rdi
call   1030 <gettext@plt>
movq   %rbx,%xmm0
punpckldq 0xe33(%rip),%xmm0
subpd  0xe3b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xe37(%rip),%xmm1
divsd  0xe37(%rip),%xmm1
cvttsd2si %xmm1,%rcx
mov    %rcx,%rsi
sar    $0x3f,%rsi
subsd  0xe2b(%rip),%xmm1
cvttsd2si %xmm1,%rdx
and    %rsi,%rdx
or     %rcx,%rdx
lea    0x2e39(%rip),%rdi
mov    %rax,%rsi
call   1050 <sprintf@plt>
lea    0x2e2a(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@HzToHuman.buffer = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"%9lli\00"
@.str.1 = [10 x i8] c"%6lli Mhz\00"
@.str.2 = [10 x i8] c"%6.2f Ghz\00"
define i8* @HzToHuman(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i32 0, i32 1024)
%5 = load i64, i64* %2
store i64 %5, i64* %3
%6 = call i8* @gettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* %3
%8 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* %6, i64 %7)
%9 = load i64, i64* %3
%10 = icmp ugt i64 %9, 1000
br i1 %10, label %11, label %17
11: ; preds = %1
%12 = call i8* @gettext(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = load i64, i64* %3
%14 = add i64 %13, 500
%15 = udiv i64 %14, 1000
%16 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* %12, i64 %15)
br label %17
17: ; preds = %11, %1
%18 = load i64, i64* %3
%19 = icmp ugt i64 %18, 1500000
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = call i8* @gettext(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%22 = load i64, i64* %3
%23 = uitofp i64 %22 to double
%24 = fadd double %23, 5.000000e+03
%25 = fdiv double %24, 1.000000e+06
%26 = fptoui double %25 to i64
%27 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* %21, i64 %26)
br label %28
28: ; preds = %20, %17
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@HzToHuman.buffer = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"%9lli\00"
@.str.1 = [10 x i8] c"%6lli Mhz\00"
@.str.2 = [10 x i8] c"%6.2f Ghz\00"
define i8* @HzToHuman(i64 %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i32 0, i32 1024)
%3 = tail call i8* @gettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) %3, i64 %0)
%5 = icmp ugt i64 %0, 1000
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = tail call i8* @gettext(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%8 = add i64 %0, 500
%9 = udiv i64 %8, 1000
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) %7, i64 %9)
%11 = icmp ugt i64 %0, 1500000
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = tail call i8* @gettext(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%14 = uitofp i64 %0 to double
%15 = fadd double %14, 5.000000e+03
%16 = fdiv double %15, 1.000000e+06
%17 = fptoui double %16 to i64
%18 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) %13, i64 %17)
br label %19
19: ; preds = %1, %12, %6
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0)
}