#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 */
int sqrt(double);
int cor2(int r, double *x, double *y, int n) {
  int result = 0;
  int i, j;
  double dx, dy;
  i = n;
  while (i-- > 0) {
    j = i;
    while (j-- > 0) {
      dx = (x[i] - x[j]);
      dy = (y[i] - y[j]);
      if (r > sqrt(dx * dx + dy * dy)) {
        result++;
      }
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<cor2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
jle    11e6 <cor2+0xd6>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x28(%rbp)
cmp    $0x0,%eax
jle    11e1 <cor2+0xd1>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jle    11dc <cor2+0xcc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114d <cor2+0x3d>
jmp    1133 <cor2+0x23>
mov    -0x20(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cor2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %ecx,%ecx
jle    11f1 <cor2+0xe1>
mov    %ecx,%r12d
mov    %rsi,%r14
mov    %edi,%r13d
lea    -0x2(%r12),%eax
mov    %ecx,%ebx
add    $0xffffffff,%r12d
xor    %ebp,%ebp
nopl   0x0(%rax)
cmp    $0x2,%rbx
jb     11f3 <cor2+0xe3>
mov    %eax,0x4(%rsp)
mov    %eax,%r8d
lea    (%rdx,%r8,8),%rax
mov    %rax,0x20(%rsp)
lea    (%r14,%r8,8),%rax
mov    %rax,0x18(%rsp)
mov    %rbx,0x10(%rsp)
lea    -0x1(%rbx),%rax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rax
movsd  (%r14,%rax,8),%xmm0
mov    0x18(%rsp),%rbx
subsd  (%rbx,%r15,8),%xmm0
movsd  (%rdx,%rax,8),%xmm1
mov    0x20(%rsp),%rax
subsd  (%rax,%r15,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    %rdx,%rbx
call   1030 <sqrt@plt>
mov    %rbx,%rdx
xor    %ecx,%ecx
cmp    %r13d,%eax
setl   %cl
add    %ecx,%ebp
add    $0xffffffffffffffff,%r15
lea    (%r15,%r12,1),%eax
test   %eax,%eax
jg     1180 <cor2+0x70>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
add    $0xffffffffffffffff,%r12
cmpq   $0x2,0x10(%rsp)
mov    0x8(%rsp),%rbx
jae    1140 <cor2+0x30>
jmp    11f3 <cor2+0xe3>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cor2(i32 %0, double* %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
%14 = load i32, i32* %8
store i32 %14, i32* %10
br label %15
15: ; preds = %61, %4
%16 = load i32, i32* %10
%17 = add nsw i32 %16, -1
store i32 %17, i32* %10
%18 = icmp sgt i32 %16, 0
br i1 %18, label %19, label %62
19: ; preds = %15
%20 = load i32, i32* %10
store i32 %20, i32* %11
br label %21
21: ; preds = %60, %19
%22 = load i32, i32* %11
%23 = add nsw i32 %22, -1
store i32 %23, i32* %11
%24 = icmp sgt i32 %22, 0
br i1 %24, label %25, label %61
25: ; preds = %21
%26 = load double*, double** %6
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %6
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = fsub double %30, %35
store double %36, double* %12
%37 = load double*, double** %7
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = load double*, double** %7
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = fsub double %41, %46
store double %47, double* %13
%48 = load i32, i32* %5
%49 = load double, double* %12
%50 = load double, double* %12
%51 = load double, double* %13
%52 = load double, double* %13
%53 = fmul double %51, %52
%54 = call double @llvm.fmuladd.f64(double %49, double %50, double %53)
%55 = call i32 @sqrt(double %54)
%56 = icmp sgt i32 %48, %55
br i1 %56, label %57, label %60
57: ; preds = %25
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %60
60: ; preds = %57, %25
br label %21
61: ; preds = %21
br label %15
62: ; preds = %15
%63 = load i32, i32* %9
ret i32 %63
}

LLVM IR (-O2):
define i32 @cor2(i32 %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %41
6: ; preds = %4
%7 = add nsw i32 %3, -2
%8 = zext i32 %3 to i64
br label %11
9: ; preds = %21
%10 = add i32 %13, -1
br i1 %16, label %11, label %41
11: ; preds = %6, %9
%12 = phi i64 [ %8, %6 ], [ %15, %9 ]
%13 = phi i32 [ %7, %6 ], [ %10, %9 ]
%14 = phi i32 [ 0, %6 ], [ %37, %9 ]
%15 = add nsw i64 %12, -1
%16 = icmp ugt i64 %12, 1
br i1 %16, label %17, label %41
17: ; preds = %11
%18 = zext i32 %13 to i64
%19 = getelementptr inbounds double, double* %1, i64 %15
%20 = getelementptr inbounds double, double* %2, i64 %15
br label %21
21: ; preds = %17, %21
%22 = phi i64 [ %18, %17 ], [ %38, %21 ]
%23 = phi i32 [ %14, %17 ], [ %37, %21 ]
%24 = load double, double* %19
%25 = getelementptr inbounds double, double* %1, i64 %22
%26 = load double, double* %25
%27 = fsub double %24, %26
%28 = load double, double* %20
%29 = getelementptr inbounds double, double* %2, i64 %22
%30 = load double, double* %29
%31 = fsub double %28, %30
%32 = fmul double %31, %31
%33 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %32)
%34 = tail call i32 @sqrt(double %33)
%35 = icmp slt i32 %34, %0
%36 = zext i1 %35 to i32
%37 = add nsw i32 %23, %36
%38 = add nsw i64 %22, -1
%39 = trunc i64 %22 to i32
%40 = icmp sgt i32 %39, 0
br i1 %40, label %21, label %9
41: ; preds = %9, %11, %4
%42 = phi i32 [ 0, %4 ], [ %14, %11 ], [ %37, %9 ]
ret i32 %42
}