#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);
int circlestarintersection(double r, double dcen, double rcir, double v[2],
                           double w[2]) {
  w[0] = (r * r - dcen * dcen - rcir * rcir) / (2.0 * dcen);
  if (w[0] >= rcir || w[0] <= (-rcir))
    return 0;
  v[0] = sqrt(rcir * rcir - w[0] * w[0]);
  return 1;
}


x86 assembly (clang, -O0):
<circlestarintersection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    11e5 <circlestarintersection+0xd5>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jb     11f1 <circlestarintersection+0xe1>
movl   $0x0,-0x4(%rbp)
jmp    123e <circlestarintersection+0x12e>
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circlestarintersection>:
push   %rbx
movapd %xmm0,%xmm3
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm0,%xmm3
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm3
movsd  %xmm3,(%rsi)
xor    %eax,%eax
ucomisd %xmm2,%xmm3
jae    117c <circlestarintersection+0x6c>
xorpd  0xeb3(%rip),%xmm2
ucomisd %xmm3,%xmm2
jae    117c <circlestarintersection+0x6c>
mov    %rdi,%rbx
mulsd  %xmm3,%xmm3
subsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116e <circlestarintersection+0x5e>
sqrtsd %xmm0,%xmm0
jmp    1173 <circlestarintersection+0x63>
call   1030 <sqrt@plt>
movsd  %xmm0,(%rbx)
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @circlestarintersection(double %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
%12 = load double, double* %7
%13 = load double, double* %7
%14 = load double, double* %8
%15 = load double, double* %8
%16 = fmul double %14, %15
%17 = fneg double %16
%18 = call double @llvm.fmuladd.f64(double %12, double %13, double %17)
%19 = load double, double* %9
%20 = load double, double* %9
%21 = fneg double %19
%22 = call double @llvm.fmuladd.f64(double %21, double %20, double %18)
%23 = load double, double* %8
%24 = fmul double 2.000000e+00, %23
%25 = fdiv double %22, %24
%26 = load double*, double** %11
%27 = getelementptr inbounds double, double* %26, i64 0
store double %25, double* %27
%28 = load double*, double** %11
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = load double, double* %9
%32 = fcmp oge double %30, %31
br i1 %32, label %40, label %33
33: ; preds = %5
%34 = load double*, double** %11
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = load double, double* %9
%38 = fneg double %37
%39 = fcmp ole double %36, %38
br i1 %39, label %40, label %41
40: ; preds = %33, %5
store i32 0, i32* %6
br label %56
41: ; preds = %33
%42 = load double, double* %9
%43 = load double, double* %9
%44 = load double*, double** %11
%45 = getelementptr inbounds double, double* %44, i64 0
%46 = load double, double* %45
%47 = load double*, double** %11
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = fmul double %46, %49
%51 = fneg double %50
%52 = call double @llvm.fmuladd.f64(double %42, double %43, double %51)
%53 = call double @sqrt(double %52)
%54 = load double*, double** %10
%55 = getelementptr inbounds double, double* %54, i64 0
store double %53, double* %55
store i32 1, i32* %6
br label %56
56: ; preds = %41, %40
%57 = load i32, i32* %6
ret i32 %57
}

LLVM IR (-O2):
define i32 @circlestarintersection(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = fneg double %1
%7 = fmul double %6, %1
%8 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %7)
%9 = fneg double %2
%10 = tail call double @llvm.fmuladd.f64(double %9, double %2, double %8)
%11 = fmul double %1, 2.000000e+00
%12 = fdiv double %10, %11
store double %12, double* %4
%13 = fcmp ult double %12, %2
%14 = fcmp ugt double %12, %9
%15 = and i1 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %5
%17 = fneg double %12
%18 = fmul double %12, %17
%19 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %18)
%20 = tail call double @sqrt(double %19)
store double %20, double* %3
br label %21
21: ; preds = %5, %16
%22 = phi i32 [ 1, %16 ], [ 0, %5 ]
ret i32 %22
}