#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ prim(int, int **, int **, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *f;
  f = fopen("graph.txt", "r");
  if (f != NULL) {
    int v = 0;
    fscanf(f, "%d\n", &v);
    int a[10][10];
    int edges[10][2];
    int i, j, k, cost = 0;
    for (i = 0; i < v; i++)
      for (j = 0; j < v; j++) {
        fscanf(f, "%d", &a[i][j]);
      }
    printf("\nMatrix:\n");
    for (i = 0; i < v; i++) {
      for (j = 0; j < v; j++) {
        printf("%d ", a[i][j]);
      }
      printf("\n");
    }
    prim(v, a, edges, cost);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12ea <main+0x1aa>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
movl   $0x0,-0x210(%rbp)
movl   $0x0,-0x204(%rbp)
mov    -0x204(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122b <main+0xeb>
movl   $0x0,-0x208(%rbp)
mov    -0x208(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1212 <main+0xd2>
mov    -0x10(%rbp),%rdi
movslq -0x204(%rbp),%rax
lea    -0x1b0(%rbp),%rdx
imul   $0x28,%rax,%rax
add    %rax,%rdx
movslq -0x208(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe17(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x208(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208(%rbp)
jmp    11bc <main+0x7c>
jmp    1217 <main+0xd7>
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    11a3 <main+0x63>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x204(%rbp)
mov    -0x204(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ce <main+0x18e>
movl   $0x0,-0x208(%rbp)
mov    -0x208(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ac <main+0x16c>
movslq -0x204(%rbp),%rcx
lea    -0x1b0(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x208(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x208(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208(%rbp)
jmp    125c <main+0x11c>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    1243 <main+0x103>
mov    -0x14(%rbp),%edi
lea    -0x1b0(%rbp),%rsi
lea    -0x200(%rbp),%rdx
mov    -0x210(%rbp),%ecx
call   1030 <prim@plt>
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f8,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     129e <main+0x13e>
mov    %rax,%r15
movl   $0x0,0xc(%rsp)
lea    0xe6d(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1212 <main+0xb2>
lea    0x60(%rsp),%r12
xor    %r13d,%r13d
lea    0xe4d(%rip),%r14
jmp    11e0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %eax,%rcx
add    $0x1,%r13
add    $0x28,%r12
cmp    %rcx,%r13
jge    1212 <main+0xb2>
test   %eax,%eax
jle    11d0 <main+0x70>
mov    %r12,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11f0 <main+0x90>
jmp    11d0 <main+0x70>
lea    0xdfe(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    128d <main+0x12d>
lea    0x60(%rsp),%rbx
lea    0xde1(%rip),%r14
xor    %r15d,%r15d
jmp    125c <main+0xfc>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rdi
add    $0x28,%rbx
cmp    %rdi,%r15
jge    128d <main+0x12d>
test   %edi,%edi
jle    1240 <main+0xe0>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jl     1270 <main+0x110>
jmp    1240 <main+0xe0>
lea    0x60(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %ecx,%ecx
call   1050 <prim@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"graph.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d \00"
@str = [9 x i8] c"\0AMatrix:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [10 x i32]]
%3 = alloca [10 x [2 x i32]]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %58, label %6
6: ; preds = %0
%7 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%8 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = bitcast [10 x [10 x i32]]* %2 to i8*
%10 = bitcast [10 x [2 x i32]]* %3 to i8*
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %30
13: ; preds = %6, %25
%14 = phi i32 [ %26, %25 ], [ %11, %6 ]
%15 = phi i64 [ %28, %25 ], [ 0, %6 ]
%16 = icmp sgt i32 %14, 0
br i1 %16, label %17, label %25
17: ; preds = %13, %17
%18 = phi i64 [ %21, %17 ], [ 0, %13 ]
%19 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %2, i64 0, i64 %15, i64 %18
%20 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %19)
%21 = add nuw nsw i64 %18, 1
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %17, label %25
25: ; preds = %17, %13
%26 = phi i32 [ %14, %13 ], [ %22, %17 ]
%27 = sext i32 %26 to i64
%28 = add nuw nsw i64 %15, 1
%29 = icmp slt i64 %28, %27
br i1 %29, label %13, label %30
30: ; preds = %25, %6
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%32 = load i32, i32* %1
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %53
34: ; preds = %30, %47
%35 = phi i32 [ %50, %47 ], [ %32, %30 ]
%36 = phi i64 [ %49, %47 ], [ 0, %30 ]
%37 = icmp sgt i32 %35, 0
br i1 %37, label %38, label %47
38: ; preds = %34, %38
%39 = phi i64 [ %43, %38 ], [ 0, %34 ]
%40 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %2, i64 0, i64 %36, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %41)
%43 = add nuw nsw i64 %39, 1
%44 = load i32, i32* %1
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %43, %45
br i1 %46, label %38, label %47
47: ; preds = %38, %34
%48 = call i32 @putchar(i32 10)
%49 = add nuw nsw i64 %36, 1
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %49, %51
br i1 %52, label %34, label %53
53: ; preds = %47, %30
%54 = phi i32 [ %32, %30 ], [ %50, %47 ]
%55 = bitcast [10 x [10 x i32]]* %2 to i32**
%56 = bitcast [10 x [2 x i32]]* %3 to i32**
%57 = call i32 @prim(i32 %54, i32** %55, i32** %56, i32 0)
br label %58
58: ; preds = %53, %0
%59 = call i32 @putchar(i32 10)
ret i32 0
}