#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 squaredDistance(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 distance;
}


x86 assembly (clang, -O0):
<squaredDistance>:
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    117f <squaredDistance+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    1132 <squaredDistance+0x22>
movss  -0x1c(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squaredDistance>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1136 <squaredDistance+0x26>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%r15d
cmp    $0x1,%edi
jne    113e <squaredDistance+0x2e>
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11af <squaredDistance+0x9f>
xorps  %xmm0,%xmm0
jmp    11ef <squaredDistance+0xdf>
mov    %r15d,%r13d
and    $0xfffffffe,%r13d
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movss  %xmm0,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  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1150 <squaredDistance+0x40>
test   $0x1,%r15b
je     11ef <squaredDistance+0xdf>
movss  %xmm0,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
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @squaredDistance(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
ret float %33
}

LLVM IR (-O2):
define float @squaredDistance(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 %27
11: ; preds = %27, %5
%12 = phi float [ undef, %5 ], [ %47, %27 ]
%13 = phi i64 [ 0, %5 ], [ %48, %27 ]
%14 = phi float [ 0.000000e+00, %5 ], [ %47, %27 ]
%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 ]
ret float %26
27: ; preds = %27, %9
%28 = phi i64 [ 0, %9 ], [ %48, %27 ]
%29 = phi float [ 0.000000e+00, %9 ], [ %47, %27 ]
%30 = phi i64 [ 0, %9 ], [ %49, %27 ]
%31 = getelementptr inbounds float, float* %2, i64 %28
%32 = load float, float* %31
%33 = getelementptr inbounds float, float* %1, i64 %28
%34 = load float, float* %33
%35 = fsub float %32, %34
%36 = tail call i64 @powf(float %35, i32 2)
%37 = sitofp i64 %36 to float
%38 = fadd float %29, %37
%39 = or i64 %28, 1
%40 = getelementptr inbounds float, float* %2, i64 %39
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %1, i64 %39
%43 = load float, float* %42
%44 = fsub float %41, %43
%45 = tail call i64 @powf(float %44, i32 2)
%46 = sitofp i64 %45 to float
%47 = fadd float %38, %46
%48 = add nuw nsw i64 %28, 2
%49 = add i64 %30, 2
%50 = icmp eq i64 %49, %10
br i1 %50, label %11, label %27
}