double range(double val, int button) {
  int k, nbvals, done;
  float vals1[] = {
      0.0002, 0.0003, 0.0004, 0.0005, 0.0006, 0.0007, 0.0008, 0.0009, 0.0010,
      0.0012, 0.0014, 0.0016, 0.0018, 0.0020, 0.0022, 0.0024, 0.0026, 0.0030,
      0.0032, 0.0034, 0.0036, 0.0038, 0.0040, 0.0042, 0.0044, 0.0046, 0.0048,
      0.0050, 0.0055, 0.0060, 0.0065, 0.0070, 0.0075, 0.0080, 0.0085, 0.0090,
      0.0095, 0.01,   0.011,  0.012,  0.013,  0.014,  0.015,  0.016,  0.017,
      0.018,  0.019,  0.02,   0.022,  0.024,  0.026,  0.028,  0.03,   0.032,
      0.034,  0.036,  0.038,  0.04,   0.042,  0.044,  0.046,  0.048,  0.05,
      0.055,  0.06,   0.065,  0.07,   0.075,  0.08,   0.085,  0.090,  0.095,
      0.1,    0.105,  0.11,   0.115,  0.12,   0.125,  0.13,   0.135,  0.14,
      0.145,  0.15,   0.155,  0.16,   0.165,  0.17,   0.175,  0.18,   0.185,
      0.19,   0.195,  0.2,    0.21,   0.22,   0.23,   0.24,   0.25,   0.26,
      0.27,   0.28,   0.29,   0.30,   0.32,   0.34,   0.36,   0.38,   0.40,
      0.42,   0.44,   0.46,   0.48,   0.5,    0.55,   0.60,   0.65,   0.70,
      0.75,   0.80,   0.85,   0.90,   0.95,   1.0,    1.05,   1.1,    1.15,
      1.2,    1.25,   1.3,    1.35,   1.4,    1.45,   1.5,    1.55,   1.6,
      1.65,   1.7,    1.75,   1.8,    1.85,   1.9,    1.95,   2,      2.1,
      2.2,    2.3,    2.4,    2.5,    2.6,    2.7,    2.8,    2.9,    3.0,
      3.1,    3.2,    3.3,    3.4,    3.5,    3.6,    3.7,    3.8,    3.9,
      4,      4.1,    4.2,    4.3,    4.4,    4.5,    4.6,    4.7,    4.8,
      4.9,    5,      5.2,    5.4,    5.6,    5.8,    6,      6.2,    6.4,
      6.6,    6.8,    7,      7.2,    7.4,    7.6,    7.8,    8,      8.2,
      8.4,    8.6,    8.8,    9,      9.2,    9.4,    9.6,    9.8,    10,
      10.5,   11,     11.5,   12,     12.5,   13,     13.5,   14,     14.5,
      15,     15.5,   16,     16.5,   17,     17.5,   18,     18.5,   19,
      19.5,   20,     21,     22,     23,     24,     25,     26,     27,
      28,     29,     30,     32,     34,     36,     38,     40,     42,
      44,     46,     48,     50,     55,     60,     65,     70,     75,
      80,     85,     90,     95,     100,    105,    110,    115,    120,
      125,    130,    135,    140,    145,    150,    155,    160,    165,
      170,    175,    180,    185,    190,    195,    200,    210,    220,
      230,    240,    250,    260,    270,    280,    290,    300,    320,
      340,    360,    380,    400,    420,    440,    460,    480,    500,
      550,    600,    650,    700,    750,    800,    850,    900,    950,
      1000,   1050,   1100,   1150,   1200,   1250,   1300,   1350,   1400,
      1450,   1500,   1550,   1600,   1650,   1700,   1750,   1800,   1850,
      1900,   1950,   2000,   2100,   2200,   2300,   2400,   2500,   2600,
      2700,   2800,   2900,   3000,   3200,   3400,   3600,   3800,   4000,
      4200,   4400,   4600,   4800,   5000,   5500,   6000};
  float vals2[] = {0.0002, 0.0005, 0.0010, 0.0020, 0.0050, 0.01, 0.02, 0.05,
                   0.1,    0.2,    0.5,    1,      2,      5,    10,   20,
                   50,     100,    200,    500,    1000,   2000, 5000, 6000};
  if (button > 0)
    val = val + 0.0001;
  else
    val = val - 0.0001;
  if (button == -1 || button == 1) {
    nbvals = sizeof(vals1) / sizeof *(vals1);
    done = 0;
    k = 0;
    while (!done) {
      if (val > vals1[k])
        k++;
      else
        done = 1;
      if (k >= nbvals)
        done = 1;
    }
    if (button == -1 && k > 1)
      val = vals1[k - 1];
    else if (button == 1 && k < nbvals)
      val = vals1[k];
    else
      val = 0;
  }
  if (button == -2 || button == 2) {
    nbvals = sizeof(vals2) / sizeof *(vals2);
    done = 0;
    k = 0;
    while (!done) {
      if (val > vals2[k])
        k++;
      else
        done = 1;
      if (k >= nbvals)
        done = 1;
    }
    if (button == -2 && k > 1)
      val = vals2[k - 1];
    else if (button == 2 && k < nbvals)
      val = vals2[k];
    else
      val = 0;
  }
  return (val);
}


