#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 */
void *malloc(int);
int minimumTotal(int **, int, int *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int i, row = 4;
  int **nums = malloc(row * sizeof(int *));
  int *sizes = malloc(row * sizeof(int));
  for (i = 0; i < row; i++) {
    sizes[i] = i + 1;
    nums[i] = malloc(sizes[i] * sizeof(int));
  }
  nums[0][0] = 2;
  nums[1][0] = 3;
  nums[1][1] = 4;
  nums[2][0] = 6;
  nums[2][1] = 5;
  nums[2][2] = 7;
  nums[3][0] = 4;
  nums[3][1] = 1;
  nums[3][2] = 8;
  nums[3][3] = 3;
  printf("%d\n", minimumTotal(nums, row, sizes));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <main+0x94>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movslq (%rax,%rcx,4),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <main+0x43>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movl   $0x2,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x6,(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x5,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x7,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x4,(%rax)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x8,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x3,0xc(%rax)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <minimumTotal@plt>
mov    %eax,%esi
lea    0xd92(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x0(%r13)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %rax,0x8(%r13)
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x10(%r13)
movaps 0xe73(%rip),%xmm0
movups %xmm0,(%r14)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%r13)
movl   $0x2,(%r15)
movabs $0x400000003,%rcx
mov    %rcx,(%r12)
movabs $0x500000006,%rcx
mov    %rcx,(%rbx)
movl   $0x7,0x8(%rbx)
movaps 0xe41(%rip),%xmm0
movups %xmm0,(%rax)
mov    %r13,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
call   1040 <minimumTotal@plt>
lea    0xe37(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%2 = bitcast i8* %1 to i32**
%3 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%4 = bitcast i8* %3 to i32*
%5 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%6 = bitcast i8* %1 to i8**
store i8* %5, i8** %6
%7 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%8 = getelementptr inbounds i32*, i32** %2, i64 1
%9 = bitcast i32** %8 to i8**
store i8* %7, i8** %9
%10 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
%11 = getelementptr inbounds i32*, i32** %2, i64 2
%12 = bitcast i32** %11 to i8**
store i8* %10, i8** %12
%13 = bitcast i8* %3 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %13
%14 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%15 = getelementptr inbounds i32*, i32** %2, i64 3
%16 = bitcast i32** %15 to i8**
store i8* %14, i8** %16
%17 = bitcast i8* %5 to i32*
store i32 2, i32* %17
%18 = bitcast i8* %7 to i32*
store i32 3, i32* %18
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 4, i32* %19
%20 = bitcast i8* %10 to i32*
store i32 6, i32* %20
%21 = getelementptr inbounds i32, i32* %20, i64 1
store i32 5, i32* %21
%22 = getelementptr inbounds i32, i32* %20, i64 2
store i32 7, i32* %22
%23 = bitcast i8* %14 to <4 x i32>*
store <4 x i32> <i32 4, i32 1, i32 8, i32 3>, <4 x i32>* %23
%24 = tail call i32 @minimumTotal(i32** %2, i32 4, i32* %4)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
ret i32 0
}