int quantize_r(const float r, const int band) {
  const static float q1[17] = {0.8116f, 0.4273f, 0.4233f, 0.3827f, 0.3783f,
                               0.3848f, 0.3726f, 0.3669f, 0.3500f, 0.3440f,
                               0.3281f, 0.3256f, 0.3148f, 0.3091f, 0.3031f,
                               0.3340f, 0.5660f};
  const static float q2[17] = {0.8528f, 0.5300f, 0.5267f, 0.4800f, 0.4765f,
                               0.4853f, 0.4711f, 0.4635f, 0.4430f, 0.4356f,
                               0.4147f, 0.4117f, 0.3993f, 0.3892f, 0.3825f,
                               0.4151f, 0.6249f};
  const static float q3[17] = {0.8824f, 0.6216f, 0.6220f, 0.5754f, 0.5736f,
                               0.5838f, 0.5699f, 0.5595f, 0.5374f, 0.5281f,
                               0.5032f, 0.4983f, 0.4850f, 0.4674f, 0.4612f,
                               0.4929f, 0.6746f};
  if (r < q1[band]) {
    return 0;
  }
  if (r < q2[band]) {
    return 1;
  }
  if (r < q3[band]) {
    return 2;
  }
  return 3;
}


x86 assembly (clang, -O0):
<quantize_r>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  -0x8(%rbp),%xmm1
movslq -0xc(%rbp),%rcx
lea    0xee4(%rip),%rax
movss  (%rax,%rcx,4),%xmm0
ucomiss %xmm1,%xmm0
jbe    1136 <quantize_r+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1191 <quantize_r+0x91>
movss  -0x8(%rbp),%xmm1
movslq -0xc(%rbp),%rcx
lea    0xf0a(%rip),%rax
movss  (%rax,%rcx,4),%xmm0
ucomiss %xmm1,%xmm0
jbe    1160 <quantize_r+0x60>
movl   $0x1,-0x4(%rbp)
jmp    1191 <quantize_r+0x91>
movss  -0x8(%rbp),%xmm1
movslq -0xc(%rbp),%rcx
lea    0xf30(%rip),%rax
movss  (%rax,%rcx,4),%xmm0
ucomiss %xmm1,%xmm0
jbe    118a <quantize_r+0x8a>
movl   $0x2,-0x4(%rbp)
jmp    1191 <quantize_r+0x91>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<quantize_r>:
movslq %edi,%rcx
lea    0xef6(%rip),%rax
movss  (%rax,%rcx,4),%xmm1
xor    %eax,%eax
ucomiss %xmm0,%xmm1
ja     1143 <quantize_r+0x43>
lea    0xf33(%rip),%rax
movss  (%rax,%rcx,4),%xmm1
mov    $0x1,%eax
ucomiss %xmm0,%xmm1
ja     1143 <quantize_r+0x43>
lea    0xf6d(%rip),%rax
movss  (%rax,%rcx,4),%xmm1
xor    %eax,%eax
ucomiss %xmm0,%xmm1
seta   %al
xor    $0x3,%eax
ret

