#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
size_t mpos(unsigned int, unsigned int);
void mx_symmultsymmx(unsigned int n, double *p, double *a, double *b) {
  unsigned int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      double t = 0.0;
      for (k = 0; k < n; k++) {
        t += a[((i) <= (k) ? mpos((i), (k)) : mpos((k), (i)))] *
             b[((k) <= (j) ? mpos((k), (j)) : mpos((j), (k)))];
      }
      p[i * n + j] = t;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<mx_symmultsymmx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1255 <mx_symmultsymmx+0x145>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1242 <mx_symmultsymmx+0x132>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    121a <mx_symmultsymmx+0x10a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
ja     1190 <mx_symmultsymmx+0x80>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <mpos@plt>
mov    %rax,-0x48(%rbp)
jmp    119f <mx_symmultsymmx+0x8f>
mov    -0x2c(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <mpos@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
ja     11d9 <mx_symmultsymmx+0xc9>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <mpos@plt>
mov    %rax,-0x60(%rbp)
jmp    11e8 <mx_symmultsymmx+0xd8>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <mpos@plt>
mov    %rax,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115c <mx_symmultsymmx+0x4c>
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x28(%rbp),%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1141 <mx_symmultsymmx+0x31>
jmp    1247 <mx_symmultsymmx+0x137>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112e <mx_symmultsymmx+0x1e>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mx_symmultsymmx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x18(%rsp)
mov    %edi,0x4(%rsp)
test   %edi,%edi
je     11f3 <mx_symmultsymmx+0xe3>
mov    %rcx,%r14
mov    %rdx,%r13
mov    0x4(%rsp),%r15d
xor    %ebp,%ebp
jmp    114c <mx_symmultsymmx+0x3c>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %r15d,%ebp
je     11f3 <mx_symmultsymmx+0xe3>
mov    %ebp,%eax
imul   0x4(%rsp),%eax
mov    %rax,0x20(%rsp)
xor    %ebx,%ebx
jmp    117a <mx_symmultsymmx+0x6a>
nopl   0x0(%rax)
mov    0x20(%rsp),%rax
add    %ebx,%eax
mov    0x18(%rsp),%rcx
movsd  %xmm0,(%rcx,%rax,8)
add    $0x1,%rbx
cmp    %r15,%rbx
je     1140 <mx_symmultsymmx+0x30>
xorps  %xmm0,%xmm0
xor    %r12d,%r12d
jmp    11b9 <mx_symmultsymmx+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r12d,%esi
call   1030 <mpos@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  (%r14,%rax,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%r12
cmp    %r12d,%r15d
je     1160 <mx_symmultsymmx+0x50>
cmp    %r12d,%ebp
movsd  %xmm0,0x10(%rsp)
jbe    11d0 <mx_symmultsymmx+0xc0>
mov    %r12d,%edi
mov    %ebp,%esi
jmp    11d5 <mx_symmultsymmx+0xc5>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r12d,%esi
call   1030 <mpos@plt>
movsd  0x0(%r13,%rax,8),%xmm0
cmp    %r12,%rbx
movsd  %xmm0,0x8(%rsp)
jb     1190 <mx_symmultsymmx+0x80>
mov    %r12d,%edi
mov    %ebx,%esi
jmp    1195 <mx_symmultsymmx+0x85>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @mx_symmultsymmx(i32 %0, double* nocapture writeonly %1, double* nocapture %2, double* nocapture %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %50, label %6
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %47
%9 = phi i32 [ %48, %47 ], [ 0, %6 ]
%10 = mul i32 %9, %0
br label %11
11: ; preds = %8, %40
%12 = phi i64 [ 0, %8 ], [ %45, %40 ]
%13 = trunc i64 %12 to i32
%14 = trunc i64 %12 to i32
br label %15
15: ; preds = %11, %33
%16 = phi double [ 0.000000e+00, %11 ], [ %37, %33 ]
%17 = phi i32 [ 0, %11 ], [ %38, %33 ]
%18 = icmp ugt i32 %9, %17
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i64 @mpos(i32 %9, i32 %17)
br label %23
21: ; preds = %15
%22 = tail call i64 @mpos(i32 %17, i32 %9)
br label %23
23: ; preds = %21, %19
%24 = phi i64 [ %20, %19 ], [ %22, %21 ]
%25 = getelementptr inbounds double, double* %2, i64 %24
%26 = load double, double* %25
%27 = zext i32 %17 to i64
%28 = icmp ult i64 %12, %27
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = tail call i64 @mpos(i32 %17, i32 %13)
br label %33
31: ; preds = %23
%32 = tail call i64 @mpos(i32 %14, i32 %17)
br label %33
33: ; preds = %31, %29
%34 = phi i64 [ %30, %29 ], [ %32, %31 ]
%35 = getelementptr inbounds double, double* %3, i64 %34
%36 = load double, double* %35
%37 = tail call double @llvm.fmuladd.f64(double %26, double %36, double %16)
%38 = add nuw i32 %17, 1
%39 = icmp eq i32 %38, %0
br i1 %39, label %40, label %15
40: ; preds = %33
%41 = trunc i64 %12 to i32
%42 = add i32 %10, %41
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds double, double* %1, i64 %43
store double %37, double* %44
%45 = add nuw nsw i64 %12, 1
%46 = icmp eq i64 %45, %7
br i1 %46, label %47, label %11
47: ; preds = %40
%48 = add nuw i32 %9, 1
%49 = icmp eq i32 %48, %0
br i1 %49, label %50, label %8
50: ; preds = %47, %4
ret void
}