int main() {
  int i;
  int source, destination;
  int numNodes = 0;
  numNodes = getNumNodesFromFile();
  int **cost = (int **)malloc(sizeof(int *) * (numNodes + 1));
  for (i = 0; i <= numNodes; i++)
    cost[i] = (int *)malloc(sizeof(int) * (numNodes + 1));
  initCost(cost, numNodes, &source, &destination);
  printToFile(cost, source, destination, numNodes + 1);
  for (i = 0; i < numNodes + 1; i++)
    free(cost[i]);
  free(cost);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <getNumNodesFromFile@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11c8 <main+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118d <main+0x3d>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1070 <initCost@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    $0x0,%al
call   1040 <printToFile@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    122c <main+0xdc>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fc <main+0xac>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getNumNodesFromFile@plt>
mov    %eax,%r15d
lea    0x1(%r15),%r14d
movslq %r14d,%rbp
lea    0x0(,%rbp,8),%rdi
call   1060 <malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
js     11f4 <main+0xa4>
shl    $0x2,%rbp
mov    %r14d,%r13d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1060 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <main+0x40>
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <initCost@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    %r12,%rdi
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printToFile@plt>
test   %r15d,%r15d
js     121d <main+0xcd>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11e0 <main+0x90>
jmp    121d <main+0xcd>
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <initCost@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    %r12,%rdi
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printToFile@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @getNumNodesFromFile()
%6 = add i32 %5, 1
%7 = sext i32 %6 to i64
%8 = shl nsw i64 %7, 3
%9 = tail call i8* @malloc(i64 %8)
%10 = bitcast i8* %9 to i32**
%11 = icmp slt i32 %5, 0
br i1 %11, label %36, label %12
12: ; preds = %0
%13 = shl nsw i64 %7, 2
%14 = zext i32 %6 to i64
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 0, %12 ], [ %20, %15 ]
%17 = tail call i8* @malloc(i64 %13)
%18 = getelementptr inbounds i32*, i32** %10, i64 %16
%19 = bitcast i32** %18 to i8**
store i8* %17, i8** %19
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %14
br i1 %21, label %22, label %15
22: ; preds = %15
%23 = call i32 (i32**, i32, i32*, i32*, ...) bitcast (i32 (...)* @initCost to i32 (i32**, i32, i32*, i32*, ...)*)(i32** %10, i32 %5, i32* %1, i32* %2)
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @printToFile to i32 (i32**, i32, i32, i32, ...)*)(i32** %10, i32 %24, i32 %25, i32 %6)
br i1 %11, label %41, label %27
27: ; preds = %22
%28 = zext i32 %6 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %34, %29 ]
%31 = getelementptr inbounds i32*, i32** %10, i64 %30
%32 = bitcast i32** %31 to i8**
%33 = load i8*, i8** %32
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, %28
br i1 %35, label %41, label %29
36: ; preds = %0
%37 = call i32 (i32**, i32, i32*, i32*, ...) bitcast (i32 (...)* @initCost to i32 (i32**, i32, i32*, i32*, ...)*)(i32** %10, i32 %5, i32* %1, i32* %2)
%38 = load i32, i32* %1
%39 = load i32, i32* %2
%40 = call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @printToFile to i32 (i32**, i32, i32, i32, ...)*)(i32** %10, i32 %38, i32 %39, i32 %6)
br label %41
41: ; preds = %29, %36, %22
ret i32 0
}