LLVM IR (-O0):
@quantize_r.q1 = internal constant [17 x float] [float 0x3FE9F8A0A0000000, float 0x3FDB58E220000000, float 0x3FDB1758E0000000, float 0x3FD87E2820000000, float 0x3FD8361140000000, float 0x3FD8A09020000000, float 0x3FD7D8ADA0000000, float 0x3FD77B4A20000000, float 0x3FD6666660000000, float 0x3FD60418A0000000, float 0x3FD4FF9720000000, float 0x3FD4D6A160000000, float 0x3FD425AEE0000000, float 0x3FD3C84B60000000, float 0x3FD365FD80000000, float 0x3FD5604180000000, float 0x3FE21CAC00000000]
@quantize_r.q2 = internal constant [17 x float] [float 0x3FEB4A2340000000, float 0x3FE0F5C280000000, float 0x3FE0DABA00000000, float 0x3FDEB851E0000000, float 0x3FDE7EF9E0000000, float 0x3FDF0F27C0000000, float 0x3FDE2680A0000000, float 0x3FDDA9FBE0000000, float 0x3FDC5A1CA0000000, float 0x3FDBE0DEE0000000, float 0x3FDA8A71E0000000, float 0x3FDA594B00000000, float 0x3FD98E21A0000000, float 0x3FD8E8A720000000, float 0x3FD87AE140000000, float 0x3FDA90FFA0000000, float 0x3FE3FF2E40000000]
@quantize_r.q3 = internal constant [17 x float] [float 0x3FEC3C9EE0000000, float 0x3FE3E425A0000000, float 0x3FE3E76C80000000, float 0x3FE269AD40000000, float 0x3FE25AEE60000000, float 0x3FE2AE7D60000000, float 0x3FE23C9EE0000000, float 0x3FE1E76C80000000, float 0x3FE1326180000000, float 0x3FE0E63200000000, float 0x3FE01A36E0000000, float 0x3FDFE425A0000000, float 0x3FDF0A3D80000000, float 0x3FDDE9E1C0000000, float 0x3FDD844D00000000, float 0x3FDF8BAC80000000, float 0x3FE59652C0000000]
define i32 @quantize_r(float %0, i32 %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
store float %0, float* %4
store i32 %1, i32* %5
%6 = load float, float* %4
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [17 x float], [17 x float]* @quantize_r.q1, i64 0, i64 %8
%10 = load float, float* %9
%11 = fcmp olt float %6, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %30
13: ; preds = %2
%14 = load float, float* %4
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [17 x float], [17 x float]* @quantize_r.q2, i64 0, i64 %16
%18 = load float, float* %17
%19 = fcmp olt float %14, %18
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 1, i32* %3
br label %30
21: ; preds = %13
%22 = load float, float* %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [17 x float], [17 x float]* @quantize_r.q3, i64 0, i64 %24
%26 = load float, float* %25
%27 = fcmp olt float %22, %26
br i1 %27, label %28, label %29
28: ; preds = %21
store i32 2, i32* %3
br label %30
29: ; preds = %21
store i32 3, i32* %3
br label %30
30: ; preds = %29, %28, %20, %12
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@quantize_r.q1 = internal unnamed_addr constant [17 x float] [float 0x3FE9F8A0A0000000, float 0x3FDB58E220000000, float 0x3FDB1758E0000000, float 0x3FD87E2820000000, float 0x3FD8361140000000, float 0x3FD8A09020000000, float 0x3FD7D8ADA0000000, float 0x3FD77B4A20000000, float 0x3FD6666660000000, float 0x3FD60418A0000000, float 0x3FD4FF9720000000, float 0x3FD4D6A160000000, float 0x3FD425AEE0000000, float 0x3FD3C84B60000000, float 0x3FD365FD80000000, float 0x3FD5604180000000, float 0x3FE21CAC00000000]
@quantize_r.q2 = internal unnamed_addr constant [17 x float] [float 0x3FEB4A2340000000, float 0x3FE0F5C280000000, float 0x3FE0DABA00000000, float 0x3FDEB851E0000000, float 0x3FDE7EF9E0000000, float 0x3FDF0F27C0000000, float 0x3FDE2680A0000000, float 0x3FDDA9FBE0000000, float 0x3FDC5A1CA0000000, float 0x3FDBE0DEE0000000, float 0x3FDA8A71E0000000, float 0x3FDA594B00000000, float 0x3FD98E21A0000000, float 0x3FD8E8A720000000, float 0x3FD87AE140000000, float 0x3FDA90FFA0000000, float 0x3FE3FF2E40000000]
@quantize_r.q3 = internal unnamed_addr constant [17 x float] [float 0x3FEC3C9EE0000000, float 0x3FE3E425A0000000, float 0x3FE3E76C80000000, float 0x3FE269AD40000000, float 0x3FE25AEE60000000, float 0x3FE2AE7D60000000, float 0x3FE23C9EE0000000, float 0x3FE1E76C80000000, float 0x3FE1326180000000, float 0x3FE0E63200000000, float 0x3FE01A36E0000000, float 0x3FDFE425A0000000, float 0x3FDF0A3D80000000, float 0x3FDDE9E1C0000000, float 0x3FDD844D00000000, float 0x3FDF8BAC80000000, float 0x3FE59652C0000000]
define i32 @quantize_r(float %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds [17 x float], [17 x float]* @quantize_r.q1, i64 0, i64 %3
%5 = load float, float* %4
%6 = fcmp ogt float %5, %0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = getelementptr inbounds [17 x float], [17 x float]* @quantize_r.q2, i64 0, i64 %3
%9 = load float, float* %8
%10 = fcmp ogt float %9, %0
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = getelementptr inbounds [17 x float], [17 x float]* @quantize_r.q3, i64 0, i64 %3
%13 = load float, float* %12
%14 = fcmp ogt float %13, %0
%15 = select i1 %14, i32 2, i32 3
br label %16
16: ; preds = %11, %7, %2
%17 = phi i32 [ 0, %2 ], [ 1, %7 ], [ %15, %11 ]
ret i32 %17
}