#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 /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ prims(int **, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int G[5][5] = {{0, 2, 0, 6, 0},
                 {2, 0, 3, 8, 5},
                 {0, 3, 0, 0, 7},
                 {6, 8, 0, 0, 9},
                 {0, 5, 7, 9, 0}};
  int i, j;
  int parent[5];
  memset(parent, 0, 5);
  printf("Edge\tWeight\n");
  prims(G, parent);
  for (i = 1; i < 5; ++i) {
    printf("%d - %d\t%d \n", parent[i], i, G[i][parent[i]]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1060 <prims@plt>
movl   $0x1,-0x74(%rbp)
cmpl   $0x5,-0x74(%rbp)
jge    11f1 <main+0xb1>
movslq -0x74(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
mov    -0x74(%rbp),%edx
movslq -0x74(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x74(%rbp),%rcx
movslq -0x90(%rbp,%rcx,4),%rcx
ff
mov    (%rax,%rcx,4),%ecx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    119f <main+0x5f>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
mov    0xf12(%rip),%eax
mov    %eax,0x80(%rsp)
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe68(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <prims@plt>
movslq 0x4(%rsp),%rsi
mov    0x34(%rsp,%rsi,4),%ecx
lea    0xe8c(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
mov    0x48(%rsp,%rsi,4),%ecx
mov    %rbx,%rdi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rsi
mov    0x5c(%rsp,%rsi,4),%ecx
mov    %rbx,%rdi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x10(%rsp),%rsi
mov    0x70(%rsp,%rsi,4),%ecx
mov    %rbx,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.G = [5 x [5 x i32]] [[5 x i32] [i32 0, i32 2, i32 0, i32 6, i32 0], [5 x i32] [i32 2, i32 0, i32 3, i32 8, i32 5], [5 x i32] [i32 0, i32 3, i32 0, i32 0, i32 7], [5 x i32] [i32 6, i32 8, i32 0, i32 0, i32 9], [5 x i32] [i32 0, i32 5, i32 7, i32 9, i32 0]]
@.str = [13 x i8] c"Edge\09Weight\0A\00"
@.str.1 = [13 x i8] c"%d - %d\09%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x [5 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x i32]
store i32 0, i32* %1
%6 = bitcast [5 x [5 x i32]]* %2 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%8 = call i32 @memset(i32* %7, i32 0, i32 5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 0
%11 = bitcast [5 x i32]* %10 to i32**
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%13 = call i32 @prims(i32** %11, i32* %12)
store i32 1, i32* %3
br label %14
14: ; preds = %34, %0
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %37
17: ; preds = %14
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %3
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 %24
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %25, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %32)
br label %34
34: ; preds = %17
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %14
37: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@__const.main.G = [5 x [5 x i32]] [[5 x i32] [i32 0, i32 2, i32 0, i32 6, i32 0], [5 x i32] [i32 2, i32 0, i32 3, i32 8, i32 5], [5 x i32] [i32 0, i32 3, i32 0, i32 0, i32 7], [5 x i32] [i32 6, i32 8, i32 0, i32 0, i32 9], [5 x i32] [i32 0, i32 5, i32 7, i32 9, i32 0]]
@.str.1 = [13 x i8] c"%d - %d\09%d \0A\00"
@str = [12 x i8] c"Edge\09Weight\00"
define i32 @main() {
%1 = alloca [5 x [5 x i32]]
%2 = alloca [5 x i32]
%3 = bitcast [5 x [5 x i32]]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%6 = call i32 @memset(i32* %5, i32 0, i32 5)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%8 = bitcast [5 x [5 x i32]]* %1 to i32**
%9 = call i32 @prims(i32** %8, i32* %5)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 1
%11 = load i32, i32* %10
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 1, i64 %12
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 1, i32 %14)
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 2
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 2, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 2, i32 %20)
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 3, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 3, i32 %26)
%28 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 4
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 4, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 4, i32 %32)
ret i32 0
}