#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);
int /*<<< orphan*/ matrixChainMul(int **, int **, int, int *);
int /*<<< orphan*/ printMatrix(int **, int);
int /*<<< orphan*/ printParenth(int **, int, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int **m;
  int **s;
  int dim[7] = {30, 35, 15, 5, 10, 20, 25};
  m = (int **)malloc(7 * sizeof(int *));
  s = (int **)malloc(7 * sizeof(int *));
  for (int i = 0; i < 7; i++) {
    m[i] = (int *)malloc(7 * sizeof(int));
    s[i] = (int *)malloc(7 * sizeof(int));
    for (int j = 0; j < 7; j++) {
      m[i][j] = 0;
      s[i][j] = 0;
    }
  }
  matrixChainMul(m, s, 7, dim);
  printMatrix(m, 7);
  printf("\n\n\n");
  printMatrix(s, 7);
  printf("\n\n");
  printParenth(s, 1, 6);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe92(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    $0x38,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x38,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x7,-0x44(%rbp)
jge    1248 <main+0xf8>
mov    $0x1c,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x1c,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x48(%rbp)
cmpl   $0x7,-0x48(%rbp)
jge    1235 <main+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x48(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x48(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11ef <main+0x9f>
jmp    123a <main+0xea>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11ac <main+0x5c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x40(%rbp),%rcx
mov    $0x7,%edx
call   1030 <matrixChainMul@plt>
mov    -0x10(%rbp),%rdi
mov    $0x7,%esi
call   1060 <printMatrix@plt>
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x7,%esi
call   1060 <printMatrix@plt>
lea    0xd90(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1050 <printParenth@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movups 0xeac(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x38,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    $0x38,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0x1c,%edi
call   1070 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
mov    $0x1c,%edi
call   1070 <malloc@plt>
mov    %rax,(%r14,%rbx,8)
mov    (%r15,%rbx,8),%rcx
movl   $0x0,(%rcx)
movl   $0x0,(%rax)
movl   $0x0,0x4(%rcx)
movl   $0x0,0x4(%rax)
movl   $0x0,0x8(%rcx)
movl   $0x0,0x8(%rax)
movl   $0x0,0xc(%rcx)
movl   $0x0,0xc(%rax)
movl   $0x0,0x10(%rcx)
movl   $0x0,0x10(%rax)
movl   $0x0,0x14(%rcx)
movl   $0x0,0x14(%rax)
movl   $0x0,0x18(%rcx)
movl   $0x0,0x18(%rax)
add    $0x1,%rbx
cmp    $0x7,%rbx
jne    1190 <main+0x40>
mov    %rsp,%rcx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <matrixChainMul@plt>
mov    %r15,%rdi
mov    $0x7,%esi
call   1060 <printMatrix@plt>
lea    0xdd7(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1060 <printMatrix@plt>
lea    0xdbf(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1050 <printParenth@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.dim = [7 x i32] [i32 30, i32 35, i32 15, i32 5, i32 10, i32 20, i32 25]
@.str = [4 x i8] c"\0A\0A\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32**
%4 = alloca [7 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [7 x i32]* %4 to i8*
%8 = call i64 @malloc(i32 56)
%9 = inttoptr i64 %8 to i32**
store i32** %9, i32*** %2
%10 = call i64 @malloc(i32 56)
%11 = inttoptr i64 %10 to i32**
store i32** %11, i32*** %3
store i32 0, i32* %5
br label %12
12: ; preds = %52, %0
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 7
br i1 %14, label %15, label %55
15: ; preds = %12
%16 = call i64 @malloc(i32 28)
%17 = inttoptr i64 %16 to i32*
%18 = load i32**, i32*** %2
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32*, i32** %18, i64 %20
store i32* %17, i32** %21
%22 = call i64 @malloc(i32 28)
%23 = inttoptr i64 %22 to i32*
%24 = load i32**, i32*** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32*, i32** %24, i64 %26
store i32* %23, i32** %27
store i32 0, i32* %6
br label %28
28: ; preds = %48, %15
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 7
br i1 %30, label %31, label %51
31: ; preds = %28
%32 = load i32**, i32*** %2
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32*, i32** %32, i64 %34
%36 = load i32*, i32** %35
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 0, i32* %39
%40 = load i32**, i32*** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32*, i32** %40, i64 %42
%44 = load i32*, i32** %43
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
store i32 0, i32* %47
br label %48
48: ; preds = %31
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %28
51: ; preds = %28
br label %52
52: ; preds = %51
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %12
55: ; preds = %12
%56 = load i32**, i32*** %2
%57 = load i32**, i32*** %3
%58 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%59 = call i32 @matrixChainMul(i32** %56, i32** %57, i32 7, i32* %58)
%60 = load i32**, i32*** %2
%61 = call i32 @printMatrix(i32** %60, i32 7)
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%63 = load i32**, i32*** %3
%64 = call i32 @printMatrix(i32** %63, i32 7)
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%66 = load i32**, i32*** %3
%67 = call i32 @printParenth(i32** %66, i32 1, i32 6)
ret i32 0
}

LLVM IR (-O2):
@__const.main.dim = [7 x i32] [i32 30, i32 35, i32 15, i32 5, i32 10, i32 20, i32 25]
@str = [3 x i8] c"\0A\0A\00"
@str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = tail call i64 @malloc(i32 56)
%4 = inttoptr i64 %3 to i32**
%5 = tail call i64 @malloc(i32 56)
%6 = inttoptr i64 %5 to i32**
br label %15
7: ; preds = %15
%8 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%9 = call i32 @matrixChainMul(i32** %4, i32** %6, i32 7, i32* %8)
%10 = call i32 @printMatrix(i32** %4, i32 7)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%12 = call i32 @printMatrix(i32** %6, i32 7)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.2, i64 0, i64 0))
%14 = call i32 @printParenth(i32** %6, i32 1, i32 6)
ret i32 0
15: ; preds = %0, %15
%16 = phi i64 [ 0, %0 ], [ %36, %15 ]
%17 = tail call i64 @malloc(i32 28)
%18 = inttoptr i64 %17 to i32*
%19 = getelementptr inbounds i32*, i32** %4, i64 %16
store i32* %18, i32** %19
%20 = tail call i64 @malloc(i32 28)
%21 = inttoptr i64 %20 to i32*
%22 = getelementptr inbounds i32*, i32** %6, i64 %16
store i32* %21, i32** %22
%23 = load i32*, i32** %19
store i32 0, i32* %23
store i32 0, i32* %21
%24 = getelementptr inbounds i32, i32* %23, i64 1
store i32 0, i32* %24
%25 = getelementptr inbounds i32, i32* %21, i64 1
store i32 0, i32* %25
%26 = getelementptr inbounds i32, i32* %23, i64 2
store i32 0, i32* %26
%27 = getelementptr inbounds i32, i32* %21, i64 2
store i32 0, i32* %27
%28 = getelementptr inbounds i32, i32* %23, i64 3
store i32 0, i32* %28
%29 = getelementptr inbounds i32, i32* %21, i64 3
store i32 0, i32* %29
%30 = getelementptr inbounds i32, i32* %23, i64 4
store i32 0, i32* %30
%31 = getelementptr inbounds i32, i32* %21, i64 4
store i32 0, i32* %31
%32 = getelementptr inbounds i32, i32* %23, i64 5
store i32 0, i32* %32
%33 = getelementptr inbounds i32, i32* %21, i64 5
store i32 0, i32* %33
%34 = getelementptr inbounds i32, i32* %23, i64 6
store i32 0, i32* %34
%35 = getelementptr inbounds i32, i32* %21, i64 6
store i32 0, i32* %35
%36 = add nuw nsw i64 %16, 1
%37 = icmp eq i64 %36, 7
br i1 %37, label %7, label %15
}