float log_meter(float db) {
  float def = 0.0f;
  if (db < -70.0f) {
    def = 0.0f;
  } else if (db < -60.0f) {
    def = (db + 70.0f) * 0.25f;
  } else if (db < -50.0f) {
    def = (db + 60.0f) * 0.5f + 2.5f;
  } else if (db < -40.0f) {
    def = (db + 50.0f) * 0.75f + 7.5f;
  } else if (db < -30.0f) {
    def = (db + 40.0f) * 1.5f + 15.0f;
  } else if (db < -20.0f) {
    def = (db + 30.0f) * 2.0f + 30.0f;
  } else if (db < 6.0f) {
    def = (db + 20.0f) * 2.5f + 50.0f;
  } else {
    def = 115.0f;
  }
  return (def / 115.0f);
}


x86 assembly (clang, -O0):
<log_meter>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xee7(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1130 <log_meter+0x30>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12cd <log_meter+0x1cd>
movss  0xecc(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1165 <log_meter+0x65>
movss  0xf06(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xef5(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12c8 <log_meter+0x1c8>
movss  0xe9b(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11a6 <log_meter+0xa6>
movss  0xec9(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xeb8(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe88(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12c3 <log_meter+0x1c3>
movss  0xe5e(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11e7 <log_meter+0xe7>
movss  0xe64(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xe6f(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe67(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12be <log_meter+0x1be>
movss  0xe21(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1228 <log_meter+0x128>
movss  0xe37(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xe22(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe1a(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12b9 <log_meter+0x1b9>
movss  0xde4(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1261 <log_meter+0x161>
movss  0xdea(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
addss  %xmm0,%xmm0
movss  0xdd9(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12b4 <log_meter+0x1b4>
movss  0xdaf(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    12a2 <log_meter+0x1a2>
movss  0xdad(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xd98(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd90(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12af <log_meter+0x1af>
movss  0xd72(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12b4 <log_meter+0x1b4>
jmp    12b9 <log_meter+0x1b9>
jmp    12be <log_meter+0x1be>
jmp    12c3 <log_meter+0x1c3>
jmp    12c8 <log_meter+0x1c8>
jmp    12cd <log_meter+0x1cd>
movss  -0x8(%rbp),%xmm0
movss  0xd42(%rip),%xmm1
divss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_meter>:
xorps  %xmm1,%xmm1
movss  0xef5(%rip),%xmm2
ucomiss %xmm0,%xmm2
ja     11f9 <log_meter+0xf9>
movss  0xee8(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1136 <log_meter+0x36>
addss  0xf23(%rip),%xmm0
mulss  0xf1f(%rip),%xmm0
jmp    11f6 <log_meter+0xf6>
movss  0xeca(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1160 <log_meter+0x60>
addss  0xef9(%rip),%xmm0
mulss  0xef5(%rip),%xmm0
addss  0xec9(%rip),%xmm0
jmp    11f6 <log_meter+0xf6>
movss  0xea4(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1187 <log_meter+0x87>
addss  0xeb3(%rip),%xmm0
mulss  0xebf(%rip),%xmm0
addss  0xebb(%rip),%xmm0
jmp    11f6 <log_meter+0xf6>
movss  0xe81(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11ae <log_meter+0xae>
addss  0xe94(%rip),%xmm0
mulss  0xe90(%rip),%xmm0
addss  0xe8c(%rip),%xmm0
jmp    11f6 <log_meter+0xf6>
movss  0xe5e(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11d1 <log_meter+0xd1>
movss  0xe69(%rip),%xmm1
addss  %xmm1,%xmm0
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
jmp    11f6 <log_meter+0xf6>
movss  0xe43(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1205 <log_meter+0x105>
addss  0xe3a(%rip),%xmm0
mulss  0xe36(%rip),%xmm0
addss  0xe32(%rip),%xmm0
movaps %xmm0,%xmm1
divss  0xe17(%rip),%xmm1
movaps %xmm1,%xmm0
ret
movss  0xe0b(%rip),%xmm1
jmp    11f9 <log_meter+0xf9>

LLVM IR (-O0):
define float @log_meter(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
store float 0.000000e+00, float* %3
%4 = load float, float* %2
%5 = fcmp olt float %4, -7.000000e+01
br i1 %5, label %6, label %7
6: ; preds = %1
store float 0.000000e+00, float* %3
br label %56
7: ; preds = %1
%8 = load float, float* %2
%9 = fcmp olt float %8, -6.000000e+01
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load float, float* %2
%12 = fadd float %11, 7.000000e+01
%13 = fmul float %12, 2.500000e-01
store float %13, float* %3
br label %55
14: ; preds = %7
%15 = load float, float* %2
%16 = fcmp olt float %15, -5.000000e+01
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load float, float* %2
%19 = fadd float %18, 6.000000e+01
%20 = call float @llvm.fmuladd.f32(float %19, float 5.000000e-01, float 2.500000e+00)
store float %20, float* %3
br label %54
21: ; preds = %14
%22 = load float, float* %2
%23 = fcmp olt float %22, -4.000000e+01
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load float, float* %2
%26 = fadd float %25, 5.000000e+01
%27 = call float @llvm.fmuladd.f32(float %26, float 7.500000e-01, float 7.500000e+00)
store float %27, float* %3
br label %53
28: ; preds = %21
%29 = load float, float* %2
%30 = fcmp olt float %29, -3.000000e+01
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load float, float* %2
%33 = fadd float %32, 4.000000e+01
%34 = call float @llvm.fmuladd.f32(float %33, float 1.500000e+00, float 1.500000e+01)
store float %34, float* %3
br label %52
35: ; preds = %28
%36 = load float, float* %2
%37 = fcmp olt float %36, -2.000000e+01
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load float, float* %2
%40 = fadd float %39, 3.000000e+01
%41 = call float @llvm.fmuladd.f32(float %40, float 2.000000e+00, float 3.000000e+01)
store float %41, float* %3
br label %51
42: ; preds = %35
%43 = load float, float* %2
%44 = fcmp olt float %43, 6.000000e+00
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load float, float* %2
%47 = fadd float %46, 2.000000e+01
%48 = call float @llvm.fmuladd.f32(float %47, float 2.500000e+00, float 5.000000e+01)
store float %48, float* %3
br label %50
49: ; preds = %42
store float 1.150000e+02, float* %3
br label %50
50: ; preds = %49, %45
br label %51
51: ; preds = %50, %38
br label %52
52: ; preds = %51, %31
br label %53
53: ; preds = %52, %24
br label %54
54: ; preds = %53, %17
br label %55
55: ; preds = %54, %10
br label %56
56: ; preds = %55, %6
%57 = load float, float* %3
%58 = fdiv float %57, 1.150000e+02
ret float %58
}

LLVM IR (-O2):
define float @log_meter(float %0) {
%2 = fcmp olt float %0, -7.000000e+01
br i1 %2, label %33, label %3
3: ; preds = %1
%4 = fcmp olt float %0, -6.000000e+01
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = fadd float %0, 7.000000e+01
%7 = fmul float %6, 2.500000e-01
br label %33
8: ; preds = %3
%9 = fcmp olt float %0, -5.000000e+01
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = fadd float %0, 6.000000e+01
%12 = tail call float @llvm.fmuladd.f32(float %11, float 5.000000e-01, float 2.500000e+00)
br label %33
13: ; preds = %8
%14 = fcmp olt float %0, -4.000000e+01
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = fadd float %0, 5.000000e+01
%17 = tail call float @llvm.fmuladd.f32(float %16, float 7.500000e-01, float 7.500000e+00)
br label %33
18: ; preds = %13
%19 = fcmp olt float %0, -3.000000e+01
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = fadd float %0, 4.000000e+01
%22 = tail call float @llvm.fmuladd.f32(float %21, float 1.500000e+00, float 1.500000e+01)
br label %33
23: ; preds = %18
%24 = fcmp olt float %0, -2.000000e+01
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = fadd float %0, 3.000000e+01
%27 = tail call float @llvm.fmuladd.f32(float %26, float 2.000000e+00, float 3.000000e+01)
br label %33
28: ; preds = %23
%29 = fcmp olt float %0, 6.000000e+00
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = fadd float %0, 2.000000e+01
%32 = tail call float @llvm.fmuladd.f32(float %31, float 2.500000e+00, float 5.000000e+01)
br label %33
33: ; preds = %28, %1, %5, %15, %25, %30, %20, %10
%34 = phi float [ %7, %5 ], [ %12, %10 ], [ %17, %15 ], [ %22, %20 ], [ %27, %25 ], [ %32, %30 ], [ 0.000000e+00, %1 ], [ 1.150000e+02, %28 ]
%35 = fdiv float %34, 1.150000e+02
ret float %35
}