#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 path_len(double pts[2][3]) {
  double del, lensq, plen;
  int i;
  lensq = 0.0;
  for (i = 0; i < 3; ++i) {
    del = pts[1][i] - pts[0][i];
    lensq += del * del;
  }
  plen = sqrt(lensq);
  return (plen);
}


x86 assembly (clang, -O0):
<path_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    117f <path_len+0x6f>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0x18(%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112b <path_len+0x1b>
movsd  -0x18(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_len>:
movsd  0x18(%rdi),%xmm0
movsd  0x20(%rdi),%xmm1
subsd  (%rdi),%xmm0
mulsd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
subsd  0x8(%rdi),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x28(%rdi),%xmm0
subsd  0x10(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1154 <path_len+0x44>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

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

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