#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char const *, unsigned long long);
char *HzToHuman(unsigned long hz) {
  static char buffer[1024];
  memset(buffer, 0, 1024);
  unsigned long long Hz;
  Hz = hz;
  sprintf(buffer, ((const char *)("%9lli")), Hz);
  if (Hz > 1000)
    sprintf(buffer, ((const char *)("%6lli Mhz")), (Hz + 500) / 1000);
  if (Hz > 1500000)
    sprintf(buffer, ((const char *)("%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   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0x2eee(%rip),%rdi
lea    0xedf(%rip),%rsi
call   1040 <sprintf@plt>
cmpq   $0x3e8,-0x10(%rbp)
jbe    1196 <HzToHuman+0x76>
mov    -0x10(%rbp),%rax
add    $0x1f4,%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0x2eb6(%rip),%rdi
lea    0xead(%rip),%rsi
call   1040 <sprintf@plt>
cmpq   $0x16e360,-0x10(%rbp)
jbe    121c <HzToHuman+0xfc>
movaps 0xe55(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe54(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe4d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe49(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdx
mov    %rdx,%rcx
sar    $0x3f,%rcx
movsd  0xe36(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdx
lea    0x2e30(%rip),%rdi
lea    0xe31(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2e1d(%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   1030 <memset@plt>
lea    0xef4(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
cmp    $0x3e9,%rbx
jb     11f7 <HzToHuman+0xd7>
lea    0x1f4(%rbx),%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
lea    0x2ec1(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1040 <sprintf@plt>
cmp    $0x16e361,%rbx
jb     11f7 <HzToHuman+0xd7>
movq   %rbx,%xmm0
punpckldq 0xe5f(%rip),%xmm0
subpd  0xe67(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xe63(%rip),%xmm1
divsd  0xe63(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe57(%rip),%xmm1
cvttsd2si %xmm1,%rdx
and    %rcx,%rdx
or     %rax,%rdx
lea    0x2e55(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2e42(%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 = load i64, i64* %3
%7 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = load i64, i64* %3
%9 = icmp ugt i64 %8, 1000
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i64, i64* %3
%12 = add i64 %11, 500
%13 = udiv i64 %12, 1000
%14 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %13)
br label %15
15: ; preds = %10, %1
%16 = load i64, i64* %3
%17 = icmp ugt i64 %16, 1500000
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i64, i64* %3
%20 = uitofp i64 %19 to double
%21 = fadd double %20, 5.000000e+03
%22 = fdiv double %21, 1.000000e+06
%23 = fptoui double %22 to i64
%24 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %18, %15
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 i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %0)
%4 = icmp ugt i64 %0, 1000
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = add i64 %0, 500
%7 = udiv i64 %6, 1000
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = icmp ugt i64 %0, 1500000
br i1 %9, label %10, label %16
10: ; preds = %5
%11 = uitofp i64 %0 to double
%12 = fadd double %11, 5.000000e+03
%13 = fdiv double %12, 1.000000e+06
%14 = fptoui double %13 to i64
%15 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 %14)
br label %16
16: ; preds = %1, %10, %5
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0)
}