int main(void) {
  int **x = malloc(4 * sizeof(int *));
  x[0] = malloc(1 * sizeof(int));
  x[1] = malloc(2 * sizeof(int));
  x[2] = malloc(3 * sizeof(int));
  x[3] = malloc(4 * sizeof(int));
  x[0][0] = 2;
  x[1][0] = 3;
  x[1][1] = 4;
  x[2][0] = 6;
  x[2][1] = 5;
  x[2][2] = 7;
  x[3][0] = 4;
  x[3][1] = 1;
  x[3][2] = 8;
  x[3][3] = 3;
  printf("%d\n", minimumTotal(x, 4));
  free(x[0]);
  free(x[1]);
  free(x[2]);
  free(x[3]);
  free(x);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x20,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x6,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x5,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x7,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x8,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x3,0xc(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1050 <minimumTotal@plt>
mov    %eax,%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x20,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,(%rbx)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x8(%rbx)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,0x10(%rbx)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,0x18(%rbx)
movl   $0x2,(%r14)
movabs $0x400000003,%rcx
mov    %rcx,(%r15)
movabs $0x500000006,%rcx
mov    %rcx,(%r12)
movl   $0x7,0x8(%r12)
movaps 0xe39(%rip),%xmm0
movups %xmm0,(%rax)
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <minimumTotal@plt>
lea    0xe30(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
call   1030 <free@plt>
mov    0x18(%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
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**
store i32 0, i32* %1
%3 = call i8* @malloc(i64 32)
%4 = bitcast i8* %3 to i32**
store i32** %4, i32*** %2
%5 = call i8* @malloc(i64 4)
%6 = bitcast i8* %5 to i32*
%7 = load i32**, i32*** %2
%8 = getelementptr inbounds i32*, i32** %7, i64 0
store i32* %6, i32** %8
%9 = call i8* @malloc(i64 8)
%10 = bitcast i8* %9 to i32*
%11 = load i32**, i32*** %2
%12 = getelementptr inbounds i32*, i32** %11, i64 1
store i32* %10, i32** %12
%13 = call i8* @malloc(i64 12)
%14 = bitcast i8* %13 to i32*
%15 = load i32**, i32*** %2
%16 = getelementptr inbounds i32*, i32** %15, i64 2
store i32* %14, i32** %16
%17 = call i8* @malloc(i64 16)
%18 = bitcast i8* %17 to i32*
%19 = load i32**, i32*** %2
%20 = getelementptr inbounds i32*, i32** %19, i64 3
store i32* %18, i32** %20
%21 = load i32**, i32*** %2
%22 = getelementptr inbounds i32*, i32** %21, i64 0
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 0
store i32 2, i32* %24
%25 = load i32**, i32*** %2
%26 = getelementptr inbounds i32*, i32** %25, i64 1
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 0
store i32 3, i32* %28
%29 = load i32**, i32*** %2
%30 = getelementptr inbounds i32*, i32** %29, i64 1
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 1
store i32 4, i32* %32
%33 = load i32**, i32*** %2
%34 = getelementptr inbounds i32*, i32** %33, i64 2
%35 = load i32*, i32** %34
%36 = getelementptr inbounds i32, i32* %35, i64 0
store i32 6, i32* %36
%37 = load i32**, i32*** %2
%38 = getelementptr inbounds i32*, i32** %37, i64 2
%39 = load i32*, i32** %38
%40 = getelementptr inbounds i32, i32* %39, i64 1
store i32 5, i32* %40
%41 = load i32**, i32*** %2
%42 = getelementptr inbounds i32*, i32** %41, i64 2
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 2
store i32 7, i32* %44
%45 = load i32**, i32*** %2
%46 = getelementptr inbounds i32*, i32** %45, i64 3
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 0
store i32 4, i32* %48
%49 = load i32**, i32*** %2
%50 = getelementptr inbounds i32*, i32** %49, i64 3
%51 = load i32*, i32** %50
%52 = getelementptr inbounds i32, i32* %51, i64 1
store i32 1, i32* %52
%53 = load i32**, i32*** %2
%54 = getelementptr inbounds i32*, i32** %53, i64 3
%55 = load i32*, i32** %54
%56 = getelementptr inbounds i32, i32* %55, i64 2
store i32 8, i32* %56
%57 = load i32**, i32*** %2
%58 = getelementptr inbounds i32*, i32** %57, i64 3
%59 = load i32*, i32** %58
%60 = getelementptr inbounds i32, i32* %59, i64 3
store i32 3, i32* %60
%61 = load i32**, i32*** %2
%62 = call i32 (i32**, i32, ...) bitcast (i32 (...)* @minimumTotal to i32 (i32**, i32, ...)*)(i32** %61, i32 4)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %62)
%64 = load i32**, i32*** %2
%65 = getelementptr inbounds i32*, i32** %64, i64 0
%66 = load i32*, i32** %65
%67 = bitcast i32* %66 to i8*
%68 = load i32**, i32*** %2
%69 = getelementptr inbounds i32*, i32** %68, i64 1
%70 = load i32*, i32** %69
%71 = bitcast i32* %70 to i8*
%72 = load i32**, i32*** %2
%73 = getelementptr inbounds i32*, i32** %72, i64 2
%74 = load i32*, i32** %73
%75 = bitcast i32* %74 to i8*
%76 = load i32**, i32*** %2
%77 = getelementptr inbounds i32*, i32** %76, i64 3
%78 = load i32*, i32** %77
%79 = bitcast i32* %78 to i8*
%80 = load i32**, i32*** %2
%81 = bitcast i32** %80 to i8*
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(i64 32)
%2 = bitcast i8* %1 to i32**
%3 = tail call dereferenceable_or_null(4) i8* @malloc(i64 4)
%4 = bitcast i8* %1 to i8**
store i8* %3, i8** %4
%5 = tail call dereferenceable_or_null(8) i8* @malloc(i64 8)
%6 = getelementptr inbounds i32*, i32** %2, i64 1
%7 = bitcast i32** %6 to i8**
store i8* %5, i8** %7
%8 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%9 = getelementptr inbounds i32*, i32** %2, i64 2
%10 = bitcast i32** %9 to i8**
store i8* %8, i8** %10
%11 = tail call dereferenceable_or_null(16) i8* @malloc(i64 16)
%12 = getelementptr inbounds i32*, i32** %2, i64 3
%13 = bitcast i32** %12 to i8**
store i8* %11, i8** %13
%14 = bitcast i8* %3 to i32*
store i32 2, i32* %14
%15 = bitcast i8* %5 to i32*
store i32 3, i32* %15
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 4, i32* %16
%17 = bitcast i8* %8 to i32*
store i32 6, i32* %17
%18 = getelementptr inbounds i32, i32* %17, i64 1
store i32 5, i32* %18
%19 = getelementptr inbounds i32, i32* %17, i64 2
store i32 7, i32* %19
%20 = bitcast i8* %11 to <4 x i32>*
store <4 x i32> <i32 4, i32 1, i32 8, i32 3>, <4 x i32>* %20
%21 = tail call i32 (i32**, i32, ...) bitcast (i32 (...)* @minimumTotal to i32 (i32**, i32, ...)*)(i32** %2, i32 4)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i8*, i8** %4
tail call void @free(i8* %23)
%24 = load i8*, i8** %7
tail call void @free(i8* %24)
%25 = load i8*, i8** %10
tail call void @free(i8* %25)
%26 = load i8*, i8** %13
tail call void @free(i8* %26)
tail call void @free(i8* %1)
ret i32 0
}