#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*/ Djikstra(int **, int *, int *, int);
int INT_MAX;
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int **readmat(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int **(adj_mat);
  int *visited, *minvalues;
  int sizegr, i;
  printf("Please specify the number of vertices in the graph: ");
  scanf("%d", &sizegr);
  adj_mat = readmat(sizegr);
  visited = (int *)malloc(sizeof(int) * sizegr);
  minvalues = (int *)malloc(sizeof(int) * sizegr);
  for (i = 0; i < sizegr; i++) {
    *(minvalues + i) = INT_MAX;
  }
  for (i = 0; i < sizegr; i++) {
    *(visited + i) = 0;
  }
  Djikstra(adj_mat, visited, minvalues, sizegr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x24(%rbp),%edi
call   1070 <readmat@plt>
mov    %rax,-0x10(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e2 <main+0x92>
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b4 <main+0x64>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1212 <main+0xc2>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e9 <main+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <Djikstra@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
call   1070 <readmat@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
jle    11e5 <main+0x95>
xor    %edx,%edx
mov    0x2e3f(%rip),%rsi
nopl   0x0(%rax)
mov    (%rsi),%ecx
mov    %ecx,(%rax,%rdx,4)
add    $0x1,%rdx
movslq 0x4(%rsp),%rcx
cmp    %rcx,%rdx
jl     11b0 <main+0x60>
test   %ecx,%ecx
jle    11e5 <main+0x95>
xor    %edx,%edx
nopl   0x0(%rax)
movl   $0x0,(%rbx,%rdx,4)
add    $0x1,%rdx
movslq 0x4(%rsp),%rcx
cmp    %rcx,%rdx
jl     11d0 <main+0x80>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <Djikstra@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Please specify the number of vertices in the graph: \00"
@.str.1 = [3 x i8] c"%d\00"
@INT_MAX = global i32 0
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 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = call i32** @readmat(i32 %9)
store i32** %10, i32*** %2
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = mul i64 4, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %4
store i32 0, i32* %6
br label %23
23: ; preds = %33, %0
%24 = load i32, i32* %6
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* @INT_MAX
%29 = load i32*, i32** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %27
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %23
36: ; preds = %23
store i32 0, i32* %6
br label %37
37: ; preds = %46, %36
%38 = load i32, i32* %6
%39 = load i32, i32* %5
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = load i32*, i32** %3
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 0, i32* %45
br label %46
46: ; preds = %41
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %37
49: ; preds = %37
%50 = load i32**, i32*** %2
%51 = load i32*, i32** %3
%52 = load i32*, i32** %4
%53 = load i32, i32* %5
%54 = call i32 @Djikstra(i32** %50, i32* %51, i32* %52, i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [53 x i8] c"Please specify the number of vertices in the graph: \00"
@.str.1 = [3 x i8] c"%d\00"
@INT_MAX = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32** @readmat(i32 %5)
%7 = load i32, i32* %1
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = load i32, i32* %1
%12 = shl i32 %11, 2
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %19, label %34
17: ; preds = %19
%18 = icmp sgt i32 %24, 0
br i1 %18, label %27, label %34
19: ; preds = %0, %19
%20 = phi i64 [ %23, %19 ], [ 0, %0 ]
%21 = load i32, i32* @INT_MAX
%22 = getelementptr inbounds i32, i32* %14, i64 %20
store i32 %21, i32* %22
%23 = add nuw nsw i64 %20, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %19, label %17
27: ; preds = %17, %27
%28 = phi i64 [ %30, %27 ], [ 0, %17 ]
%29 = getelementptr inbounds i32, i32* %10, i64 %28
store i32 0, i32* %29
%30 = add nuw nsw i64 %28, 1
%31 = load i32, i32* %1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %27, label %34
34: ; preds = %27, %0, %17
%35 = phi i32 [ %24, %17 ], [ %15, %0 ], [ %31, %27 ]
%36 = call i32 @Djikstra(i32** %6, i32* %10, i32* %14, i32 %35)
ret i32 0
}