#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 M_PI;
double cos(double);
double cosh(double);
double fabs(double);
double log(int);
double reb_tools_mod2pi(double);
double sin(double);
double sinh(double);
double reb_tools_M_to_E(double e, double M) {
  double E;
  if (e < 1.) {
    M = reb_tools_mod2pi(M);
    E = e < 0.8 ? M : M_PI;
    double F = E - e * sin(E) - M;
    for (int i = 0; i < 100; i++) {
      E = E - F / (1. - e * cos(E));
      F = E - e * sin(E) - M;
      if (fabs(F) < 1.e-16) {
        break;
      }
    }
    E = reb_tools_mod2pi(E);
    return E;
  } else {
    E = M / fabs(M) * log(2. * fabs(M) / e + 1.8);
    double F = E - e * sinh(E) + M;
    for (int i = 0; i < 100; i++) {
      E = E - F / (1.0 - e * cosh(E));
      F = E - e * sinh(E) + M;
      if (fabs(F) < 1.e-16) {
        break;
      }
    }
    return E;
  }
}


x86 assembly (clang, -O0):
<reb_tools_M_to_E>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xe83(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1352 <reb_tools_M_to_E+0x1f2>
movsd  -0x18(%rbp),%xmm0
call   1080 <reb_tools_mod2pi@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe81(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b9 <reb_tools_M_to_E+0x59>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11c9 <reb_tools_M_to_E+0x69>
mov    0x2e28(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x64,-0x2c(%rbp)
jge    1334 <reb_tools_M_to_E+0x1d4>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x80(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x70(%rbp),%xmm0
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xd6b(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movaps 0xd2a(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd06(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1321 <reb_tools_M_to_E+0x1c1>
jmp    1334 <reb_tools_M_to_E+0x1d4>
jmp    1326 <reb_tools_M_to_E+0x1c6>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    122e <reb_tools_M_to_E+0xce>
movsd  -0x20(%rbp),%xmm0
call   1080 <reb_tools_mod2pi@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1552 <reb_tools_M_to_E+0x3f2>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movaps 0xccd(%rip),%xmm2
pand   %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x18(%rbp),%xmm1
movaps 0xcb1(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xc85(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xc6c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <sinh@plt>
movsd  -0x90(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x64,-0x3c(%rbp)
jge    1548 <reb_tools_M_to_E+0x3e8>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1040 <cosh@plt>
movsd  -0xc0(%rbp),%xmm2
ff
movsd  -0xb8(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0xb0(%rbp),%xmm0
ff
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xb63(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <sinh@plt>
movsd  -0xa8(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0xa0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movaps 0xb16(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xaf2(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1535 <reb_tools_M_to_E+0x3d5>
jmp    1548 <reb_tools_M_to_E+0x3e8>
jmp    153a <reb_tools_M_to_E+0x3da>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1424 <reb_tools_M_to_E+0x2c4>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reb_tools_M_to_E>:
push   %rbx
sub    $0x40,%rsp
movapd %xmm0,%xmm2
movsd  0xe8f(%rip),%xmm0
ucomisd %xmm2,%xmm0
movapd %xmm2,0x10(%rsp)
jbe    1293 <reb_tools_M_to_E+0x133>
movapd %xmm1,%xmm0
call   1080 <reb_tools_mod2pi@plt>
movapd %xmm0,0x20(%rsp)
mov    0x2e51(%rip),%rax
movapd 0x10(%rsp),%xmm3
cmpltsd 0xe72(%rip),%xmm3
movapd %xmm3,%xmm2
andpd  %xmm0,%xmm2
movsd  (%rax),%xmm1
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,(%rsp)
movapd %xmm3,%xmm0
call   1050 <sin@plt>
movapd (%rsp),%xmm1
movapd 0xe5b(%rip),%xmm2
movapd 0x10(%rsp),%xmm3
xorpd  %xmm3,%xmm2
movapd %xmm2,0x30(%rsp)
mulsd  %xmm3,%xmm0
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
subsd  0x20(%rsp),%xmm2
mov    $0x63,%ebx
nopl   0x0(%rax)
movapd %xmm2,0x10(%rsp)
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1060 <cos@plt>
mulsd  0x30(%rsp),%xmm0
addsd  0xdde(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd (%rsp),%xmm0
subsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
movapd (%rsp),%xmm0
call   1050 <sin@plt>
movapd (%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0x30(%rsp),%xmm2
addsd  %xmm1,%xmm2
subsd  0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
andpd  0xdb7(%rip),%xmm0
sub    $0x1,%ebx
setb   %al
movsd  0xd99(%rip),%xmm3
ucomisd %xmm0,%xmm3
ja     1285 <reb_tools_M_to_E+0x125>
test   %al,%al
je     1200 <reb_tools_M_to_E+0xa0>
movapd %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbx
jmp    1080 <reb_tools_mod2pi@plt>
movapd 0xd85(%rip),%xmm0
andpd  %xmm1,%xmm0
movapd %xmm1,%xmm3
divsd  %xmm0,%xmm3
movapd %xmm3,(%rsp)
addsd  %xmm0,%xmm0
divsd  %xmm2,%xmm0
addsd  0xd4c(%rip),%xmm0
cvttsd2si %xmm0,%edi
movapd %xmm1,0x20(%rsp)
call   1070 <log@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sinh@plt>
movsd  (%rsp),%xmm1
movapd 0xd49(%rip),%xmm2
movapd 0x10(%rsp),%xmm3
xorpd  %xmm3,%xmm2
movapd %xmm2,0x30(%rsp)
mulsd  %xmm3,%xmm0
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
addsd  0x20(%rsp),%xmm2
mov    $0x63,%ebx
xchg   %ax,%ax
movapd %xmm2,0x10(%rsp)
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1040 <cosh@plt>
mulsd  0x30(%rsp),%xmm0
addsd  0xcce(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sinh@plt>
movsd  (%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0x30(%rsp),%xmm2
addsd  %xmm1,%xmm2
addsd  0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
andpd  0xca7(%rip),%xmm0
sub    $0x1,%ebx
setb   %al
movsd  0xc89(%rip),%xmm3
ucomisd %xmm0,%xmm3
ja     1395 <reb_tools_M_to_E+0x235>
test   %al,%al
je     1310 <reb_tools_M_to_E+0x1b0>
movapd %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @reb_tools_M_to_E(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
store double %0, double* %4
store double %1, double* %5
%11 = load double, double* %4
%12 = fcmp olt double %11, 1.000000e+00
br i1 %12, label %13, label %65
13: ; preds = %2
%14 = load double, double* %5
%15 = call double @reb_tools_mod2pi(double %14)
store double %15, double* %5
%16 = load double, double* %4
%17 = fcmp olt double %16, 8.000000e-01
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load double, double* %5
br label %22
20: ; preds = %13
%21 = load double, double* @M_PI
br label %22
22: ; preds = %20, %18
%23 = phi double [ %19, %18 ], [ %21, %20 ]
store double %23, double* %6
%24 = load double, double* %6
%25 = load double, double* %4
%26 = load double, double* %6
%27 = call double @sin(double %26)
%28 = fneg double %25
%29 = call double @llvm.fmuladd.f64(double %28, double %27, double %24)
%30 = load double, double* %5
%31 = fsub double %29, %30
store double %31, double* %7
store i32 0, i32* %8
br label %32
32: ; preds = %58, %22
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 100
br i1 %34, label %35, label %61
35: ; preds = %32
%36 = load double, double* %6
%37 = load double, double* %7
%38 = load double, double* %4
%39 = load double, double* %6
%40 = call double @cos(double %39)
%41 = fneg double %38
%42 = call double @llvm.fmuladd.f64(double %41, double %40, double 1.000000e+00)
%43 = fdiv double %37, %42
%44 = fsub double %36, %43
store double %44, double* %6
%45 = load double, double* %6
%46 = load double, double* %4
%47 = load double, double* %6
%48 = call double @sin(double %47)
%49 = fneg double %46
%50 = call double @llvm.fmuladd.f64(double %49, double %48, double %45)
%51 = load double, double* %5
%52 = fsub double %50, %51
store double %52, double* %7
%53 = load double, double* %7
%54 = call double @llvm.fabs.f64(double %53)
%55 = fcmp olt double %54, 0x3C9CD2B297D889BC
br i1 %55, label %56, label %57
56: ; preds = %35
br label %61
57: ; preds = %35
br label %58
58: ; preds = %57
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %32
61: ; preds = %56, %32
%62 = load double, double* %6
%63 = call double @reb_tools_mod2pi(double %62)
store double %63, double* %6
%64 = load double, double* %6
store double %64, double* %3
br label %118
65: ; preds = %2
%66 = load double, double* %5
%67 = load double, double* %5
%68 = call double @llvm.fabs.f64(double %67)
%69 = fdiv double %66, %68
%70 = load double, double* %5
%71 = call double @llvm.fabs.f64(double %70)
%72 = fmul double 2.000000e+00, %71
%73 = load double, double* %4
%74 = fdiv double %72, %73
%75 = fadd double %74, 1.800000e+00
%76 = fptosi double %75 to i32
%77 = call double @log(i32 %76)
%78 = fmul double %69, %77
store double %78, double* %6
%79 = load double, double* %6
%80 = load double, double* %4
%81 = load double, double* %6
%82 = call double @sinh(double %81)
%83 = fneg double %80
%84 = call double @llvm.fmuladd.f64(double %83, double %82, double %79)
%85 = load double, double* %5
%86 = fadd double %84, %85
store double %86, double* %9
store i32 0, i32* %10
br label %87
87: ; preds = %113, %65
%88 = load i32, i32* %10
%89 = icmp slt i32 %88, 100
br i1 %89, label %90, label %116
90: ; preds = %87
%91 = load double, double* %6
%92 = load double, double* %9
%93 = load double, double* %4
%94 = load double, double* %6
%95 = call double @cosh(double %94)
%96 = fneg double %93
%97 = call double @llvm.fmuladd.f64(double %96, double %95, double 1.000000e+00)
%98 = fdiv double %92, %97
%99 = fsub double %91, %98
store double %99, double* %6
%100 = load double, double* %6
%101 = load double, double* %4
%102 = load double, double* %6
%103 = call double @sinh(double %102)
%104 = fneg double %101
%105 = call double @llvm.fmuladd.f64(double %104, double %103, double %100)
%106 = load double, double* %5
%107 = fadd double %105, %106
store double %107, double* %9
%108 = load double, double* %9
%109 = call double @llvm.fabs.f64(double %108)
%110 = fcmp olt double %109, 0x3C9CD2B297D889BC
br i1 %110, label %111, label %112
111: ; preds = %90
br label %116
112: ; preds = %90
br label %113
113: ; preds = %112
%114 = load i32, i32* %10
%115 = add nsw i32 %114, 1
store i32 %115, i32* %10
br label %87
116: ; preds = %111, %87
%117 = load double, double* %6
store double %117, double* %3
br label %118
118: ; preds = %116, %61
%119 = load double, double* %3
ret double %119
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @reb_tools_M_to_E(double %0, double %1) {
%3 = fcmp olt double %0, 1.000000e+00
br i1 %3, label %4, label %31
4: ; preds = %2
%5 = tail call double @reb_tools_mod2pi(double %1)
%6 = fcmp olt double %0, 8.000000e-01
%7 = load double, double* @M_PI
%8 = select i1 %6, double %5, double %7
%9 = tail call double @sin(double %8)
%10 = fneg double %0
%11 = tail call double @llvm.fmuladd.f64(double %10, double %9, double %8)
%12 = fsub double %11, %5
br label %13
13: ; preds = %13, %4
%14 = phi i32 [ 0, %4 ], [ %26, %13 ]
%15 = phi double [ %12, %4 ], [ %23, %13 ]
%16 = phi double [ %8, %4 ], [ %20, %13 ]
%17 = tail call double @cos(double %16)
%18 = tail call double @llvm.fmuladd.f64(double %10, double %17, double 1.000000e+00)
%19 = fdiv double %15, %18
%20 = fsub double %16, %19
%21 = tail call double @sin(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %10, double %21, double %20)
%23 = fsub double %22, %5
%24 = tail call double @llvm.fabs.f64(double %23)
%25 = fcmp olt double %24, 0x3C9CD2B297D889BC
%26 = add nuw nsw i32 %14, 1
%27 = icmp eq i32 %26, 100
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %29, label %13
29: ; preds = %13
%30 = tail call double @reb_tools_mod2pi(double %20)
br label %60
31: ; preds = %2
%32 = tail call double @llvm.fabs.f64(double %1)
%33 = fdiv double %1, %32
%34 = fmul double %32, 2.000000e+00
%35 = fdiv double %34, %0
%36 = fadd double %35, 1.800000e+00
%37 = fptosi double %36 to i32
%38 = tail call double @log(i32 %37)
%39 = fmul double %33, %38
%40 = tail call double @sinh(double %39)
%41 = fneg double %0
%42 = tail call double @llvm.fmuladd.f64(double %41, double %40, double %39)
%43 = fadd double %42, %1
br label %44
44: ; preds = %44, %31
%45 = phi i32 [ 0, %31 ], [ %57, %44 ]
%46 = phi double [ %43, %31 ], [ %54, %44 ]
%47 = phi double [ %39, %31 ], [ %51, %44 ]
%48 = tail call double @cosh(double %47)
%49 = tail call double @llvm.fmuladd.f64(double %41, double %48, double 1.000000e+00)
%50 = fdiv double %46, %49
%51 = fsub double %47, %50
%52 = tail call double @sinh(double %51)
%53 = tail call double @llvm.fmuladd.f64(double %41, double %52, double %51)
%54 = fadd double %53, %1
%55 = tail call double @llvm.fabs.f64(double %54)
%56 = fcmp olt double %55, 0x3C9CD2B297D889BC
%57 = add nuw nsw i32 %45, 1
%58 = icmp eq i32 %57, 100
%59 = select i1 %56, i1 true, i1 %58
br i1 %59, label %60, label %44
60: ; preds = %44, %29
%61 = phi double [ %30, %29 ], [ %51, %44 ]
ret double %61
}