#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 /*<<< orphan*/ MATRIX_CHAIN_ORDER(int *, int, int **, int **);
int /*<<< orphan*/ PRINT_OPTIMAL_PARRNS(int **, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int n = 6;
  int p[7];
  p[0] = 30;
  p[1] = 35;
  p[2] = 15;
  p[3] = 5;
  p[4] = 10;
  p[5] = 20;
  p[6] = 25;
  int m[n + 1][n + 1];
  int s[n + 1][n + 1];
  MATRIX_CHAIN_ORDER(p, n, (int **)m, (int **)s);
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j++) {
      printf("%d  ", m[i][j]);
    }
    printf("\n");
  }
  PRINT_OPTIMAL_PARRNS((int **)s, 1, 6, 7);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movl   $0x1e,-0x30(%rbp)
movl   $0x23,-0x2c(%rbp)
movl   $0xf,-0x28(%rbp)
movl   $0x5,-0x24(%rbp)
movl   $0xa,-0x20(%rbp)
movl   $0x14,-0x1c(%rbp)
movl   $0x19,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %rax,-0x78(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
imul   %rcx,%rcx
lea    0xf(,%rcx,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x70(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x40(%rbp)
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %rax,%rsi
mov    %rax,%rcx
imul   %rcx,%rcx
lea    0xf(,%rcx,4),%rdi
and    $0xfffffffffffffff0,%rdi
mov    %rsp,%rcx
sub    %rdi,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rsi,-0x50(%rbp)
mov    %rax,-0x58(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <MATRIX_CHAIN_ORDER@plt>
movl   $0x1,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     126b <main+0x13b>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     124f <main+0x11f>
mov    -0x70(%rbp),%rax
mov    -0x78(%rbp),%rdx
movslq -0x5c(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x60(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1209 <main+0xd9>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11f7 <main+0xc7>
mov    -0x68(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
mov    $0x7,%ecx
call   1030 <PRINT_OPTIMAL_PARRNS@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1c0,%rsp
mov    %rsp,%r15
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x140000000a,%rax
mov    %rax,0x10(%rsp)
movl   $0x19,0x18(%rsp)
mov    %rsp,%rdi
lea    0x20(%rsp),%rdx
lea    0xf0(%rsp),%r14
mov    $0x6,%esi
mov    %r14,%rcx
call   1050 <MATRIX_CHAIN_ORDER@plt>
mov    0x40(%rsp),%esi
lea    0xe77(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x48(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x50(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x54(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x60(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x64(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x68(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x6c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x70(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x80(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x84(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x88(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xa0(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xa4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xa8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc0(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xe0(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
mov    $0x7,%ecx
call   1040 <PRINT_OPTIMAL_PARRNS@plt>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = bitcast [7 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 30, i32 35, i32 15, i32 5>, <4 x i32>* %4
%5 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 4
store i32 10, i32* %5
%6 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 5
store i32 20, i32* %6
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 6
store i32 25, i32* %7
%8 = tail call i8* @llvm.stacksave()
%9 = alloca [49 x i32]
%10 = alloca [49 x i32]
%11 = bitcast [49 x i32]* %9 to i32**
%12 = bitcast [49 x i32]* %10 to i32**
%13 = call i32 @MATRIX_CHAIN_ORDER(i32* %3, i32 6, i32** %11, i32** %12)
%14 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 8
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 9
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 10
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 11
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 12
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 13
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = call i32 @putchar(i32 10)
%33 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 16
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 17
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 18
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 19
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 20
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = call i32 @putchar(i32 10)
%49 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 24
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 25
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 26
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 27
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = call i32 @putchar(i32 10)
%62 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 32
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 33
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %66)
%68 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 34
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %69)
%71 = call i32 @putchar(i32 10)
%72 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 40
%73 = load i32, i32* %72
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %73)
%75 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 41
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %76)
%78 = call i32 @putchar(i32 10)
%79 = getelementptr inbounds [49 x i32], [49 x i32]* %9, i64 0, i64 48
%80 = load i32, i32* %79
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %80)
%82 = call i32 @putchar(i32 10)
%83 = call i32 @PRINT_OPTIMAL_PARRNS(i32** %12, i32 1, i32 6, i32 7)
ret i32 0
}