#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*/ assert(int);
int dijkstra(int **, int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  int graph[9][9] = {
      {0, 4, 0, 0, 0, 0, 0, 8, 0},  {4, 0, 8, 0, 0, 0, 0, 11, 0},
      {0, 8, 0, 7, 0, 4, 0, 0, 2},  {0, 0, 7, 0, 9, 14, 0, 0, 0},
      {0, 0, 0, 9, 0, 10, 0, 0, 0}, {0, 0, 4, 14, 10, 0, 2, 0, 0},
      {0, 0, 0, 0, 0, 2, 0, 1, 6},  {8, 11, 0, 0, 0, 0, 1, 0, 7},
      {0, 0, 2, 0, 0, 0, 6, 7, 0}};
  printf("\nThe ditance from vertex %d to vertex %d is: %d\n", 0, 4,
         dijkstra(graph, 0, 4));
  assert(dijkstra(graph, 0, 4) == 21);
  printf("The ditance from vertex %d to vertex %d is: %d\n", 4, 0,
         dijkstra(graph, 4, 0));
  assert(dijkstra(graph, 4, 0) == 21);
  printf("The ditance from vertex %d to vertex %d is: %d\n", 1, 5,
         dijkstra(graph, 1, 5));
  assert(dijkstra(graph, 1, 5) == 12);
  printf("The ditance from vertex %d to vertex %d is: %d\n", 3, 7,
         dijkstra(graph, 3, 7));
  assert(dijkstra(graph, 3, 7) == 14);
  printf("The ditance from vertex %d to vertex %d is: %d\n\n", 1, 6,
         dijkstra(graph, 1, 6));
  assert(dijkstra(graph, 1, 6) == 12);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x150(%rbp),%rdi
lea    0xea0(%rip),%rsi
mov    $0x144,%edx
call   1050 <memcpy@plt>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <dijkstra@plt>
mov    %eax,%ecx
lea    0xfbe(%rip),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <dijkstra@plt>
cmp    $0x15,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x150(%rbp),%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <dijkstra@plt>
mov    %eax,%ecx
lea    0xf74(%rip),%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <dijkstra@plt>
cmp    $0x15,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x150(%rbp),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1060 <dijkstra@plt>
mov    %eax,%ecx
lea    0xf26(%rip),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1060 <dijkstra@plt>
cmp    $0xc,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x150(%rbp),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1060 <dijkstra@plt>
mov    %eax,%ecx
lea    0xed2(%rip),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1060 <dijkstra@plt>
cmp    $0xe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x150(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1060 <dijkstra@plt>
mov    %eax,%ecx
lea    0xeae(%rip),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1060 <dijkstra@plt>
cmp    $0xc,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x148,%rsp
lea    0xeaf(%rip),%rsi
mov    %rsp,%rbx
mov    $0x144,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <dijkstra@plt>
lea    0xfcd(%rip),%rdi
xor    %esi,%esi
mov    $0x4,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <dijkstra@plt>
xor    %edi,%edi
cmp    $0x15,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <dijkstra@plt>
lea    0xf8d(%rip),%r14
mov    %r14,%rdi
mov    $0x4,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <dijkstra@plt>
xor    %edi,%edi
cmp    $0x15,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1060 <dijkstra@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1060 <dijkstra@plt>
xor    %edi,%edi
cmp    $0xc,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1060 <dijkstra@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1060 <dijkstra@plt>
xor    %edi,%edi
cmp    $0xe,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1060 <dijkstra@plt>
lea    0xeea(%rip),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1060 <dijkstra@plt>
xor    %edi,%edi
cmp    $0xc,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.graph = [9 x [9 x i32]] [[9 x i32] [i32 0, i32 4, i32 0, i32 0, i32 0, i32 0, i32 0, i32 8, i32 0], [9 x i32] [i32 4, i32 0, i32 8, i32 0, i32 0, i32 0, i32 0, i32 11, i32 0], [9 x i32] [i32 0, i32 8, i32 0, i32 7, i32 0, i32 4, i32 0, i32 0, i32 2], [9 x i32] [i32 0, i32 0, i32 7, i32 0, i32 9, i32 14, i32 0, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 0, i32 9, i32 0, i32 10, i32 0, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 4, i32 14, i32 10, i32 0, i32 2, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, i32 0, i32 1, i32 6], [9 x i32] [i32 8, i32 11, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 7], [9 x i32] [i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 6, i32 7, i32 0]]
@.str = [49 x i8] c"\0AThe ditance from vertex %d to vertex %d is: %d\0A\00"
@.str.1 = [48 x i8] c"The ditance from vertex %d to vertex %d is: %d\0A\00"
@.str.2 = [49 x i8] c"The ditance from vertex %d to vertex %d is: %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x [9 x i32]]
store i32 0, i32* %1
%3 = bitcast [9 x [9 x i32]]* %2 to i8*
%4 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%5 = bitcast [9 x i32]* %4 to i32**
%6 = call i32 @dijkstra(i32** %5, i32 0, i32 4)
%7 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 0, i32 4, i32 %6)
%8 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%9 = bitcast [9 x i32]* %8 to i32**
%10 = call i32 @dijkstra(i32** %9, i32 0, i32 4)
%11 = icmp eq i32 %10, 21
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%15 = bitcast [9 x i32]* %14 to i32**
%16 = call i32 @dijkstra(i32** %15, i32 4, i32 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 0, i32 %16)
%18 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%19 = bitcast [9 x i32]* %18 to i32**
%20 = call i32 @dijkstra(i32** %19, i32 4, i32 0)
%21 = icmp eq i32 %20, 21
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%25 = bitcast [9 x i32]* %24 to i32**
%26 = call i32 @dijkstra(i32** %25, i32 1, i32 5)
%27 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 5, i32 %26)
%28 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%29 = bitcast [9 x i32]* %28 to i32**
%30 = call i32 @dijkstra(i32** %29, i32 1, i32 5)
%31 = icmp eq i32 %30, 12
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%35 = bitcast [9 x i32]* %34 to i32**
%36 = call i32 @dijkstra(i32** %35, i32 3, i32 7)
%37 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 7, i32 %36)
%38 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%39 = bitcast [9 x i32]* %38 to i32**
%40 = call i32 @dijkstra(i32** %39, i32 3, i32 7)
%41 = icmp eq i32 %40, 14
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%45 = bitcast [9 x i32]* %44 to i32**
%46 = call i32 @dijkstra(i32** %45, i32 1, i32 6)
%47 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 6, i32 %46)
%48 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %2, i64 0, i64 0
%49 = bitcast [9 x i32]* %48 to i32**
%50 = call i32 @dijkstra(i32** %49, i32 1, i32 6)
%51 = icmp eq i32 %50, 12
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
ret i32 0
}

