#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 */
double sqrt(double);
double len3(double a[4], double b[4]) {
  int i;
  double r, v[4];
  r = 0.0;
  for (i = 1; i <= 3; i++) {
    v[i] = a[i] - b[i];
    r += v[i] * v[i];
  }
  return sqrt(r);
}


x86 assembly (clang, -O0):
<len3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     1191 <len3+0x81>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
movslq -0x14(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movslq -0x14(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <len3+0x1f>
movsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<len3>:
movsd  0x8(%rdi),%xmm0
movsd  0x10(%rdi),%xmm1
subsd  0x8(%rsi),%xmm0
mulsd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
subsd  0x10(%rsi),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x18(%rdi),%xmm0
subsd  0x18(%rsi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1155 <len3+0x45>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @len3(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca [4 x double]
store double* %0, double** %3
store double* %1, double** %4
store double 0.000000e+00, double* %6
store i32 1, i32* %5
br label %8
8: ; preds = %36, %2
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 3
br i1 %10, label %11, label %39
11: ; preds = %8
%12 = load double*, double** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = load double*, double** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = fsub double %16, %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %24
store double %22, double* %25
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %27
%29 = load double, double* %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %31
%33 = load double, double* %32
%34 = load double, double* %6
%35 = call double @llvm.fmuladd.f64(double %29, double %33, double %34)
store double %35, double* %6
br label %36
36: ; preds = %11
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %8
39: ; preds = %8
%40 = load double, double* %6
%41 = call double @sqrt(double %40)
ret double %41
}

LLVM IR (-O2):
define double @len3(double* nocapture %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = getelementptr inbounds double, double* %1, i64 1
%6 = load double, double* %5
%7 = fsub double %4, %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double %7, double 0.000000e+00)
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %1, i64 2
%12 = load double, double* %11
%13 = fsub double %10, %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %8)
%15 = getelementptr inbounds double, double* %0, i64 3
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %1, i64 3
%18 = load double, double* %17
%19 = fsub double %16, %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %14)
%21 = tail call double @sqrt(double %20)
ret double %21
}