#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 sqrtf(float);
float vec4_length(float *a) {
  float x = a[0];
  float y = a[1];
  float z = a[2];
  float w = a[3];
  return sqrtf(x * x + y * y + z * z + w * w);
}


x86 assembly (clang, -O0):
<vec4_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec4_length>:
movss  (%rdi),%xmm1
movss  0x4(%rdi),%xmm2
movss  0x8(%rdi),%xmm3
movss  0xc(%rdi),%xmm0
mulss  %xmm2,%xmm2
mulss  %xmm1,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm3,%xmm3
addss  %xmm1,%xmm3
mulss  %xmm0,%xmm0
addss  %xmm3,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     114c <vec4_length+0x3c>
sqrtss %xmm0,%xmm0
ret
jmp    1030 <sqrtf@plt>

LLVM IR (-O0):
define float @vec4_length(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float* %0, float** %2
%7 = load float*, float** %2
%8 = getelementptr inbounds float, float* %7, i64 0
%9 = load float, float* %8
store float %9, float* %3
%10 = load float*, float** %2
%11 = getelementptr inbounds float, float* %10, i64 1
%12 = load float, float* %11
store float %12, float* %4
%13 = load float*, float** %2
%14 = getelementptr inbounds float, float* %13, i64 2
%15 = load float, float* %14
store float %15, float* %5
%16 = load float*, float** %2
%17 = getelementptr inbounds float, float* %16, i64 3
%18 = load float, float* %17
store float %18, float* %6
%19 = load float, float* %3
%20 = load float, float* %3
%21 = load float, float* %4
%22 = load float, float* %4
%23 = fmul float %21, %22
%24 = call float @llvm.fmuladd.f32(float %19, float %20, float %23)
%25 = load float, float* %5
%26 = load float, float* %5
%27 = call float @llvm.fmuladd.f32(float %25, float %26, float %24)
%28 = load float, float* %6
%29 = load float, float* %6
%30 = call float @llvm.fmuladd.f32(float %28, float %29, float %27)
%31 = call float @sqrtf(float %30)
ret float %31
}

LLVM IR (-O2):
define float @vec4_length(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = getelementptr inbounds float, float* %0, i64 2
%6 = load float, float* %5
%7 = getelementptr inbounds float, float* %0, i64 3
%8 = load float, float* %7
%9 = fmul float %4, %4
%10 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %9)
%11 = tail call float @llvm.fmuladd.f32(float %6, float %6, float %10)
%12 = tail call float @llvm.fmuladd.f32(float %8, float %8, float %11)
%13 = tail call float @sqrtf(float %12)
ret float %13
}