#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 atan2(double, double);
double cos(double const);
double const fabs(double);
double sin(double const);
double find_closest_point_on_ellipse(double x, double y, const double a,
                                     double b, double *lat) {
  double
      min_u = 0.,
      max_u =
          3.1415926535897932384626433832795028841971693993751058209749445923 /
          2.;
  double
      u1 = 3.1415926535897932384626433832795028841971693993751058209749445923 /
           2.,
      z1;
  double u2 = 0., z2;
  const double tolerance = 1e-13;
  double dist, c;
  const bool x_positive = (x > 0.);
  const bool y_positive = (y > 0.);
  if (!y_positive)
    y = -y;
  if (!x_positive)
    x = -x;
  b /= a;
  x /= a;
  y /= a;
  c = 1. - b * b;
  z2 = b * y;
  z1 = -x;
  do {
    const double u0 = (u1 * z2 - u2 * z1) / (z2 - z1);
    const double u = (u0 >= min_u && u0 <= max_u) ? u0 : (min_u + max_u) / 2.;
    const double sin_u = sin(u), cos_u = cos(u);
    const double z = (c * cos_u - x) * sin_u + b * y * cos_u;
    u2 = u1;
    z2 = z1;
    u1 = u;
    z1 = z;
    if (z >= 0.)
      min_u = u;
    else
      max_u = u;
  } while (fabs(z1) > tolerance);
  *lat = atan2(sin(u1), cos(u1) * b);
  dist = cos(*lat) * (x - cos(u1)) + sin(*lat) * (y - b * sin(u1));
  if (!y_positive)
    *lat = -*lat;
  if (!x_positive)
    *lat = 3.1415926535897932384626433832795028841971693993751058209749445923 -
           *lat;
  return (a * dist);
}


