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


x86 assembly (clang, -O0):
<radius_effective>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x6,%eax
ja     117d <radius_effective+0x4d>
mov    -0x40(%rbp),%rax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1182 <radius_effective+0x52>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
call   1030 <radius_from_excluded_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <radius_effective+0x1c2>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
call   1050 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <radius_effective+0x1c2>
movsd  0xe26(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe21(%rip),%xmm2
addsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <radius_effective+0x1c2>
movsd  0xdfd(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1237 <radius_effective+0x107>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1246 <radius_effective+0x116>
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <radius_effective+0x1c2>
movsd  -0x20(%rbp),%xmm0
movsd  0xda6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    128d <radius_effective+0x15d>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    129c <radius_effective+0x16c>
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <radius_effective+0x1c2>
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xd43(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <radius_effective+0x1c2>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
call   1040 <radius_from_diagonal@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radius_effective>:
add    $0xfffffffe,%edi
cmp    $0x5,%edi
ja     114d <radius_effective+0x1d>
lea    0xed1(%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>
mulsd  0xea6(%rip),%xmm0
addsd  0xea6(%rip),%xmm1
mulsd  %xmm0,%xmm1
jmp    1185 <radius_effective+0x55>
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
cmpltsd 0xe8f(%rip),%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm0,%xmm1
orpd   %xmm3,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xe72(%rip),%xmm3
cmpltsd %xmm1,%xmm3
mulsd  %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,%xmm0
ret
mulsd  0xe44(%rip),%xmm4
addsd  %xmm3,%xmm4
movapd %xmm4,%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, double %5) {
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 %0, i32* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%14 = load i32, i32* %8
switch i32 %14, label %15 [
i32 1, label %16
i32 2, label %23
i32 3, label %30
i32 4, label %37
i32 5, label %51
i32 6, label %65
i32 7, label %69
]
15: ; preds = %6
br label %16
16: ; preds = %6, %15
%17 = load double, double* %9
%18 = load double, double* %10
%19 = load double, double* %11
%20 = load double, double* %12
%21 = load double, double* %13
%22 = call double @radius_from_excluded_volume(double %17, double %18, double %19, double %20, double %21)
store double %22, double* %7
br label %76
23: ; preds = %6
%24 = load double, double* %9
%25 = load double, double* %10
%26 = load double, double* %11
%27 = load double, double* %12
%28 = load double, double* %13
%29 = call double @radius_from_volume(double %24, double %25, double %26, double %27, double %28)
store double %29, double* %7
br label %76
30: ; preds = %6
%31 = load double, double* %9
%32 = fmul double 5.000000e-01, %31
%33 = load double, double* %10
%34 = fadd double 1.000000e+00, %33
%35 = load double, double* %11
%36 = call double @llvm.fmuladd.f64(double %32, double %34, double %35)
store double %36, double* %7
br label %76
37: ; preds = %6
%38 = load double, double* %10
%39 = fcmp olt double %38, 1.000000e+00
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load double, double* %10
%42 = load double, double* %9
%43 = load double, double* %11
%44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
br label %49
45: ; preds = %37
%46 = load double, double* %9
%47 = load double, double* %11
%48 = fadd double %46, %47
br label %49
49: ; preds = %45, %40
%50 = phi double [ %44, %40 ], [ %48, %45 ]
store double %50, double* %7
br label %76
51: ; preds = %6
%52 = load double, double* %10
%53 = fcmp ogt double %52, 1.000000e+00
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = load double, double* %10
%56 = load double, double* %9
%57 = load double, double* %11
%58 = call double @llvm.fmuladd.f64(double %55, double %56, double %57)
br label %63
59: ; preds = %51
%60 = load double, double* %9
%61 = load double, double* %11
%62 = fadd double %60, %61
br label %63
63: ; preds = %59, %54
%64 = phi double [ %58, %54 ], [ %62, %59 ]
store double %64, double* %7
br label %76
65: ; preds = %6
%66 = load double, double* %13
%67 = load double, double* %12
%68 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %66, double %67)
store double %68, double* %7
br label %76
69: ; preds = %6
%70 = load double, double* %9
%71 = load double, double* %10
%72 = load double, double* %11
%73 = load double, double* %12
%74 = load double, double* %13
%75 = call double @radius_from_diagonal(double %70, double %71, double %72, double %73, double %74)
store double %75, double* %7
br label %76
76: ; preds = %69, %65, %63, %49, %30, %23, %16
%77 = load double, double* %7
ret double %77
}

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