#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 radius_from_diagonal(double, double, double, double);
double radius_from_excluded_volume(double, double, double, double);
double radius_from_volume(double, double, double, double);
double radius_effective(int mode, double radius, double thick_rim,
                        double thick_face, double length) {
  switch (mode) {
  default:
  case 1:
    return radius_from_excluded_volume(radius, thick_rim, thick_face, length);
  case 2:
    return radius_from_volume(radius, thick_rim, thick_face, length);
  case 3:
    return radius + thick_rim;
  case 4:
    return 0.5 * length + thick_face;
  case 5:
    return radius_from_diagonal(radius, thick_rim, thick_face, length);
  }
}


x86 assembly (clang, -O0):
<radius_effective>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x4,%eax
ja     1178 <radius_effective+0x48>
mov    -0x38(%rbp),%rax
lea    0xe99(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    117d <radius_effective+0x4d>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1030 <radius_from_excluded_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1219 <radius_effective+0xe9>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1050 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1219 <radius_effective+0xe9>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1219 <radius_effective+0xe9>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe17(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1219 <radius_effective+0xe9>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1040 <radius_from_diagonal@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radius_effective>:
add    $0xfffffffe,%edi
cmp    $0x3,%edi
ja     114d <radius_effective+0x1d>
lea    0xec9(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
jmp    1050 <radius_from_volume@plt>
jmp    1030 <radius_from_excluded_volume@plt>
addsd  %xmm1,%xmm0
ret
mulsd  0xea1(%rip),%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,%xmm0
ret
jmp    1040 <radius_from_diagonal@plt>

LLVM IR (-O0):
define double @radius_effective(i32 %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%12 = load i32, i32* %7
switch i32 %12, label %13 [
i32 1, label %14
i32 2, label %20
i32 3, label %26
i32 4, label %30
i32 5, label %34
]
13: ; preds = %5
br label %14
14: ; preds = %5, %13
%15 = load double, double* %8
%16 = load double, double* %9
%17 = load double, double* %10
%18 = load double, double* %11
%19 = call double @radius_from_excluded_volume(double %15, double %16, double %17, double %18)
store double %19, double* %6
br label %40
20: ; preds = %5
%21 = load double, double* %8
%22 = load double, double* %9
%23 = load double, double* %10
%24 = load double, double* %11
%25 = call double @radius_from_volume(double %21, double %22, double %23, double %24)
store double %25, double* %6
br label %40
26: ; preds = %5
%27 = load double, double* %8
%28 = load double, double* %9
%29 = fadd double %27, %28
store double %29, double* %6
br label %40
30: ; preds = %5
%31 = load double, double* %11
%32 = load double, double* %10
%33 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %31, double %32)
store double %33, double* %6
br label %40
34: ; preds = %5
%35 = load double, double* %8
%36 = load double, double* %9
%37 = load double, double* %10
%38 = load double, double* %11
%39 = call double @radius_from_diagonal(double %35, double %36, double %37, double %38)
store double %39, double* %6
br label %40
40: ; preds = %34, %30, %26, %20, %14
%41 = load double, double* %6
ret double %41
}

LLVM IR (-O2):
define double @radius_effective(i32 %0, double %1, double %2, double %3, double %4) {
switch i32 %0, label %6 [
i32 5, label %14
i32 2, label %8
i32 3, label %10
i32 4, label %12
]
6: ; preds = %5
%7 = tail call double @radius_from_excluded_volume(double %1, double %2, double %3, double %4)
br label %16
8: ; preds = %5
%9 = tail call double @radius_from_volume(double %1, double %2, double %3, double %4)
br label %16
10: ; preds = %5
%11 = fadd double %1, %2
br label %16
12: ; preds = %5
%13 = tail call double @llvm.fmuladd.f64(double %4, double 5.000000e-01, double %3)
br label %16
14: ; preds = %5
%15 = tail call double @radius_from_diagonal(double %1, double %2, double %3, double %4)
br label %16
16: ; preds = %14, %12, %10, %8, %6
%17 = phi double [ %7, %6 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %15, %14 ]
ret double %17
}