void multiply_matrix(float *A, float *B, float *C) {
  int i, j, k;
  float aTmp[16];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      aTmp[j * 4 + i] = 0.0;
      for (k = 0; k < 4; k++) {
        aTmp[j * 4 + i] += A[k * 4 + i] * B[j * 4 + k];
      }
    }
  }
  for (i = 0; i < 16; i++) {
    C[i] = aTmp[i];
  }
}


x86 assembly (clang, -O0):
<multiply_matrix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11d4 <multiply_matrix+0xd4>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    11c1 <multiply_matrix+0xc1>
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
add    -0x1c(%rbp),%eax
cltq
xorps  %xmm0,%xmm0
movss  %xmm0,-0x70(%rbp,%rax,4)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11ae <multiply_matrix+0xae>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x2,%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
shl    $0x2,%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm2
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
add    -0x1c(%rbp),%eax
cltq
movss  -0x70(%rbp,%rax,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x70(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <multiply_matrix+0x4d>
jmp    11b3 <multiply_matrix+0xb3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1128 <multiply_matrix+0x28>
jmp    11c6 <multiply_matrix+0xc6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <multiply_matrix+0x17>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    120a <multiply_matrix+0x10a>
movslq -0x1c(%rbp),%rax
movss  -0x70(%rbp,%rax,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11db <multiply_matrix+0xdb>
pop    %rbp
ret

x86 assembly (clang, -O2):
<multiply_matrix>:
movss  0x3c(%rsi),%xmm0
movaps %xmm0,-0x58(%rsp)
movss  0x38(%rsi),%xmm11
movss  0x34(%rsi),%xmm12
movss  0x30(%rsi),%xmm14
movss  0x2c(%rsi),%xmm9
movss  0x28(%rsi),%xmm8
movss  0x24(%rsi),%xmm6
movss  0x20(%rsi),%xmm7
movss  0x1c(%rsi),%xmm5
movss  (%rsi),%xmm1
movss  0x4(%rsi),%xmm3
movss  0x8(%rsi),%xmm2
movss  0xc(%rsi),%xmm4
shufps $0x0,%xmm4,%xmm4
shufps $0x0,%xmm2,%xmm2
shufps $0x0,%xmm3,%xmm3
shufps $0x0,%xmm1,%xmm1
movups (%rdi),%xmm13
movups 0x10(%rdi),%xmm10
mulps  %xmm13,%xmm1
xorps  %xmm0,%xmm0
addps  %xmm0,%xmm1
mulps  %xmm10,%xmm3
addps  %xmm1,%xmm3
movups 0x20(%rdi),%xmm15
mulps  %xmm15,%xmm2
addps  %xmm3,%xmm2
movups 0x30(%rdi),%xmm1
mulps  %xmm1,%xmm4
addps  %xmm2,%xmm4
movss  0x18(%rsi),%xmm2
movss  0x14(%rsi),%xmm3
movss  0x10(%rsi),%xmm0
movaps %xmm4,-0x48(%rsp)
shufps $0x0,%xmm3,%xmm3
shufps $0x0,%xmm0,%xmm0
mulps  %xmm13,%xmm0
xorps  %xmm4,%xmm4
addps  %xmm4,%xmm0
mulps  %xmm10,%xmm3
addps  %xmm0,%xmm3
shufps $0x0,%xmm2,%xmm2
mulps  %xmm15,%xmm2
addps  %xmm3,%xmm2
shufps $0x0,%xmm5,%xmm5
mulps  %xmm1,%xmm5
addps  %xmm2,%xmm5
movaps %xmm5,-0x38(%rsp)
shufps $0x0,%xmm6,%xmm6
shufps $0x0,%xmm7,%xmm7
mulps  %xmm13,%xmm7
addps  %xmm4,%xmm7
xorps  %xmm0,%xmm0
mulps  %xmm10,%xmm6
addps  %xmm7,%xmm6
shufps $0x0,%xmm8,%xmm8
mulps  %xmm15,%xmm8
addps  %xmm6,%xmm8
shufps $0x0,%xmm9,%xmm9
mulps  %xmm1,%xmm9
addps  %xmm8,%xmm9
movaps %xmm9,-0x28(%rsp)
shufps $0x0,%xmm14,%xmm14
mulps  %xmm13,%xmm14
addps  %xmm0,%xmm14
shufps $0x0,%xmm12,%xmm12
mulps  %xmm10,%xmm12
addps  %xmm14,%xmm12
shufps $0x0,%xmm11,%xmm11
mulps  %xmm15,%xmm11
addps  %xmm12,%xmm11
movaps -0x58(%rsp),%xmm0
shufps $0x0,%xmm0,%xmm0
mulps  %xmm1,%xmm0
addps  %xmm11,%xmm0
movaps %xmm0,-0x18(%rsp)
movaps -0x48(%rsp),%xmm0
movups %xmm0,(%rdx)
movaps -0x38(%rsp),%xmm0
movups %xmm0,0x10(%rdx)
movaps -0x28(%rsp),%xmm0
movups %xmm0,0x20(%rdx)
movaps -0x18(%rsp),%xmm0
movups %xmm0,0x30(%rdx)
ret

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

LLVM IR (-O2):
define void @multiply_matrix(float* nocapture %0, float* nocapture %1, float* nocapture writeonly %2) {
%4 = alloca [16 x float]
%5 = bitcast [16 x float]* %4 to i8*
%6 = getelementptr inbounds float, float* %1, i64 15
%7 = load float, float* %6
%8 = insertelement <4 x float> poison, float %7, i64 0
%9 = shufflevector <4 x float> %8, <4 x float> poison, <4 x i32> zeroinitializer
%10 = getelementptr inbounds float, float* %1, i64 14
%11 = load float, float* %10
%12 = insertelement <4 x float> poison, float %11, i64 0
%13 = shufflevector <4 x float> %12, <4 x float> poison, <4 x i32> zeroinitializer
%14 = getelementptr inbounds float, float* %1, i64 13
%15 = load float, float* %14
%16 = insertelement <4 x float> poison, float %15, i64 0
%17 = shufflevector <4 x float> %16, <4 x float> poison, <4 x i32> zeroinitializer
%18 = getelementptr inbounds float, float* %1, i64 12
%19 = load float, float* %18
%20 = insertelement <4 x float> poison, float %19, i64 0
%21 = shufflevector <4 x float> %20, <4 x float> poison, <4 x i32> zeroinitializer
%22 = getelementptr inbounds float, float* %1, i64 11
%23 = load float, float* %22
%24 = insertelement <4 x float> poison, float %23, i64 0
%25 = shufflevector <4 x float> %24, <4 x float> poison, <4 x i32> zeroinitializer
%26 = getelementptr inbounds float, float* %1, i64 10
%27 = load float, float* %26
%28 = insertelement <4 x float> poison, float %27, i64 0
%29 = shufflevector <4 x float> %28, <4 x float> poison, <4 x i32> zeroinitializer
%30 = getelementptr inbounds float, float* %1, i64 9
%31 = load float, float* %30
%32 = insertelement <4 x float> poison, float %31, i64 0
%33 = shufflevector <4 x float> %32, <4 x float> poison, <4 x i32> zeroinitializer
%34 = getelementptr inbounds float, float* %1, i64 8
%35 = load float, float* %34
%36 = insertelement <4 x float> poison, float %35, i64 0
%37 = shufflevector <4 x float> %36, <4 x float> poison, <4 x i32> zeroinitializer
%38 = getelementptr inbounds float, float* %1, i64 7
%39 = load float, float* %38
%40 = insertelement <4 x float> poison, float %39, i64 0
%41 = shufflevector <4 x float> %40, <4 x float> poison, <4 x i32> zeroinitializer
%42 = getelementptr inbounds float, float* %1, i64 6
%43 = load float, float* %42
%44 = insertelement <4 x float> poison, float %43, i64 0
%45 = shufflevector <4 x float> %44, <4 x float> poison, <4 x i32> zeroinitializer
%46 = getelementptr inbounds float, float* %1, i64 5
%47 = load float, float* %46
%48 = insertelement <4 x float> poison, float %47, i64 0
%49 = shufflevector <4 x float> %48, <4 x float> poison, <4 x i32> zeroinitializer
%50 = getelementptr inbounds float, float* %1, i64 4
%51 = load float, float* %50
%52 = insertelement <4 x float> poison, float %51, i64 0
%53 = shufflevector <4 x float> %52, <4 x float> poison, <4 x i32> zeroinitializer
%54 = getelementptr inbounds float, float* %1, i64 3
%55 = load float, float* %54
%56 = insertelement <4 x float> poison, float %55, i64 0
%57 = shufflevector <4 x float> %56, <4 x float> poison, <4 x i32> zeroinitializer
%58 = getelementptr inbounds float, float* %1, i64 2
%59 = load float, float* %58
%60 = insertelement <4 x float> poison, float %59, i64 0
%61 = shufflevector <4 x float> %60, <4 x float> poison, <4 x i32> zeroinitializer
%62 = getelementptr inbounds float, float* %1, i64 1
%63 = load float, float* %62
%64 = insertelement <4 x float> poison, float %63, i64 0
%65 = shufflevector <4 x float> %64, <4 x float> poison, <4 x i32> zeroinitializer
%66 = load float, float* %1
%67 = insertelement <4 x float> poison, float %66, i64 0
%68 = shufflevector <4 x float> %67, <4 x float> poison, <4 x i32> zeroinitializer
%69 = bitcast float* %0 to <4 x float>*
%70 = load <4 x float>, <4 x float>* %69
%71 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %70, <4 x float> %68, <4 x float> zeroinitializer)
%72 = getelementptr inbounds float, float* %0, i64 4
%73 = bitcast float* %72 to <4 x float>*
%74 = load <4 x float>, <4 x float>* %73
%75 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %74, <4 x float> %65, <4 x float> %71)
%76 = getelementptr inbounds float, float* %0, i64 8
%77 = bitcast float* %76 to <4 x float>*
%78 = load <4 x float>, <4 x float>* %77
%79 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %78, <4 x float> %61, <4 x float> %75)
%80 = getelementptr inbounds float, float* %0, i64 12
%81 = bitcast float* %80 to <4 x float>*
%82 = load <4 x float>, <4 x float>* %81
%83 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %82, <4 x float> %57, <4 x float> %79)
%84 = bitcast [16 x float]* %4 to <4 x float>*
store <4 x float> %83, <4 x float>* %84
%85 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 4
%86 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %70, <4 x float> %53, <4 x float> zeroinitializer)
%87 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %74, <4 x float> %49, <4 x float> %86)
%88 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %78, <4 x float> %45, <4 x float> %87)
%89 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %82, <4 x float> %41, <4 x float> %88)
%90 = bitcast float* %85 to <4 x float>*
store <4 x float> %89, <4 x float>* %90
%91 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 8
%92 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %70, <4 x float> %37, <4 x float> zeroinitializer)
%93 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %74, <4 x float> %33, <4 x float> %92)
%94 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %78, <4 x float> %29, <4 x float> %93)
%95 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %82, <4 x float> %25, <4 x float> %94)
%96 = bitcast float* %91 to <4 x float>*
store <4 x float> %95, <4 x float>* %96
%97 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 12
%98 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %70, <4 x float> %21, <4 x float> zeroinitializer)
%99 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %74, <4 x float> %17, <4 x float> %98)
%100 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %78, <4 x float> %13, <4 x float> %99)
%101 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %82, <4 x float> %9, <4 x float> %100)
%102 = bitcast float* %97 to <4 x float>*
store <4 x float> %101, <4 x float>* %102
%103 = bitcast float* %2 to i8*
ret void
}