#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double speedBicycle(double, double);
double speedMotor(double, double);
double speedWalk(double, double);
double modSwitcher(int mod, double speed, double slope) {
  double v;
  switch (mod) {
  case 1:
    v = speedWalk(speed, slope);
    break;
  case 2:
    v = speedBicycle(speed, slope);
    break;
  case 3:
    v = speedMotor(speed, slope);
    break;
  default:
    v = 0;
  };
  return v;
}


x86 assembly (clang, -O0):
<modSwitcher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     117b <modSwitcher+0x4b>
jmp    1159 <modSwitcher+0x29>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     1194 <modSwitcher+0x64>
jmp    116a <modSwitcher+0x3a>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     11ad <modSwitcher+0x7d>
jmp    11c6 <modSwitcher+0x96>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <speedWalk@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11ce <modSwitcher+0x9e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <speedBicycle@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11ce <modSwitcher+0x9e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <speedMotor@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11ce <modSwitcher+0x9e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modSwitcher>:
cmp    $0x3,%edi
je     1144 <modSwitcher+0x14>
cmp    $0x2,%edi
je     1149 <modSwitcher+0x19>
cmp    $0x1,%edi
jne    114e <modSwitcher+0x1e>
jmp    1050 <speedWalk@plt>
jmp    1040 <speedMotor@plt>
jmp    1030 <speedBicycle@plt>
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @modSwitcher(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%8 = load i32, i32* %4
switch i32 %8, label %21 [
i32 1, label %9
i32 2, label %13
i32 3, label %17
]
9: ; preds = %3
%10 = load double, double* %5
%11 = load double, double* %6
%12 = call double @speedWalk(double %10, double %11)
store double %12, double* %7
br label %22
13: ; preds = %3
%14 = load double, double* %5
%15 = load double, double* %6
%16 = call double @speedBicycle(double %14, double %15)
store double %16, double* %7
br label %22
17: ; preds = %3
%18 = load double, double* %5
%19 = load double, double* %6
%20 = call double @speedMotor(double %18, double %19)
store double %20, double* %7
br label %22
21: ; preds = %3
store double 0.000000e+00, double* %7
br label %22
22: ; preds = %21, %17, %13, %9
%23 = load double, double* %7
ret double %23
}

LLVM IR (-O2):
define double @modSwitcher(i32 %0, double %1, double %2) {
switch i32 %0, label %10 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
]
4: ; preds = %3
%5 = tail call double @speedWalk(double %1, double %2)
br label %10
6: ; preds = %3
%7 = tail call double @speedBicycle(double %1, double %2)
br label %10
8: ; preds = %3
%9 = tail call double @speedMotor(double %1, double %2)
br label %10
10: ; preds = %3, %8, %6, %4
%11 = phi double [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ 0.000000e+00, %3 ]
ret double %11
}