#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 */
scalar_t__ pow(double const, int);
double sqrt(double);
double normalised_euclidean_distance(const double *a, const double *b,
                                     const double *f_max, const double *f_min,
                                     int dimension) {
  int i;
  double distance;
  distance = 0.0;
  for (i = 0; i < dimension; i++)
    distance += pow((a[i] - b[i]) / (f_max[i] - f_min[i]), 2);
  return sqrt(distance);
}


x86 assembly (clang, -O0):
<normalised_euclidean_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b6 <normalised_euclidean_distance+0x96>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114b <normalised_euclidean_distance+0x2b>
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalised_euclidean_distance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xorpd  %xmm0,%xmm0
test   %r8d,%r8d
jle    11a0 <normalised_euclidean_distance+0x80>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    %r8d,%ebx
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movsd  0x0(%r13,%rbp,8),%xmm0
subsd  (%r12,%rbp,8),%xmm0
movsd  (%r15,%rbp,8),%xmm1
subsd  (%r14,%rbp,8),%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <normalised_euclidean_distance+0x30>
ucomisd 0xe58(%rip),%xmm0
jb     11bd <normalised_euclidean_distance+0x9d>
sqrtsd %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @normalised_euclidean_distance(double* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
store double 0.000000e+00, double* %12
store i32 0, i32* %11
br label %13
13: ; preds = %45, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %10
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %48
17: ; preds = %13
%18 = load double*, double** %6
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %7
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fsub double %22, %27
%29 = load double*, double** %8
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %9
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %33, %38
%40 = fdiv double %28, %39
%41 = call i64 @pow(double %40, i32 2)
%42 = sitofp i64 %41 to double
%43 = load double, double* %12
%44 = fadd double %43, %42
store double %44, double* %12
br label %45
45: ; preds = %17
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %13
48: ; preds = %13
%49 = load double, double* %12
%50 = call double @sqrt(double %49)
ret double %50
}

LLVM IR (-O2):
define double @normalised_euclidean_distance(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %28
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %26, %9 ]
%11 = phi double [ 0.000000e+00, %7 ], [ %25, %9 ]
%12 = getelementptr inbounds double, double* %0, i64 %10
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %1, i64 %10
%15 = load double, double* %14
%16 = fsub double %13, %15
%17 = getelementptr inbounds double, double* %2, i64 %10
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %3, i64 %10
%20 = load double, double* %19
%21 = fsub double %18, %20
%22 = fdiv double %16, %21
%23 = tail call i64 @pow(double %22, i32 2)
%24 = sitofp i64 %23 to double
%25 = fadd double %11, %24
%26 = add nuw nsw i64 %10, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %9
28: ; preds = %9, %5
%29 = phi double [ 0.000000e+00, %5 ], [ %25, %9 ]
%30 = tail call double @sqrt(double %29)
ret double %30
}