#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 *);
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, 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);
  if (is_turbo(hz))
    sprintf(buffer, "%s", gettext("Turbo Mode"));
  return buffer;
}


x86 assembly (clang, -O0):
<HzToHuman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2efd(%rip),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xec2(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rdx
lea    0x2ecf(%rip),%rdi
mov    $0x0,%al
call   1060 <sprintf@plt>
cmpq   $0x3e8,-0x10(%rbp)
jbe    11ca <HzToHuman+0x8a>
lea    0xe99(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rax
add    $0x1f4,%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0x2e8d(%rip),%rdi
mov    $0x0,%al
call   1060 <sprintf@plt>
cmpq   $0x16e360,-0x10(%rbp)
jbe    1234 <HzToHuman+0xf4>
lea    0xe61(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rsi
movaps 0xe22(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe21(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdf2(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdde(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0x2e23(%rip),%rdi
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <is_turbo@plt>
cmp    $0x0,%rax
je     126b <HzToHuman+0x12b>
lea    0xdff(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdx
lea    0x2df3(%rip),%rdi
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    0x2dde(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HzToHuman>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f02(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    0xebc(%rip),%rdi
call   1050 <gettext@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
cmp    $0x3e9,%rbx
jb     1226 <HzToHuman+0xd6>
lea    0xe99(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rsi
lea    0x1f4(%rbx),%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
lea    0x2e98(%rip),%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
cmp    $0x16e361,%rbx
jb     1226 <HzToHuman+0xd6>
lea    0xe61(%rip),%rdi
call   1050 <gettext@plt>
movq   %rbx,%xmm1
punpckldq 0xe0f(%rip),%xmm1
subpd  0xe17(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe13(%rip),%xmm0
divsd  0xe13(%rip),%xmm0
lea    0x2e44(%rip),%rdi
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <is_turbo@plt>
test   %rax,%rax
je     124e <HzToHuman+0xfe>
lea    0xe10(%rip),%rdi
call   1050 <gettext@plt>
lea    0x2e1a(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0x2e0b(%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 = 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 (i8*, i8*, ...) @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 (i8*, i8*, ...) @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 %27
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 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* %21, double %25)
br label %27
27: ; preds = %20, %17
%28 = load i64, i64* %2
%29 = call i64 @is_turbo(i64 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = call i8* @gettext(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%33 = 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* %32)
br label %34
34: ; preds = %31, %27
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 i8* @gettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = 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) %3, i64 %0)
%5 = icmp ugt i64 %0, 1000
br i1 %5, label %6, label %18
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 (i8*, i8*, ...) @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 %18
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 = 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) %13, double %16)
br label %18
18: ; preds = %1, %12, %6
%19 = tail call i64 @is_turbo(i64 %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i8* @gettext(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%23 = tail call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0), i8* dereferenceable(1) %22)
br label %24
24: ; preds = %21, %18
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @HzToHuman.buffer, i64 0, i64 0)
}