#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*/ dij(int, int **, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int n, src, i, j, cost[10][10], dist[10];
  printf("Enter the number of vertices \n");
  scanf("%d", &n);
  printf("Enter cost matrix:\n");
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      scanf("%d", &cost[i][j]);
  printf("Enter the source vertex\n");
  scanf("%d", &src);
  dij(src, cost, dist, n);
  printf("The Shortest path to source %d to other vertices are \n", src);
  for (i = 1; i <= n; i++)
    printf("to %d = %d \n", i, dist[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11e5 <main+0xb5>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11d2 <main+0xa2>
movslq -0x1c(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe60(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118f <main+0x5f>
jmp    11d7 <main+0xa7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <main+0x4c>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%edi
lea    -0x1b0(%rbp),%rsi
lea    -0x1e0(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1040 <dij@plt>
mov    -0x18(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     126a <main+0x13a>
mov    -0x1c(%rbp),%esi
movslq -0x1c(%rbp),%rax
mov    -0x1e0(%rbp,%rax,4),%edx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1234 <main+0x104>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d0,%rsp
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9d(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    11df <main+0x9f>
lea    0x6c(%rsp),%r15
mov    $0x1,%r12d
lea    0xe6d(%rip),%r14
jmp    11b4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %eax,%rcx
lea    0x1(%r12),%rdx
add    $0x28,%r15
cmp    %rcx,%r12
mov    %rdx,%r12
jge    11df <main+0x9f>
test   %eax,%eax
jle    11a0 <main+0x60>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbx
add    $0x4,%r13
cmp    %rax,%rbx
jl     11c0 <main+0x80>
jmp    11a0 <main+0x60>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%ecx
lea    0x40(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1050 <dij@plt>
mov    0xc(%rsp),%esi
lea    0xde5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1261 <main+0x121>
mov    $0x1,%ebx
lea    0xe02(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbx),%rax
movslq 0x8(%rsp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1240 <main+0x100>
xor    %eax,%eax
add    $0x1d0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter the number of vertices \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter cost matrix:\0A\00"
@.str.3 = [25 x i8] c"Enter the source vertex\0A\00"
@.str.4 = [55 x i8] c"The Shortest path to source %d to other vertices are \0A\00"
@.str.5 = [13 x i8] c"to %d = %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10 x [10 x i32]]
%11 = alloca [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %8
br label %15
15: ; preds = %36, %2
%16 = load i32, i32* %8
%17 = load i32, i32* %6
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %39
19: ; preds = %15
store i32 1, i32* %9
br label %20
20: ; preds = %32, %19
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %10, i64 0, i64 %26
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %27, i64 0, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
br label %32
32: ; preds = %24
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %20
35: ; preds = %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %15
39: ; preds = %15
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%42 = load i32, i32* %7
%43 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %10, i64 0, i64 0
%44 = bitcast [10 x i32]* %43 to i32**
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 0
%46 = load i32, i32* %6
%47 = call i32 @dij(i32 %42, i32** %44, i32* %45, i32 %46)
%48 = load i32, i32* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %48)
store i32 1, i32* %8
br label %50
50: ; preds = %61, %39
%51 = load i32, i32* %8
%52 = load i32, i32* %6
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %64
54: ; preds = %50
%55 = load i32, i32* %8
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %55, i32 %59)
br label %61
61: ; preds = %54
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %50
64: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [55 x i8] c"The Shortest path to source %d to other vertices are \0A\00"
@.str.5 = [13 x i8] c"to %d = %d \0A\00"
@str = [30 x i8] c"Enter the number of vertices \00"
@str.6 = [19 x i8] c"Enter cost matrix:\00"
@str.7 = [24 x i8] c"Enter the source vertex\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x [10 x i32]]
%6 = alloca [10 x i32]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast [10 x [10 x i32]]* %5 to i8*
%10 = bitcast [10 x i32]* %6 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 1
br i1 %15, label %33, label %16
16: ; preds = %2, %28
%17 = phi i32 [ %29, %28 ], [ %14, %2 ]
%18 = phi i64 [ %31, %28 ], [ 1, %2 ]
%19 = icmp slt i32 %17, 1
br i1 %19, label %28, label %20
20: ; preds = %16, %20
%21 = phi i64 [ %24, %20 ], [ 1, %16 ]
%22 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %5, i64 0, i64 %18, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %21, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %21, %26
br i1 %27, label %20, label %28
28: ; preds = %20, %16
%29 = phi i32 [ %17, %16 ], [ %25, %20 ]
%30 = sext i32 %29 to i64
%31 = add nuw nsw i64 %18, 1
%32 = icmp slt i64 %18, %30
br i1 %32, label %16, label %33
33: ; preds = %28, %2
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%36 = load i32, i32* %4
%37 = bitcast [10 x [10 x i32]]* %5 to i32**
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%39 = load i32, i32* %3
%40 = call i32 @dij(i32 %36, i32** %37, i32* %38, i32 %39)
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %3
%44 = icmp slt i32 %43, 1
br i1 %44, label %55, label %45
45: ; preds = %33, %45
%46 = phi i64 [ %51, %45 ], [ 1, %33 ]
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = trunc i64 %46 to i32
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %49, i32 %48)
%51 = add nuw nsw i64 %46, 1
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = icmp slt i64 %46, %53
br i1 %54, label %45, label %55
55: ; preds = %45, %33
ret i32 0
}