#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 cost(int **, int);
int **prims(int **, int);
int /*<<< orphan*/ printf(char *, ...);
int **read(int *);
int main() {
  printf("Here we go\n");
  int numberOfNodes;
  int **adjMatrix = read(&numberOfNodes);
  int **returtree, i, j;
  returtree = prims(adjMatrix, numberOfNodes);
  for (i = 0; i < numberOfNodes; i++) {
    for (j = 0; j < numberOfNodes; j++)
      printf("%d ", returtree[i][j]);
    printf("\n");
  }
  printf("\nCostul este: %d", cost(returtree, numberOfNodes));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1050 <read@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <prims@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11eb <main+0xab>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cf <main+0x8f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1194 <main+0x54>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <main+0x41>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <cost@plt>
mov    %eax,%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
lea    0x4(%rsp),%rdi
call   1070 <read@plt>
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1080 <prims@plt>
mov    %rax,%r15
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11f1 <main+0x91>
lea    0xe64(%rip),%r14
xor    %r12d,%r12d
jmp    11c8 <main+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rsi
cmp    %rsi,%r12
jge    11f1 <main+0x91>
test   %esi,%esi
jle    11b0 <main+0x50>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r15,%r12,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11d0 <main+0x70>
jmp    11b0 <main+0x50>
mov    %r15,%rdi
call   1060 <cost@plt>
lea    0xe04(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Here we go\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [17 x i8] c"\0ACostul este: %d\00"
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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = call i32** @read(i32* %2)
store i32** %8, i32*** %3
%9 = load i32**, i32*** %3
%10 = load i32, i32* %2
%11 = call i32** @prims(i32** %9, i32 %10)
store i32** %11, i32*** %4
store i32 0, i32* %5
br label %12
12: ; preds = %37, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %40
16: ; preds = %12
store i32 0, i32* %6
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i32**, i32*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32*, i32** %22, i64 %24
%26 = load i32*, i32** %25
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %21
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %17
35: ; preds = %17
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %12
40: ; preds = %12
%41 = load i32**, i32*** %4
%42 = load i32, i32* %2
%43 = call i32 @cost(i32** %41, i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [17 x i8] c"\0ACostul este: %d\00"
@str = [11 x i8] c"Here we go\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32** @read(i32* %1)
%5 = load i32, i32* %1
%6 = call i32** @prims(i32** %4, i32 %5)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %0, %25
%10 = phi i32 [ %28, %25 ], [ %7, %0 ]
%11 = phi i64 [ %27, %25 ], [ 0, %0 ]
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = getelementptr inbounds i32*, i32** %6, i64 %11
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %21, %15 ]
%17 = load i32*, i32** %14
%18 = getelementptr inbounds i32, i32* %17, i64 %16
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %16, 1
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %15, label %25
25: ; preds = %15, %9
%26 = call i32 @putchar(i32 10)
%27 = add nuw nsw i64 %11, 1
%28 = load i32, i32* %1
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %9, label %31
31: ; preds = %25, %0
%32 = phi i32 [ %7, %0 ], [ %28, %25 ]
%33 = call i32 @cost(i32** %6, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %33)
ret i32 0
}