double convert_channel(int which, double mv_value, double aux_value) {
  double val = 0.0;
  double degc;
  switch (which) {
  case 0:
    val = (mv_value / 1000.0) / 0.01;
    break;
  case 1:
    val = mv_value;
    break;
  case 2:
    val = mv_value / 10.0;
    break;
  case 3:
    val = (mv_value / 1000.0) / 0.128236877;
    break;
  case 4:
    val = mv_value;
    break;
  case 5:
    val = mv_value;
    break;
  case 6:
    val = mv_value;
    break;
  case 7:
    val = mv_value;
    break;
  default:
    break;
  }
  return (val);
}


x86 assembly (clang, -O0):
<convert_channel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x7,%rax
ja     11f2 <convert_channel+0xf2>
mov    -0x30(%rbp),%rax
lea    0xeeb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
movsd  0xebd(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xec1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <convert_channel+0xf7>
jmp    11f7 <convert_channel+0xf7>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_channel>:
cmp    $0x7,%edi
ja     1118 <convert_channel+0x18>
mov    %edi,%eax
lea    0xf12(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
ret
xorps  %xmm0,%xmm0
ret
divsd  0xedc(%rip),%xmm0
divsd  0xeec(%rip),%xmm0
ret
divsd  0xedb(%rip),%xmm0
ret
divsd  0xec2(%rip),%xmm0
divsd  0xec2(%rip),%xmm0
ret

LLVM IR (-O0):
define double @convert_channel(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
%9 = load i32, i32* %4
switch i32 %9, label %31 [
i32 0, label %10
i32 1, label %14
i32 2, label %16
i32 3, label %19
i32 4, label %23
i32 5, label %25
i32 6, label %27
i32 7, label %29
]
10: ; preds = %3
%11 = load double, double* %5
%12 = fdiv double %11, 1.000000e+03
%13 = fdiv double %12, 1.000000e-02
store double %13, double* %7
br label %32
14: ; preds = %3
%15 = load double, double* %5
store double %15, double* %7
br label %32
16: ; preds = %3
%17 = load double, double* %5
%18 = fdiv double %17, 1.000000e+01
store double %18, double* %7
br label %32
19: ; preds = %3
%20 = load double, double* %5
%21 = fdiv double %20, 1.000000e+03
%22 = fdiv double %21, 0x3FC06A10E46D9721
store double %22, double* %7
br label %32
23: ; preds = %3
%24 = load double, double* %5
store double %24, double* %7
br label %32
25: ; preds = %3
%26 = load double, double* %5
store double %26, double* %7
br label %32
27: ; preds = %3
%28 = load double, double* %5
store double %28, double* %7
br label %32
29: ; preds = %3
%30 = load double, double* %5
store double %30, double* %7
br label %32
31: ; preds = %3
br label %32
32: ; preds = %31, %29, %27, %25, %23, %19, %16, %14, %10
%33 = load double, double* %7
ret double %33
}

LLVM IR (-O2):
define double @convert_channel(i32 %0, double %1, double %2) {
switch i32 %0, label %17 [
i32 0, label %4
i32 1, label %7
i32 2, label %8
i32 3, label %10
i32 4, label %13
i32 5, label %14
i32 6, label %15
i32 7, label %16
]
4: ; preds = %3
%5 = fdiv double %1, 1.000000e+03
%6 = fdiv double %5, 1.000000e-02
br label %17
7: ; preds = %3
br label %17
8: ; preds = %3
%9 = fdiv double %1, 1.000000e+01
br label %17
10: ; preds = %3
%11 = fdiv double %1, 1.000000e+03
%12 = fdiv double %11, 0x3FC06A10E46D9721
br label %17
13: ; preds = %3
br label %17
14: ; preds = %3
br label %17
15: ; preds = %3
br label %17
16: ; preds = %3
br label %17
17: ; preds = %3, %16, %15, %14, %13, %10, %8, %7, %4
%18 = phi double [ 0.000000e+00, %3 ], [ %1, %16 ], [ %1, %15 ], [ %1, %14 ], [ %1, %13 ], [ %12, %10 ], [ %9, %8 ], [ %1, %7 ], [ %6, %4 ]
ret double %18
}