#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 */
scalar_t__ malloc(int);
double *ma_transform_matrix(double mat[20][20]) {
  double *new_mat;
  int i, j, m;
  new_mat = (double *)malloc(sizeof(double) * 8000);
  for (m = 0; m < 20; ++m)
    for (i = 0; i < 20; ++i)
      for (j = 0; j < 20; ++j)
        new_mat[m + i * 20 + j * 400] = mat[m][i] * mat[m][j];
  return new_mat;
}


x86 assembly (clang, -O0):
<ma_transform_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xfa00,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    11e5 <ma_transform_matrix+0xd5>
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11d2 <ma_transform_matrix+0xc2>
movl   $0x0,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jge    11bf <ma_transform_matrix+0xaf>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   $0x14,-0x14(%rbp),%edx
add    %edx,%ecx
imul   $0x190,-0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <ma_transform_matrix+0x43>
jmp    11c4 <ma_transform_matrix+0xb4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <ma_transform_matrix+0x32>
jmp    11d7 <ma_transform_matrix+0xc7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <ma_transform_matrix+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ma_transform_matrix>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xfa00,%edi
call   1030 <malloc@plt>
xor    %r9d,%r9d
mov    %rax,%r8
mov    %r14,%rsi
nopw   0x0(%rax,%rax,1)
mov    %r8,%r10
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r9,%r9,4),%rcx
shl    $0x5,%rcx
add    %r14,%rcx
lea    (%rcx,%rdx,8),%rbx
mov    $0x1,%ecx
mov    %r10,%rdi
nopw   0x0(%rax,%rax,1)
movsd  (%rbx),%xmm0
mulsd  -0x8(%rsi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi)
movsd  (%rbx),%xmm0
mulsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,0xc80(%rdi)
add    $0x2,%rcx
add    $0x1900,%rdi
cmp    $0x15,%rcx
jne    1160 <ma_transform_matrix+0x50>
add    $0x1,%rdx
add    $0xa0,%r10
cmp    $0x14,%rdx
jne    1140 <ma_transform_matrix+0x30>
add    $0x1,%r9
add    $0xa0,%rsi
add    $0x8,%r8
cmp    $0x14,%r9
jne    1130 <ma_transform_matrix+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define double* @ma_transform_matrix([20 x double]* nocapture %0) {
%2 = tail call i64 @malloc(i32 64000)
%3 = inttoptr i64 %2 to double*
br label %4
4: ; preds = %1, %33
%5 = phi i64 [ 0, %1 ], [ %34, %33 ]
br label %6
6: ; preds = %4, %30
%7 = phi i64 [ 0, %4 ], [ %31, %30 ]
%8 = getelementptr inbounds [20 x double], [20 x double]* %0, i64 %5, i64 %7
%9 = mul nuw nsw i64 %7, 20
%10 = add nuw nsw i64 %9, %5
br label %11
11: ; preds = %11, %6
%12 = phi i64 [ 0, %6 ], [ %28, %11 ]
%13 = load double, double* %8
%14 = getelementptr inbounds [20 x double], [20 x double]* %0, i64 %5, i64 %12
%15 = load double, double* %14
%16 = fmul double %13, %15
%17 = mul nuw nsw i64 %12, 400
%18 = add nuw nsw i64 %10, %17
%19 = getelementptr inbounds double, double* %3, i64 %18
store double %16, double* %19
%20 = or i64 %12, 1
%21 = load double, double* %8
%22 = getelementptr inbounds [20 x double], [20 x double]* %0, i64 %5, i64 %20
%23 = load double, double* %22
%24 = fmul double %21, %23
%25 = mul nuw nsw i64 %20, 400
%26 = add nuw nsw i64 %10, %25
%27 = getelementptr inbounds double, double* %3, i64 %26
store double %24, double* %27
%28 = add nuw nsw i64 %12, 2
%29 = icmp eq i64 %28, 20
br i1 %29, label %30, label %11
30: ; preds = %11
%31 = add nuw nsw i64 %7, 1
%32 = icmp eq i64 %31, 20
br i1 %32, label %33, label %6
33: ; preds = %30
%34 = add nuw nsw i64 %5, 1
%35 = icmp eq i64 %34, 20
br i1 %35, label %36, label %4
36: ; preds = %33
ret double* %3
}