#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 cos(double);
double cosh(double);
double fabs(double);
double log(int);
double mod2pi(double);
double sin(double);
double sinh(double);
double reb_tools_M_to_E(double e, double M) {
  double E;
  if (e < 1.) {
    M = mod2pi(M);
    E = e < 0.8 ? M : 3.14159265358979323846;
    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 = 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    1354 <reb_tools_M_to_E+0x1f4>
movsd  -0x18(%rbp),%xmm0
call   1040 <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    11cb <reb_tools_M_to_E+0x6b>
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11cb <reb_tools_M_to_E+0x6b>
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   1060 <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    1336 <reb_tools_M_to_E+0x1d6>
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   1070 <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  0xd69(%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   1060 <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 0xd28(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd04(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1323 <reb_tools_M_to_E+0x1c3>
jmp    1336 <reb_tools_M_to_E+0x1d6>
jmp    1328 <reb_tools_M_to_E+0x1c8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1230 <reb_tools_M_to_E+0xd0>
movsd  -0x20(%rbp),%xmm0
call   1040 <mod2pi@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1554 <reb_tools_M_to_E+0x3f4>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movaps 0xccb(%rip),%xmm2
pand   %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x18(%rbp),%xmm1
movaps 0xcaf(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xc83(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xc6a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <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    154a <reb_tools_M_to_E+0x3ea>
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   1050 <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  0xb61(%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 0xb14(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xaf0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1537 <reb_tools_M_to_E+0x3d7>
jmp    154a <reb_tools_M_to_E+0x3ea>
jmp    153c <reb_tools_M_to_E+0x3dc>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1426 <reb_tools_M_to_E+0x2c6>
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   1040 <mod2pi@plt>
movapd %xmm0,0x20(%rsp)
movapd 0x10(%rsp),%xmm3
cmpltsd 0xe79(%rip),%xmm3
movapd %xmm3,%xmm2
andpd  %xmm0,%xmm2
movsd  0xe71(%rip),%xmm1
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,(%rsp)
movapd %xmm3,%xmm0
call   1060 <sin@plt>
movapd (%rsp),%xmm1
movapd 0xe6e(%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   1070 <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   1060 <sin@plt>
movapd (%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0x30(%rsp),%xmm2
addsd  %xmm1,%xmm2
subsd  0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
andpd  0xdc7(%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    1040 <mod2pi@plt>
movapd 0xd95(%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   1080 <log@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sinh@plt>
movsd  (%rsp),%xmm1
movapd 0xd59(%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   1050 <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  0xcb7(%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):
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 %64
13: ; preds = %2
%14 = load double, double* %5
%15 = call double @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 %21
20: ; preds = %13
br label %21
21: ; preds = %20, %18
%22 = phi double [ %19, %18 ], [ 0x400921FB54442D18, %20 ]
store double %22, double* %6
%23 = load double, double* %6
%24 = load double, double* %4
%25 = load double, double* %6
%26 = call double @sin(double %25)
%27 = fneg double %24
%28 = call double @llvm.fmuladd.f64(double %27, double %26, double %23)
%29 = load double, double* %5
%30 = fsub double %28, %29
store double %30, double* %7
store i32 0, i32* %8
br label %31
31: ; preds = %57, %21
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 100
br i1 %33, label %34, label %60
34: ; preds = %31
%35 = load double, double* %6
%36 = load double, double* %7
%37 = load double, double* %4
%38 = load double, double* %6
%39 = call double @cos(double %38)
%40 = fneg double %37
%41 = call double @llvm.fmuladd.f64(double %40, double %39, double 1.000000e+00)
%42 = fdiv double %36, %41
%43 = fsub double %35, %42
store double %43, double* %6
%44 = load double, double* %6
%45 = load double, double* %4
%46 = load double, double* %6
%47 = call double @sin(double %46)
%48 = fneg double %45
%49 = call double @llvm.fmuladd.f64(double %48, double %47, double %44)
%50 = load double, double* %5
%51 = fsub double %49, %50
store double %51, double* %7
%52 = load double, double* %7
%53 = call double @llvm.fabs.f64(double %52)
%54 = fcmp olt double %53, 0x3C9CD2B297D889BC
br i1 %54, label %55, label %56
55: ; preds = %34
br label %60
56: ; preds = %34
br label %57
57: ; preds = %56
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
br label %31
60: ; preds = %55, %31
%61 = load double, double* %6
%62 = call double @mod2pi(double %61)
store double %62, double* %6
%63 = load double, double* %6
store double %63, double* %3
br label %117
64: ; preds = %2
%65 = load double, double* %5
%66 = load double, double* %5
%67 = call double @llvm.fabs.f64(double %66)
%68 = fdiv double %65, %67
%69 = load double, double* %5
%70 = call double @llvm.fabs.f64(double %69)
%71 = fmul double 2.000000e+00, %70
%72 = load double, double* %4
%73 = fdiv double %71, %72
%74 = fadd double %73, 1.800000e+00
%75 = fptosi double %74 to i32
%76 = call double @log(i32 %75)
%77 = fmul double %68, %76
store double %77, double* %6
%78 = load double, double* %6
%79 = load double, double* %4
%80 = load double, double* %6
%81 = call double @sinh(double %80)
%82 = fneg double %79
%83 = call double @llvm.fmuladd.f64(double %82, double %81, double %78)
%84 = load double, double* %5
%85 = fadd double %83, %84
store double %85, double* %9
store i32 0, i32* %10
br label %86
86: ; preds = %112, %64
%87 = load i32, i32* %10
%88 = icmp slt i32 %87, 100
br i1 %88, label %89, label %115
89: ; preds = %86
%90 = load double, double* %6
%91 = load double, double* %9
%92 = load double, double* %4
%93 = load double, double* %6
%94 = call double @cosh(double %93)
%95 = fneg double %92
%96 = call double @llvm.fmuladd.f64(double %95, double %94, double 1.000000e+00)
%97 = fdiv double %91, %96
%98 = fsub double %90, %97
store double %98, double* %6
%99 = load double, double* %6
%100 = load double, double* %4
%101 = load double, double* %6
%102 = call double @sinh(double %101)
%103 = fneg double %100
%104 = call double @llvm.fmuladd.f64(double %103, double %102, double %99)
%105 = load double, double* %5
%106 = fadd double %104, %105
store double %106, double* %9
%107 = load double, double* %9
%108 = call double @llvm.fabs.f64(double %107)
%109 = fcmp olt double %108, 0x3C9CD2B297D889BC
br i1 %109, label %110, label %111
110: ; preds = %89
br label %115
111: ; preds = %89
br label %112
112: ; preds = %111
%113 = load i32, i32* %10
%114 = add nsw i32 %113, 1
store i32 %114, i32* %10
br label %86
115: ; preds = %110, %86
%116 = load double, double* %6
store double %116, double* %3
br label %117
117: ; preds = %115, %60
%118 = load double, double* %3
ret double %118
}

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