#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 radius_from_excluded_volume(double, double, double);
double radius_from_max_dimension(double, double, double);
double radius_from_min_dimension(double, double, double);
double radius_from_volume(double, double, double);
double sqrt(double);
double radius_effective(int mode, double radius_minor, double r_ratio,
                        double length) {
  switch (mode) {
  default:
  case 1:
    return radius_from_excluded_volume(radius_minor, r_ratio, length);
  case 2:
    return radius_from_volume(radius_minor, r_ratio, length);
  case 3:
    return 0.5 * radius_minor * (1.0 + r_ratio);
  case 4:
    return (r_ratio > 1.0 ? radius_minor : r_ratio * radius_minor);
  case 5:
    return (r_ratio < 1.0 ? radius_minor : r_ratio * radius_minor);
  case 6:
    return sqrt(radius_minor * radius_minor * r_ratio);
  case 7:
    return 0.5 * length;
  case 8:
    return radius_from_min_dimension(radius_minor, r_ratio, 0.5 * length);
  case 9:
    return radius_from_max_dimension(radius_minor, r_ratio, 0.5 * length);
  case 10:
    return radius_from_diagonal(radius_minor, r_ratio, 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)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x9,%eax
ja     11a3 <radius_effective+0x43>
mov    -0x30(%rbp),%rax
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11a8 <radius_effective+0x48>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1030 <radius_from_excluded_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1080 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  0xe14(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe0f(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  -0x20(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1232 <radius_effective+0xd2>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1241 <radius_effective+0xe1>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  0xdb0(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1272 <radius_effective+0x112>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1281 <radius_effective+0x121>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  0xd4a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd29(%rip),%xmm2
mulsd  -0x28(%rbp),%xmm2
call   1070 <radius_from_min_dimension@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd03(%rip),%xmm2
mulsd  -0x28(%rbp),%xmm2
call   1050 <radius_from_max_dimension@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    132a <radius_effective+0x1ca>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
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    $0x8,%edi
ja     1194 <radius_effective+0x34>
lea    0xea1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
jmp    1080 <radius_from_volume@plt>
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1201 <radius_effective+0xa1>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <radius_from_excluded_volume@plt>
mulsd  0xe5f(%rip),%xmm0
addsd  0xe5f(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xe4e(%rip),%xmm2
minsd  %xmm1,%xmm2
jmp    11cc <radius_effective+0x6c>
movsd  0xe40(%rip),%xmm2
maxsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
ret
mulsd  0xe23(%rip),%xmm2
movapd %xmm2,%xmm0
ret
mulsd  0xe16(%rip),%xmm2
jmp    1070 <radius_from_min_dimension@plt>
mulsd  0xe09(%rip),%xmm2
jmp    1050 <radius_from_max_dimension@plt>
jmp    1040 <radius_from_diagonal@plt>
jmp    1060 <sqrt@plt>

LLVM IR (-O0):
define double @radius_effective(i32 %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%10 = load i32, i32* %6
switch i32 %10, label %11 [
i32 1, label %12
i32 2, label %17
i32 3, label %22
i32 4, label %28
i32 5, label %39
i32 6, label %50
i32 7, label %57
i32 8, label %60
i32 9, label %66
i32 10, label %72
]
11: ; preds = %4
br label %12
12: ; preds = %4, %11
%13 = load double, double* %7
%14 = load double, double* %8
%15 = load double, double* %9
%16 = call double @radius_from_excluded_volume(double %13, double %14, double %15)
store double %16, double* %5
br label %77
17: ; preds = %4
%18 = load double, double* %7
%19 = load double, double* %8
%20 = load double, double* %9
%21 = call double @radius_from_volume(double %18, double %19, double %20)
store double %21, double* %5
br label %77
22: ; preds = %4
%23 = load double, double* %7
%24 = fmul double 5.000000e-01, %23
%25 = load double, double* %8
%26 = fadd double 1.000000e+00, %25
%27 = fmul double %24, %26
store double %27, double* %5
br label %77
28: ; preds = %4
%29 = load double, double* %8
%30 = fcmp ogt double %29, 1.000000e+00
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = load double, double* %7
br label %37
33: ; preds = %28
%34 = load double, double* %8
%35 = load double, double* %7
%36 = fmul double %34, %35
br label %37
37: ; preds = %33, %31
%38 = phi double [ %32, %31 ], [ %36, %33 ]
store double %38, double* %5
br label %77
39: ; preds = %4
%40 = load double, double* %8
%41 = fcmp olt double %40, 1.000000e+00
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = load double, double* %7
br label %48
44: ; preds = %39
%45 = load double, double* %8
%46 = load double, double* %7
%47 = fmul double %45, %46
br label %48
48: ; preds = %44, %42
%49 = phi double [ %43, %42 ], [ %47, %44 ]
store double %49, double* %5
br label %77
50: ; preds = %4
%51 = load double, double* %7
%52 = load double, double* %7
%53 = fmul double %51, %52
%54 = load double, double* %8
%55 = fmul double %53, %54
%56 = call double @sqrt(double %55)
store double %56, double* %5
br label %77
57: ; preds = %4
%58 = load double, double* %9
%59 = fmul double 5.000000e-01, %58
store double %59, double* %5
br label %77
60: ; preds = %4
%61 = load double, double* %7
%62 = load double, double* %8
%63 = load double, double* %9
%64 = fmul double 5.000000e-01, %63
%65 = call double @radius_from_min_dimension(double %61, double %62, double %64)
store double %65, double* %5
br label %77
66: ; preds = %4
%67 = load double, double* %7
%68 = load double, double* %8
%69 = load double, double* %9
%70 = fmul double 5.000000e-01, %69
%71 = call double @radius_from_max_dimension(double %67, double %68, double %70)
store double %71, double* %5
br label %77
72: ; preds = %4
%73 = load double, double* %7
%74 = load double, double* %8
%75 = load double, double* %9
%76 = call double @radius_from_diagonal(double %73, double %74, double %75)
store double %76, double* %5
br label %77
77: ; preds = %72, %66, %60, %57, %50, %48, %37, %22, %17, %12
%78 = load double, double* %5
ret double %78
}

LLVM IR (-O2):
define double @radius_effective(i32 %0, double %1, double %2, double %3) {
switch i32 %0, label %5 [
i32 10, label %33
i32 2, label %7
i32 3, label %9
i32 4, label %13
i32 5, label %17
i32 6, label %21
i32 7, label %25
i32 8, label %27
i32 9, label %30
]
5: ; preds = %4
%6 = tail call double @radius_from_excluded_volume(double %1, double %2, double %3)
br label %35
7: ; preds = %4
%8 = tail call double @radius_from_volume(double %1, double %2, double %3)
br label %35
9: ; preds = %4
%10 = fmul double %1, 5.000000e-01
%11 = fadd double %2, 1.000000e+00
%12 = fmul double %10, %11
br label %35
13: ; preds = %4
%14 = fcmp ogt double %2, 1.000000e+00
%15 = select i1 %14, double 1.000000e+00, double %2
%16 = fmul double %15, %1
br label %35
17: ; preds = %4
%18 = fcmp olt double %2, 1.000000e+00
%19 = select i1 %18, double 1.000000e+00, double %2
%20 = fmul double %19, %1
br label %35
21: ; preds = %4
%22 = fmul double %1, %1
%23 = fmul double %22, %2
%24 = tail call double @sqrt(double %23)
br label %35
25: ; preds = %4
%26 = fmul double %3, 5.000000e-01
br label %35
27: ; preds = %4
%28 = fmul double %3, 5.000000e-01
%29 = tail call double @radius_from_min_dimension(double %1, double %2, double %28)
br label %35
30: ; preds = %4
%31 = fmul double %3, 5.000000e-01
%32 = tail call double @radius_from_max_dimension(double %1, double %2, double %31)
br label %35
33: ; preds = %4
%34 = tail call double @radius_from_diagonal(double %1, double %2, double %3)
br label %35
35: ; preds = %33, %30, %27, %25, %21, %17, %13, %9, %7, %5
%36 = phi double [ %6, %5 ], [ %32, %30 ], [ %29, %27 ], [ %26, %25 ], [ %24, %21 ], [ %20, %17 ], [ %16, %13 ], [ %12, %9 ], [ %8, %7 ], [ %34, %33 ]
ret double %36
}