#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 */
float floatsumsquared(float *in, size_t size) {
  float *pt, *fpt;
  double sum = 0;
  fpt = in + size;
  for (pt = in; pt < fpt; pt++)
    sum += *pt * *pt;
  return sum;
}


x86 assembly (clang, -O0):
<floatsumsquared>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    116c <floatsumsquared+0x6c>
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mulss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <floatsumsquared+0x2f>
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<floatsumsquared>:
test   %rsi,%rsi
jle    112e <floatsumsquared+0x2e>
lea    (%rdi,%rsi,4),%rax
xorpd  %xmm0,%xmm0
nopl   (%rax)
movss  (%rdi),%xmm1
mulss  %xmm1,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x4,%rdi
cmp    %rax,%rdi
jb     1110 <floatsumsquared+0x10>
cvtsd2ss %xmm0,%xmm0
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @floatsumsquared(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca float*
%6 = alloca float*
%7 = alloca double
store float* %0, float** %3
store i64 %1, i64* %4
store double 0.000000e+00, double* %7
%8 = load float*, float** %3
%9 = load i64, i64* %4
%10 = getelementptr inbounds float, float* %8, i64 %9
store float* %10, float** %6
%11 = load float*, float** %3
store float* %11, float** %5
br label %12
12: ; preds = %25, %2
%13 = load float*, float** %5
%14 = load float*, float** %6
%15 = icmp ult float* %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load float*, float** %5
%18 = load float, float* %17
%19 = load float*, float** %5
%20 = load float, float* %19
%21 = fmul float %18, %20
%22 = fpext float %21 to double
%23 = load double, double* %7
%24 = fadd double %23, %22
store double %24, double* %7
br label %25
25: ; preds = %16
%26 = load float*, float** %5
%27 = getelementptr inbounds float, float* %26, i32 1
store float* %27, float** %5
br label %12
28: ; preds = %12
%29 = load double, double* %7
%30 = fptrunc double %29 to float
ret float %30
}

LLVM IR (-O2):
define float @floatsumsquared(float* %0, i64 %1) {
%3 = getelementptr inbounds float, float* %0, i64 %1
%4 = icmp sgt i64 %1, 0
br i1 %4, label %5, label %16
5: ; preds = %2, %5
%6 = phi double [ %11, %5 ], [ 0.000000e+00, %2 ]
%7 = phi float* [ %12, %5 ], [ %0, %2 ]
%8 = load float, float* %7
%9 = fmul float %8, %8
%10 = fpext float %9 to double
%11 = fadd double %6, %10
%12 = getelementptr inbounds float, float* %7, i64 1
%13 = icmp ult float* %12, %3
br i1 %13, label %5, label %14
14: ; preds = %5
%15 = fptrunc double %11 to float
br label %16
16: ; preds = %14, %2
%17 = phi float [ 0.000000e+00, %2 ], [ %15, %14 ]
ret float %17
}