#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 */
int /*<<< orphan*/ fatalError(char *);
int /*<<< orphan*/ root1(double);
int /*<<< orphan*/ root2(double);
int /*<<< orphan*/ root3(double);
int /*<<< orphan*/ root4(double);
int /*<<< orphan*/ root5(double);
int /*<<< orphan*/ rootN(int, double);
void Rys_findRoots(int n, double X) {
  switch (n) {
  case 0:
    fatalError("Roots: cannot have rys.roots for zero order");
    break;
  case 1:
    root1(X);
    break;
  case 2:
    root2(X);
    break;
  case 3:
    root3(X);
    break;
  case 4:
    root4(X);
    break;
  case 5:
    root5(X);
    break;
  default:
    rootN(n, X);
    break;
  }
}


x86 assembly (clang, -O0):
<Rys_findRoots>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x5,%rax
ja     1201 <Rys_findRoots+0x91>
mov    -0x18(%rbp),%rax
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6c(%rip),%rdi
call   1090 <fatalError@plt>
jmp    120e <Rys_findRoots+0x9e>
movsd  -0x10(%rbp),%xmm0
call   1070 <root1@plt>
jmp    120e <Rys_findRoots+0x9e>
movsd  -0x10(%rbp),%xmm0
call   1030 <root2@plt>
jmp    120e <Rys_findRoots+0x9e>
movsd  -0x10(%rbp),%xmm0
call   1080 <root3@plt>
jmp    120e <Rys_findRoots+0x9e>
movsd  -0x10(%rbp),%xmm0
call   1040 <root4@plt>
jmp    120e <Rys_findRoots+0x9e>
movsd  -0x10(%rbp),%xmm0
call   1060 <root5@plt>
jmp    120e <Rys_findRoots+0x9e>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
call   1050 <rootN@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rys_findRoots>:
cmp    $0x5,%edi
ja     1193 <Rys_findRoots+0x23>
mov    %edi,%eax
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe8a(%rip),%rdi
jmp    1090 <fatalError@plt>
jmp    1050 <rootN@plt>
jmp    1070 <root1@plt>
jmp    1030 <root2@plt>
jmp    1080 <root3@plt>
jmp    1040 <root4@plt>
jmp    1060 <root5@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"Roots: cannot have rys.roots for zero order\00"
define void @Rys_findRoots(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
store i32 %0, i32* %3
store double %1, double* %4
%5 = load i32, i32* %3
switch i32 %5, label %23 [
i32 0, label %6
i32 1, label %8
i32 2, label %11
i32 3, label %14
i32 4, label %17
i32 5, label %20
]
6: ; preds = %2
%7 = call i32 @fatalError(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %27
8: ; preds = %2
%9 = load double, double* %4
%10 = call i32 @root1(double %9)
br label %27
11: ; preds = %2
%12 = load double, double* %4
%13 = call i32 @root2(double %12)
br label %27
14: ; preds = %2
%15 = load double, double* %4
%16 = call i32 @root3(double %15)
br label %27
17: ; preds = %2
%18 = load double, double* %4
%19 = call i32 @root4(double %18)
br label %27
20: ; preds = %2
%21 = load double, double* %4
%22 = call i32 @root5(double %21)
br label %27
23: ; preds = %2
%24 = load i32, i32* %3
%25 = load double, double* %4
%26 = call i32 @rootN(i32 %24, double %25)
br label %27
27: ; preds = %23, %20, %17, %14, %11, %8, %6
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"Roots: cannot have rys.roots for zero order\00"
define void @Rys_findRoots(i32 %0, double %1) {
switch i32 %0, label %15 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 4, label %11
i32 5, label %13
]
3: ; preds = %2
%4 = tail call i32 @fatalError(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %17
5: ; preds = %2
%6 = tail call i32 @root1(double %1)
br label %17
7: ; preds = %2
%8 = tail call i32 @root2(double %1)
br label %17
9: ; preds = %2
%10 = tail call i32 @root3(double %1)
br label %17
11: ; preds = %2
%12 = tail call i32 @root4(double %1)
br label %17
13: ; preds = %2
%14 = tail call i32 @root5(double %1)
br label %17
15: ; preds = %2
%16 = tail call i32 @rootN(i32 %0, double %1)
br label %17
17: ; preds = %15, %13, %11, %9, %7, %5, %3
ret void
}