#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 */
int atan2(double, double);
int atanh(double);
double cos(double);
double sin(double);
double sqrt(double);
double tan(double);
double eccentric_anomaly_at_true_anomaly(double e, double v) {
  if (e < 1) {
    double x = sqrt(1 + e) * cos(v / 2);
    double y = sqrt(1 - e) * sin(v / 2);
    return 2 * atan2(y, x);
  } else if (e == 1) {
    return tan(v / 2);
  } else {
    return 2 * atanh(sqrt((e - 1) / (e + 1)) * tan(v / 2));
  }
}


x86 assembly (clang, -O0):
<eccentric_anomaly_at_true_anomaly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xe86(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1221 <eccentric_anomaly_at_true_anomaly+0xc1>
movsd  0xe73(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe35(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <atan2@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12bd <eccentric_anomaly_at_true_anomaly+0x15d>
movsd  -0x10(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    125e <eccentric_anomaly_at_true_anomaly+0xfe>
jp     125e <eccentric_anomaly_at_true_anomaly+0xfe>
movsd  -0x18(%rbp),%xmm0
movsd  0xdbd(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <tan@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12bd <eccentric_anomaly_at_true_anomaly+0x15d>
movsd  -0x10(%rbp),%xmm0
movsd  0xd95(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xd89(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xd71(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <tan@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <atanh@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eccentric_anomaly_at_true_anomaly>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movsd  0xe90(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    1197 <eccentric_anomaly_at_true_anomaly+0x37>
movsd  0xe82(%rip),%xmm0
movsd  %xmm2,(%rsp)
addsd  %xmm2,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     11c0 <eccentric_anomaly_at_true_anomaly+0x60>
sqrtsd %xmm0,%xmm0
jmp    11d1 <eccentric_anomaly_at_true_anomaly+0x71>
ucomisd 0xe61(%rip),%xmm2
jne    123e <eccentric_anomaly_at_true_anomaly+0xde>
jp     123e <eccentric_anomaly_at_true_anomaly+0xde>
mulsd  0xe5d(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
jmp    1060 <tan@plt>
movsd  %xmm1,0x8(%rsp)
call   1080 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x10(%rsp)
mulsd  0xe31(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xdfe(%rip),%xmm0
subsd  (%rsp),%xmm0
ucomisd 0xe09(%rip),%xmm0
jb     1217 <eccentric_anomaly_at_true_anomaly+0xb7>
sqrtsd %xmm0,%xmm0
jmp    121c <eccentric_anomaly_at_true_anomaly+0xbc>
call   1080 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <atan2@plt>
jmp    1297 <eccentric_anomaly_at_true_anomaly+0x137>
movsd  0xdc2(%rip),%xmm0
addsd  %xmm2,%xmm0
addsd  0xdae(%rip),%xmm2
divsd  %xmm2,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     1266 <eccentric_anomaly_at_true_anomaly+0x106>
sqrtsd %xmm0,%xmm0
jmp    1277 <eccentric_anomaly_at_true_anomaly+0x117>
movsd  %xmm1,0x8(%rsp)
call   1080 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,(%rsp)
mulsd  0xd8c(%rip),%xmm1
movapd %xmm1,%xmm0
call   1060 <tan@plt>
mulsd  (%rsp),%xmm0
call   1040 <atanh@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @eccentric_anomaly_at_true_anomaly(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = fcmp olt double %8, 1.000000e+00
br i1 %9, label %10, label %30
10: ; preds = %2
%11 = load double, double* %4
%12 = fadd double 1.000000e+00, %11
%13 = call double @sqrt(double %12)
%14 = load double, double* %5
%15 = fdiv double %14, 2.000000e+00
%16 = call double @cos(double %15)
%17 = fmul double %13, %16
store double %17, double* %6
%18 = load double, double* %4
%19 = fsub double 1.000000e+00, %18
%20 = call double @sqrt(double %19)
%21 = load double, double* %5
%22 = fdiv double %21, 2.000000e+00
%23 = call double @sin(double %22)
%24 = fmul double %20, %23
store double %24, double* %7
%25 = load double, double* %7
%26 = load double, double* %6
%27 = call i32 @atan2(double %25, double %26)
%28 = mul nsw i32 2, %27
%29 = sitofp i32 %28 to double
store double %29, double* %3
br label %51
30: ; preds = %2
%31 = load double, double* %4
%32 = fcmp oeq double %31, 1.000000e+00
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load double, double* %5
%35 = fdiv double %34, 2.000000e+00
%36 = call double @tan(double %35)
store double %36, double* %3
br label %51
37: ; preds = %30
%38 = load double, double* %4
%39 = fsub double %38, 1.000000e+00
%40 = load double, double* %4
%41 = fadd double %40, 1.000000e+00
%42 = fdiv double %39, %41
%43 = call double @sqrt(double %42)
%44 = load double, double* %5
%45 = fdiv double %44, 2.000000e+00
%46 = call double @tan(double %45)
%47 = fmul double %43, %46
%48 = call i32 @atanh(double %47)
%49 = mul nsw i32 2, %48
%50 = sitofp i32 %49 to double
store double %50, double* %3
br label %51
51: ; preds = %37, %33, %10
%52 = load double, double* %3
ret double %52
}

LLVM IR (-O2):
define double @eccentric_anomaly_at_true_anomaly(double %0, double %1) {
%3 = fcmp olt double %0, 1.000000e+00
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = fadd double %0, 1.000000e+00
%6 = tail call double @sqrt(double %5)
%7 = fmul double %1, 5.000000e-01
%8 = tail call double @cos(double %7)
%9 = fmul double %6, %8
%10 = fsub double 1.000000e+00, %0
%11 = tail call double @sqrt(double %10)
%12 = tail call double @sin(double %7)
%13 = fmul double %11, %12
%14 = tail call i32 @atan2(double %13, double %9)
%15 = shl nsw i32 %14, 1
%16 = sitofp i32 %15 to double
br label %33
17: ; preds = %2
%18 = fcmp oeq double %0, 1.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = fmul double %1, 5.000000e-01
%21 = tail call double @tan(double %20)
br label %33
22: ; preds = %17
%23 = fadd double %0, -1.000000e+00
%24 = fadd double %0, 1.000000e+00
%25 = fdiv double %23, %24
%26 = tail call double @sqrt(double %25)
%27 = fmul double %1, 5.000000e-01
%28 = tail call double @tan(double %27)
%29 = fmul double %26, %28
%30 = tail call i32 @atanh(double %29)
%31 = shl nsw i32 %30, 1
%32 = sitofp i32 %31 to double
br label %33
33: ; preds = %22, %19, %4
%34 = phi double [ %16, %4 ], [ %21, %19 ], [ %32, %22 ]
ret double %34
}