float *mat4_transpose(float *result, float *m) {
  float transposed[16];
  transposed[0] = m[0];
  transposed[1] = m[4];
  transposed[2] = m[8];
  transposed[3] = m[12];
  transposed[4] = m[1];
  transposed[5] = m[5];
  transposed[6] = m[9];
  transposed[7] = m[13];
  transposed[8] = m[2];
  transposed[9] = m[6];
  transposed[10] = m[10];
  transposed[11] = m[14];
  transposed[12] = m[3];
  transposed[13] = m[7];
  transposed[14] = m[11];
  transposed[15] = m[15];
  result[0] = transposed[0];
  result[1] = transposed[1];
  result[2] = transposed[2];
  result[3] = transposed[3];
  result[4] = transposed[4];
  result[5] = transposed[5];
  result[6] = transposed[6];
  result[7] = transposed[7];
  result[8] = transposed[8];
  result[9] = transposed[9];
  result[10] = transposed[10];
  result[11] = transposed[11];
  result[12] = transposed[12];
  result[13] = transposed[13];
  result[14] = transposed[14];
  result[15] = transposed[15];
  return result;
}


x86 assembly (clang, -O0):
<mat4_transpose>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movss  0x10(%rax),%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x20(%rax),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0x30(%rax),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movss  0x14(%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x24(%rax),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movss  0x34(%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  0x18(%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x28(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  0x38(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  0x1c(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x2c(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  0x3c(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
movss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x10(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x18(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x1c(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x20(%rax)
movss  -0x2c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x24(%rax)
movss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x2c(%rax)
movss  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x30(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x34(%rax)
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x3c(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4_transpose>:
mov    %rdi,%rax
movss  0x10(%rsi),%xmm8
movss  0x20(%rsi),%xmm9
movss  0x30(%rsi),%xmm10
movss  (%rsi),%xmm3
movss  0x4(%rsi),%xmm4
movss  0x14(%rsi),%xmm5
movss  0x24(%rsi),%xmm6
movss  0x34(%rsi),%xmm7
movss  0x8(%rsi),%xmm0
movss  0x18(%rsi),%xmm1
movss  0x28(%rsi),%xmm2
movss  0x38(%rsi),%xmm11
movss  0xc(%rsi),%xmm12
movss  0x1c(%rsi),%xmm13
movss  0x2c(%rsi),%xmm14
movss  0x3c(%rsi),%xmm15
movss  %xmm3,(%rdi)
movss  %xmm8,0x4(%rdi)
movss  %xmm9,0x8(%rdi)
movss  %xmm10,0xc(%rdi)
movss  %xmm4,0x10(%rdi)
movss  %xmm5,0x14(%rdi)
movss  %xmm6,0x18(%rdi)
movss  %xmm7,0x1c(%rdi)
movss  %xmm0,0x20(%rdi)
movss  %xmm1,0x24(%rdi)
movss  %xmm2,0x28(%rdi)
movss  %xmm11,0x2c(%rdi)
movss  %xmm12,0x30(%rdi)
movss  %xmm13,0x34(%rdi)
movss  %xmm14,0x38(%rdi)
movss  %xmm15,0x3c(%rdi)
ret

LLVM IR (-O0):
define float* @mat4_transpose(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca [16 x float]
store float* %0, float** %3
store float* %1, float** %4
%6 = load float*, float** %4
%7 = getelementptr inbounds float, float* %6, i64 0
%8 = load float, float* %7
%9 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 0
store float %8, float* %9
%10 = load float*, float** %4
%11 = getelementptr inbounds float, float* %10, i64 4
%12 = load float, float* %11
%13 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 1
store float %12, float* %13
%14 = load float*, float** %4
%15 = getelementptr inbounds float, float* %14, i64 8
%16 = load float, float* %15
%17 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 2
store float %16, float* %17
%18 = load float*, float** %4
%19 = getelementptr inbounds float, float* %18, i64 12
%20 = load float, float* %19
%21 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 3
store float %20, float* %21
%22 = load float*, float** %4
%23 = getelementptr inbounds float, float* %22, i64 1
%24 = load float, float* %23
%25 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 4
store float %24, float* %25
%26 = load float*, float** %4
%27 = getelementptr inbounds float, float* %26, i64 5
%28 = load float, float* %27
%29 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 5
store float %28, float* %29
%30 = load float*, float** %4
%31 = getelementptr inbounds float, float* %30, i64 9
%32 = load float, float* %31
%33 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 6
store float %32, float* %33
%34 = load float*, float** %4
%35 = getelementptr inbounds float, float* %34, i64 13
%36 = load float, float* %35
%37 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 7
store float %36, float* %37
%38 = load float*, float** %4
%39 = getelementptr inbounds float, float* %38, i64 2
%40 = load float, float* %39
%41 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 8
store float %40, float* %41
%42 = load float*, float** %4
%43 = getelementptr inbounds float, float* %42, i64 6
%44 = load float, float* %43
%45 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 9
store float %44, float* %45
%46 = load float*, float** %4
%47 = getelementptr inbounds float, float* %46, i64 10
%48 = load float, float* %47
%49 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 10
store float %48, float* %49
%50 = load float*, float** %4
%51 = getelementptr inbounds float, float* %50, i64 14
%52 = load float, float* %51
%53 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 11
store float %52, float* %53
%54 = load float*, float** %4
%55 = getelementptr inbounds float, float* %54, i64 3
%56 = load float, float* %55
%57 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 12
store float %56, float* %57
%58 = load float*, float** %4
%59 = getelementptr inbounds float, float* %58, i64 7
%60 = load float, float* %59
%61 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 13
store float %60, float* %61
%62 = load float*, float** %4
%63 = getelementptr inbounds float, float* %62, i64 11
%64 = load float, float* %63
%65 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 14
store float %64, float* %65
%66 = load float*, float** %4
%67 = getelementptr inbounds float, float* %66, i64 15
%68 = load float, float* %67
%69 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 15
store float %68, float* %69
%70 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 0
%71 = load float, float* %70
%72 = load float*, float** %3
%73 = getelementptr inbounds float, float* %72, i64 0
store float %71, float* %73
%74 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 1
%75 = load float, float* %74
%76 = load float*, float** %3
%77 = getelementptr inbounds float, float* %76, i64 1
store float %75, float* %77
%78 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 2
%79 = load float, float* %78
%80 = load float*, float** %3
%81 = getelementptr inbounds float, float* %80, i64 2
store float %79, float* %81
%82 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 3
%83 = load float, float* %82
%84 = load float*, float** %3
%85 = getelementptr inbounds float, float* %84, i64 3
store float %83, float* %85
%86 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 4
%87 = load float, float* %86
%88 = load float*, float** %3
%89 = getelementptr inbounds float, float* %88, i64 4
store float %87, float* %89
%90 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 5
%91 = load float, float* %90
%92 = load float*, float** %3
%93 = getelementptr inbounds float, float* %92, i64 5
store float %91, float* %93
%94 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 6
%95 = load float, float* %94
%96 = load float*, float** %3
%97 = getelementptr inbounds float, float* %96, i64 6
store float %95, float* %97
%98 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 7
%99 = load float, float* %98
%100 = load float*, float** %3
%101 = getelementptr inbounds float, float* %100, i64 7
store float %99, float* %101
%102 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 8
%103 = load float, float* %102
%104 = load float*, float** %3
%105 = getelementptr inbounds float, float* %104, i64 8
store float %103, float* %105
%106 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 9
%107 = load float, float* %106
%108 = load float*, float** %3
%109 = getelementptr inbounds float, float* %108, i64 9
store float %107, float* %109
%110 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 10
%111 = load float, float* %110
%112 = load float*, float** %3
%113 = getelementptr inbounds float, float* %112, i64 10
store float %111, float* %113
%114 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 11
%115 = load float, float* %114
%116 = load float*, float** %3
%117 = getelementptr inbounds float, float* %116, i64 11
store float %115, float* %117
%118 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 12
%119 = load float, float* %118
%120 = load float*, float** %3
%121 = getelementptr inbounds float, float* %120, i64 12
store float %119, float* %121
%122 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 13
%123 = load float, float* %122
%124 = load float*, float** %3
%125 = getelementptr inbounds float, float* %124, i64 13
store float %123, float* %125
%126 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 14
%127 = load float, float* %126
%128 = load float*, float** %3
%129 = getelementptr inbounds float, float* %128, i64 14
store float %127, float* %129
%130 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 15
%131 = load float, float* %130
%132 = load float*, float** %3
%133 = getelementptr inbounds float, float* %132, i64 15
store float %131, float* %133
%134 = load float*, float** %3
ret float* %134
}

LLVM IR (-O2):
define float* @mat4_transpose(float* returned writeonly %0, float* nocapture %1) {
%3 = load float, float* %1
%4 = getelementptr inbounds float, float* %1, i64 4
%5 = load float, float* %4
%6 = getelementptr inbounds float, float* %1, i64 8
%7 = load float, float* %6
%8 = getelementptr inbounds float, float* %1, i64 12
%9 = load float, float* %8
%10 = getelementptr inbounds float, float* %1, i64 1
%11 = load float, float* %10
%12 = getelementptr inbounds float, float* %1, i64 5
%13 = load float, float* %12
%14 = getelementptr inbounds float, float* %1, i64 9
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %1, i64 13
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %1, i64 2
%19 = load float, float* %18
%20 = getelementptr inbounds float, float* %1, i64 6
%21 = load float, float* %20
%22 = getelementptr inbounds float, float* %1, i64 10
%23 = load float, float* %22
%24 = getelementptr inbounds float, float* %1, i64 14
%25 = load float, float* %24
%26 = getelementptr inbounds float, float* %1, i64 3
%27 = load float, float* %26
%28 = getelementptr inbounds float, float* %1, i64 7
%29 = load float, float* %28
%30 = getelementptr inbounds float, float* %1, i64 11
%31 = load float, float* %30
%32 = getelementptr inbounds float, float* %1, i64 15
%33 = load float, float* %32
store float %3, float* %0
%34 = getelementptr inbounds float, float* %0, i64 1
store float %5, float* %34
%35 = getelementptr inbounds float, float* %0, i64 2
store float %7, float* %35
%36 = getelementptr inbounds float, float* %0, i64 3
store float %9, float* %36
%37 = getelementptr inbounds float, float* %0, i64 4
store float %11, float* %37
%38 = getelementptr inbounds float, float* %0, i64 5
store float %13, float* %38
%39 = getelementptr inbounds float, float* %0, i64 6
store float %15, float* %39
%40 = getelementptr inbounds float, float* %0, i64 7
store float %17, float* %40
%41 = getelementptr inbounds float, float* %0, i64 8
store float %19, float* %41
%42 = getelementptr inbounds float, float* %0, i64 9
store float %21, float* %42
%43 = getelementptr inbounds float, float* %0, i64 10
store float %23, float* %43
%44 = getelementptr inbounds float, float* %0, i64 11
store float %25, float* %44
%45 = getelementptr inbounds float, float* %0, i64 12
store float %27, float* %45
%46 = getelementptr inbounds float, float* %0, i64 13
store float %29, float* %46
%47 = getelementptr inbounds float, float* %0, i64 14
store float %31, float* %47
%48 = getelementptr inbounds float, float* %0, i64 15
store float %33, float* %48
ret float* %0
}