#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 calc_EccAnom(double MeanAnom, double ecc) {
  double EccAnom, f_EccAnom, fder_EccAnom;
  if (sin(MeanAnom) > 0) {
    EccAnom = MeanAnom + 0.85 * ecc;
  } else {
    EccAnom = MeanAnom - 0.85 * ecc;
  }
  do {
    f_EccAnom = EccAnom - ecc * sin(EccAnom) - MeanAnom;
    fder_EccAnom = 1 - ecc * cos(EccAnom);
    EccAnom = EccAnom - f_EccAnom / fder_EccAnom;
  } while (f_EccAnom > 0.000001 || f_EccAnom < -0.000001);
  return EccAnom;
}


x86 assembly (clang, -O0):
<calc_EccAnom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    116d <calc_EccAnom+0x4d>
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xead(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118c <calc_EccAnom+0x6c>
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe81(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1191 <calc_EccAnom+0x71>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%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  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%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 <calc_EccAnom+0x154>
movsd  0xdb7(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
seta   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1191 <calc_EccAnom+0x71>
movsd  -0x18(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_EccAnom>:
sub    $0x28,%rsp
movapd %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
seta   %al
lea    0xeb7(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movapd 0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
xorpd  0xeb0(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
addsd  0x8(%rsp),%xmm0
nopl   0x0(%rax)
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 <calc_EccAnom+0x50>
movsd  0xe59(%rip),%xmm1
ucomisd %xmm2,%xmm1
ja     1170 <calc_EccAnom+0x50>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @calc_EccAnom(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* %3
%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* %3
%13 = load double, double* %4
%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* %3
%17 = load double, double* %4
%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* %4
%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* %3
%28 = fsub double %26, %27
store double %28, double* %6
%29 = load double, double* %4
%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 @calc_EccAnom(double %0, double %1) {
%3 = tail call double @sin(double %0)
%4 = fcmp ogt double %3, 0.000000e+00
%5 = tail call double @llvm.fmuladd.f64(double %1, double 8.500000e-01, double %0)
%6 = tail call double @llvm.fmuladd.f64(double %1, double -8.500000e-01, double %0)
%7 = select i1 %4, double %5, double %6
%8 = fneg double %1
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, %0
%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
}