LLVM IR (-O2):
@__const.main.graph = [9 x [9 x i32]] [[9 x i32] [i32 0, i32 4, i32 0, i32 0, i32 0, i32 0, i32 0, i32 8, i32 0], [9 x i32] [i32 4, i32 0, i32 8, i32 0, i32 0, i32 0, i32 0, i32 11, i32 0], [9 x i32] [i32 0, i32 8, i32 0, i32 7, i32 0, i32 4, i32 0, i32 0, i32 2], [9 x i32] [i32 0, i32 0, i32 7, i32 0, i32 9, i32 14, i32 0, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 0, i32 9, i32 0, i32 10, i32 0, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 4, i32 14, i32 10, i32 0, i32 2, i32 0, i32 0], [9 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, i32 0, i32 1, i32 6], [9 x i32] [i32 8, i32 11, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 7], [9 x i32] [i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 6, i32 7, i32 0]]
@.str = [49 x i8] c"\0AThe ditance from vertex %d to vertex %d is: %d\0A\00"
@.str.1 = [48 x i8] c"The ditance from vertex %d to vertex %d is: %d\0A\00"
@.str.2 = [49 x i8] c"The ditance from vertex %d to vertex %d is: %d\0A\0A\00"
define i32 @main() {
%1 = alloca [9 x [9 x i32]]
%2 = bitcast [9 x [9 x i32]]* %1 to i8*
%3 = bitcast [9 x [9 x i32]]* %1 to i32**
%4 = call i32 @dijkstra(i32** %3, i32 0, i32 4)
%5 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 0, i32 4, i32 %4)
%6 = call i32 @dijkstra(i32** %3, i32 0, i32 4)
%7 = icmp eq i32 %6, 21
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @dijkstra(i32** %3, i32 4, i32 0)
%11 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 0, i32 %10)
%12 = call i32 @dijkstra(i32** %3, i32 4, i32 0)
%13 = icmp eq i32 %12, 21
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @dijkstra(i32** %3, i32 1, i32 5)
%17 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 5, i32 %16)
%18 = call i32 @dijkstra(i32** %3, i32 1, i32 5)
%19 = icmp eq i32 %18, 12
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @dijkstra(i32** %3, i32 3, i32 7)
%23 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 7, i32 %22)
%24 = call i32 @dijkstra(i32** %3, i32 3, i32 7)
%25 = icmp eq i32 %24, 14
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call i32 @dijkstra(i32** %3, i32 1, i32 6)
%29 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 6, i32 %28)
%30 = call i32 @dijkstra(i32** %3, i32 1, i32 6)
%31 = icmp eq i32 %30, 12
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
ret i32 0
}