#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 */
int EXIT_SUCCESS;
int /*<<< orphan*/ freeMat(int, int **);
int /*<<< orphan*/ getInt(int, int *);
int /*<<< orphan*/ getMat(int, int, int **);
int **matAlloc(int, int);
int /*<<< orphan*/ matMulti(int, int, int **, int, int, int **, int **);
int /*<<< orphan*/ prnMat(int, int, int **);
int main(int argc, char **argv) {
  int dim;
  int **matrix1, **matrix2, **result;
  getInt(1, &dim);
  matrix1 = matAlloc(dim, dim);
  matrix2 = matAlloc(dim, dim);
  result = matAlloc(dim, dim);
  getMat(dim, dim, matrix1);
  getMat(dim, dim, matrix2);
  matMulti(dim, dim, matrix1, dim, dim, matrix2, result);
  prnMat(dim, dim, result);
  freeMat(dim, matrix1);
  freeMat(dim, matrix2);
  freeMat(dim, result);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
call   1070 <getInt@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <matAlloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <matAlloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <matAlloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1030 <getMat@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <getMat@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1080 <matMulti@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1060 <prnMat@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <freeMat@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1050 <freeMat@plt>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <freeMat@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1070 <getInt@plt>
mov    0xc(%rsp),%edi
mov    %edi,%esi
call   1040 <matAlloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
mov    %edi,%esi
call   1040 <matAlloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%edi
mov    %edi,%esi
call   1040 <matAlloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
mov    %edi,%esi
mov    %r14,%rdx
call   1030 <getMat@plt>
mov    0xc(%rsp),%edi
mov    %edi,%esi
mov    %r15,%rdx
call   1030 <getMat@plt>
mov    0xc(%rsp),%ecx
mov    %rbx,(%rsp)
mov    %ecx,%edi
mov    %ecx,%esi
mov    %r14,%rdx
mov    %ecx,%r8d
mov    %r15,%r9
call   1080 <matMulti@plt>
mov    0xc(%rsp),%edi
mov    %edi,%esi
mov    %rbx,%rdx
call   1060 <prnMat@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1050 <freeMat@plt>
mov    0xc(%rsp),%edi
mov    %r15,%rsi
call   1050 <freeMat@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1050 <freeMat@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32**
%9 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @getInt(i32 1, i32* %6)
%11 = load i32, i32* %6
%12 = load i32, i32* %6
%13 = call i32** @matAlloc(i32 %11, i32 %12)
store i32** %13, i32*** %7
%14 = load i32, i32* %6
%15 = load i32, i32* %6
%16 = call i32** @matAlloc(i32 %14, i32 %15)
store i32** %16, i32*** %8
%17 = load i32, i32* %6
%18 = load i32, i32* %6
%19 = call i32** @matAlloc(i32 %17, i32 %18)
store i32** %19, i32*** %9
%20 = load i32, i32* %6
%21 = load i32, i32* %6
%22 = load i32**, i32*** %7
%23 = call i32 @getMat(i32 %20, i32 %21, i32** %22)
%24 = load i32, i32* %6
%25 = load i32, i32* %6
%26 = load i32**, i32*** %8
%27 = call i32 @getMat(i32 %24, i32 %25, i32** %26)
%28 = load i32, i32* %6
%29 = load i32, i32* %6
%30 = load i32**, i32*** %7
%31 = load i32, i32* %6
%32 = load i32, i32* %6
%33 = load i32**, i32*** %8
%34 = load i32**, i32*** %9
%35 = call i32 @matMulti(i32 %28, i32 %29, i32** %30, i32 %31, i32 %32, i32** %33, i32** %34)
%36 = load i32, i32* %6
%37 = load i32, i32* %6
%38 = load i32**, i32*** %9
%39 = call i32 @prnMat(i32 %36, i32 %37, i32** %38)
%40 = load i32, i32* %6
%41 = load i32**, i32*** %7
%42 = call i32 @freeMat(i32 %40, i32** %41)
%43 = load i32, i32* %6
%44 = load i32**, i32*** %8
%45 = call i32 @freeMat(i32 %43, i32** %44)
%46 = load i32, i32* %6
%47 = load i32**, i32*** %9
%48 = call i32 @freeMat(i32 %46, i32** %47)
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @getInt(i32 1, i32* %3)
%6 = load i32, i32* %3
%7 = call i32** @matAlloc(i32 %6, i32 %6)
%8 = load i32, i32* %3
%9 = call i32** @matAlloc(i32 %8, i32 %8)
%10 = load i32, i32* %3
%11 = call i32** @matAlloc(i32 %10, i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @getMat(i32 %12, i32 %12, i32** %7)
%14 = load i32, i32* %3
%15 = call i32 @getMat(i32 %14, i32 %14, i32** %9)
%16 = load i32, i32* %3
%17 = call i32 @matMulti(i32 %16, i32 %16, i32** %7, i32 %16, i32 %16, i32** %9, i32** %11)
%18 = load i32, i32* %3
%19 = call i32 @prnMat(i32 %18, i32 %18, i32** %11)
%20 = load i32, i32* %3
%21 = call i32 @freeMat(i32 %20, i32** %7)
%22 = load i32, i32* %3
%23 = call i32 @freeMat(i32 %22, i32** %9)
%24 = load i32, i32* %3
%25 = call i32 @freeMat(i32 %24, i32** %11)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}