#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_volume(double, double, double);
double radius_effective(int mode, double radius, double thickness,
                        double length) {
  switch (mode) {
  default:
  case 1:
    return radius_from_excluded_volume(radius, thickness, length);
  case 2:
    return radius_from_volume(radius, thickness, length);
  case 3:
    return radius + thickness;
  case 4:
    return 0.5 * length;
  case 5:
    return (radius + thickness < 0.5 * length ? radius + thickness
                                              : 0.5 * length);
  case 6:
    return (radius + thickness > 0.5 * length ? radius + thickness
                                              : 0.5 * length);
  case 7:
    return radius_from_diagonal(radius, thickness, 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    $0x6,%eax
ja     1173 <radius_effective+0x43>
mov    -0x30(%rbp),%rax
lea    0xe9e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1178 <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    12a4 <radius_effective+0x174>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1050 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <radius_effective+0x174>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <radius_effective+0x174>
movsd  0xe30(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <radius_effective+0x174>
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xe0f(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1214 <radius_effective+0xe4>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1226 <radius_effective+0xf6>
movsd  0xde4(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <radius_effective+0x174>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xdb9(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    126a <radius_effective+0x13a>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    127c <radius_effective+0x14c>
movsd  0xd8e(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <radius_effective+0x174>
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    $0x5,%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),%xmm2
movapd %xmm2,%xmm0
ret
addsd  %xmm1,%xmm0
mulsd  0xe90(%rip),%xmm2
minsd  %xmm2,%xmm0
ret
addsd  %xmm1,%xmm0
mulsd  0xe7f(%rip),%xmm2
maxsd  %xmm2,%xmm0
ret
jmp    1040 <radius_from_diagonal@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 %26
i32 5, label %29
i32 6, label %45
i32 7, label %61
]
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 %66
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 %66
22: ; preds = %4
%23 = load double, double* %7
%24 = load double, double* %8
%25 = fadd double %23, %24
store double %25, double* %5
br label %66
26: ; preds = %4
%27 = load double, double* %9
%28 = fmul double 5.000000e-01, %27
store double %28, double* %5
br label %66
29: ; preds = %4
%30 = load double, double* %7
%31 = load double, double* %8
%32 = fadd double %30, %31
%33 = load double, double* %9
%34 = fmul double 5.000000e-01, %33
%35 = fcmp olt double %32, %34
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = load double, double* %7
%38 = load double, double* %8
%39 = fadd double %37, %38
br label %43
40: ; preds = %29
%41 = load double, double* %9
%42 = fmul double 5.000000e-01, %41
br label %43
43: ; preds = %40, %36
%44 = phi double [ %39, %36 ], [ %42, %40 ]
store double %44, double* %5
br label %66
45: ; preds = %4
%46 = load double, double* %7
%47 = load double, double* %8
%48 = fadd double %46, %47
%49 = load double, double* %9
%50 = fmul double 5.000000e-01, %49
%51 = fcmp ogt double %48, %50
br i1 %51, label %52, label %56
52: ; preds = %45
%53 = load double, double* %7
%54 = load double, double* %8
%55 = fadd double %53, %54
br label %59
56: ; preds = %45
%57 = load double, double* %9
%58 = fmul double 5.000000e-01, %57
br label %59
59: ; preds = %56, %52
%60 = phi double [ %55, %52 ], [ %58, %56 ]
store double %60, double* %5
br label %66
61: ; preds = %4
%62 = load double, double* %7
%63 = load double, double* %8
%64 = load double, double* %9
%65 = call double @radius_from_diagonal(double %62, double %63, double %64)
store double %65, double* %5
br label %66
66: ; preds = %61, %59, %43, %26, %22, %17, %12
%67 = load double, double* %5
ret double %67
}

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