#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 pow(double const, int);
double sqrt(double);
double grid_box_radius(const double *x, const double *y, const double *z,
                       int n) {
  double radius;
  int i, j;
  radius = 0;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      radius = (radius > pow(x[i] - x[j], 2.) + pow(y[i] - y[j], 2.) +
                             pow(z[i] - z[j], 2.)
                    ? radius
                    : pow(x[i] - x[j], 2.) + pow(y[i] - y[j], 2.) +
                          pow(z[i] - z[j], 2.));
    }
  }
  radius = sqrt(radius);
  return (radius);
}


x86 assembly (clang, -O0):
<grid_box_radius>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12e0 <grid_box_radius+0x1c0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12cd <grid_box_radius+0x1ad>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1222 <grid_box_radius+0x102>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12b5 <grid_box_radius+0x195>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1160 <grid_box_radius+0x40>
jmp    12d2 <grid_box_radius+0x1b2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1146 <grid_box_radius+0x26>
movsd  -0x28(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_box_radius>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
xorpd  %xmm0,%xmm0
cmp    $0x2,%ecx
jl     12bc <grid_box_radius+0x19c>
mov    %rcx,%rax
mov    %eax,%ebp
add    $0xffffffff,%eax
mov    %rax,0x38(%rsp)
xorpd  %xmm0,%xmm0
xor    %r14d,%r14d
mov    %rbp,0x30(%rsp)
mov    0x10(%rsp),%rbx
mov    0x18(%rsp),%r12
mov    0x20(%rsp),%r15
jmp    11a0 <grid_box_radius+0x80>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x8,%r15
add    $0x8,%r12
add    $0x8,%rbx
add    $0xffffffffffffffff,%rbp
mov    0x40(%rsp),%r14
cmp    0x38(%rsp),%r14
je     12bc <grid_box_radius+0x19c>
lea    0x1(%r14),%rax
cmp    0x30(%rsp),%rax
mov    %rax,0x40(%rsp)
jae    1180 <grid_box_radius+0x60>
mov    $0x1,%r13d
jmp    11c9 <grid_box_radius+0xa9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%rbp
je     1180 <grid_box_radius+0x60>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%rbx,%r13,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x18(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%r12,%r13,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    0x20(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%r15,%r13,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0x28(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
ja     11c0 <grid_box_radius+0xa0>
mov    0x10(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%rbx,%r13,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%r12,%r13,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x20(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%r15,%r13,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0x8(%rsp),%xmm0
jmp    11c0 <grid_box_radius+0xa0>
ucomisd 0xd3c(%rip),%xmm0
jb     12d9 <grid_box_radius+0x1b9>
sqrtsd %xmm0,%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @grid_box_radius(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %12
12: ; preds = %112, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %8
%15 = sub nsw i32 %14, 1
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %115
17: ; preds = %12
%18 = load i32, i32* %10
%19 = add nsw i32 %18, 1
store i32 %19, i32* %11
br label %20
20: ; preds = %108, %17
%21 = load i32, i32* %11
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %111
24: ; preds = %20
%25 = load double, double* %9
%26 = load double*, double** %5
%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** %5
%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
%37 = call double @pow(double %36, i32 2)
%38 = load double*, double** %6
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %6
%44 = load i32, i32* %11
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fsub double %42, %47
%49 = call double @pow(double %48, i32 2)
%50 = fadd double %37, %49
%51 = load double*, double** %7
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double*, double** %7
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = fsub double %55, %60
%62 = call double @pow(double %61, i32 2)
%63 = fadd double %50, %62
%64 = fcmp ogt double %25, %63
br i1 %64, label %65, label %67
65: ; preds = %24
%66 = load double, double* %9
br label %106
67: ; preds = %24
%68 = load double*, double** %5
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = load double*, double** %5
%74 = load i32, i32* %11
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fsub double %72, %77
%79 = call double @pow(double %78, i32 2)
%80 = load double*, double** %6
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = load double*, double** %6
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %85, i64 %87
%89 = load double, double* %88
%90 = fsub double %84, %89
%91 = call double @pow(double %90, i32 2)
%92 = fadd double %79, %91
%93 = load double*, double** %7
%94 = load i32, i32* %10
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = load double*, double** %7
%99 = load i32, i32* %11
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = load double, double* %101
%103 = fsub double %97, %102
%104 = call double @pow(double %103, i32 2)
%105 = fadd double %92, %104
br label %106
106: ; preds = %67, %65
%107 = phi double [ %66, %65 ], [ %105, %67 ]
store double %107, double* %9
br label %108
108: ; preds = %106
%109 = load i32, i32* %11
%110 = add nsw i32 %109, 1
store i32 %110, i32* %11
br label %20
111: ; preds = %20
br label %112
112: ; preds = %111
%113 = load i32, i32* %10
%114 = add nsw i32 %113, 1
store i32 %114, i32* %10
br label %12
115: ; preds = %12
%116 = load double, double* %9
%117 = call double @sqrt(double %116)
store double %117, double* %9
%118 = load double, double* %9
ret double %118
}

LLVM IR (-O2):
define double @grid_box_radius(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 1
br i1 %5, label %6, label %65
6: ; preds = %4
%7 = add nsw i32 %3, -1
%8 = zext i32 %3 to i64
%9 = zext i32 %7 to i64
%10 = zext i32 %3 to i64
br label %15
11: ; preds = %61, %15
%12 = phi double [ %18, %15 ], [ %62, %61 ]
%13 = add nuw nsw i64 %17, 1
%14 = icmp eq i64 %19, %9
br i1 %14, label %65, label %15
15: ; preds = %6, %11
%16 = phi i64 [ 0, %6 ], [ %19, %11 ]
%17 = phi i64 [ 1, %6 ], [ %13, %11 ]
%18 = phi double [ 0.000000e+00, %6 ], [ %12, %11 ]
%19 = add nuw nsw i64 %16, 1
%20 = icmp ult i64 %19, %8
br i1 %20, label %21, label %11
21: ; preds = %15
%22 = getelementptr inbounds double, double* %0, i64 %16
%23 = getelementptr inbounds double, double* %1, i64 %16
%24 = getelementptr inbounds double, double* %2, i64 %16
br label %25
25: ; preds = %21, %61
%26 = phi i64 [ %17, %21 ], [ %63, %61 ]
%27 = phi double [ %18, %21 ], [ %62, %61 ]
%28 = load double, double* %22
%29 = getelementptr inbounds double, double* %0, i64 %26
%30 = load double, double* %29
%31 = fsub double %28, %30
%32 = tail call double @pow(double %31, i32 2)
%33 = load double, double* %23
%34 = getelementptr inbounds double, double* %1, i64 %26
%35 = load double, double* %34
%36 = fsub double %33, %35
%37 = tail call double @pow(double %36, i32 2)
%38 = fadd double %32, %37
%39 = load double, double* %24
%40 = getelementptr inbounds double, double* %2, i64 %26
%41 = load double, double* %40
%42 = fsub double %39, %41
%43 = tail call double @pow(double %42, i32 2)
%44 = fadd double %38, %43
%45 = fcmp ogt double %27, %44
br i1 %45, label %61, label %46
46: ; preds = %25
%47 = load double, double* %22
%48 = load double, double* %29
%49 = fsub double %47, %48
%50 = tail call double @pow(double %49, i32 2)
%51 = load double, double* %23
%52 = load double, double* %34
%53 = fsub double %51, %52
%54 = tail call double @pow(double %53, i32 2)
%55 = fadd double %50, %54
%56 = load double, double* %24
%57 = load double, double* %40
%58 = fsub double %56, %57
%59 = tail call double @pow(double %58, i32 2)
%60 = fadd double %55, %59
br label %61
61: ; preds = %25, %46
%62 = phi double [ %60, %46 ], [ %27, %25 ]
%63 = add nuw nsw i64 %26, 1
%64 = icmp eq i64 %63, %10
br i1 %64, label %11, label %25
65: ; preds = %11, %4
%66 = phi double [ 0.000000e+00, %4 ], [ %12, %11 ]
%67 = tail call double @sqrt(double %66)
ret double %67
}