#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 sin(double);
double ecc_anom(double e, double M) {
  double E;
  if (sin(M) > 0)
    E = M + 0.85 * e;
  else
    E = M - 0.85 * e;
  double f_E, fder_E;
  do {
    f_E = E - e * sin(E) - M;
    fder_E = 1 - e * cos(E);
    E = E - f_E / fder_E;
  } while (f_E > 0.000001 || f_E < -0.000001);
  return E;
}


x86 assembly (clang, -O0):
<ecc_anom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    116d <ecc_anom+0x4d>
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xead(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118c <ecc_anom+0x6c>
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xe81(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1191 <ecc_anom+0x71>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdec(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
movsd  0xdc4(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x41(%rbp)
ja     1274 <ecc_anom+0x154>
movsd  0xdb7(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
seta   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1191 <ecc_anom+0x71>
movsd  -0x18(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecc_anom>:
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
movaps %xmm0,0x10(%rsp)
movapd %xmm1,%xmm0
call   1030 <sin@plt>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
seta   %al
lea    0xeb4(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movapd 0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
xorpd  0xead(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
addsd  0x8(%rsp),%xmm0
nop
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
addsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x20(%rsp),%xmm2
mulsd  0x10(%rsp),%xmm0
addsd  0xe6c(%rip),%xmm0
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
ucomisd 0xe5b(%rip),%xmm2
ja     1170 <ecc_anom+0x50>
movsd  0xe59(%rip),%xmm1
ucomisd %xmm2,%xmm1
ja     1170 <ecc_anom+0x50>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @ecc_anom(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
%8 = load double, double* %4
%9 = call double @sin(double %8)
%10 = fcmp ogt double %9, 0.000000e+00
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load double, double* %4
%13 = load double, double* %3
%14 = call double @llvm.fmuladd.f64(double 8.500000e-01, double %13, double %12)
store double %14, double* %5
br label %19
15: ; preds = %2
%16 = load double, double* %4
%17 = load double, double* %3
%18 = call double @llvm.fmuladd.f64(double -8.500000e-01, double %17, double %16)
store double %18, double* %5
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %45, %19
%21 = load double, double* %5
%22 = load double, double* %3
%23 = load double, double* %5
%24 = call double @sin(double %23)
%25 = fneg double %22
%26 = call double @llvm.fmuladd.f64(double %25, double %24, double %21)
%27 = load double, double* %4
%28 = fsub double %26, %27
store double %28, double* %6
%29 = load double, double* %3
%30 = load double, double* %5
%31 = call double @cos(double %30)
%32 = fneg double %29
%33 = call double @llvm.fmuladd.f64(double %32, double %31, double 1.000000e+00)
store double %33, double* %7
%34 = load double, double* %5
%35 = load double, double* %6
%36 = load double, double* %7
%37 = fdiv double %35, %36
%38 = fsub double %34, %37
store double %38, double* %5
br label %39
39: ; preds = %20
%40 = load double, double* %6
%41 = fcmp ogt double %40, 0x3EB0C6F7A0B5ED8D
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load double, double* %6
%44 = fcmp olt double %43, 0xBEB0C6F7A0B5ED8D
br label %45
45: ; preds = %42, %39
%46 = phi i1 [ true, %39 ], [ %44, %42 ]
br i1 %46, label %20, label %47
47: ; preds = %45
%48 = load double, double* %5
ret double %48
}

LLVM IR (-O2):
define double @ecc_anom(double %0, double %1) {
%3 = tail call double @sin(double %1)
%4 = fcmp ogt double %3, 0.000000e+00
%5 = tail call double @llvm.fmuladd.f64(double %0, double 8.500000e-01, double %1)
%6 = tail call double @llvm.fmuladd.f64(double %0, double -8.500000e-01, double %1)
%7 = select i1 %4, double %5, double %6
%8 = fneg double %0
br label %9
9: ; preds = %9, %2
%10 = phi double [ %7, %2 ], [ %17, %9 ]
%11 = tail call double @sin(double %10)
%12 = tail call double @llvm.fmuladd.f64(double %8, double %11, double %10)
%13 = fsub double %12, %1
%14 = tail call double @cos(double %10)
%15 = tail call double @llvm.fmuladd.f64(double %8, double %14, double 1.000000e+00)
%16 = fdiv double %13, %15
%17 = fsub double %10, %16
%18 = fcmp ogt double %13, 0x3EB0C6F7A0B5ED8D
%19 = fcmp olt double %13, 0xBEB0C6F7A0B5ED8D
%20 = or i1 %18, %19
br i1 %20, label %9, label %21
21: ; preds = %9
ret double %17
}