x86 assembly (clang, -O0):
<range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5d0,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
lea    -0x570(%rbp),%rdi
lea    0xedf(%rip),%rsi
mov    $0x550,%edx
call   1030 <memcpy@plt>
lea    -0x5d0(%rbp),%rdi
lea    0x1417(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1174 <range+0x64>
movsd  0xe9b(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118a <range+0x7a>
movsd  -0x8(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     119e <range+0x8e>
cmpl   $0x1,-0xc(%rbp)
jne    128c <range+0x17c>
movl   $0x154,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c9 <range+0xb9>
jmp    1216 <range+0x106>
movsd  -0x8(%rbp),%xmm0
movslq -0x10(%rbp),%rax
movss  -0x570(%rbp,%rax,4),%xmm1
ff ff
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f7 <range+0xe7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fe <range+0xee>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1211 <range+0x101>
movl   $0x1,-0x18(%rbp)
jmp    11b3 <range+0xa3>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1249 <range+0x139>
cmpl   $0x1,-0x10(%rbp)
jle    1249 <range+0x139>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0x570(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <range+0x177>
cmpl   $0x1,-0xc(%rbp)
jne    127a <range+0x16a>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    127a <range+0x16a>
movslq -0x10(%rbp),%rax
movss  -0x570(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1282 <range+0x172>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <range+0x177>
jmp    128c <range+0x17c>
cmpl   $0xfffffffe,-0xc(%rbp)
je     12a0 <range+0x190>
cmpl   $0x2,-0xc(%rbp)
jne    138e <range+0x27e>
movl   $0x18,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12cb <range+0x1bb>
jmp    1318 <range+0x208>
movsd  -0x8(%rbp),%xmm0
movslq -0x10(%rbp),%rax
movss  -0x5d0(%rbp,%rax,4),%xmm1
ff ff
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12f9 <range+0x1e9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1300 <range+0x1f0>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1313 <range+0x203>
movl   $0x1,-0x18(%rbp)
jmp    12b5 <range+0x1a5>
cmpl   $0xfffffffe,-0xc(%rbp)
jne    134b <range+0x23b>
cmpl   $0x1,-0x10(%rbp)
jle    134b <range+0x23b>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0x5d0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1389 <range+0x279>
cmpl   $0x2,-0xc(%rbp)
jne    137c <range+0x26c>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    137c <range+0x26c>
movslq -0x10(%rbp),%rax
movss  -0x5d0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1384 <range+0x274>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1389 <range+0x279>
jmp    138e <range+0x27e>
movsd  -0x8(%rbp),%xmm0
add    $0x5d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<range>:
xor    %eax,%eax
test   %edi,%edi
setg   %al
lea    0xef2(%rip),%rcx
addsd  (%rcx,%rax,8),%xmm0
cmp    $0x1,%edi
je     111d <range+0x1d>
cmp    $0xffffffff,%edi
jne    1171 <range+0x71>
xor    %ecx,%ecx
lea    0xeea(%rip),%rax
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%edx
mov    %ecx,%ecx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
xor    %ecx,%ecx
ucomisd %xmm1,%xmm0
seta   %cl
add    %edx,%ecx
cmp    $0x153,%ecx
ja     1156 <range+0x56>
ucomisd %xmm1,%xmm0
ja     1130 <range+0x30>
cmp    $0xffffffff,%edi
jne    1160 <range+0x60>
cmp    $0x2,%ecx
jae    11bd <range+0xbd>
xorpd  %xmm0,%xmm0
cmp    $0x1,%edi
jne    1171 <range+0x71>
cmp    $0x153,%ecx
jbe    11d0 <range+0xd0>
cmp    $0x2,%edi
je     117b <range+0x7b>
cmp    $0xfffffffe,%edi
jne    11de <range+0xde>
xor    %ecx,%ecx
lea    0x13dc(%rip),%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%edx
mov    %ecx,%ecx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
xor    %ecx,%ecx
ucomisd %xmm1,%xmm0
seta   %cl
add    %edx,%ecx
cmp    $0x17,%ecx
ja     11b3 <range+0xb3>
ucomisd %xmm1,%xmm0
ja     1190 <range+0x90>
cmp    $0xfffffffe,%edi
jne    11c2 <range+0xc2>
cmp    $0x2,%ecx
jb     11c2 <range+0xc2>
add    $0xffffffff,%ecx
jmp    11d2 <range+0xd2>
xorpd  %xmm0,%xmm0
cmp    $0x2,%edi
jne    11de <range+0xde>
cmp    $0x17,%ecx
ja     11de <range+0xde>
mov    %ecx,%ecx
lea    (%rax,%rcx,4),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
ret

LLVM IR (-O0):
@__const.range.vals1 = [340 x float] [float 0x3F2A36E2E0000000, float 0x3F33A92A40000000, float 0x3F3A36E2E0000000, float 0x3F40624DE0000000, float 0x3F43A92A40000000, float 0x3F46F00680000000, float 0x3F4A36E2E0000000, float 0x3F4D7DBF40000000, float 0x3F50624DE0000000, float 0x3F53A92A40000000, float 0x3F56F00680000000, float 0x3F5A36E2E0000000, float 0x3F5D7DBF40000000, float 0x3F60624DE0000000, float 0x3F6205BC00000000, float 0x3F63A92A40000000, float 0x3F654C9860000000, float 0x3F689374C0000000, float 0x3F6A36E2E0000000, float 0x3F6BDA5120000000, float 0x3F6D7DBF40000000, float 0x3F6F212D80000000, float 0x3F70624DE0000000, float 0x3F713404E0000000, float 0x3F7205BC00000000, float 0x3F72D77320000000, float 0x3F73A92A40000000, float 0x3F747AE140000000, float 0x3F76872B00000000, float 0x3F789374C0000000, float 0x3F7A9FBE80000000, float 0x3F7CAC0840000000, float 0x3F7EB851E0000000, float 0x3F80624DE0000000, float 0x3F816872C0000000, float 0x3F826E9780000000, float 0x3F8374BC60000000, float 0x3F847AE140000000, float 0x3F86872B00000000, float 0x3F889374C0000000, float 0x3F8A9FBE80000000, float 0x3F8CAC0840000000, float 0x3F8EB851E0000000, float 0x3F90624DE0000000, float 0x3F916872C0000000, float 0x3F926E9780000000, float 0x3F9374BC60000000, float 0x3F947AE140000000, float 0x3F96872B00000000, float 0x3F989374C0000000, float 0x3F9A9FBE80000000, float 0x3F9CAC0840000000, float 0x3F9EB851E0000000, float 0x3FA0624DE0000000, float 0x3FA16872C0000000, float 0x3FA26E9780000000, float 0x3FA374BC60000000, float 0x3FA47AE140000000, float 0x3FA5810620000000, float 0x3FA6872B00000000, float 0x3FA78D4FE0000000, float 0x3FA89374C0000000, float 0x3FA99999A0000000, float 0x3FAC28F5C0000000, float 0x3FAEB851E0000000, float 0x3FB0A3D700000000, float 0x3FB1EB8520000000, float 0x3FB3333340000000, float 0x3FB47AE140000000, float 0x3FB5C28F60000000, float 0x3FB70A3D80000000, float 0x3FB851EB80000000, float 0x3FB99999A0000000, float 0x3FBAE147A0000000, float 0x3FBC28F5C0000000, float 0x3FBD70A3E0000000, float 0x3FBEB851E0000000, float 1.250000e-01, float 0x3FC0A3D700000000, float 0x3FC147AE20000000, float 0x3FC1EB8520000000, float 0x3FC28F5C20000000, float 0x3FC3333340000000, float 0x3FC3D70A40000000, float 0x3FC47AE140000000, float 0x3FC51EB860000000, float 0x3FC5C28F60000000, float 0x3FC6666660000000, float 0x3FC70A3D80000000, float 0x3FC7AE1480000000, float 0x3FC851EB80000000, float 0x3FC8F5C280000000, float 0x3FC99999A0000000, float 0x3FCAE147A0000000, float 0x3FCC28F5C0000000, float 0x3FCD70A3E0000000, float 0x3FCEB851E0000000, float 2.500000e-01, float 0x3FD0A3D700000000, float 0x3FD147AE20000000, float 0x3FD1EB8520000000, float 0x3FD28F5C20000000, float 0x3FD3333340000000, float 0x3FD47AE140000000, float 0x3FD5C28F60000000, float 0x3FD70A3D80000000, float 0x3FD851EB80000000, float 0x3FD99999A0000000, float 0x3FDAE147A0000000, float 0x3FDC28F5C0000000, float 0x3FDD70A3E0000000, float 0x3FDEB851E0000000, float 5.000000e-01, float 0x3FE19999A0000000, float 0x3FE3333340000000, float 0x3FE4CCCCC0000000, float 0x3FE6666660000000, float 7.500000e-01, float 0x3FE99999A0000000, float 0x3FEB333340000000, float 0x3FECCCCCC0000000, float 0x3FEE666660000000, float 1.000000e+00, float 0x3FF0CCCCC0000000, float 0x3FF19999A0000000, float 0x3FF2666660000000, float 0x3FF3333340000000, float 1.250000e+00, float 0x3FF4CCCCC0000000, float 0x3FF59999A0000000, float 0x3FF6666660000000, float 0x3FF7333340000000, float 1.500000e+00, float 0x3FF8CCCCC0000000, float 0x3FF99999A0000000, float 0x3FFA666660000000, float 0x3FFB333340000000, float 1.750000e+00, float 0x3FFCCCCCC0000000, float 0x3FFD9999A0000000, float 0x3FFE666660000000, float 0x3FFF333340000000, float 2.000000e+00, float 0x4000CCCCC0000000, float 0x40019999A0000000, float 0x4002666660000000, float 0x4003333340000000, float 2.500000e+00, float 0x4004CCCCC0000000, float 0x40059999A0000000, float 0x4006666660000000, float 0x4007333340000000, float 3.000000e+00, float 0x4008CCCCC0000000, float 0x40099999A0000000, float 0x400A666660000000, float 0x400B333340000000, float 3.500000e+00, float 0x400CCCCCC0000000, float 0x400D9999A0000000, float 0x400E666660000000, float 0x400F333340000000, float 4.000000e+00, float 0x4010666660000000, float 0x4010CCCCC0000000, float 0x4011333340000000, float 0x40119999A0000000, float 4.500000e+00, float 0x4012666660000000, float 0x4012CCCCC0000000, float 0x4013333340000000, float 0x40139999A0000000, float 5.000000e+00, float 0x4014CCCCC0000000, float 0x40159999A0000000, float 0x4016666660000000, float 0x4017333340000000, float 6.000000e+00, float 0x4018CCCCC0000000, float 0x40199999A0000000, float 0x401A666660000000, float 0x401B333340000000, float 7.000000e+00, float 0x401CCCCCC0000000, float 0x401D9999A0000000, float 0x401E666660000000, float 0x401F333340000000, float 8.000000e+00, float 0x4020666660000000, float 0x4020CCCCC0000000, float 0x4021333340000000, float 0x40219999A0000000, float 9.000000e+00, float 0x4022666660000000, float 0x4022CCCCC0000000, float 0x4023333340000000, float 0x40239999A0000000, float 1.000000e+01, float 1.050000e+01, float 1.100000e+01, float 1.150000e+01, float 1.200000e+01, float 1.250000e+01, float 1.300000e+01, float 1.350000e+01, float 1.400000e+01, float 1.450000e+01, float 1.500000e+01, float 1.550000e+01, float 1.600000e+01, float 1.650000e+01, float 1.700000e+01, float 1.750000e+01, float 1.800000e+01, float 1.850000e+01, float 1.900000e+01, float 1.950000e+01, float 2.000000e+01, float 2.100000e+01, float 2.200000e+01, float 2.300000e+01, float 2.400000e+01, float 2.500000e+01, float 2.600000e+01, float 2.700000e+01, float 2.800000e+01, float 2.900000e+01, float 3.000000e+01, float 3.200000e+01, float 3.400000e+01, float 3.600000e+01, float 3.800000e+01, float 4.000000e+01, float 4.200000e+01, float 4.400000e+01, float 4.600000e+01, float 4.800000e+01, float 5.000000e+01, float 5.500000e+01, float 6.000000e+01, float 6.500000e+01, float 7.000000e+01, float 7.500000e+01, float 8.000000e+01, float 8.500000e+01, float 9.000000e+01, float 9.500000e+01, float 1.000000e+02, float 1.050000e+02, float 1.100000e+02, float 1.150000e+02, float 1.200000e+02, float 1.250000e+02, float 1.300000e+02, float 1.350000e+02, float 1.400000e+02, float 1.450000e+02, float 1.500000e+02, float 1.550000e+02, float 1.600000e+02, float 1.650000e+02, float 1.700000e+02, float 1.750000e+02, float 1.800000e+02, float 1.850000e+02, float 1.900000e+02, float 1.950000e+02, float 2.000000e+02, float 2.100000e+02, float 2.200000e+02, float 2.300000e+02, float 2.400000e+02, float 2.500000e+02, float 2.600000e+02, float 2.700000e+02, float 2.800000e+02, float 2.900000e+02, float 3.000000e+02, float 3.200000e+02, float 3.400000e+02, float 3.600000e+02, float 3.800000e+02, float 4.000000e+02, float 4.200000e+02, float 4.400000e+02, float 4.600000e+02, float 4.800000e+02, float 5.000000e+02, float 5.500000e+02, float 6.000000e+02, float 6.500000e+02, float 7.000000e+02, float 7.500000e+02, float 8.000000e+02, float 8.500000e+02, float 9.000000e+02, float 9.500000e+02, float 1.000000e+03, float 1.050000e+03, float 1.100000e+03, float 1.150000e+03, float 1.200000e+03, float 1.250000e+03, float 1.300000e+03, float 1.350000e+03, float 1.400000e+03, float 1.450000e+03, float 1.500000e+03, float 1.550000e+03, float 1.600000e+03, float 1.650000e+03, float 1.700000e+03, float 1.750000e+03, float 1.800000e+03, float 1.850000e+03, float 1.900000e+03, float 1.950000e+03, float 2.000000e+03, float 2.100000e+03, float 2.200000e+03, float 2.300000e+03, float 2.400000e+03, float 2.500000e+03, float 2.600000e+03, float 2.700000e+03, float 2.800000e+03, float 2.900000e+03, float 3.000000e+03, float 3.200000e+03, float 3.400000e+03, float 3.600000e+03, float 3.800000e+03, float 4.000000e+03, float 4.200000e+03, float 4.400000e+03, float 4.600000e+03, float 4.800000e+03, float 5.000000e+03, float 5.500000e+03, float 6.000000e+03]
@__const.range.vals2 = [24 x float] [float 0x3F2A36E2E0000000, float 0x3F40624DE0000000, float 0x3F50624DE0000000, float 0x3F60624DE0000000, float 0x3F747AE140000000, float 0x3F847AE140000000, float 0x3F947AE140000000, float 0x3FA99999A0000000, float 0x3FB99999A0000000, float 0x3FC99999A0000000, float 5.000000e-01, float 1.000000e+00, float 2.000000e+00, float 5.000000e+00, float 1.000000e+01, float 2.000000e+01, float 5.000000e+01, float 1.000000e+02, float 2.000000e+02, float 5.000000e+02, float 1.000000e+03, float 2.000000e+03, float 5.000000e+03, float 6.000000e+03]
define double @range(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [340 x float]
%9 = alloca [24 x float]
store double %0, double* %3
store i32 %1, i32* %4
%10 = bitcast [340 x float]* %8 to i8*
%11 = bitcast [24 x float]* %9 to i8*
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load double, double* %3
%16 = fadd double %15, 1.000000e-04
store double %16, double* %3
br label %20
17: ; preds = %2
%18 = load double, double* %3
%19 = fsub double %18, 1.000000e-04
store double %19, double* %3
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, -1
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %78
26: ; preds = %23, %20
store i32 340, i32* %6
store i32 0, i32* %7
store i32 0, i32* %5
br label %27
27: ; preds = %48, %26
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
br i1 %30, label %31, label %49
31: ; preds = %27
%32 = load double, double* %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [340 x float], [340 x float]* %8, i64 0, i64 %34
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = fcmp ogt double %32, %37
br i1 %38, label %39, label %42
39: ; preds = %31
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %43
42: ; preds = %31
store i32 1, i32* %7
br label %43
43: ; preds = %42, %39
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = icmp sge i32 %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 1, i32* %7
br label %48
48: ; preds = %47, %43
br label %27
49: ; preds = %27
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %62
52: ; preds = %49
%53 = load i32, i32* %5
%54 = icmp sgt i32 %53, 1
br i1 %54, label %55, label %62
55: ; preds = %52
%56 = load i32, i32* %5
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [340 x float], [340 x float]* %8, i64 0, i64 %58
%60 = load float, float* %59
%61 = fpext float %60 to double
store double %61, double* %3
br label %77
62: ; preds = %52, %49
%63 = load i32, i32* %4
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %75
65: ; preds = %62
%66 = load i32, i32* %5
%67 = load i32, i32* %6
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %75
69: ; preds = %65
%70 = load i32, i32* %5
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [340 x float], [340 x float]* %8, i64 0, i64 %71
%73 = load float, float* %72
%74 = fpext float %73 to double
store double %74, double* %3
br label %76
75: ; preds = %65, %62
store double 0.000000e+00, double* %3
br label %76
76: ; preds = %75, %69
br label %77
77: ; preds = %76, %55
br label %78
78: ; preds = %77, %23
%79 = load i32, i32* %4
%80 = icmp eq i32 %79, -2
br i1 %80, label %84, label %81
81: ; preds = %78
%82 = load i32, i32* %4
%83 = icmp eq i32 %82, 2
br i1 %83, label %84, label %136
84: ; preds = %81, %78
store i32 24, i32* %6
store i32 0, i32* %7
store i32 0, i32* %5
br label %85
85: ; preds = %106, %84
%86 = load i32, i32* %7
%87 = icmp ne i32 %86, 0
%88 = xor i1 %87, true
br i1 %88, label %89, label %107
89: ; preds = %85
%90 = load double, double* %3
%91 = load i32, i32* %5
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [24 x float], [24 x float]* %9, i64 0, i64 %92
%94 = load float, float* %93
%95 = fpext float %94 to double
%96 = fcmp ogt double %90, %95
br i1 %96, label %97, label %100
97: ; preds = %89
%98 = load i32, i32* %5
%99 = add nsw i32 %98, 1
store i32 %99, i32* %5
br label %101
100: ; preds = %89
store i32 1, i32* %7
br label %101
101: ; preds = %100, %97
%102 = load i32, i32* %5
%103 = load i32, i32* %6
%104 = icmp sge i32 %102, %103
br i1 %104, label %105, label %106
105: ; preds = %101
store i32 1, i32* %7
br label %106
106: ; preds = %105, %101
br label %85
107: ; preds = %85
%108 = load i32, i32* %4
%109 = icmp eq i32 %108, -2
br i1 %109, label %110, label %120
110: ; preds = %107
%111 = load i32, i32* %5
%112 = icmp sgt i32 %111, 1
br i1 %112, label %113, label %120
113: ; preds = %110
%114 = load i32, i32* %5
%115 = sub nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [24 x float], [24 x float]* %9, i64 0, i64 %116
%118 = load float, float* %117
%119 = fpext float %118 to double
store double %119, double* %3
br label %135
120: ; preds = %110, %107
%121 = load i32, i32* %4
%122 = icmp eq i32 %121, 2
br i1 %122, label %123, label %133
123: ; preds = %120
%124 = load i32, i32* %5
%125 = load i32, i32* %6
%126 = icmp slt i32 %124, %125
br i1 %126, label %127, label %133
127: ; preds = %123
%128 = load i32, i32* %5
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [24 x float], [24 x float]* %9, i64 0, i64 %129
%131 = load float, float* %130
%132 = fpext float %131 to double
store double %132, double* %3
br label %134
133: ; preds = %123, %120
store double 0.000000e+00, double* %3
br label %134
134: ; preds = %133, %127
br label %135
135: ; preds = %134, %113
br label %136
136: ; preds = %135, %81
%137 = load double, double* %3
ret double %137
}

LLVM IR (-O2):
@__const.range.vals1 = [340 x float] [float 0x3F2A36E2E0000000, float 0x3F33A92A40000000, float 0x3F3A36E2E0000000, float 0x3F40624DE0000000, float 0x3F43A92A40000000, float 0x3F46F00680000000, float 0x3F4A36E2E0000000, float 0x3F4D7DBF40000000, float 0x3F50624DE0000000, float 0x3F53A92A40000000, float 0x3F56F00680000000, float 0x3F5A36E2E0000000, float 0x3F5D7DBF40000000, float 0x3F60624DE0000000, float 0x3F6205BC00000000, float 0x3F63A92A40000000, float 0x3F654C9860000000, float 0x3F689374C0000000, float 0x3F6A36E2E0000000, float 0x3F6BDA5120000000, float 0x3F6D7DBF40000000, float 0x3F6F212D80000000, float 0x3F70624DE0000000, float 0x3F713404E0000000, float 0x3F7205BC00000000, float 0x3F72D77320000000, float 0x3F73A92A40000000, float 0x3F747AE140000000, float 0x3F76872B00000000, float 0x3F789374C0000000, float 0x3F7A9FBE80000000, float 0x3F7CAC0840000000, float 0x3F7EB851E0000000, float 0x3F80624DE0000000, float 0x3F816872C0000000, float 0x3F826E9780000000, float 0x3F8374BC60000000, float 0x3F847AE140000000, float 0x3F86872B00000000, float 0x3F889374C0000000, float 0x3F8A9FBE80000000, float 0x3F8CAC0840000000, float 0x3F8EB851E0000000, float 0x3F90624DE0000000, float 0x3F916872C0000000, float 0x3F926E9780000000, float 0x3F9374BC60000000, float 0x3F947AE140000000, float 0x3F96872B00000000, float 0x3F989374C0000000, float 0x3F9A9FBE80000000, float 0x3F9CAC0840000000, float 0x3F9EB851E0000000, float 0x3FA0624DE0000000, float 0x3FA16872C0000000, float 0x3FA26E9780000000, float 0x3FA374BC60000000, float 0x3FA47AE140000000, float 0x3FA5810620000000, float 0x3FA6872B00000000, float 0x3FA78D4FE0000000, float 0x3FA89374C0000000, float 0x3FA99999A0000000, float 0x3FAC28F5C0000000, float 0x3FAEB851E0000000, float 0x3FB0A3D700000000, float 0x3FB1EB8520000000, float 0x3FB3333340000000, float 0x3FB47AE140000000, float 0x3FB5C28F60000000, float 0x3FB70A3D80000000, float 0x3FB851EB80000000, float 0x3FB99999A0000000, float 0x3FBAE147A0000000, float 0x3FBC28F5C0000000, float 0x3FBD70A3E0000000, float 0x3FBEB851E0000000, float 1.250000e-01, float 0x3FC0A3D700000000, float 0x3FC147AE20000000, float 0x3FC1EB8520000000, float 0x3FC28F5C20000000, float 0x3FC3333340000000, float 0x3FC3D70A40000000, float 0x3FC47AE140000000, float 0x3FC51EB860000000, float 0x3FC5C28F60000000, float 0x3FC6666660000000, float 0x3FC70A3D80000000, float 0x3FC7AE1480000000, float 0x3FC851EB80000000, float 0x3FC8F5C280000000, float 0x3FC99999A0000000, float 0x3FCAE147A0000000, float 0x3FCC28F5C0000000, float 0x3FCD70A3E0000000, float 0x3FCEB851E0000000, float 2.500000e-01, float 0x3FD0A3D700000000, float 0x3FD147AE20000000, float 0x3FD1EB8520000000, float 0x3FD28F5C20000000, float 0x3FD3333340000000, float 0x3FD47AE140000000, float 0x3FD5C28F60000000, float 0x3FD70A3D80000000, float 0x3FD851EB80000000, float 0x3FD99999A0000000, float 0x3FDAE147A0000000, float 0x3FDC28F5C0000000, float 0x3FDD70A3E0000000, float 0x3FDEB851E0000000, float 5.000000e-01, float 0x3FE19999A0000000, float 0x3FE3333340000000, float 0x3FE4CCCCC0000000, float 0x3FE6666660000000, float 7.500000e-01, float 0x3FE99999A0000000, float 0x3FEB333340000000, float 0x3FECCCCCC0000000, float 0x3FEE666660000000, float 1.000000e+00, float 0x3FF0CCCCC0000000, float 0x3FF19999A0000000, float 0x3FF2666660000000, float 0x3FF3333340000000, float 1.250000e+00, float 0x3FF4CCCCC0000000, float 0x3FF59999A0000000, float 0x3FF6666660000000, float 0x3FF7333340000000, float 1.500000e+00, float 0x3FF8CCCCC0000000, float 0x3FF99999A0000000, float 0x3FFA666660000000, float 0x3FFB333340000000, float 1.750000e+00, float 0x3FFCCCCCC0000000, float 0x3FFD9999A0000000, float 0x3FFE666660000000, float 0x3FFF333340000000, float 2.000000e+00, float 0x4000CCCCC0000000, float 0x40019999A0000000, float 0x4002666660000000, float 0x4003333340000000, float 2.500000e+00, float 0x4004CCCCC0000000, float 0x40059999A0000000, float 0x4006666660000000, float 0x4007333340000000, float 3.000000e+00, float 0x4008CCCCC0000000, float 0x40099999A0000000, float 0x400A666660000000, float 0x400B333340000000, float 3.500000e+00, float 0x400CCCCCC0000000, float 0x400D9999A0000000, float 0x400E666660000000, float 0x400F333340000000, float 4.000000e+00, float 0x4010666660000000, float 0x4010CCCCC0000000, float 0x4011333340000000, float 0x40119999A0000000, float 4.500000e+00, float 0x4012666660000000, float 0x4012CCCCC0000000, float 0x4013333340000000, float 0x40139999A0000000, float 5.000000e+00, float 0x4014CCCCC0000000, float 0x40159999A0000000, float 0x4016666660000000, float 0x4017333340000000, float 6.000000e+00, float 0x4018CCCCC0000000, float 0x40199999A0000000, float 0x401A666660000000, float 0x401B333340000000, float 7.000000e+00, float 0x401CCCCCC0000000, float 0x401D9999A0000000, float 0x401E666660000000, float 0x401F333340000000, float 8.000000e+00, float 0x4020666660000000, float 0x4020CCCCC0000000, float 0x4021333340000000, float 0x40219999A0000000, float 9.000000e+00, float 0x4022666660000000, float 0x4022CCCCC0000000, float 0x4023333340000000, float 0x40239999A0000000, float 1.000000e+01, float 1.050000e+01, float 1.100000e+01, float 1.150000e+01, float 1.200000e+01, float 1.250000e+01, float 1.300000e+01, float 1.350000e+01, float 1.400000e+01, float 1.450000e+01, float 1.500000e+01, float 1.550000e+01, float 1.600000e+01, float 1.650000e+01, float 1.700000e+01, float 1.750000e+01, float 1.800000e+01, float 1.850000e+01, float 1.900000e+01, float 1.950000e+01, float 2.000000e+01, float 2.100000e+01, float 2.200000e+01, float 2.300000e+01, float 2.400000e+01, float 2.500000e+01, float 2.600000e+01, float 2.700000e+01, float 2.800000e+01, float 2.900000e+01, float 3.000000e+01, float 3.200000e+01, float 3.400000e+01, float 3.600000e+01, float 3.800000e+01, float 4.000000e+01, float 4.200000e+01, float 4.400000e+01, float 4.600000e+01, float 4.800000e+01, float 5.000000e+01, float 5.500000e+01, float 6.000000e+01, float 6.500000e+01, float 7.000000e+01, float 7.500000e+01, float 8.000000e+01, float 8.500000e+01, float 9.000000e+01, float 9.500000e+01, float 1.000000e+02, float 1.050000e+02, float 1.100000e+02, float 1.150000e+02, float 1.200000e+02, float 1.250000e+02, float 1.300000e+02, float 1.350000e+02, float 1.400000e+02, float 1.450000e+02, float 1.500000e+02, float 1.550000e+02, float 1.600000e+02, float 1.650000e+02, float 1.700000e+02, float 1.750000e+02, float 1.800000e+02, float 1.850000e+02, float 1.900000e+02, float 1.950000e+02, float 2.000000e+02, float 2.100000e+02, float 2.200000e+02, float 2.300000e+02, float 2.400000e+02, float 2.500000e+02, float 2.600000e+02, float 2.700000e+02, float 2.800000e+02, float 2.900000e+02, float 3.000000e+02, float 3.200000e+02, float 3.400000e+02, float 3.600000e+02, float 3.800000e+02, float 4.000000e+02, float 4.200000e+02, float 4.400000e+02, float 4.600000e+02, float 4.800000e+02, float 5.000000e+02, float 5.500000e+02, float 6.000000e+02, float 6.500000e+02, float 7.000000e+02, float 7.500000e+02, float 8.000000e+02, float 8.500000e+02, float 9.000000e+02, float 9.500000e+02, float 1.000000e+03, float 1.050000e+03, float 1.100000e+03, float 1.150000e+03, float 1.200000e+03, float 1.250000e+03, float 1.300000e+03, float 1.350000e+03, float 1.400000e+03, float 1.450000e+03, float 1.500000e+03, float 1.550000e+03, float 1.600000e+03, float 1.650000e+03, float 1.700000e+03, float 1.750000e+03, float 1.800000e+03, float 1.850000e+03, float 1.900000e+03, float 1.950000e+03, float 2.000000e+03, float 2.100000e+03, float 2.200000e+03, float 2.300000e+03, float 2.400000e+03, float 2.500000e+03, float 2.600000e+03, float 2.700000e+03, float 2.800000e+03, float 2.900000e+03, float 3.000000e+03, float 3.200000e+03, float 3.400000e+03, float 3.600000e+03, float 3.800000e+03, float 4.000000e+03, float 4.200000e+03, float 4.400000e+03, float 4.600000e+03, float 4.800000e+03, float 5.000000e+03, float 5.500000e+03, float 6.000000e+03]
@__const.range.vals2 = [24 x float] [float 0x3F2A36E2E0000000, float 0x3F40624DE0000000, float 0x3F50624DE0000000, float 0x3F60624DE0000000, float 0x3F747AE140000000, float 0x3F847AE140000000, float 0x3F947AE140000000, float 0x3FA99999A0000000, float 0x3FB99999A0000000, float 0x3FC99999A0000000, float 5.000000e-01, float 1.000000e+00, float 2.000000e+00, float 5.000000e+00, float 1.000000e+01, float 2.000000e+01, float 5.000000e+01, float 1.000000e+02, float 2.000000e+02, float 5.000000e+02, float 1.000000e+03, float 2.000000e+03, float 5.000000e+03, float 6.000000e+03]
define double @range(double %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = select i1 %3, double 1.000000e-04, double -1.000000e-04
%5 = fadd double %4, %0
%6 = icmp eq i32 %1, -1
%7 = icmp eq i32 %1, 1
switch i32 %1, label %33 [
i32 -1, label %8
i32 1, label %8
]
8: ; preds = %2, %2
br label %9
9: ; preds = %8, %9
%10 = phi i32 [ %17, %9 ], [ 0, %8 ]
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [340 x float], [340 x float]* @__const.range.vals1, i64 0, i64 %11
%13 = load float, float* %12
%14 = fpext float %13 to double
%15 = fcmp ogt double %5, %14
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %10, %16
%18 = icmp ult i32 %17, 340
%19 = select i1 %18, i1 %15, i1 false
br i1 %19, label %9, label %20
20: ; preds = %9
%21 = icmp ugt i32 %17, 1
%22 = select i1 %6, i1 %21, i1 false
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = add nsw i32 %17, -1
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [340 x float], [340 x float]* @__const.range.vals1, i64 0, i64 %25
br label %62
27: ; preds = %20
%28 = icmp ult i32 %17, 340
%29 = select i1 %7, i1 %28, i1 false
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = zext i32 %17 to i64
%32 = getelementptr inbounds [340 x float], [340 x float]* @__const.range.vals1, i64 0, i64 %31
br label %62
33: ; preds = %2, %27
%34 = phi double [ %5, %2 ], [ 0.000000e+00, %27 ]
%35 = icmp eq i32 %1, -2
%36 = icmp eq i32 %1, 2
switch i32 %1, label %66 [
i32 -2, label %37
i32 2, label %37
]
37: ; preds = %33, %33
br label %38
38: ; preds = %37, %38
%39 = phi i32 [ %46, %38 ], [ 0, %37 ]
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [24 x float], [24 x float]* @__const.range.vals2, i64 0, i64 %40
%42 = load float, float* %41
%43 = fpext float %42 to double
%44 = fcmp ogt double %34, %43
%45 = zext i1 %44 to i32
%46 = add nuw nsw i32 %39, %45
%47 = icmp ult i32 %46, 24
%48 = select i1 %47, i1 %44, i1 false
br i1 %48, label %38, label %49
49: ; preds = %38
%50 = icmp ugt i32 %46, 1
%51 = select i1 %35, i1 %50, i1 false
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = add nsw i32 %46, -1
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [24 x float], [24 x float]* @__const.range.vals2, i64 0, i64 %54
br label %62
56: ; preds = %49
%57 = icmp ult i32 %46, 24
%58 = select i1 %36, i1 %57, i1 false
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = zext i32 %46 to i64
%61 = getelementptr inbounds [24 x float], [24 x float]* @__const.range.vals2, i64 0, i64 %60
br label %62
62: ; preds = %59, %52, %23, %30
%63 = phi float* [ %32, %30 ], [ %26, %23 ], [ %55, %52 ], [ %61, %59 ]
%64 = load float, float* %63
%65 = fpext float %64 to double
br label %66
66: ; preds = %62, %56, %33
%67 = phi double [ %34, %33 ], [ 0.000000e+00, %56 ], [ %65, %62 ]
ret double %67
}