const char *clock_rate(float *rate) {
  float r;
  r = *rate;
  if (r >= 1000000000) {
    *rate = r / 1000000000;
    return "GHZ";
  } else if (r >= 1000000) {
    *rate = r / 1000000;
    return "MHZ";
  } else if (r >= 1000) {
    *rate = r / 1000;
    return "KHZ";
  } else
    *rate = r;
  return "HZ";
  return "";
}


x86 assembly (clang, -O0):
<clock_rate>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xede(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1154 <clock_rate+0x54>
movss  -0x14(%rbp),%xmm0
movss  0xec8(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f4 <clock_rate+0xf4>
movss  -0x14(%rbp),%xmm0
movss  0xea3(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1193 <clock_rate+0x93>
movss  -0x14(%rbp),%xmm0
movss  0xe8d(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
lea    0xe86(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f4 <clock_rate+0xf4>
movss  -0x14(%rbp),%xmm0
movss  0xe68(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11d2 <clock_rate+0xd2>
movss  -0x14(%rbp),%xmm0
movss  0xe52(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
lea    0xe4b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f4 <clock_rate+0xf4>
movss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11e4 <clock_rate+0xe4>
jmp    11e9 <clock_rate+0xe9>
lea    0xe1d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_rate>:
movss  (%rdi),%xmm0
movss  0xef4(%rip),%xmm1
ucomiss %xmm1,%xmm0
jae    1133 <clock_rate+0x33>
movss  0xeeb(%rip),%xmm1
ucomiss %xmm1,%xmm0
jae    113c <clock_rate+0x3c>
movss  0xee2(%rip),%xmm1
ucomiss %xmm1,%xmm0
jae    1145 <clock_rate+0x45>
lea    0xedb(%rip),%rax
ret
lea    0xed2(%rip),%rax
jmp    114c <clock_rate+0x4c>
lea    0xecd(%rip),%rax
jmp    114c <clock_rate+0x4c>
lea    0xec8(%rip),%rax
divss  %xmm1,%xmm0
movss  %xmm0,(%rdi)
ret

LLVM IR (-O0):
@.str = [4 x i8] c"GHZ\00"
@.str.1 = [4 x i8] c"MHZ\00"
@.str.2 = [4 x i8] c"KHZ\00"
@.str.3 = [3 x i8] c"HZ\00"
define i8* @clock_rate(float* %0) {
%2 = alloca i8*
%3 = alloca float*
%4 = alloca float
store float* %0, float** %3
%5 = load float*, float** %3
%6 = load float, float* %5
store float %6, float* %4
%7 = load float, float* %4
%8 = fcmp oge float %7, 1.000000e+09
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load float, float* %4
%11 = fdiv float %10, 1.000000e+09
%12 = load float*, float** %3
store float %11, float* %12
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %33
13: ; preds = %1
%14 = load float, float* %4
%15 = fcmp oge float %14, 1.000000e+06
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load float, float* %4
%18 = fdiv float %17, 1.000000e+06
%19 = load float*, float** %3
store float %18, float* %19
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %33
20: ; preds = %13
%21 = load float, float* %4
%22 = fcmp oge float %21, 1.000000e+03
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load float, float* %4
%25 = fdiv float %24, 1.000000e+03
%26 = load float*, float** %3
store float %25, float* %26
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %33
27: ; preds = %20
%28 = load float, float* %4
%29 = load float*, float** %3
store float %28, float* %29
br label %30
30: ; preds = %27
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %33
33: ; preds = %32, %23, %16, %9
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
@.str = [4 x i8] c"GHZ\00"
@.str.1 = [4 x i8] c"MHZ\00"
@.str.2 = [4 x i8] c"KHZ\00"
@.str.3 = [3 x i8] c"HZ\00"
define i8* @clock_rate(float* nocapture %0) {
%2 = load float, float* %0
%3 = fcmp ult float %2, 1.000000e+09
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = fcmp ult float %2, 1.000000e+06
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = fcmp ult float %2, 1.000000e+03
br i1 %7, label %12, label %8
8: ; preds = %6, %4, %1
%9 = phi float [ 1.000000e+09, %1 ], [ 1.000000e+06, %4 ], [ 1.000000e+03, %6 ]
%10 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %6 ]
%11 = fdiv float %2, %9
store float %11, float* %0
br label %12
12: ; preds = %8, %6
%13 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %6 ], [ %10, %8 ]
ret i8* %13
}