#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 dfs(int **, int, int *, int /*<<< orphan*/, int /*<<< orphan*/, int **,
        int **);
void *malloc(int);
int /*<<< orphan*/ memset(int *, int, int);
int minimumTotal(int **triangle, int triangleSize, int *triangleColSizes) {
  int i;
  int **sums = malloc(triangleSize * sizeof(int *));
  bool **passed = malloc(triangleSize * sizeof(bool *));
  for (i = 0; i < triangleSize; i++) {
    passed[i] = malloc(triangleColSizes[i]);
    memset(passed[i], false, triangleColSizes[i]);
    sums[i] = malloc(triangleColSizes[i] * sizeof(int));
  }
  return dfs(triangle, triangleSize, triangleColSizes, 0, 0, sums, passed);
}


x86 assembly (clang, -O0):
<minimumTotal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ed <minimumTotal+0xbd>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movslq (%rax,%rcx,4),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <minimumTotal+0x40>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
xor    %r8d,%r8d
mov    %r8d,%ecx
mov    %rax,(%rsp)
call   1050 <dfs@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minimumTotal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,0x10(%rsp)
lea    0x0(,%rbp,8),%r14d
mov    %r14d,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %r14d,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %rbp,0x8(%rsp)
test   %ebp,%ebp
jle    11b5 <minimumTotal+0x85>
mov    0x8(%rsp),%r15d
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r14,4),%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%r13,%r14,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
mov    (%rbx,%r14,4),%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,(%r12,%r14,8)
add    $0x1,%r14
cmp    %r14,%r15
jne    1180 <minimumTotal+0x50>
mov    %r13,(%rsp)
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r12,%r9
call   1050 <dfs@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @minimumTotal(i32** %0, i32 %1, i32* %2) {
%4 = shl i32 %1, 3
%5 = tail call i8* @malloc(i32 %4)
%6 = bitcast i8* %5 to i32**
%7 = tail call i8* @malloc(i32 %4)
%8 = bitcast i8* %7 to i32**
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %28
10: ; preds = %3
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %26, %12 ]
%14 = getelementptr inbounds i32, i32* %2, i64 %13
%15 = load i32, i32* %14
%16 = tail call i8* @malloc(i32 %15)
%17 = bitcast i8* %16 to i32*
%18 = getelementptr inbounds i32*, i32** %8, i64 %13
%19 = bitcast i32** %18 to i8**
store i8* %16, i8** %19
%20 = tail call i32 @memset(i32* %17, i32 0, i32 %15)
%21 = load i32, i32* %14
%22 = shl i32 %21, 2
%23 = tail call i8* @malloc(i32 %22)
%24 = getelementptr inbounds i32*, i32** %6, i64 %13
%25 = bitcast i32** %24 to i8**
store i8* %23, i8** %25
%26 = add nuw nsw i64 %13, 1
%27 = icmp eq i64 %26, %11
br i1 %27, label %28, label %12
28: ; preds = %12, %3
%29 = tail call i32 @dfs(i32** %0, i32 %1, i32* %2, i32 0, i32 0, i32** %6, i32** %8)
ret i32 %29
}