#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 atan(int);
double reb_M_to_E(double, double);
int sqrt(int);
int tan(double);
int tanh(double);
double reb_tools_M_to_f(double e, double M) {
  double E = reb_M_to_E(e, M);
  if (e > 1.) {
    return 2. * atan(sqrt((1. + e) / (e - 1.)) * tanh(0.5 * E));
  } else {
    return 2 * atan(sqrt((1. + e) / (1. - e)) * tan(0.5 * E));
  }
}


x86 assembly (clang, -O0):
<reb_tools_M_to_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1070 <reb_M_to_E@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f2 <reb_tools_M_to_f+0xa2>
movsd  0xe6b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe59(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    %eax,-0x24(%rbp)
movsd  0xe45(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <tanh@plt>
mov    -0x24(%rbp),%edi
imul   %eax,%edi
call   1040 <atan@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe2c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1245 <reb_tools_M_to_f+0xf5>
movsd  0xe06(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xdf9(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    %eax,-0x28(%rbp)
movsd  0xde4(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <tan@plt>
mov    -0x28(%rbp),%edi
imul   %eax,%edi
call   1040 <atan@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reb_tools_M_to_f>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
call   1070 <reb_M_to_E@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm0,(%rsp)
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm1,%xmm2
movapd %xmm2,%xmm0
addsd  %xmm1,%xmm0
jbe    11c1 <reb_tools_M_to_f+0x71>
addsd  0xe87(%rip),%xmm2
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  0xe63(%rip),%xmm0
call   1030 <tanh@plt>
imul   %eax,%ebx
mov    %ebx,%edi
call   1040 <atan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
jmp    11f9 <reb_tools_M_to_f+0xa9>
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  0xe27(%rip),%xmm0
call   1050 <tan@plt>
imul   %eax,%ebx
mov    %ebx,%edi
call   1040 <atan@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @reb_tools_M_to_f(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = load double, double* %5
%9 = call double @reb_M_to_E(double %7, double %8)
store double %9, double* %6
%10 = load double, double* %4
%11 = fcmp ogt double %10, 1.000000e+00
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = load double, double* %4
%14 = fadd double 1.000000e+00, %13
%15 = load double, double* %4
%16 = fsub double %15, 1.000000e+00
%17 = fdiv double %14, %16
%18 = fptosi double %17 to i32
%19 = call i32 @sqrt(i32 %18)
%20 = load double, double* %6
%21 = fmul double 5.000000e-01, %20
%22 = call i32 @tanh(double %21)
%23 = mul nsw i32 %19, %22
%24 = call i32 @atan(i32 %23)
%25 = sitofp i32 %24 to double
%26 = fmul double 2.000000e+00, %25
store double %26, double* %3
br label %42
27: ; preds = %2
%28 = load double, double* %4
%29 = fadd double 1.000000e+00, %28
%30 = load double, double* %4
%31 = fsub double 1.000000e+00, %30
%32 = fdiv double %29, %31
%33 = fptosi double %32 to i32
%34 = call i32 @sqrt(i32 %33)
%35 = load double, double* %6
%36 = fmul double 5.000000e-01, %35
%37 = call i32 @tan(double %36)
%38 = mul nsw i32 %34, %37
%39 = call i32 @atan(i32 %38)
%40 = mul nsw i32 2, %39
%41 = sitofp i32 %40 to double
store double %41, double* %3
br label %42
42: ; preds = %27, %12
%43 = load double, double* %3
ret double %43
}

LLVM IR (-O2):
define double @reb_tools_M_to_f(double %0, double %1) {
%3 = tail call double @reb_M_to_E(double %0, double %1)
%4 = fcmp ogt double %0, 1.000000e+00
%5 = fadd double %0, 1.000000e+00
br i1 %4, label %6, label %17
6: ; preds = %2
%7 = fadd double %0, -1.000000e+00
%8 = fdiv double %5, %7
%9 = fptosi double %8 to i32
%10 = tail call i32 @sqrt(i32 %9)
%11 = fmul double %3, 5.000000e-01
%12 = tail call i32 @tanh(double %11)
%13 = mul nsw i32 %12, %10
%14 = tail call i32 @atan(i32 %13)
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 2.000000e+00
br label %28
17: ; preds = %2
%18 = fsub double 1.000000e+00, %0
%19 = fdiv double %5, %18
%20 = fptosi double %19 to i32
%21 = tail call i32 @sqrt(i32 %20)
%22 = fmul double %3, 5.000000e-01
%23 = tail call i32 @tan(double %22)
%24 = mul nsw i32 %23, %21
%25 = tail call i32 @atan(i32 %24)
%26 = shl nsw i32 %25, 1
%27 = sitofp i32 %26 to double
br label %28
28: ; preds = %17, %6
%29 = phi double [ %16, %6 ], [ %27, %17 ]
ret double %29
}