#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 distance_sq(double *, double *);
int in_spheres(int n, double *probe, double probe_radius, double *spheres,
               double *sphere_radii) {
  int i;
  double tmp;
  for (i = n - 1; i >= 0; i--) {
    tmp = (*sphere_radii + probe_radius);
    tmp = distance_sq(spheres, probe) - tmp * tmp;
    if (tmp < -1e-10) {
      return -1;
    }
    spheres += 3;
    sphere_radii++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<in_spheres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     11d4 <in_spheres+0xc4>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <distance_sq@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe69(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11ae <in_spheres+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <in_spheres+0xcb>
mov    -0x20(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1135 <in_spheres+0x25>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_spheres>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,(%rsp)
xor    %r14d,%r14d
test   %edi,%edi
jle    1190 <in_spheres+0x80>
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %edi,%ebx
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
movsd  (%r12),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <distance_sq@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     118a <in_spheres+0x7a>
add    $0x18,%rbp
add    $0x8,%r12
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1140 <in_spheres+0x30>
jmp    1190 <in_spheres+0x80>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @in_spheres(i32 %0, double* %1, double %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double
store i32 %0, i32* %7
store double* %1, double** %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
%14 = load i32, i32* %7
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %12
br label %16
16: ; preds = %39, %5
%17 = load i32, i32* %12
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = load double*, double** %11
%21 = load double, double* %20
%22 = load double, double* %9
%23 = fadd double %21, %22
store double %23, double* %13
%24 = load double*, double** %10
%25 = load double*, double** %8
%26 = call double @distance_sq(double* %24, double* %25)
%27 = load double, double* %13
%28 = load double, double* %13
%29 = fneg double %27
%30 = call double @llvm.fmuladd.f64(double %29, double %28, double %26)
store double %30, double* %13
%31 = load double, double* %13
%32 = fcmp olt double %31, -1.000000e-10
br i1 %32, label %33, label %34
33: ; preds = %19
store i32 -1, i32* %6
br label %43
34: ; preds = %19
%35 = load double*, double** %10
%36 = getelementptr inbounds double, double* %35, i64 3
store double* %36, double** %10
%37 = load double*, double** %11
%38 = getelementptr inbounds double, double* %37, i32 1
store double* %38, double** %11
br label %39
39: ; preds = %34
%40 = load i32, i32* %12
%41 = add nsw i32 %40, -1
store i32 %41, i32* %12
br label %16
42: ; preds = %16
store i32 0, i32* %6
br label %43
43: ; preds = %42, %33
%44 = load i32, i32* %6
ret i32 %44
}

LLVM IR (-O2):
define i32 @in_spheres(i32 %0, double* %1, double %2, double* %3, double* nocapture %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %22
7: ; preds = %5, %17
%8 = phi i32 [ %18, %17 ], [ %0, %5 ]
%9 = phi double* [ %20, %17 ], [ %4, %5 ]
%10 = phi double* [ %19, %17 ], [ %3, %5 ]
%11 = load double, double* %9
%12 = fadd double %11, %2
%13 = tail call double @distance_sq(double* %10, double* %1)
%14 = fneg double %12
%15 = tail call double @llvm.fmuladd.f64(double %14, double %12, double %13)
%16 = fcmp olt double %15, -1.000000e-10
br i1 %16, label %22, label %17
17: ; preds = %7
%18 = add nsw i32 %8, -1
%19 = getelementptr inbounds double, double* %10, i64 3
%20 = getelementptr inbounds double, double* %9, i64 1
%21 = icmp sgt i32 %8, 1
br i1 %21, label %7, label %22
22: ; preds = %7, %17, %5
%23 = phi i32 [ 0, %5 ], [ 0, %17 ], [ -1, %7 ]
ret i32 %23
}