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


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

x86 assembly (clang, -O2):
<vec4_distance>:
movss  (%rsi),%xmm1
movss  0x4(%rsi),%xmm2
subss  (%rdi),%xmm1
subss  0x4(%rdi),%xmm2
movss  0x8(%rsi),%xmm3
subss  0x8(%rdi),%xmm3
movss  0xc(%rsi),%xmm0
subss  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     115f <vec4_distance+0x4f>
sqrtss %xmm0,%xmm0
ret
jmp    1030 <sqrtf@plt>

LLVM IR (-O0):
define float @vec4_distance(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%9 = load float*, float** %4
%10 = getelementptr inbounds float, float* %9, i64 0
%11 = load float, float* %10
%12 = load float*, float** %3
%13 = getelementptr inbounds float, float* %12, i64 0
%14 = load float, float* %13
%15 = fsub float %11, %14
store float %15, float* %5
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 1
%18 = load float, float* %17
%19 = load float*, float** %3
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = fsub float %18, %21
store float %22, float* %6
%23 = load float*, float** %4
%24 = getelementptr inbounds float, float* %23, i64 2
%25 = load float, float* %24
%26 = load float*, float** %3
%27 = getelementptr inbounds float, float* %26, i64 2
%28 = load float, float* %27
%29 = fsub float %25, %28
store float %29, float* %7
%30 = load float*, float** %4
%31 = getelementptr inbounds float, float* %30, i64 3
%32 = load float, float* %31
%33 = load float*, float** %3
%34 = getelementptr inbounds float, float* %33, i64 3
%35 = load float, float* %34
%36 = fsub float %32, %35
store float %36, float* %8
%37 = load float, float* %5
%38 = load float, float* %5
%39 = load float, float* %6
%40 = load float, float* %6
%41 = fmul float %39, %40
%42 = call float @llvm.fmuladd.f32(float %37, float %38, float %41)
%43 = load float, float* %7
%44 = load float, float* %7
%45 = call float @llvm.fmuladd.f32(float %43, float %44, float %42)
%46 = load float, float* %8
%47 = load float, float* %8
%48 = call float @llvm.fmuladd.f32(float %46, float %47, float %45)
%49 = call float @sqrtf(float %48)
ret float %49
}

LLVM IR (-O2):
define float @vec4_distance(float* nocapture %0, float* nocapture %1) {
%3 = load float, float* %1
%4 = load float, float* %0
%5 = fsub float %3, %4
%6 = getelementptr inbounds float, float* %1, i64 1
%7 = load float, float* %6
%8 = getelementptr inbounds float, float* %0, i64 1
%9 = load float, float* %8
%10 = fsub float %7, %9
%11 = getelementptr inbounds float, float* %1, i64 2
%12 = load float, float* %11
%13 = getelementptr inbounds float, float* %0, i64 2
%14 = load float, float* %13
%15 = fsub float %12, %14
%16 = getelementptr inbounds float, float* %1, i64 3
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %0, i64 3
%19 = load float, float* %18
%20 = fsub float %17, %19
%21 = fmul float %10, %10
%22 = tail call float @llvm.fmuladd.f32(float %5, float %5, float %21)
%23 = tail call float @llvm.fmuladd.f32(float %15, float %15, float %22)
%24 = tail call float @llvm.fmuladd.f32(float %20, float %20, float %23)
%25 = tail call float @sqrtf(float %24)
ret float %25
}