#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__ powf(float, int);
float sqrtf(float);
float euclideanDistance(int size, float *v1, float *v2) {
  float distance = 0.0f;
  for (int i = 0; i < size; i++)
    distance += powf(v2[i] - v1[i], 2);
  return sqrtf(distance);
}


x86 assembly (clang, -O0):
<euclideanDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118f <euclideanDistance+0x6f>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
cvtsi2ss %rax,%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1142 <euclideanDistance+0x22>
movss  -0x1c(%rbp),%xmm0
call   1040 <sqrtf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euclideanDistance>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
test   %edi,%edi
jle    11f9 <euclideanDistance+0xd9>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%r15d
cmp    $0x1,%edi
jne    1150 <euclideanDistance+0x30>
xorps  %xmm1,%xmm1
xor    %ebx,%ebx
jmp    11bf <euclideanDistance+0x9f>
mov    %r15d,%r13d
and    $0xfffffffe,%r13d
xorps  %xmm1,%xmm1
xor    %ebx,%ebx
nopl   0x0(%rax)
movss  %xmm1,0xc(%rsp)
movss  (%r12,%rbx,4),%xmm0
subss  (%r14,%rbx,4),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x4(%r12,%rbx,4),%xmm0
subss  0x4(%r14,%rbx,4),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
addss  0xc(%rsp),%xmm1
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1160 <euclideanDistance+0x40>
test   $0x1,%r15b
xorps  %xmm0,%xmm0
je     11f9 <euclideanDistance+0xd9>
movss  (%r12,%rbx,4),%xmm0
subss  (%r14,%rbx,4),%xmm0
mov    $0x2,%edi
movss  %xmm1,0xc(%rsp)
call   1030 <powf@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jb     1213 <euclideanDistance+0xf3>
xorps  %xmm0,%xmm0
sqrtss %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <sqrtf@plt>

LLVM IR (-O0):
define float @euclideanDistance(i32 %0, float* %1, float* %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca float*
%7 = alloca float
%8 = alloca i32
store i32 %0, i32* %4
store float* %1, float** %5
store float* %2, float** %6
store float 0.000000e+00, float* %7
store i32 0, i32* %8
br label %9
9: ; preds = %29, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load float*, float** %6
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %14, i64 %16
%18 = load float, float* %17
%19 = load float*, float** %5
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
%23 = load float, float* %22
%24 = fsub float %18, %23
%25 = call i64 @powf(float %24, i32 2)
%26 = sitofp i64 %25 to float
%27 = load float, float* %7
%28 = fadd float %27, %26
store float %28, float* %7
br label %29
29: ; preds = %13
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %9
32: ; preds = %9
%33 = load float, float* %7
%34 = call float @sqrtf(float %33)
ret float %34
}

LLVM IR (-O2):
define float @euclideanDistance(i32 %0, float* nocapture %1, float* nocapture %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %25
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %0, 1
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %28
11: ; preds = %28, %5
%12 = phi float [ undef, %5 ], [ %48, %28 ]
%13 = phi i64 [ 0, %5 ], [ %49, %28 ]
%14 = phi float [ 0.000000e+00, %5 ], [ %48, %28 ]
%15 = icmp eq i64 %7, 0
br i1 %15, label %25, label %16
16: ; preds = %11
%17 = getelementptr inbounds float, float* %2, i64 %13
%18 = load float, float* %17
%19 = getelementptr inbounds float, float* %1, i64 %13
%20 = load float, float* %19
%21 = fsub float %18, %20
%22 = tail call i64 @powf(float %21, i32 2)
%23 = sitofp i64 %22 to float
%24 = fadd float %14, %23
br label %25
25: ; preds = %16, %11, %3
%26 = phi float [ 0.000000e+00, %3 ], [ %12, %11 ], [ %24, %16 ]
%27 = tail call float @sqrtf(float %26)
ret float %27
28: ; preds = %28, %9
%29 = phi i64 [ 0, %9 ], [ %49, %28 ]
%30 = phi float [ 0.000000e+00, %9 ], [ %48, %28 ]
%31 = phi i64 [ 0, %9 ], [ %50, %28 ]
%32 = getelementptr inbounds float, float* %2, i64 %29
%33 = load float, float* %32
%34 = getelementptr inbounds float, float* %1, i64 %29
%35 = load float, float* %34
%36 = fsub float %33, %35
%37 = tail call i64 @powf(float %36, i32 2)
%38 = sitofp i64 %37 to float
%39 = fadd float %30, %38
%40 = or i64 %29, 1
%41 = getelementptr inbounds float, float* %2, i64 %40
%42 = load float, float* %41
%43 = getelementptr inbounds float, float* %1, i64 %40
%44 = load float, float* %43
%45 = fsub float %42, %44
%46 = tail call i64 @powf(float %45, i32 2)
%47 = sitofp i64 %46 to float
%48 = fadd float %39, %47
%49 = add nuw nsw i64 %29, 2
%50 = add i64 %31, 2
%51 = icmp eq i64 %50, %10
br i1 %51, label %11, label %28
}