#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 dsnorm(double a[3]) {
  double dp;
  dp = a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
  if (dp < 0.0)
    return (0.0);
  dp = sqrt(dp);
  return (dp);
}


x86 assembly (clang, -O0):
<dsnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1180 <dsnorm+0x70>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1199 <dsnorm+0x89>
movsd  -0x18(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsnorm>:
movsd  0x10(%rdi),%xmm0
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1141 <dsnorm+0x31>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

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

LLVM IR (-O2):
define double @dsnorm(double* nocapture %0) {
%2 = getelementptr inbounds double, double* %0, i64 2
%3 = load double, double* %2
%4 = load double, double* %0
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = fmul double %6, %6
%8 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %7)
%9 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %8)
%10 = tail call double @sqrt(double %9)
ret double %10
}