#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 DBL_EPSILON;
double sqrt(double);
void Positive2A(double u, double v, double a, double height, double *xc,
                double *p0, double *q0) {
  double y0, m0, xcap, ycap;
  double d, p, q;
  d = 1.0 - a * a;
  if (d < DBL_EPSILON)
    d = DBL_EPSILON;
  y0 = 0.5 * v * v;
  m0 = -(u + a * v);
  if (m0 <= 0.0) {
    xcap = 0.0;
    ycap = height + y0;
    p = 0.0;
    q = m0 - sqrt(2.0 * d * height);
  } else {
    xcap = m0 / d;
    ycap = height + 0.5 * (m0 * xcap + v * v);
    if (ycap - y0 <= m0 * xcap)
      p = sqrt(2.0 * d * height);
    else
      p = (ycap - y0) / xcap;
    q = -sqrt(2.0 * d * height);
  }
  *xc = xcap;
  *p0 = p;
  *q0 = q;
}


x86 assembly (clang, -O0):
<Positive2A>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%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  0xe98(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
mov    0x2e6b(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    119b <Positive2A+0x8b>
mov    0x2e56(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe65(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     1249 <Positive2A+0x139>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xdec(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    1314 <Positive2A+0x204>
movsd  -0x48(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm2
mulsd  -0x10(%rbp),%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  0xd87(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12cd <Positive2A+0x1bd>
movsd  0xd5c(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
jmp    12e1 <Positive2A+0x1d1>
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xd27(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Positive2A>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movapd %xmm2,%xmm5
mulsd  %xmm2,%xmm5
movsd  0xece(%rip),%xmm4
subsd  %xmm5,%xmm4
mov    0x2eab(%rip),%rax
movsd  (%rax),%xmm5
maxsd  %xmm4,%xmm5
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movapd 0xebb(%rip),%xmm6
xorpd  %xmm2,%xmm6
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jae    11ab <Positive2A+0x9b>
movsd  0xe9d(%rip),%xmm0
movapd %xmm1,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm6,%xmm4
divsd  %xmm5,%xmm4
mulsd  %xmm1,%xmm1
mulsd  %xmm4,%xmm6
addsd  %xmm6,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm6
jae    11c2 <Positive2A+0xb2>
divsd  %xmm4,%xmm1
addsd  %xmm5,%xmm5
mulsd  %xmm3,%xmm5
jmp    1225 <Positive2A+0x115>
addsd  %xmm5,%xmm5
mulsd  %xmm3,%xmm5
ucomisd %xmm0,%xmm5
jb     11dd <Positive2A+0xcd>
xorps  %xmm0,%xmm0
sqrtsd %xmm5,%xmm0
jmp    11f2 <Positive2A+0xe2>
addsd  %xmm5,%xmm5
mulsd  %xmm3,%xmm5
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm5
jb     1200 <Positive2A+0xf0>
xorps  %xmm1,%xmm1
sqrtsd %xmm5,%xmm1
jmp    1225 <Positive2A+0x115>
movapd %xmm5,%xmm0
movapd %xmm6,0x10(%rsp)
call   1030 <sqrt@plt>
movapd 0x10(%rsp),%xmm6
subsd  %xmm0,%xmm6
xorpd  %xmm4,%xmm4
xorpd  %xmm1,%xmm1
jmp    1265 <Positive2A+0x155>
movapd %xmm5,%xmm0
movsd  %xmm5,0x8(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1030 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm5
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm5
jb     1238 <Positive2A+0x128>
xorps  %xmm6,%xmm6
sqrtsd %xmm5,%xmm6
jmp    125d <Positive2A+0x14d>
movapd %xmm5,%xmm0
movsd  %xmm1,0x8(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1030 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm6
xorpd  0xdab(%rip),%xmm6
movsd  %xmm4,(%rbx)
movsd  %xmm1,(%r15)
movsd  %xmm6,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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