#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 */
typedef int /*<<< orphan*/ p;

/* Variables and functions */
void *malloc(int);
int /*<<< orphan*/ matrix_chain_order(int *, int, unsigned int *, int *);
int /*<<< orphan*/ print_optimal_parens(int *, int, int);
int main(void) {
  unsigned int *m;
  int *s;
  int p[] = {30, 35, 15, 5, 10, 20, 25};
  m = malloc(sizeof(unsigned int) * 6 * 6);
  s = malloc(sizeof(int) * 6 * 6);
  matrix_chain_order(p, sizeof(p), m, s);
  print_optimal_parens(s, 1, 6);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    $0x90,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x90,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1c,%esi
call   1030 <matrix_chain_order@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1050 <print_optimal_parens@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movups 0xece(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x90,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0x90,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1c,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1030 <matrix_chain_order@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1050 <print_optimal_parens@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.p = [7 x i32] [i32 30, i32 35, i32 15, i32 5, i32 10, i32 20, i32 25]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [7 x i32]
store i32 0, i32* %1
%5 = bitcast [7 x i32]* %4 to i8*
%6 = call i8* @malloc(i32 144)
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %2
%8 = call i8* @malloc(i32 144)
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %3
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = load i32*, i32** %3
%13 = call i32 @matrix_chain_order(i32* %10, i32 28, i32* %11, i32* %12)
%14 = load i32*, i32** %3
%15 = call i32 @print_optimal_parens(i32* %14, i32 1, i32 6)
ret i32 0
}

LLVM IR (-O2):
@__const.main.p = [7 x i32] [i32 30, i32 35, i32 15, i32 5, i32 10, i32 20, i32 25]
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = tail call dereferenceable_or_null(144) i8* @malloc(i32 144)
%4 = bitcast i8* %3 to i32*
%5 = tail call dereferenceable_or_null(144) i8* @malloc(i32 144)
%6 = bitcast i8* %5 to i32*
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%8 = call i32 @matrix_chain_order(i32* %7, i32 28, i32* %4, i32* %6)
%9 = call i32 @print_optimal_parens(i32* %6, i32 1, i32 6)
ret i32 0
}