x86 assembly (clang, -O0):
<find_closest_point_on_ellipse>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe88(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe6b(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x74(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jne    11f3 <find_closest_point_on_ellipse+0xb3>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x74(%rbp)
jne    121e <find_closest_point_on_ellipse+0xde>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd8c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1339 <find_closest_point_on_ellipse+0x1f9>
movsd  -0x80(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1339 <find_closest_point_on_ellipse+0x1f9>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
jmp    1357 <find_closest_point_on_ellipse+0x217>
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xccd(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
call   1050 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
call   1060 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  -0x98(%rbp),%xmm2
ff
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x20(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x40(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x48(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1441 <find_closest_point_on_ellipse+0x301>
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x30(%rbp)
jmp    144e <find_closest_point_on_ellipse+0x30e>
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x38(%rbp)
jmp    1453 <find_closest_point_on_ellipse+0x313>
movsd  -0x48(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  0xb9b(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     12bd <find_closest_point_on_ellipse+0x17d>
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xe0(%rbp),%xmm0
ff
mulsd  -0x20(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xd8(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0xd0(%rbp),%xmm3
ff
movsd  -0xc8(%rbp),%xmm4
ff
movsd  -0xc0(%rbp),%xmm1
ff
movsd  -0xb8(%rbp),%xmm2
ff
movaps %xmm0,%xmm5
movsd  -0xb0(%rbp),%xmm0
ff
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x0,-0x78(%rbp)
jne    15b0 <find_closest_point_on_ellipse+0x470>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
cmpl   $0x0,-0x74(%rbp)
jne    15d2 <find_closest_point_on_ellipse+0x492>
mov    -0x28(%rbp),%rax
movsd  0xa5a(%rip),%xmm0
subsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_closest_point_on_ellipse>:
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%rbx
movapd 0xebd(%rip),%xmm7
movapd %xmm1,%xmm4
xorpd  %xmm7,%xmm4
xorpd  %xmm6,%xmm6
cmpltsd %xmm1,%xmm6
movapd %xmm6,%xmm5
andnpd %xmm4,%xmm5
movapd %xmm1,0x80(%rsp)
andpd  %xmm1,%xmm6
orpd   %xmm5,%xmm6
movapd %xmm0,%xmm5
xorpd  %xmm7,%xmm5
xorpd  %xmm4,%xmm4
cmpltsd %xmm0,%xmm4
movapd %xmm4,%xmm1
andnpd %xmm5,%xmm1
movapd %xmm0,0x90(%rsp)
andpd  %xmm0,%xmm4
orpd   %xmm1,%xmm4
divsd  %xmm2,%xmm4
unpcklpd %xmm6,%xmm3
movapd %xmm2,0xb0(%rsp)
movapd %xmm2,%xmm0
unpcklpd %xmm2,%xmm0
divpd  %xmm0,%xmm3
movapd %xmm3,%xmm0
xorpd  %xmm7,%xmm0
movapd %xmm0,0x70(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
movsd  0xe4e(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x40(%rsp)
movapd %xmm3,%xmm0
unpckhpd %xmm3,%xmm0
movapd %xmm0,0x60(%rsp)
movapd %xmm3,0x50(%rsp)
mulsd  %xmm3,%xmm0
movapd %xmm4,0xa0(%rsp)
xorpd  %xmm4,%xmm7
movsd  0xe1f(%rip),%xmm1
movapd %xmm0,0xc0(%rsp)
xorpd  %xmm2,%xmm2
movapd %xmm7,0xd0(%rsp)
movapd %xmm1,%xmm5
xorpd  %xmm3,%xmm3
movsd  %xmm3,0x28(%rsp)
jmp    127c <find_closest_point_on_ellipse+0x14c>
nop
xorpd  %xmm3,%xmm3
cmpnlesd %xmm1,%xmm3
movapd %xmm4,%xmm0
andpd  %xmm3,%xmm0
andnpd 0x30(%rsp),%xmm3
orpd   %xmm0,%xmm3
movapd %xmm1,%xmm0
andpd  0xdb9(%rip),%xmm0
ucomisd 0xdd9(%rip),%xmm0
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm2
movapd %xmm1,%xmm7
movapd %xmm4,%xmm1
movapd %xmm3,%xmm5
jbe    134a <find_closest_point_on_ellipse+0x21a>
movapd %xmm5,0x30(%rsp)
movsd  %xmm7,0x8(%rsp)
mulsd  %xmm7,%xmm2
movsd  %xmm1,(%rsp)
mulsd  %xmm0,%xmm1
subsd  %xmm2,%xmm1
subsd  %xmm7,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm5,%xmm0
movsd  0x28(%rsp),%xmm4
addsd  %xmm4,%xmm0
mulsd  0xd79(%rip),%xmm0
movapd %xmm1,%xmm2
cmpnlesd %xmm5,%xmm2
movapd %xmm2,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm0,%xmm2
orpd   %xmm3,%xmm2
cmpnlesd %xmm1,%xmm4
movapd %xmm4,%xmm1
andnpd %xmm2,%xmm1
andpd  %xmm0,%xmm4
orpd   %xmm1,%xmm4
movapd %xmm4,0x10(%rsp)
movapd %xmm4,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x48(%rsp)
movapd 0x10(%rsp),%xmm0
call   1050 <cos@plt>
movapd 0x10(%rsp),%xmm4
movsd  0x40(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xd0(%rsp),%xmm1
mulsd  0xc0(%rsp),%xmm0
mulsd  0x48(%rsp),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xd0f(%rip),%xmm1
jb     1230 <find_closest_point_on_ellipse+0x100>
movsd  %xmm4,0x28(%rsp)
jmp    1230 <find_closest_point_on_ellipse+0x100>
movapd %xmm4,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1050 <cos@plt>
movapd %xmm0,%xmm1
mulsd  0x50(%rsp),%xmm1
movsd  (%rsp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,(%rbx)
call   1050 <cos@plt>
movsd  %xmm0,(%rsp)
movaps 0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  (%rbx),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
call   1040 <sin@plt>
xorpd  %xmm1,%xmm1
movapd 0x80(%rsp),%xmm2
ucomisd %xmm1,%xmm2
ja     13d2 <find_closest_point_on_ellipse+0x2a2>
movsd  (%rbx),%xmm2
xorpd  0xc32(%rip),%xmm2
movlpd %xmm2,(%rbx)
movapd 0x90(%rsp),%xmm2
ucomisd %xmm1,%xmm2
ja     13f1 <find_closest_point_on_ellipse+0x2c1>
movsd  0xc57(%rip),%xmm1
subsd  (%rbx),%xmm1
movsd  %xmm1,(%rbx)
movapd 0xa0(%rsp),%xmm1
subsd  0x30(%rsp),%xmm1
movapd 0x70(%rsp),%xmm2
mulsd  %xmm0,%xmm2
addsd  0x60(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
mulsd  %xmm2,%xmm3
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
mulsd  0xb0(%rsp),%xmm0
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @find_closest_point_on_ellipse(double %0, double %1, double %2, double %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca i32
%21 = alloca i32
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double* %4, double** %10
store double 0.000000e+00, double* %11
store double 0x3FF921FB54442D18, double* %12
store double 0x3FF921FB54442D18, double* %13
store double 0.000000e+00, double* %15
store double 1.000000e-13, double* %17
%27 = load double, double* %6
%28 = fcmp ogt double %27, 0.000000e+00
%29 = zext i1 %28 to i32
store i32 %29, i32* %20
%30 = load double, double* %7
%31 = fcmp ogt double %30, 0.000000e+00
%32 = zext i1 %31 to i32
store i32 %32, i32* %21
%33 = load i32, i32* %21
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %5
%36 = load double, double* %7
%37 = fneg double %36
store double %37, double* %7
br label %38
38: ; preds = %35, %5
%39 = load i32, i32* %20
%40 = icmp ne i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load double, double* %6
%43 = fneg double %42
store double %43, double* %6
br label %44
44: ; preds = %41, %38
%45 = load double, double* %8
%46 = load double, double* %9
%47 = fdiv double %46, %45
store double %47, double* %9
%48 = load double, double* %8
%49 = load double, double* %6
%50 = fdiv double %49, %48
store double %50, double* %6
%51 = load double, double* %8
%52 = load double, double* %7
%53 = fdiv double %52, %51
store double %53, double* %7
%54 = load double, double* %9
%55 = load double, double* %9
%56 = fneg double %54
%57 = call double @llvm.fmuladd.f64(double %56, double %55, double 1.000000e+00)
store double %57, double* %19
%58 = load double, double* %9
%59 = load double, double* %7
%60 = fmul double %58, %59
store double %60, double* %16
%61 = load double, double* %6
%62 = fneg double %61
store double %62, double* %14
br label %63
63: ; preds = %118, %44
%64 = load double, double* %13
%65 = load double, double* %16
%66 = load double, double* %15
%67 = load double, double* %14
%68 = fmul double %66, %67
%69 = fneg double %68
%70 = call double @llvm.fmuladd.f64(double %64, double %65, double %69)
%71 = load double, double* %16
%72 = load double, double* %14
%73 = fsub double %71, %72
%74 = fdiv double %70, %73
store double %74, double* %22
%75 = load double, double* %22
%76 = load double, double* %11
%77 = fcmp oge double %75, %76
br i1 %77, label %78, label %84
78: ; preds = %63
%79 = load double, double* %22
%80 = load double, double* %12
%81 = fcmp ole double %79, %80
br i1 %81, label %82, label %84
82: ; preds = %78
%83 = load double, double* %22
br label %89
84: ; preds = %78, %63
%85 = load double, double* %11
%86 = load double, double* %12
%87 = fadd double %85, %86
%88 = fdiv double %87, 2.000000e+00
br label %89
89: ; preds = %84, %82
%90 = phi double [ %83, %82 ], [ %88, %84 ]
store double %90, double* %23
%91 = load double, double* %23
%92 = call double @sin(double %91)
store double %92, double* %24
%93 = load double, double* %23
%94 = call double @cos(double %93)
store double %94, double* %25
%95 = load double, double* %19
%96 = load double, double* %25
%97 = load double, double* %6
%98 = fneg double %97
%99 = call double @llvm.fmuladd.f64(double %95, double %96, double %98)
%100 = load double, double* %24
%101 = load double, double* %9
%102 = load double, double* %7
%103 = fmul double %101, %102
%104 = load double, double* %25
%105 = fmul double %103, %104
%106 = call double @llvm.fmuladd.f64(double %99, double %100, double %105)
store double %106, double* %26
%107 = load double, double* %13
store double %107, double* %15
%108 = load double, double* %14
store double %108, double* %16
%109 = load double, double* %23
store double %109, double* %13
%110 = load double, double* %26
store double %110, double* %14
%111 = load double, double* %26
%112 = fcmp oge double %111, 0.000000e+00
br i1 %112, label %113, label %115
113: ; preds = %89
%114 = load double, double* %23
store double %114, double* %11
br label %117
115: ; preds = %89
%116 = load double, double* %23
store double %116, double* %12
br label %117
117: ; preds = %115, %113
br label %118
118: ; preds = %117
%119 = load double, double* %14
%120 = call double @fabs(double %119)
%121 = fcmp ogt double %120, 1.000000e-13
br i1 %121, label %63, label %122
122: ; preds = %118
%123 = load double, double* %13
%124 = call double @sin(double %123)
%125 = load double, double* %13
%126 = call double @cos(double %125)
%127 = load double, double* %9
%128 = fmul double %126, %127
%129 = call double @atan2(double %124, double %128)
%130 = load double*, double** %10
store double %129, double* %130
%131 = load double*, double** %10
%132 = load double, double* %131
%133 = call double @cos(double %132)
%134 = load double, double* %6
%135 = load double, double* %13
%136 = call double @cos(double %135)
%137 = fsub double %134, %136
%138 = load double*, double** %10
%139 = load double, double* %138
%140 = call double @sin(double %139)
%141 = load double, double* %7
%142 = load double, double* %9
%143 = load double, double* %13
%144 = call double @sin(double %143)
%145 = fneg double %142
%146 = call double @llvm.fmuladd.f64(double %145, double %144, double %141)
%147 = fmul double %140, %146
%148 = call double @llvm.fmuladd.f64(double %133, double %137, double %147)
store double %148, double* %18
%149 = load i32, i32* %21
%150 = icmp ne i32 %149, 0
br i1 %150, label %156, label %151
151: ; preds = %122
%152 = load double*, double** %10
%153 = load double, double* %152
%154 = fneg double %153
%155 = load double*, double** %10
store double %154, double* %155
br label %156
156: ; preds = %151, %122
%157 = load i32, i32* %20
%158 = icmp ne i32 %157, 0
br i1 %158, label %164, label %159
159: ; preds = %156
%160 = load double*, double** %10
%161 = load double, double* %160
%162 = fsub double 0x400921FB54442D18, %161
%163 = load double*, double** %10
store double %162, double* %163
br label %164
164: ; preds = %159, %156
%165 = load double, double* %8
%166 = load double, double* %18
%167 = fmul double %165, %166
ret double %167
}

LLVM IR (-O2):
define double @find_closest_point_on_ellipse(double %0, double %1, double %2, double %3, double* nocapture %4) {
%6 = fcmp ogt double %0, 0.000000e+00
%7 = fcmp ogt double %1, 0.000000e+00
%8 = fneg double %1
%9 = select i1 %7, double %1, double %8
%10 = fneg double %0
%11 = select i1 %6, double %0, double %10
%12 = fdiv double %11, %2
%13 = insertelement <2 x double> poison, double %3, i64 0
%14 = insertelement <2 x double> %13, double %9, i64 1
%15 = insertelement <2 x double> poison, double %2, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x double> %14, %16
%18 = extractelement <2 x double> %17, i64 0
%19 = fneg double %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double %18, double 1.000000e+00)
%21 = extractelement <2 x double> %17, i64 1
%22 = fmul double %18, %21
%23 = fneg double %12
br label %24
24: ; preds = %24, %5
%25 = phi double [ %22, %5 ], [ %27, %24 ]
%26 = phi double [ 0.000000e+00, %5 ], [ %28, %24 ]
%27 = phi double [ %23, %5 ], [ %46, %24 ]
%28 = phi double [ 0x3FF921FB54442D18, %5 ], [ %41, %24 ]
%29 = phi double [ 0x3FF921FB54442D18, %5 ], [ %48, %24 ]
%30 = phi double [ 0.000000e+00, %5 ], [ %49, %24 ]
%31 = fneg double %26
%32 = fmul double %27, %31
%33 = tail call double @llvm.fmuladd.f64(double %28, double %25, double %32)
%34 = fsub double %25, %27
%35 = fdiv double %33, %34
%36 = fcmp ult double %35, %30
%37 = fcmp ugt double %35, %29
%38 = select i1 %36, i1 true, i1 %37
%39 = fadd double %29, %30
%40 = fmul double %39, 5.000000e-01
%41 = select i1 %38, double %40, double %35
%42 = tail call double @sin(double %41)
%43 = tail call double @cos(double %41)
%44 = tail call double @llvm.fmuladd.f64(double %20, double %43, double %23)
%45 = fmul double %22, %43
%46 = tail call double @llvm.fmuladd.f64(double %44, double %42, double %45)
%47 = fcmp ult double %46, 0.000000e+00
%48 = select i1 %47, double %41, double %29
%49 = select i1 %47, double %30, double %41
%50 = tail call double @llvm.fabs.f64(double %46)
%51 = fcmp ogt double %50, 1.000000e-13
br i1 %51, label %24, label %52
52: ; preds = %24
%53 = tail call double @sin(double %41)
%54 = tail call double @cos(double %41)
%55 = fmul double %18, %54
%56 = tail call double @atan2(double %53, double %55)
store double %56, double* %4
%57 = tail call double @cos(double %56)
%58 = tail call double @cos(double %41)
%59 = load double, double* %4
%60 = tail call double @sin(double %59)
%61 = tail call double @sin(double %41)
br i1 %7, label %65, label %62
62: ; preds = %52
%63 = load double, double* %4
%64 = fneg double %63
store double %64, double* %4
br label %65
65: ; preds = %62, %52
br i1 %6, label %69, label %66
66: ; preds = %65
%67 = load double, double* %4
%68 = fsub double 0x400921FB54442D18, %67
store double %68, double* %4
br label %69
69: ; preds = %66, %65
%70 = fsub double %12, %58
%71 = tail call double @llvm.fmuladd.f64(double %19, double %61, double %21)
%72 = fmul double %60, %71
%73 = tail call double @llvm.fmuladd.f64(double %57, double %70, double %72)
%74 = fmul double %73, %2
ret double %74
}