double TkOvalToPoint(ovalPtr, width, filled, pointPtr)
double ovalPtr[4];
double width;
int filled;
double pointPtr[2];
{
  double xDelta, yDelta, scaledDistance, distToOutline, distToCenter;
  xDelta = (pointPtr[0] - (ovalPtr[0] + ovalPtr[2]) / 2.0);
  yDelta = (pointPtr[1] - (ovalPtr[1] + ovalPtr[3]) / 2.0);
  distToCenter = hypot(xDelta, yDelta);
  scaledDistance = hypot(xDelta / ((ovalPtr[2] + width - ovalPtr[0]) / 2.0),
                         yDelta / ((ovalPtr[3] + width - ovalPtr[1]) / 2.0));
  if (scaledDistance > 1.0) {
    return (distToCenter / scaledDistance) * (scaledDistance - 1.0);
  }
  if (filled) {
    return 0.0;
  }
  distToOutline =
      (distToCenter / scaledDistance) * (1.0 - scaledDistance) - width;
  if (distToOutline < 0.0) {
    return 0.0;
  }
  return distToOutline;
}


x86 assembly (clang, -O0):
<TkOvalToPoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  0x10(%rax),%xmm1
movsd  0xebf(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  0x18(%rax),%xmm1
movsd  0xe8f(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <hypot@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
addsd  -0x18(%rbp),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
movsd  0xe4b(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
addsd  -0x18(%rbp),%xmm2
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm2
movsd  0xe1f(%rip),%xmm3
divsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
call   1030 <hypot@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xdf8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123b <TkOvalToPoint+0x12b>
movsd  -0x50(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xdd7(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b7 <TkOvalToPoint+0x1a7>
cmpl   $0x0,-0x1c(%rbp)
je     1252 <TkOvalToPoint+0x142>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b7 <TkOvalToPoint+0x1a7>
movsd  -0x50(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  0xd9c(%rip),%xmm2
subsd  -0x40(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    12ad <TkOvalToPoint+0x19d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b7 <TkOvalToPoint+0x1a7>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TkOvalToPoint>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
movsd  (%rdi),%xmm2
movsd  0x8(%rdi),%xmm4
addsd  0x10(%rdi),%xmm2
movsd  0xec9(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  (%rdx),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rdx),%xmm1
addsd  0x18(%rdi),%xmm4
mulsd  %xmm3,%xmm4
subsd  %xmm4,%xmm1
movsd  %xmm1,0x20(%rsp)
call   1030 <hypot@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm2
movsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm2
subsd  (%rbx),%xmm2
movsd  0xe79(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0x18(%rsp),%xmm0
divsd  %xmm2,%xmm0
movsd  0x18(%rbx),%xmm2
addsd  %xmm1,%xmm2
subsd  0x8(%rbx),%xmm2
mulsd  %xmm3,%xmm2
movsd  0x20(%rsp),%xmm1
divsd  %xmm2,%xmm1
call   1030 <hypot@plt>
ucomisd 0xe4a(%rip),%xmm0
jbe    11dc <TkOvalToPoint+0xcc>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0xe3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
jmp    1210 <TkOvalToPoint+0x100>
movsd  0x8(%rsp),%xmm2
xorpd  %xmm1,%xmm1
test   %ebp,%ebp
jne    1210 <TkOvalToPoint+0x100>
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  0xe0e(%rip),%xmm2
subsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
subsd  0x10(%rsp),%xmm2
xorpd  %xmm1,%xmm1
maxsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @TkOvalToPoint(double* %0, double %1, i32 %2, double* %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double* %0, double** %6
store double %1, double* %7
store i32 %2, i32* %8
store double* %3, double** %9
%15 = load double*, double** %9
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 2
%23 = load double, double* %22
%24 = fadd double %20, %23
%25 = fdiv double %24, 2.000000e+00
%26 = fsub double %17, %25
store double %26, double* %10
%27 = load double*, double** %9
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = load double*, double** %6
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = load double*, double** %6
%34 = getelementptr inbounds double, double* %33, i64 3
%35 = load double, double* %34
%36 = fadd double %32, %35
%37 = fdiv double %36, 2.000000e+00
%38 = fsub double %29, %37
store double %38, double* %11
%39 = load double, double* %10
%40 = load double, double* %11
%41 = call double @hypot(double %39, double %40)
store double %41, double* %14
%42 = load double, double* %10
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 2
%45 = load double, double* %44
%46 = load double, double* %7
%47 = fadd double %45, %46
%48 = load double*, double** %6
%49 = getelementptr inbounds double, double* %48, i64 0
%50 = load double, double* %49
%51 = fsub double %47, %50
%52 = fdiv double %51, 2.000000e+00
%53 = fdiv double %42, %52
%54 = load double, double* %11
%55 = load double*, double** %6
%56 = getelementptr inbounds double, double* %55, i64 3
%57 = load double, double* %56
%58 = load double, double* %7
%59 = fadd double %57, %58
%60 = load double*, double** %6
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
%63 = fsub double %59, %62
%64 = fdiv double %63, 2.000000e+00
%65 = fdiv double %54, %64
%66 = call double @hypot(double %53, double %65)
store double %66, double* %12
%67 = load double, double* %12
%68 = fcmp ogt double %67, 1.000000e+00
br i1 %68, label %69, label %76
69: ; preds = %4
%70 = load double, double* %14
%71 = load double, double* %12
%72 = fdiv double %70, %71
%73 = load double, double* %12
%74 = fsub double %73, 1.000000e+00
%75 = fmul double %72, %74
store double %75, double* %5
br label %94
76: ; preds = %4
%77 = load i32, i32* %8
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %76
store double 0.000000e+00, double* %5
br label %94
80: ; preds = %76
%81 = load double, double* %14
%82 = load double, double* %12
%83 = fdiv double %81, %82
%84 = load double, double* %12
%85 = fsub double 1.000000e+00, %84
%86 = load double, double* %7
%87 = fneg double %86
%88 = call double @llvm.fmuladd.f64(double %83, double %85, double %87)
store double %88, double* %13
%89 = load double, double* %13
%90 = fcmp olt double %89, 0.000000e+00
br i1 %90, label %91, label %92
91: ; preds = %80
store double 0.000000e+00, double* %5
br label %94
92: ; preds = %80
%93 = load double, double* %13
store double %93, double* %5
br label %94
94: ; preds = %92, %91, %79, %69
%95 = load double, double* %5
ret double %95
}

LLVM IR (-O2):
define double @TkOvalToPoint(double* nocapture %0, double %1, i32 %2, double* nocapture %3) {
%5 = load double, double* %3
%6 = load double, double* %0
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
%9 = fadd double %6, %8
%10 = fmul double %9, 5.000000e-01
%11 = fsub double %5, %10
%12 = getelementptr inbounds double, double* %3, i64 1
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %0, i64 1
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %0, i64 3
%17 = load double, double* %16
%18 = fadd double %15, %17
%19 = fmul double %18, 5.000000e-01
%20 = fsub double %13, %19
%21 = tail call double @hypot(double %11, double %20)
%22 = load double, double* %7
%23 = fadd double %22, %1
%24 = load double, double* %0
%25 = fsub double %23, %24
%26 = fmul double %25, 5.000000e-01
%27 = fdiv double %11, %26
%28 = load double, double* %16
%29 = fadd double %28, %1
%30 = load double, double* %14
%31 = fsub double %29, %30
%32 = fmul double %31, 5.000000e-01
%33 = fdiv double %20, %32
%34 = tail call double @hypot(double %27, double %33)
%35 = fcmp ogt double %34, 1.000000e+00
br i1 %35, label %36, label %40
36: ; preds = %4
%37 = fdiv double %21, %34
%38 = fadd double %34, -1.000000e+00
%39 = fmul double %37, %38
br label %49
40: ; preds = %4
%41 = icmp eq i32 %2, 0
br i1 %41, label %42, label %49
42: ; preds = %40
%43 = fdiv double %21, %34
%44 = fsub double 1.000000e+00, %34
%45 = fneg double %1
%46 = tail call double @llvm.fmuladd.f64(double %43, double %44, double %45)
%47 = fcmp olt double %46, 0.000000e+00
%48 = select i1 %47, double 0.000000e+00, double %46
br label %49
49: ; preds = %42, %40, %36
%50 = phi double [ %39, %36 ], [ 0.000000e+00, %40 ], [ %48, %42 ]
ret double %50
}