#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 vec2_distance(float *a, float *b) {
  return sqrtf((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
}


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

x86 assembly (clang, -O2):
<vec2_distance>:
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
subss  (%rsi),%xmm0
subss  0x4(%rsi),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     113b <vec2_distance+0x2b>
sqrtss %xmm0,%xmm0
ret
jmp    1030 <sqrtf@plt>

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

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