#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_curvature(double, double);
double radius_from_volume(double, double);
double radius_effective(int mode, double radius_polar,
                        double radius_equatorial) {
  switch (mode) {
  default:
  case 1:
    return radius_from_curvature(radius_polar, radius_equatorial);
  case 2:
    return radius_from_volume(radius_polar, radius_equatorial);
  case 3:
    return (radius_polar < radius_equatorial ? radius_polar
                                             : radius_equatorial);
  case 4:
    return (radius_polar > radius_equatorial ? radius_polar
                                             : radius_equatorial);
  }
}


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    $0x3,%eax
ja     115e <radius_effective+0x3e>
mov    -0x28(%rbp),%rax
lea    0xeab(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1163 <radius_effective+0x43>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <radius_from_curvature@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1204 <radius_effective+0xe4>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <radius_from_volume@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1204 <radius_effective+0xe4>
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b8 <radius_effective+0x98>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11c2 <radius_effective+0xa2>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1204 <radius_effective+0xe4>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f0 <radius_effective+0xd0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11fa <radius_effective+0xda>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radius_effective>:
cmp    $0x2,%edi
je     1134 <radius_effective+0x14>
cmp    $0x3,%edi
je     1139 <radius_effective+0x19>
cmp    $0x4,%edi
jne    113e <radius_effective+0x1e>
maxsd  %xmm1,%xmm0
ret
jmp    1040 <radius_from_volume@plt>
minsd  %xmm1,%xmm0
ret
jmp    1030 <radius_from_curvature@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 %28
]
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_curvature(double %11, double %12)
store double %13, double* %4
br label %38
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 %38
18: ; preds = %3
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load double, double* %6
br label %26
24: ; preds = %18
%25 = load double, double* %7
br label %26
26: ; preds = %24, %22
%27 = phi double [ %23, %22 ], [ %25, %24 ]
store double %27, double* %4
br label %38
28: ; preds = %3
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load double, double* %6
br label %36
34: ; preds = %28
%35 = load double, double* %7
br label %36
36: ; preds = %34, %32
%37 = phi double [ %33, %32 ], [ %35, %34 ]
store double %37, double* %4
br label %38
38: ; preds = %36, %26, %14, %10
%39 = load double, double* %4
ret double %39
}

LLVM IR (-O2):
define double @radius_effective(i32 %0, double %1, double %2) {
switch i32 %0, label %4 [
i32 4, label %11
i32 2, label %6
i32 3, label %8
]
4: ; preds = %3
%5 = tail call double @radius_from_curvature(double %1, double %2)
br label %14
6: ; preds = %3
%7 = tail call double @radius_from_volume(double %1, double %2)
br label %14
8: ; preds = %3
%9 = fcmp olt double %1, %2
%10 = select i1 %9, double %1, double %2
br label %14
11: ; preds = %3
%12 = fcmp ogt double %1, %2
%13 = select i1 %12, double %1, double %2
br label %14
14: ; preds = %11, %8, %6, %4
%15 = phi double [ %5, %4 ], [ %10, %8 ], [ %7, %6 ], [ %13, %11 ]
ret double %15
}