#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 a(double, double);
double b(double, double);
double c(double, double);
double d(double, double);
double f(double t, double y, int func) {
  switch (func) {
  case 0:
    return a(t, y);
    break;
  case 1:
    return b(t, y);
    break;
  case 2:
    return c(t, y);
    break;
  case 3:
    return d(t, y);
    break;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     11de <f+0x9e>
mov    -0x28(%rbp),%rax
lea    0xe8f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1060 <a@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11e6 <f+0xa6>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <b@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11e6 <f+0xa6>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <c@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11e6 <f+0xa6>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <d@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11e6 <f+0xa6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
cmp    $0x3,%edi
ja     115c <f+0x1c>
mov    %edi,%eax
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1060 <a@plt>
xorps  %xmm0,%xmm0
ret
jmp    1040 <b@plt>
jmp    1050 <c@plt>
jmp    1030 <d@plt>

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

LLVM IR (-O2):
define double @f(double %0, double %1, i32 %2) {
switch i32 %2, label %12 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
]
4: ; preds = %3
%5 = tail call double @a(double %0, double %1)
br label %12
6: ; preds = %3
%7 = tail call double @b(double %0, double %1)
br label %12
8: ; preds = %3
%9 = tail call double @c(double %0, double %1)
br label %12
10: ; preds = %3
%11 = tail call double @d(double %0, double %1)
br label %12
12: ; preds = %3, %10, %8, %6, %4
%13 = phi double [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ 0.000000e+00, %3 ]
ret double %13
}