#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 *lqunit(double *a, double *aunit) {
  double norm = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]);
  if (!norm)
    aunit[0] = aunit[1] = aunit[2] = aunit[3] = 0;
  else {
    aunit[0] = a[0] / norm;
    aunit[1] = a[1] / norm;
    aunit[2] = a[2] / norm;
    aunit[3] = a[3] / norm;
  }
  return (aunit);
}


x86 assembly (clang, -O0):
<lqunit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d4 <lqunit+0xc4>
jp     11d4 <lqunit+0xc4>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    122e <lqunit+0x11e>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lqunit>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%rdi),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x18(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1159 <lqunit+0x49>
sqrtsd %xmm0,%xmm0
jmp    1162 <lqunit+0x52>
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116a <lqunit+0x5a>
jnp    11a0 <lqunit+0x90>
movsd  (%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
movsd  0x18(%rbx),%xmm1
divsd  %xmm0,%xmm1
jmp    11b5 <lqunit+0xa5>
xorpd  %xmm0,%xmm0
movupd %xmm0,(%r14)
movq   $0x0,0x10(%r14)
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x18(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @lqunit(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = load double*, double** %3
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = load double*, double** %3
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %13
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = fmul double %14, %17
%19 = call double @llvm.fmuladd.f64(double %8, double %11, double %18)
%20 = load double*, double** %3
%21 = getelementptr inbounds double, double* %20, i64 2
%22 = load double, double* %21
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %22, double %25, double %19)
%27 = load double*, double** %3
%28 = getelementptr inbounds double, double* %27, i64 3
%29 = load double, double* %28
%30 = load double*, double** %3
%31 = getelementptr inbounds double, double* %30, i64 3
%32 = load double, double* %31
%33 = call double @llvm.fmuladd.f64(double %29, double %32, double %26)
%34 = call double @sqrt(double %33)
store double %34, double* %5
%35 = load double, double* %5
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %46, label %37
37: ; preds = %2
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i64 3
store double 0.000000e+00, double* %39
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 2
store double 0.000000e+00, double* %41
%42 = load double*, double** %4
%43 = getelementptr inbounds double, double* %42, i64 1
store double 0.000000e+00, double* %43
%44 = load double*, double** %4
%45 = getelementptr inbounds double, double* %44, i64 0
store double 0.000000e+00, double* %45
br label %75
46: ; preds = %2
%47 = load double*, double** %3
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = load double, double* %5
%51 = fdiv double %49, %50
%52 = load double*, double** %4
%53 = getelementptr inbounds double, double* %52, i64 0
store double %51, double* %53
%54 = load double*, double** %3
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = load double, double* %5
%58 = fdiv double %56, %57
%59 = load double*, double** %4
%60 = getelementptr inbounds double, double* %59, i64 1
store double %58, double* %60
%61 = load double*, double** %3
%62 = getelementptr inbounds double, double* %61, i64 2
%63 = load double, double* %62
%64 = load double, double* %5
%65 = fdiv double %63, %64
%66 = load double*, double** %4
%67 = getelementptr inbounds double, double* %66, i64 2
store double %65, double* %67
%68 = load double*, double** %3
%69 = getelementptr inbounds double, double* %68, i64 3
%70 = load double, double* %69
%71 = load double, double* %5
%72 = fdiv double %70, %71
%73 = load double*, double** %4
%74 = getelementptr inbounds double, double* %73, i64 3
store double %72, double* %74
br label %75
75: ; preds = %46, %37
%76 = load double*, double** %4
ret double* %76
}

LLVM IR (-O2):
define double* @lqunit(double* nocapture %0, double* returned writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %7)
%11 = getelementptr inbounds double, double* %0, i64 3
%12 = load double, double* %11
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %10)
%14 = tail call double @sqrt(double %13)
%15 = fcmp une double %14, 0.000000e+00
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = bitcast double* %1 to i8*
br label %29
18: ; preds = %2
%19 = load double, double* %0
%20 = fdiv double %19, %14
store double %20, double* %1
%21 = load double, double* %4
%22 = fdiv double %21, %14
%23 = getelementptr inbounds double, double* %1, i64 1
store double %22, double* %23
%24 = load double, double* %8
%25 = fdiv double %24, %14
%26 = getelementptr inbounds double, double* %1, i64 2
store double %25, double* %26
%27 = load double, double* %11
%28 = fdiv double %27, %14
br label %29
29: ; preds = %18, %16
%30 = phi double [ %28, %18 ], [ 0.000000e+00, %16 ]
%31 = getelementptr inbounds double, double* %1, i64 3
store double %30, double* %31
ret double* %1
}