#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 const asin(double const);
double cbrt(double const);
double log(double const);
double sqrt(double);
double radius_from_curvature(double radius_polar, double radius_equatorial) {
  if (radius_polar == radius_equatorial)
    return radius_polar;
  if (radius_polar * radius_equatorial == 0.)
    return 0.;
  const double ratio =
      (radius_polar < radius_equatorial ? radius_polar / radius_equatorial
                                        : radius_equatorial / radius_polar);
  const double e1 = sqrt(1.0 - ratio * ratio);
  const double b1 = 1.0 + asin(e1) / (e1 * ratio);
  const double bL = (1.0 + e1) / (1.0 - e1);
  const double b2 = 1.0 + 0.5 * ratio * ratio / e1 * log(bL);
  const double delta = 0.75 * b1 * b2;
  const double ddd = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial *
                     radius_equatorial;
  return 0.5 * cbrt(ddd);
}


x86 assembly (clang, -O0):
<radius_from_curvature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1177 <radius_from_curvature+0x37>
jp     1177 <radius_from_curvature+0x37>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1311 <radius_from_curvature+0x1d1>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a1 <radius_from_curvature+0x61>
jp     11a1 <radius_from_curvature+0x61>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1311 <radius_from_curvature+0x1d1>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c9 <radius_from_curvature+0x89>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    11d8 <radius_from_curvature+0x98>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe01(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <asin@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdd0(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdbf(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xdb2(%rip),%xmm1
subsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd8c(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd6a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd61(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd42(%rip),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xd2d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <cbrt@plt>
movaps %xmm0,%xmm1
movsd  0xcf8(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radius_from_curvature>:
movapd %xmm0,%xmm3
ucomisd %xmm1,%xmm0
jne    1151 <radius_from_curvature+0x11>
jp     1151 <radius_from_curvature+0x11>
movapd %xmm3,%xmm0
ret
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1166 <radius_from_curvature+0x26>
jp     1166 <radius_from_curvature+0x26>
ret
ucomisd %xmm3,%xmm1
jbe    1176 <radius_from_curvature+0x36>
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
jmp    117e <radius_from_curvature+0x3e>
movapd %xmm1,%xmm0
divsd  %xmm3,%xmm0
sub    $0x28,%rsp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe5d(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b7 <radius_from_curvature+0x77>
sqrtsd %xmm0,%xmm0
jmp    11bc <radius_from_curvature+0x7c>
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <asin@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm2
movapd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm4
mulsd  %xmm4,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe16(%rip),%xmm3
addsd  %xmm3,%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm4,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm3,%xmm1
subsd  %xmm4,%xmm1
divsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
mulsd  0xdf4(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm4,%xmm1
movsd  %xmm1,(%rsp)
call   1050 <log@plt>
mulsd  (%rsp),%xmm0
movsd  0xdcd(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xdcb(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm0,%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <cbrt@plt>
mulsd  0xd96(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @radius_from_curvature(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
%13 = load double, double* %4
%14 = load double, double* %5
%15 = fcmp oeq double %13, %14
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = load double, double* %4
store double %17, double* %3
br label %80
18: ; preds = %2
%19 = load double, double* %4
%20 = load double, double* %5
%21 = fmul double %19, %20
%22 = fcmp oeq double %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %18
store double 0.000000e+00, double* %3
br label %80
24: ; preds = %18
%25 = load double, double* %4
%26 = load double, double* %5
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load double, double* %4
%30 = load double, double* %5
%31 = fdiv double %29, %30
br label %36
32: ; preds = %24
%33 = load double, double* %5
%34 = load double, double* %4
%35 = fdiv double %33, %34
br label %36
36: ; preds = %32, %28
%37 = phi double [ %31, %28 ], [ %35, %32 ]
store double %37, double* %6
%38 = load double, double* %6
%39 = load double, double* %6
%40 = fneg double %38
%41 = call double @llvm.fmuladd.f64(double %40, double %39, double 1.000000e+00)
%42 = call double @sqrt(double %41)
store double %42, double* %7
%43 = load double, double* %7
%44 = call double @asin(double %43)
%45 = load double, double* %7
%46 = load double, double* %6
%47 = fmul double %45, %46
%48 = fdiv double %44, %47
%49 = fadd double 1.000000e+00, %48
store double %49, double* %8
%50 = load double, double* %7
%51 = fadd double 1.000000e+00, %50
%52 = load double, double* %7
%53 = fsub double 1.000000e+00, %52
%54 = fdiv double %51, %53
store double %54, double* %9
%55 = load double, double* %6
%56 = fmul double 5.000000e-01, %55
%57 = load double, double* %6
%58 = fmul double %56, %57
%59 = load double, double* %7
%60 = fdiv double %58, %59
%61 = load double, double* %9
%62 = call double @log(double %61)
%63 = call double @llvm.fmuladd.f64(double %60, double %62, double 1.000000e+00)
store double %63, double* %10
%64 = load double, double* %8
%65 = fmul double 7.500000e-01, %64
%66 = load double, double* %10
%67 = fmul double %65, %66
store double %67, double* %11
%68 = load double, double* %11
%69 = fadd double %68, 1.000000e+00
%70 = fmul double 2.000000e+00, %69
%71 = load double, double* %4
%72 = fmul double %70, %71
%73 = load double, double* %5
%74 = fmul double %72, %73
%75 = load double, double* %5
%76 = fmul double %74, %75
store double %76, double* %12
%77 = load double, double* %12
%78 = call double @cbrt(double %77)
%79 = fmul double 5.000000e-01, %78
store double %79, double* %3
br label %80
80: ; preds = %36, %23, %16
%81 = load double, double* %3
ret double %81
}

LLVM IR (-O2):
define double @radius_from_curvature(double %0, double %1) {
%3 = fcmp oeq double %0, %1
br i1 %3, label %39, label %4
4: ; preds = %2
%5 = fmul double %0, %1
%6 = fcmp oeq double %5, 0.000000e+00
br i1 %6, label %39, label %7
7: ; preds = %4
%8 = fcmp olt double %0, %1
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = fdiv double %0, %1
br label %13
11: ; preds = %7
%12 = fdiv double %1, %0
br label %13
13: ; preds = %11, %9
%14 = phi double [ %10, %9 ], [ %12, %11 ]
%15 = fneg double %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double %14, double 1.000000e+00)
%17 = tail call double @sqrt(double %16)
%18 = tail call double @asin(double %17)
%19 = fmul double %14, %17
%20 = fdiv double %18, %19
%21 = fadd double %20, 1.000000e+00
%22 = fadd double %17, 1.000000e+00
%23 = fsub double 1.000000e+00, %17
%24 = fdiv double %22, %23
%25 = fmul double %14, 5.000000e-01
%26 = fmul double %14, %25
%27 = fdiv double %26, %17
%28 = tail call double @log(double %24)
%29 = tail call double @llvm.fmuladd.f64(double %27, double %28, double 1.000000e+00)
%30 = fmul double %21, 7.500000e-01
%31 = fmul double %29, %30
%32 = fadd double %31, 1.000000e+00
%33 = fmul double %32, 2.000000e+00
%34 = fmul double %33, %0
%35 = fmul double %34, %1
%36 = fmul double %35, %1
%37 = tail call double @cbrt(double %36)
%38 = fmul double %37, 5.000000e-01
br label %39
39: ; preds = %4, %2, %13
%40 = phi double [ %38, %13 ], [ %0, %2 ], [ 0.000000e+00, %4 ]
ret double %40
}