#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 radius_from_excluded_volume(double, double);
double radius_from_volume(double, double);
double radius_effective(int mode, double radius, double length) {
  switch (mode) {
  default:
  case 1:
    return radius_from_excluded_volume(radius, length);
  case 2:
    return radius_from_volume(radius, length);
  case 3:
    return radius;
  case 4:
    return 0.5 * length;
  case 5:
    return (radius < 0.5 * length ? radius : 0.5 * length);
  case 6:
    return (radius > 0.5 * length ? radius : 0.5 * length);
  case 7:
    return radius_from_diagonal(radius, 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)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x6,%eax
ja     116e <radius_effective+0x3e>
mov    -0x28(%rbp),%rax
lea    0xea3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1173 <radius_effective+0x43>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <radius_from_excluded_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1277 <radius_effective+0x147>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1050 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1277 <radius_effective+0x147>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1277 <radius_effective+0x147>
movsd  0xe44(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1277 <radius_effective+0x147>
movsd  -0x18(%rbp),%xmm1
movsd  0xe28(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f6 <radius_effective+0xc6>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1208 <radius_effective+0xd8>
movsd  0xe02(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1277 <radius_effective+0x147>
movsd  -0x18(%rbp),%xmm0
movsd  0xddc(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1242 <radius_effective+0x112>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1254 <radius_effective+0x124>
movsd  0xdb6(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1277 <radius_effective+0x147>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
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),%xmm1
movapd %xmm1,%xmm0
ret
mulsd  0xe99(%rip),%xmm1
minsd  %xmm1,%xmm0
ret
mulsd  0xe8c(%rip),%xmm1
maxsd  %xmm1,%xmm0
ret
jmp    1040 <radius_from_diagonal@plt>

LLVM IR (-O0):
define double @radius_effective(i32 %0, double %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
%8 = load i32, i32* %5
switch i32 %8, label %9 [
i32 1, label %10
i32 2, label %14
i32 3, label %18
i32 4, label %20
i32 5, label %23
i32 6, label %35
i32 7, label %47
]
9: ; preds = %3
br label %10
10: ; preds = %3, %9
%11 = load double, double* %6
%12 = load double, double* %7
%13 = call double @radius_from_excluded_volume(double %11, double %12)
store double %13, double* %4
br label %51
14: ; preds = %3
%15 = load double, double* %6
%16 = load double, double* %7
%17 = call double @radius_from_volume(double %15, double %16)
store double %17, double* %4
br label %51
18: ; preds = %3
%19 = load double, double* %6
store double %19, double* %4
br label %51
20: ; preds = %3
%21 = load double, double* %7
%22 = fmul double 5.000000e-01, %21
store double %22, double* %4
br label %51
23: ; preds = %3
%24 = load double, double* %6
%25 = load double, double* %7
%26 = fmul double 5.000000e-01, %25
%27 = fcmp olt double %24, %26
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load double, double* %6
br label %33
30: ; preds = %23
%31 = load double, double* %7
%32 = fmul double 5.000000e-01, %31
br label %33
33: ; preds = %30, %28
%34 = phi double [ %29, %28 ], [ %32, %30 ]
store double %34, double* %4
br label %51
35: ; preds = %3
%36 = load double, double* %6
%37 = load double, double* %7
%38 = fmul double 5.000000e-01, %37
%39 = fcmp ogt double %36, %38
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = load double, double* %6
br label %45
42: ; preds = %35
%43 = load double, double* %7
%44 = fmul double 5.000000e-01, %43
br label %45
45: ; preds = %42, %40
%46 = phi double [ %41, %40 ], [ %44, %42 ]
store double %46, double* %4
br label %51
47: ; preds = %3
%48 = load double, double* %6
%49 = load double, double* %7
%50 = call double @radius_from_diagonal(double %48, double %49)
store double %50, double* %4
br label %51
51: ; preds = %47, %45, %33, %20, %18, %14, %10
%52 = load double, double* %4
ret double %52
}

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