void mm(double *A, double *B, double *C) {
  int i, j, k;
#pragma offload target(mic) in(A, B                                            \
                               : length(DIM *DIM))inout(C                      \
                                                        : length(DIM *DIM))
#pragma omp parallel for schedule(static)
  for (i = 0; i < 4; i++) {
    for (k = 0; k < 4; k++) {
      for (j = 0; j < 4; j++) {
        C[i * 4 + j] += A[i * 4 + k] * B[k * 4 + j];
      }
    }
  }
}


x86 assembly (clang, -O0):
<mm>:
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    11c3 <mm+0xc3>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11b0 <mm+0xb0>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    119d <mm+0x9d>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x2,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1139 <mm+0x39>
jmp    11a2 <mm+0xa2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1128 <mm+0x28>
jmp    11b5 <mm+0xb5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <mm+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rdi,%rax,1),%xmm0
mulsd  (%rsi),%xmm0
addsd  (%rdx,%rax,1),%xmm0
movsd  %xmm0,(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm1
mulsd  0x8(%rsi),%xmm1
addsd  0x8(%rdx,%rax,1),%xmm1
movsd  %xmm1,0x8(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm2
mulsd  0x10(%rsi),%xmm2
addsd  0x10(%rdx,%rax,1),%xmm2
movsd  %xmm2,0x10(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm3
mulsd  0x18(%rsi),%xmm3
addsd  0x18(%rdx,%rax,1),%xmm3
movsd  %xmm3,0x18(%rdx,%rax,1)
movsd  0x8(%rdi,%rax,1),%xmm4
mulsd  0x20(%rsi),%xmm4
addsd  %xmm0,%xmm4
movsd  %xmm4,(%rdx,%rax,1)
movsd  0x8(%rdi,%rax,1),%xmm0
mulsd  0x28(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rdx,%rax,1)
movsd  0x8(%rdi,%rax,1),%xmm1
mulsd  0x30(%rsi),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rdx,%rax,1)
movsd  0x8(%rdi,%rax,1),%xmm2
mulsd  0x38(%rsi),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x18(%rdx,%rax,1)
movsd  0x10(%rdi,%rax,1),%xmm3
mulsd  0x40(%rsi),%xmm3
addsd  %xmm4,%xmm3
movsd  %xmm3,(%rdx,%rax,1)
movsd  0x10(%rdi,%rax,1),%xmm4
mulsd  0x48(%rsi),%xmm4
addsd  %xmm0,%xmm4
movsd  %xmm4,0x8(%rdx,%rax,1)
movsd  0x10(%rdi,%rax,1),%xmm0
mulsd  0x50(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rdx,%rax,1)
movsd  0x10(%rdi,%rax,1),%xmm1
mulsd  0x58(%rsi),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x18(%rdx,%rax,1)
movsd  0x18(%rdi,%rax,1),%xmm2
mulsd  0x60(%rsi),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rdx,%rax,1)
movsd  0x18(%rdi,%rax,1),%xmm2
mulsd  0x68(%rsi),%xmm2
addsd  %xmm4,%xmm2
movsd  %xmm2,0x8(%rdx,%rax,1)
movsd  0x18(%rdi,%rax,1),%xmm2
mulsd  0x70(%rsi),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rdx,%rax,1)
movsd  0x18(%rdi,%rax,1),%xmm0
mulsd  0x78(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rdx,%rax,1)
add    $0x20,%rax
cmp    $0x80,%rax
jne    1110 <mm+0x10>
ret

