#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*/ check(float *);
void square(const float *__restrict__ a, float *__restrict__ out) {
  unsigned int i;
  for (i = 0; i < 512; i++) {
    float ai = a[i];
    float a2 = ai * ai;
    out[i] = a2;
  }
  check(out);
}


x86 assembly (clang, -O0):
<square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
jae    1173 <square+0x63>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <square+0x17>
mov    -0x10(%rbp),%rdi
call   1030 <check@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<square>:
mov    $0xc,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movups -0x30(%rdi,%rax,4),%xmm0
movups -0x20(%rdi,%rax,4),%xmm1
mulps  %xmm0,%xmm0
mulps  %xmm1,%xmm1
movups %xmm0,-0x30(%rsi,%rax,4)
movups %xmm1,-0x20(%rsi,%rax,4)
movups -0x10(%rdi,%rax,4),%xmm0
movups (%rdi,%rax,4),%xmm1
mulps  %xmm0,%xmm0
mulps  %xmm1,%xmm1
movups %xmm0,-0x10(%rsi,%rax,4)
movups %xmm1,(%rsi,%rax,4)
add    $0x10,%rax
cmp    $0x20c,%rax
jne    1120 <square+0x10>
mov    %rsi,%rdi
jmp    1030 <check@plt>

LLVM IR (-O0):
define void @square(float* noalias %0, float* noalias %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca i32
%6 = alloca float
%7 = alloca float
store float* %0, float** %3
store float* %1, float** %4
store i32 0, i32* %5
br label %8
8: ; preds = %25, %2
%9 = load i32, i32* %5
%10 = icmp ult i32 %9, 512
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load float*, float** %3
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds float, float* %12, i64 %14
%16 = load float, float* %15
store float %16, float* %6
%17 = load float, float* %6
%18 = load float, float* %6
%19 = fmul float %17, %18
store float %19, float* %7
%20 = load float, float* %7
%21 = load float*, float** %4
%22 = load i32, i32* %5
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
br label %25
25: ; preds = %11
%26 = load i32, i32* %5
%27 = add i32 %26, 1
store i32 %27, i32* %5
br label %8
28: ; preds = %8
%29 = load float*, float** %4
%30 = call i32 @check(float* %29)
ret void
}

LLVM IR (-O2):
define void @square(float* noalias nocapture %0, float* noalias %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %30, %3 ]
%5 = getelementptr inbounds float, float* %0, i64 %4
%6 = bitcast float* %5 to <4 x float>*
%7 = load <4 x float>, <4 x float>* %6
%8 = getelementptr inbounds float, float* %5, i64 4
%9 = bitcast float* %8 to <4 x float>*
%10 = load <4 x float>, <4 x float>* %9
%11 = fmul <4 x float> %7, %7
%12 = fmul <4 x float> %10, %10
%13 = getelementptr inbounds float, float* %1, i64 %4
%14 = bitcast float* %13 to <4 x float>*
store <4 x float> %11, <4 x float>* %14
%15 = getelementptr inbounds float, float* %13, i64 4
%16 = bitcast float* %15 to <4 x float>*
store <4 x float> %12, <4 x float>* %16
%17 = or i64 %4, 8
%18 = getelementptr inbounds float, float* %0, i64 %17
%19 = bitcast float* %18 to <4 x float>*
%20 = load <4 x float>, <4 x float>* %19
%21 = getelementptr inbounds float, float* %18, i64 4
%22 = bitcast float* %21 to <4 x float>*
%23 = load <4 x float>, <4 x float>* %22
%24 = fmul <4 x float> %20, %20
%25 = fmul <4 x float> %23, %23
%26 = getelementptr inbounds float, float* %1, i64 %17
%27 = bitcast float* %26 to <4 x float>*
store <4 x float> %24, <4 x float>* %27
%28 = getelementptr inbounds float, float* %26, i64 4
%29 = bitcast float* %28 to <4 x float>*
store <4 x float> %25, <4 x float>* %29
%30 = add nuw nsw i64 %4, 16
%31 = icmp eq i64 %30, 512
br i1 %31, label %32, label %3
32: ; preds = %3
%33 = tail call i32 @check(float* %1)
ret void
}