#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 sqrt(double);
double astrofuncs_y1lim(double rprs, double delv, double vp, double yp) {
  if (delv >= 1.0 || delv <= -1.0)
    return 0.0;
  if (delv - vp >= rprs || delv - vp <= -rprs)
    return 0.0;
  if (yp - sqrt(rprs * rprs - (delv - vp) * (delv - vp)) >=
      sqrt(1.0 - delv * delv))
    return sqrt(1.0 - delv * delv);
  if (yp - sqrt(rprs * rprs - (delv - vp) * (delv - vp)) <=
      -sqrt(1.0 - delv * delv))
    return -sqrt(1.0 - delv * delv);
  return yp - sqrt(rprs * rprs - (delv - vp) * (delv - vp));
}


x86 assembly (clang, -O0):
<astrofuncs_y1lim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1156 <astrofuncs_y1lim+0x46>
movsd  0xebd(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1163 <astrofuncs_y1lim+0x53>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1413 <astrofuncs_y1lim+0x303>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    11a8 <astrofuncs_y1lim+0x98>
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jb     11b5 <astrofuncs_y1lim+0xa5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1413 <astrofuncs_y1lim+0x303>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
subsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdbd(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     129e <astrofuncs_y1lim+0x18e>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd75(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1413 <astrofuncs_y1lim+0x303>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
subsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xcd4(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  -0x40(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jb     13b2 <astrofuncs_y1lim+0x2a2>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xc78(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1413 <astrofuncs_y1lim+0x303>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
subsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astrofuncs_y1lim>:
sub    $0x38,%rsp
movapd %xmm0,%xmm4
ucomisd 0xee0(%rip),%xmm1
xorpd  %xmm0,%xmm0
jae    12cc <astrofuncs_y1lim+0x1bc>
movsd  0xed6(%rip),%xmm5
ucomisd %xmm1,%xmm5
jae    12cc <astrofuncs_y1lim+0x1bc>
movapd %xmm1,%xmm5
subsd  %xmm2,%xmm5
ucomisd %xmm4,%xmm5
jae    12cc <astrofuncs_y1lim+0x1bc>
movapd 0xeba(%rip),%xmm2
xorpd  %xmm4,%xmm2
ucomisd %xmm5,%xmm2
jae    12cc <astrofuncs_y1lim+0x1bc>
mulsd  %xmm5,%xmm5
mulsd  %xmm4,%xmm4
subsd  %xmm5,%xmm4
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm4
movsd  %xmm3,0x10(%rsp)
movapd %xmm4,0x20(%rsp)
jb     118f <astrofuncs_y1lim+0x7f>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    11ae <astrofuncs_y1lim+0x9e>
movapd %xmm4,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm5,%xmm5
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
subsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm1
movsd  0xe42(%rip),%xmm2
subsd  %xmm1,%xmm2
ucomisd %xmm5,%xmm2
movsd  %xmm2,0x8(%rsp)
jb     11d7 <astrofuncs_y1lim+0xc7>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    11f2 <astrofuncs_y1lim+0xe2>
movapd %xmm2,%xmm0
movsd  %xmm3,0x18(%rsp)
call   1030 <sqrt@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd 0x20(%rsp),%xmm1
ucomisd %xmm0,%xmm3
jae    1211 <astrofuncs_y1lim+0x101>
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm1
jb     1227 <astrofuncs_y1lim+0x117>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    123a <astrofuncs_y1lim+0x12a>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     1253 <astrofuncs_y1lim+0x143>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
add    $0x38,%rsp
ret
movapd %xmm1,%xmm0
call   1030 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
subsd  %xmm0,%xmm3
ucomisd %xmm4,%xmm2
jb     1260 <astrofuncs_y1lim+0x150>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    127b <astrofuncs_y1lim+0x16b>
movapd %xmm2,%xmm0
add    $0x38,%rsp
jmp    1030 <sqrt@plt>
movapd %xmm2,%xmm0
movsd  %xmm3,0x18(%rsp)
call   1030 <sqrt@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd 0x20(%rsp),%xmm1
xorpd  0xd87(%rip),%xmm0
ucomisd %xmm3,%xmm0
jae    12a2 <astrofuncs_y1lim+0x192>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     12b5 <astrofuncs_y1lim+0x1a5>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    12be <astrofuncs_y1lim+0x1ae>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     12d1 <astrofuncs_y1lim+0x1c1>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    12da <astrofuncs_y1lim+0x1ca>
movapd %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret
movapd %xmm2,%xmm0
call   1030 <sqrt@plt>
xorpd  0xd2e(%rip),%xmm0
add    $0x38,%rsp
ret

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

LLVM IR (-O2):
define double @astrofuncs_y1lim(double %0, double %1, double %2, double %3) {
%5 = fcmp oge double %1, 1.000000e+00
%6 = fcmp ole double %1, -1.000000e+00
%7 = or i1 %5, %6
br i1 %7, label %38, label %8
8: ; preds = %4
%9 = fsub double %1, %2
%10 = fcmp ult double %9, %0
%11 = fneg double %0
%12 = fcmp ugt double %9, %11
%13 = and i1 %10, %12
br i1 %13, label %14, label %38
14: ; preds = %8
%15 = fneg double %9
%16 = fmul double %9, %15
%17 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %16)
%18 = tail call double @sqrt(double %17)
%19 = fsub double %3, %18
%20 = fneg double %1
%21 = tail call double @llvm.fmuladd.f64(double %20, double %1, double 1.000000e+00)
%22 = tail call double @sqrt(double %21)
%23 = fcmp ult double %19, %22
br i1 %23, label %26, label %24
24: ; preds = %14
%25 = tail call double @sqrt(double %21)
br label %38
26: ; preds = %14
%27 = tail call double @sqrt(double %17)
%28 = fsub double %3, %27
%29 = tail call double @sqrt(double %21)
%30 = fneg double %29
%31 = fcmp ugt double %28, %30
br i1 %31, label %35, label %32
32: ; preds = %26
%33 = tail call double @sqrt(double %21)
%34 = fneg double %33
br label %38
35: ; preds = %26
%36 = tail call double @sqrt(double %17)
%37 = fsub double %3, %36
br label %38
38: ; preds = %8, %4, %35, %32, %24
%39 = phi double [ %25, %24 ], [ %34, %32 ], [ %37, %35 ], [ 0.000000e+00, %4 ], [ 0.000000e+00, %8 ]
ret double %39
}