void metric_gam(const double x[3], double gam[9]) {
  double r = x[0];
  gam[0] = 1.0;
  gam[1] = 0.0;
  gam[2] = 0.0;
  gam[3] = 0.0;
  gam[4] = r * r;
  gam[5] = 0.0;
  gam[6] = 0.0;
  gam[7] = 0.0;
  gam[8] = 1.0;
}


x86 assembly (clang, -O0):
<metric_gam>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe70(%rip),%xmm0
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<metric_gam>:
movsd  (%rdi),%xmm0
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rsi)
mulsd  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movups %xmm1,0x8(%rsi)
movq   $0x0,0x18(%rsi)
movsd  %xmm0,0x20(%rsi)
movups %xmm1,0x28(%rsi)
movq   $0x0,0x38(%rsi)
mov    %rax,0x40(%rsi)
ret

LLVM IR (-O0):
define void @metric_gam(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
store double %8, double* %5
%9 = load double*, double** %4
%10 = getelementptr inbounds double, double* %9, i64 0
store double 1.000000e+00, double* %10
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 1
store double 0.000000e+00, double* %12
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 2
store double 0.000000e+00, double* %14
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 3
store double 0.000000e+00, double* %16
%17 = load double, double* %5
%18 = load double, double* %5
%19 = fmul double %17, %18
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 4
store double %19, double* %21
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 5
store double 0.000000e+00, double* %23
%24 = load double*, double** %4
%25 = getelementptr inbounds double, double* %24, i64 6
store double 0.000000e+00, double* %25
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 7
store double 0.000000e+00, double* %27
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 8
store double 1.000000e+00, double* %29
ret void
}

LLVM IR (-O2):
define void @metric_gam(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
store double 1.000000e+00, double* %1
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = fmul double %3, %3
%6 = getelementptr inbounds double, double* %1, i64 4
%7 = bitcast double* %4 to i8*
store double %5, double* %6
%8 = getelementptr inbounds double, double* %1, i64 5
%9 = getelementptr inbounds double, double* %1, i64 8
%10 = bitcast double* %8 to i8*
store double 1.000000e+00, double* %9
ret void
}