#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ mstPrim(int, int **, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *pf;
  pf = fopen("graph.txt", "r");
  if (pf != NULL) {
    int V;
    fscanf(pf, "%d\n", &V);
    int graph[V][V];
    int i, j;
    for (i = 0; i < V; i++)
      for (j = 0; j < V; j++)
        fscanf(pf, "%d ", &graph[i][j]);
    fclose(pf);
    mstPrim(V, graph, 0);
  } else
    printf("file not found / return");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     126c <main+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe80(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1249 <main+0xf9>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1236 <main+0xe6>
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x10(%rbp),%rdi
movslq -0x34(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rdx
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xded(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11ea <main+0x9a>
jmp    123b <main+0xeb>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d7 <main+0x87>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edi
xor    %edx,%edx
call   1040 <mstPrim@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    1278 <main+0x128>
lea    0xda1(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe98(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1241 <main+0xf1>
mov    %rax,%r12
lea    0xe85(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %rsp,-0x48(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rax,-0x40(%rbp)
imul   %rax,%rax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    1225 <main+0xd5>
shlq   $0x2,-0x40(%rbp)
xor    %r14d,%r14d
lea    0xe3f(%rip),%r15
mov    -0x38(%rbp),%rbx
jmp    11f0 <main+0xa0>
nopw   0x0(%rax,%rax,1)
movslq %eax,%rcx
add    $0x1,%r14
add    -0x40(%rbp),%rbx
cmp    %rcx,%r14
jge    1225 <main+0xd5>
test   %eax,%eax
jle    11e0 <main+0x90>
mov    %rbx,-0x50(%rbp)
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     1200 <main+0xb0>
mov    -0x50(%rbp),%rbx
jmp    11e0 <main+0x90>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1040 <mstPrim@plt>
mov    -0x48(%rbp),%rsp
jmp    124d <main+0xfd>
lea    0xdcc(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%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 = [4 x i8] c"%d \00"
@.str.4 = [24 x i8] c"file not found / return\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = 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* %9, i32** %2
%10 = load i32*, i32** %2
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %55
12: ; preds = %0
%13 = load i32*, i32** %2
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = zext i32 %15 to i64
%17 = load i32, i32* %3
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %4
%20 = mul nuw i64 %16, %18
%21 = alloca i32, i64 %20
store i64 %16, i64* %5
store i64 %18, i64* %6
store i32 0, i32* %7
br label %22
22: ; preds = %45, %12
%23 = load i32, i32* %7
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %48
26: ; preds = %22
store i32 0, i32* %8
br label %27
27: ; preds = %41, %26
%28 = load i32, i32* %8
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %44
31: ; preds = %27
%32 = load i32*, i32** %2
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = mul nsw i64 %34, %18
%36 = getelementptr inbounds i32, i32* %21, i64 %35
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %39)
br label %41
41: ; preds = %31
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %27
44: ; preds = %27
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %22
48: ; preds = %22
%49 = load i32*, i32** %2
%50 = call i32 @fclose(i32* %49)
%51 = load i32, i32* %3
%52 = bitcast i32* %21 to i32**
%53 = call i32 @mstPrim(i32 %51, i32** %52, i32 0)
%54 = load i8*, i8** %4
br label %57
55: ; preds = %0
%56 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %48
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 = [4 x i8] c"%d \00"
@.str.4 = [24 x i8] c"file not found / return\00"
define i32 @main() {
%1 = alloca i32
%2 = 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))
%3 = icmp eq i32* %2, null
br i1 %3, label %39, label %4
4: ; preds = %0
%5 = bitcast i32* %1 to i8*
%6 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = mul nuw i64 %8, %8
%11 = alloca i32, i64 %10
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %4, %29
%15 = phi i32 [ %30, %29 ], [ %12, %4 ]
%16 = phi i64 [ %32, %29 ], [ 0, %4 ]
%17 = icmp sgt i32 %15, 0
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = mul nuw nsw i64 %16, %8
%20 = getelementptr inbounds i32, i32* %11, i64 %19
br label %21
21: ; preds = %18, %21
%22 = phi i64 [ 0, %18 ], [ %25, %21 ]
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %22, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %21, label %29
29: ; preds = %21, %14
%30 = phi i32 [ %15, %14 ], [ %26, %21 ]
%31 = sext i32 %30 to i64
%32 = add nuw nsw i64 %16, 1
%33 = icmp slt i64 %32, %31
br i1 %33, label %14, label %34
34: ; preds = %29, %4
%35 = call i32 @fclose(i32* %2)
%36 = load i32, i32* %1
%37 = bitcast i32* %11 to i32**
%38 = call i32 @mstPrim(i32 %36, i32** %37, i32 0)
br label %41
39: ; preds = %0
%40 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %34
ret i32 0
}