#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*/ dijkstra(int **, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num_nodes, adjacency[20][20], source;
  printf("Number of nodes : ");
  scanf("%d", &num_nodes);
  printf("Enter the source : ");
  scanf("%d", &source);
  source -= 1;
  printf("Enter the cost adjacency matrix : \n");
  for (int i = 0; i < num_nodes; i++)
    for (int j = 0; j < num_nodes; j++)
      scanf("%d", &adjacency[i][j]);
  dijkstra(adjacency, num_nodes, source);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x654(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x654(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x654(%rbp)
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x658(%rbp)
mov    -0x658(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1226 <main+0xf6>
movl   $0x0,-0x65c(%rbp)
mov    -0x65c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120d <main+0xdd>
movslq -0x658(%rbp),%rax
lea    -0x650(%rbp),%rsi
imul   $0x50,%rax,%rax
add    %rax,%rsi
movslq -0x65c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe1f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x65c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x65c(%rbp)
jmp    11bb <main+0x8b>
jmp    1212 <main+0xe2>
mov    -0x658(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x658(%rbp)
jmp    11a2 <main+0x72>
lea    -0x650(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x654(%rbp),%edx
call   1050 <dijkstra@plt>
xor    %eax,%eax
add    $0x660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x650,%rsp
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb0(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
addl   $0xffffffff,0x8(%rsp)
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11ff <main+0xbf>
lea    0x10(%rsp),%r15
xor    %r12d,%r12d
lea    0xe62(%rip),%r14
jmp    11d0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %esi,%rax
add    $0x1,%r12
add    $0x50,%r15
cmp    %rax,%r12
jge    11ff <main+0xbf>
test   %esi,%esi
jle    11c0 <main+0x80>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11e0 <main+0xa0>
jmp    11c0 <main+0x80>
mov    0x8(%rsp),%edx
lea    0x10(%rsp),%rdi
call   1060 <dijkstra@plt>
xor    %eax,%eax
add    $0x650,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Number of nodes : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter the source : \00"
@.str.3 = [36 x i8] c"Enter the cost adjacency matrix : \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x [20 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 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* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %4
%13 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %14
14: ; preds = %35, %0
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %38
18: ; preds = %14
store i32 0, i32* %6
br label %19
19: ; preds = %31, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 %25
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %26, i64 0, i64 %28
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %19
34: ; preds = %19
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %14
38: ; preds = %14
%39 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 0
%40 = bitcast [20 x i32]* %39 to i32**
%41 = load i32, i32* %2
%42 = load i32, i32* %4
%43 = call i32 @dijkstra(i32** %40, i32 %41, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Number of nodes : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter the source : \00"
@str = [35 x i8] c"Enter the cost adjacency matrix : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x [20 x i32]]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast [20 x [20 x i32]]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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* %1)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %0, %25
%17 = phi i32 [ %26, %25 ], [ %14, %0 ]
%18 = phi i64 [ %28, %25 ], [ 0, %0 ]
%19 = icmp sgt i32 %17, 0
br i1 %19, label %30, label %25
20: ; preds = %25, %0
%21 = phi i32 [ %14, %0 ], [ %26, %25 ]
%22 = bitcast [20 x [20 x i32]]* %2 to i32**
%23 = load i32, i32* %3
%24 = call i32 @dijkstra(i32** %22, i32 %21, i32 %23)
ret i32 0
25: ; preds = %30, %16
%26 = phi i32 [ %17, %16 ], [ %35, %30 ]
%27 = sext i32 %26 to i64
%28 = add nuw nsw i64 %18, 1
%29 = icmp slt i64 %28, %27
br i1 %29, label %16, label %20
30: ; preds = %16, %30
%31 = phi i64 [ %34, %30 ], [ 0, %16 ]
%32 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %2, i64 0, i64 %18, i64 %31
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32)
%34 = add nuw nsw i64 %31, 1
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %30, label %25
}