#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 + thickness;
  case 5:
    return (radius < 0.5 * length ? radius + thickness
                                  : 0.5 * length + thickness);
  case 6:
    return (radius > 0.5 * length ? radius + thickness
                                  : 0.5 * length + thickness);
  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    12c1 <radius_effective+0x191>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1050 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12c1 <radius_effective+0x191>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c1 <radius_effective+0x191>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe26(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c1 <radius_effective+0x191>
movsd  -0x18(%rbp),%xmm1
movsd  0xe07(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    121c <radius_effective+0xec>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    123b <radius_effective+0x10b>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xdd2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c1 <radius_effective+0x191>
movsd  -0x18(%rbp),%xmm0
movsd  0xda9(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    127a <radius_effective+0x14a>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1299 <radius_effective+0x169>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd74(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c1 <radius_effective+0x191>
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>
mulsd  0xea6(%rip),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
ret
mulsd  0xe95(%rip),%xmm2
minsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
ret
mulsd  0xe84(%rip),%xmm2
maxsd  %xmm2,%xmm0
addsd  %xmm1,%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 %30
i32 6, label %45
i32 7, label %60
]
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 %65
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 %65
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 %65
26: ; preds = %4
%27 = load double, double* %9
%28 = load double, double* %8
%29 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %27, double %28)
store double %29, double* %5
br label %65
30: ; preds = %4
%31 = load double, double* %7
%32 = load double, double* %9
%33 = fmul double 5.000000e-01, %32
%34 = fcmp olt double %31, %33
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load double, double* %7
%37 = load double, double* %8
%38 = fadd double %36, %37
br label %43
39: ; preds = %30
%40 = load double, double* %9
%41 = load double, double* %8
%42 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %40, double %41)
br label %43
43: ; preds = %39, %35
%44 = phi double [ %38, %35 ], [ %42, %39 ]
store double %44, double* %5
br label %65
45: ; preds = %4
%46 = load double, double* %7
%47 = load double, double* %9
%48 = fmul double 5.000000e-01, %47
%49 = fcmp ogt double %46, %48
br i1 %49, label %50, label %54
50: ; preds = %45
%51 = load double, double* %7
%52 = load double, double* %8
%53 = fadd double %51, %52
br label %58
54: ; preds = %45
%55 = load double, double* %9
%56 = load double, double* %8
%57 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %55, double %56)
br label %58
58: ; preds = %54, %50
%59 = phi double [ %53, %50 ], [ %57, %54 ]
store double %59, double* %5
br label %65
60: ; preds = %4
%61 = load double, double* %7
%62 = load double, double* %8
%63 = load double, double* %9
%64 = call double @radius_from_diagonal(double %61, double %62, double %63)
store double %64, double* %5
br label %65
65: ; preds = %60, %58, %43, %26, %22, %17, %12
%66 = load double, double* %5
ret double %66
}

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