#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);
void mt2sm(double *vm, double *sm) {
  *sm = vm[0] * vm[0] + vm[1] * vm[1] + vm[2] * vm[2];
  *sm += 2. * (vm[3] * vm[3] + vm[4] * vm[4] + vm[5] * vm[5]);
  *sm = sqrt(*sm / 2.);
}


x86 assembly (clang, -O0):
<mt2sm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x20(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mt2sm>:
push   %rbx
mov    %rsi,%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  %xmm1,(%rsi)
movsd  0x18(%rdi),%xmm2
movsd  0x20(%rdi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
movsd  0x28(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe93(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     117d <mt2sm+0x6d>
sqrtsd %xmm0,%xmm0
jmp    1182 <mt2sm+0x72>
call   1030 <sqrt@plt>
movsd  %xmm0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @mt2sm(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%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)
%26 = load double*, double** %4
store double %25, double* %26
%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 = load double*, double** %3
%34 = getelementptr inbounds double, double* %33, i64 4
%35 = load double, double* %34
%36 = load double*, double** %3
%37 = getelementptr inbounds double, double* %36, i64 4
%38 = load double, double* %37
%39 = fmul double %35, %38
%40 = call double @llvm.fmuladd.f64(double %29, double %32, double %39)
%41 = load double*, double** %3
%42 = getelementptr inbounds double, double* %41, i64 5
%43 = load double, double* %42
%44 = load double*, double** %3
%45 = getelementptr inbounds double, double* %44, i64 5
%46 = load double, double* %45
%47 = call double @llvm.fmuladd.f64(double %43, double %46, double %40)
%48 = load double*, double** %4
%49 = load double, double* %48
%50 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %47, double %49)
store double %50, double* %48
%51 = load double*, double** %4
%52 = load double, double* %51
%53 = fdiv double %52, 2.000000e+00
%54 = call double @sqrt(double %53)
%55 = load double*, double** %4
store double %54, double* %55
ret void
}

LLVM IR (-O2):
define void @mt2sm(double* nocapture %0, double* nocapture 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)
store double %10, double* %1
%11 = getelementptr inbounds double, double* %0, i64 3
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %0, i64 4
%14 = load double, double* %13
%15 = fmul double %14, %14
%16 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %15)
%17 = getelementptr inbounds double, double* %0, i64 5
%18 = load double, double* %17
%19 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %16)
%20 = tail call double @llvm.fmuladd.f64(double %19, double 2.000000e+00, double %10)
%21 = fmul double %20, 5.000000e-01
%22 = tail call double @sqrt(double %21)
store double %22, double* %1
ret void
}