LLVM IR (-O0):
define void @mm(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %10
10: ; preds = %55, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %58
13: ; preds = %10
store i32 0, i32* %9
br label %14
14: ; preds = %51, %13
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %54
17: ; preds = %14
store i32 0, i32* %8
br label %18
18: ; preds = %47, %17
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %50
21: ; preds = %18
%22 = load double*, double** %4
%23 = load i32, i32* %7
%24 = mul nsw i32 %23, 4
%25 = load i32, i32* %9
%26 = add nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %22, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %5
%31 = load i32, i32* %9
%32 = mul nsw i32 %31, 4
%33 = load i32, i32* %8
%34 = add nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %30, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %6
%39 = load i32, i32* %7
%40 = mul nsw i32 %39, 4
%41 = load i32, i32* %8
%42 = add nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %38, i64 %43
%45 = load double, double* %44
%46 = call double @llvm.fmuladd.f64(double %29, double %37, double %45)
store double %46, double* %44
br label %47
47: ; preds = %21
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %18
50: ; preds = %18
br label %51
51: ; preds = %50
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %14
54: ; preds = %14
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %10
58: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @mm(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = getelementptr inbounds double, double* %1, i64 2
%6 = getelementptr inbounds double, double* %1, i64 3
%7 = getelementptr inbounds double, double* %1, i64 4
%8 = getelementptr inbounds double, double* %1, i64 5
%9 = getelementptr inbounds double, double* %1, i64 6
%10 = getelementptr inbounds double, double* %1, i64 7
%11 = getelementptr inbounds double, double* %1, i64 8
%12 = getelementptr inbounds double, double* %1, i64 9
%13 = getelementptr inbounds double, double* %1, i64 10
%14 = getelementptr inbounds double, double* %1, i64 11
%15 = getelementptr inbounds double, double* %1, i64 12
%16 = getelementptr inbounds double, double* %1, i64 13
%17 = getelementptr inbounds double, double* %1, i64 14
%18 = getelementptr inbounds double, double* %1, i64 15
br label %19
19: ; preds = %3, %19
%20 = phi i64 [ 0, %3 ], [ %97, %19 ]
%21 = shl nsw i64 %20, 2
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = load double, double* %1
%25 = getelementptr inbounds double, double* %2, i64 %21
%26 = load double, double* %25
%27 = tail call double @llvm.fmuladd.f64(double %23, double %24, double %26)
store double %27, double* %25
%28 = load double, double* %22
%29 = load double, double* %4
%30 = or i64 %21, 1
%31 = getelementptr inbounds double, double* %2, i64 %30
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %32)
store double %33, double* %31
%34 = load double, double* %22
%35 = load double, double* %5
%36 = or i64 %21, 2
%37 = getelementptr inbounds double, double* %2, i64 %36
%38 = load double, double* %37
%39 = tail call double @llvm.fmuladd.f64(double %34, double %35, double %38)
store double %39, double* %37
%40 = load double, double* %22
%41 = load double, double* %6
%42 = or i64 %21, 3
%43 = getelementptr inbounds double, double* %2, i64 %42
%44 = load double, double* %43
%45 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %44)
store double %45, double* %43
%46 = getelementptr inbounds double, double* %0, i64 %30
%47 = load double, double* %46
%48 = load double, double* %7
%49 = load double, double* %25
%50 = tail call double @llvm.fmuladd.f64(double %47, double %48, double %49)
store double %50, double* %25
%51 = load double, double* %46
%52 = load double, double* %8
%53 = load double, double* %31
%54 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %53)
store double %54, double* %31
%55 = load double, double* %46
%56 = load double, double* %9
%57 = load double, double* %37
%58 = tail call double @llvm.fmuladd.f64(double %55, double %56, double %57)
store double %58, double* %37
%59 = load double, double* %46
%60 = load double, double* %10
%61 = load double, double* %43
%62 = tail call double @llvm.fmuladd.f64(double %59, double %60, double %61)
store double %62, double* %43
%63 = getelementptr inbounds double, double* %0, i64 %36
%64 = load double, double* %63
%65 = load double, double* %11
%66 = load double, double* %25
%67 = tail call double @llvm.fmuladd.f64(double %64, double %65, double %66)
store double %67, double* %25
%68 = load double, double* %63
%69 = load double, double* %12
%70 = load double, double* %31
%71 = tail call double @llvm.fmuladd.f64(double %68, double %69, double %70)
store double %71, double* %31
%72 = load double, double* %63
%73 = load double, double* %13
%74 = load double, double* %37
%75 = tail call double @llvm.fmuladd.f64(double %72, double %73, double %74)
store double %75, double* %37
%76 = load double, double* %63
%77 = load double, double* %14
%78 = load double, double* %43
%79 = tail call double @llvm.fmuladd.f64(double %76, double %77, double %78)
store double %79, double* %43
%80 = getelementptr inbounds double, double* %0, i64 %42
%81 = load double, double* %80
%82 = load double, double* %15
%83 = load double, double* %25
%84 = tail call double @llvm.fmuladd.f64(double %81, double %82, double %83)
store double %84, double* %25
%85 = load double, double* %80
%86 = load double, double* %16
%87 = load double, double* %31
%88 = tail call double @llvm.fmuladd.f64(double %85, double %86, double %87)
store double %88, double* %31
%89 = load double, double* %80
%90 = load double, double* %17
%91 = load double, double* %37
%92 = tail call double @llvm.fmuladd.f64(double %89, double %90, double %91)
store double %92, double* %37
%93 = load double, double* %80
%94 = load double, double* %18
%95 = load double, double* %43
%96 = tail call double @llvm.fmuladd.f64(double %93, double %94, double %95)
store double %96, double* %43
%97 = add nuw nsw i64 %20, 1
%98 = icmp eq i64 %97, 4
br i1 %98, label %99, label %19
99: ; preds = %19
ret void
}