#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 */
scalar_t__ is_turbo(unsigned long);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *HzToHuman(unsigned long hz) {
  static char buffer[1024];
  memset(buffer, 0, 1024);
  unsigned long long Hz;
  Hz = hz;
  sprintf(buffer, "%9lli", Hz);
  if (Hz > 1000)
    sprintf(buffer, "%6lli Mhz", (Hz + 500) / 1000);
  if (Hz > 1500000)
    sprintf(buffer, "%6.2f Ghz", (Hz + 5000.0) / 1000000);
  if (is_turbo(hz))
    sprintf(buffer, "%s", "Turbo Mode");
  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)
mov    -0x10(%rbp),%rdx
lea    0x2eee(%rip),%rdi
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
cmpq   $0x3e8,-0x10(%rbp)
jbe    11aa <HzToHuman+0x7a>
mov    -0x10(%rbp),%rax
add    $0x1f4,%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0x2eb4(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
cmpq   $0x16e360,-0x10(%rbp)
jbe    120c <HzToHuman+0xdc>
movaps 0xe51(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe50(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe21(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe0d(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0x2e52(%rip),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x1,%al
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <is_turbo@plt>
cmp    $0x0,%rax
je     123b <HzToHuman+0x10b>
lea    0x2e2a(%rip),%rdi
lea    0xe1d(%rip),%rsi
lea    0xe19(%rip),%rdx
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    0x2e0e(%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    0xedc(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
cmp    $0x3e9,%rbx
jb     11ee <HzToHuman+0xbe>
lea    0x1f4(%rbx),%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
lea    0x2ebf(%rip),%rdi
lea    0xe9e(%rip),%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
cmp    $0x16e361,%rbx
jb     11ee <HzToHuman+0xbe>
movq   %rbx,%xmm1
punpckldq 0xe4b(%rip),%xmm1
subpd  0xe53(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe4f(%rip),%xmm0
divsd  0xe4f(%rip),%xmm0
lea    0x2e70(%rip),%rdi
lea    0xe59(%rip),%rsi
mov    $0x1,%al
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <is_turbo@plt>
test   %rax,%rax
je     1216 <HzToHuman+0xe6>
movabs $0x6f4d206f62727554,%rax
20 4d 6f
mov    %rax,0x2e44(%rip)
movl   $0x65646f,0x2e41(%rip)
lea    0x2e33(%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"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [11 x i8] c"Turbo Mode\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 (i8*, i8*, ...) @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 (i8*, i8*, ...) @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 %24
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 = call i32 (i8*, i8*, ...) @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), double %22)
br label %24
24: ; preds = %18, %15
%25 = load i64, i64* %2
%26 = call i64 @is_turbo(i64 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
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"
@.str.4 = [11 x i8] c"Turbo Mode\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 (i8*, i8*, ...) @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 %15
5: ; preds = %1
%6 = add i64 %0, 500
%7 = udiv i64 %6, 1000
%8 = tail call i32 (i8*, i8*, ...) @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 %15
10: ; preds = %5
%11 = uitofp i64 %0 to double
%12 = fadd double %11, 5.000000e+03
%13 = fdiv double %12, 1.000000e+06
%14 = tail call i32 (i8*, i8*, ...) @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), double %13)
br label %15
15: ; preds = %1, %10, %5
%16 = tail call i64 @is_turbo(i64 %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %15
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(11) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 11, i1 false)
br label %19
19: ; preds = %18, %15
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0)
}