float *mat3_scaling(float *result, float *v) {
  result[0] = v[0];
  result[1] = 0.0f;
  result[2] = 0.0f;
  result[3] = 0.0f;
  result[4] = v[1];
  result[5] = 0.0f;
  result[6] = 0.0f;
  result[7] = 0.0f;
  result[8] = v[2];
  return result;
}


x86 assembly (clang, -O0):
<mat3_scaling>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x14(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x1c(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat3_scaling>:
mov    %rdi,%rax
movss  (%rsi),%xmm0
movss  %xmm0,(%rdi)
movq   $0x0,0x4(%rdi)
movl   $0x0,0xc(%rdi)
movss  0x4(%rsi),%xmm0
movss  %xmm0,0x10(%rdi)
movq   $0x0,0x14(%rdi)
movl   $0x0,0x1c(%rdi)
movss  0x8(%rsi),%xmm0
movss  %xmm0,0x20(%rdi)
ret

LLVM IR (-O0):
define float* @mat3_scaling(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
store float* %0, float** %3
store float* %1, float** %4
%5 = load float*, float** %4
%6 = getelementptr inbounds float, float* %5, i64 0
%7 = load float, float* %6
%8 = load float*, float** %3
%9 = getelementptr inbounds float, float* %8, i64 0
store float %7, float* %9
%10 = load float*, float** %3
%11 = getelementptr inbounds float, float* %10, i64 1
store float 0.000000e+00, float* %11
%12 = load float*, float** %3
%13 = getelementptr inbounds float, float* %12, i64 2
store float 0.000000e+00, float* %13
%14 = load float*, float** %3
%15 = getelementptr inbounds float, float* %14, i64 3
store float 0.000000e+00, float* %15
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 1
%18 = load float, float* %17
%19 = load float*, float** %3
%20 = getelementptr inbounds float, float* %19, i64 4
store float %18, float* %20
%21 = load float*, float** %3
%22 = getelementptr inbounds float, float* %21, i64 5
store float 0.000000e+00, float* %22
%23 = load float*, float** %3
%24 = getelementptr inbounds float, float* %23, i64 6
store float 0.000000e+00, float* %24
%25 = load float*, float** %3
%26 = getelementptr inbounds float, float* %25, i64 7
store float 0.000000e+00, float* %26
%27 = load float*, float** %4
%28 = getelementptr inbounds float, float* %27, i64 2
%29 = load float, float* %28
%30 = load float*, float** %3
%31 = getelementptr inbounds float, float* %30, i64 8
store float %29, float* %31
%32 = load float*, float** %3
ret float* %32
}

LLVM IR (-O2):
define float* @mat3_scaling(float* returned writeonly %0, float* nocapture %1) {
%3 = load float, float* %1
store float %3, float* %0
%4 = getelementptr inbounds float, float* %0, i64 1
store float 0.000000e+00, float* %4
%5 = getelementptr inbounds float, float* %0, i64 2
store float 0.000000e+00, float* %5
%6 = getelementptr inbounds float, float* %0, i64 3
store float 0.000000e+00, float* %6
%7 = getelementptr inbounds float, float* %1, i64 1
%8 = load float, float* %7
%9 = getelementptr inbounds float, float* %0, i64 4
store float %8, float* %9
%10 = getelementptr inbounds float, float* %0, i64 5
store float 0.000000e+00, float* %10
%11 = getelementptr inbounds float, float* %0, i64 6
store float 0.000000e+00, float* %11
%12 = getelementptr inbounds float, float* %0, i64 7
store float 0.000000e+00, float* %12
%13 = getelementptr inbounds float, float* %1, i64 2
%14 = load float, float* %13
%15 = getelementptr inbounds float, float* %0, i64 8
store float %14, float* %15
ret float* %0
}