#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 /*<<< orphan*/ dist0(int, double, double, double, double *, double *,
                         double *, int *);
int /*<<< orphan*/ printf(char *, double, double, double, double);
double rad(double, double, double);
void dist(int n, double *x, double *y, double *z, double *x0, double *y0,
          double *z0) {
  int i, j;
  double d;
  double dx, dy, dz;
  for (i = 0; i < n; i++) {
    dist0(n, x[i], y[i], z[i], x0, y0, z0, &j);
    dx = x[i] - x0[j];
    dy = y[i] - y0[j];
    dz = z[i] - z0[j];
    d = rad(dx, dy, dz);
    printf("%16.10e %16.10e %16.10e %16.10e\n", x[i], y[i], z[i], d);
  }
}


x86 assembly (clang, -O0):
<dist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1261 <dist+0x131>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    0x10(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1040 <dist0@plt>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
call   1050 <rad@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x40(%rbp),%xmm3
lea    0xdb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115a <dist+0x2a>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,(%rsp)
test   %edi,%edi
jle    120a <dist+0xda>
mov    %r9,%r15
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    (%rsp),%eax
mov    %rax,0x10(%rsp)
xor    %ebp,%ebp
mov    %r8,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r12,%rbp,8),%xmm0
movsd  (%r14,%rbp,8),%xmm1
movsd  (%rbx,%rbp,8),%xmm2
mov    (%rsp),%edi
mov    %r8,%rsi
mov    %r15,%rdx
mov    %r14,%r13
mov    0x50(%rsp),%r14
mov    %r14,%rcx
lea    0x4(%rsp),%r8
call   1040 <dist0@plt>
movsd  (%r12,%rbp,8),%xmm0
movslq 0x4(%rsp),%rax
mov    0x8(%rsp),%rcx
subsd  (%rcx,%rax,8),%xmm0
movsd  0x0(%r13,%rbp,8),%xmm1
subsd  (%r15,%rax,8),%xmm1
movsd  (%rbx,%rbp,8),%xmm2
subsd  (%r14,%rax,8),%xmm2
mov    %r13,%r14
call   1050 <rad@plt>
movapd %xmm0,%xmm3
movsd  (%r12,%rbp,8),%xmm0
movsd  0x0(%r13,%rbp,8),%xmm1
movsd  (%rbx,%rbp,8),%xmm2
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%r8
add    $0x1,%rbp
cmp    %rbp,0x10(%rsp)
jne    1170 <dist+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"%16.10e %16.10e %16.10e %16.10e\0A\00"
define void @dist(i32 %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store i32 %0, i32* %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
store i32 0, i32* %15
br label %21
21: ; preds = %100, %7
%22 = load i32, i32* %15
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %103
25: ; preds = %21
%26 = load i32, i32* %8
%27 = load double*, double** %9
%28 = load i32, i32* %15
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %10
%33 = load i32, i32* %15
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %11
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = load double*, double** %12
%43 = load double*, double** %13
%44 = load double*, double** %14
%45 = call i32 @dist0(i32 %26, double %31, double %36, double %41, double* %42, double* %43, double* %44, i32* %16)
%46 = load double*, double** %9
%47 = load i32, i32* %15
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = load double, double* %49
%51 = load double*, double** %12
%52 = load i32, i32* %16
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fsub double %50, %55
store double %56, double* %18
%57 = load double*, double** %10
%58 = load i32, i32* %15
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = load double*, double** %13
%63 = load i32, i32* %16
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = fsub double %61, %66
store double %67, double* %19
%68 = load double*, double** %11
%69 = load i32, i32* %15
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = load double*, double** %14
%74 = load i32, i32* %16
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fsub double %72, %77
store double %78, double* %20
%79 = load double, double* %18
%80 = load double, double* %19
%81 = load double, double* %20
%82 = call double @rad(double %79, double %80, double %81)
store double %82, double* %17
%83 = load double*, double** %9
%84 = load i32, i32* %15
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
%87 = load double, double* %86
%88 = load double*, double** %10
%89 = load i32, i32* %15
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %11
%94 = load i32, i32* %15
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = load double, double* %17
%99 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %87, double %92, double %97, double %98)
br label %100
100: ; preds = %25
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
store i32 %102, i32* %15
br label %21
103: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"%16.10e %16.10e %16.10e %16.10e\0A\00"
define void @dist(i32 %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %43
11: ; preds = %7
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %41, %13 ]
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %2, i64 %14
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %3, i64 %14
%20 = load double, double* %19
%21 = call i32 @dist0(i32 %0, double %16, double %18, double %20, double* %4, double* %5, double* %6, i32* %8)
%22 = load double, double* %15
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %4, i64 %24
%26 = load double, double* %25
%27 = fsub double %22, %26
%28 = load double, double* %17
%29 = getelementptr inbounds double, double* %5, i64 %24
%30 = load double, double* %29
%31 = fsub double %28, %30
%32 = load double, double* %19
%33 = getelementptr inbounds double, double* %6, i64 %24
%34 = load double, double* %33
%35 = fsub double %32, %34
%36 = call double @rad(double %27, double %31, double %35)
%37 = load double, double* %15
%38 = load double, double* %17
%39 = load double, double* %19
%40 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %37, double %38, double %39, double %36)
%41 = add nuw nsw i64 %14, 1
%42 = icmp eq i64 %41, %12
br i1 %42, label %43, label %13
43: ; preds = %13, %7
ret void
}