#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 dijkstra(int const **, int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  int source = 0;
  int destination = 4;
  const int graph[8][8] = {
      {0, 4, 0, 0, 0, 0, 0, 8},  {4, 0, 8, 0, 0, 0, 0, 11},
      {0, 8, 0, 7, 0, 4, 0, 0},  {0, 0, 7, 0, 9, 14, 0, 0},
      {0, 0, 0, 9, 0, 10, 0, 0}, {0, 0, 4, 14, 10, 0, 2, 0},
      {0, 0, 0, 0, 0, 2, 0, 1},  {8, 11, 0, 0, 0, 0, 1, 0},
  };
  printf("The minimum distance from %d to %d is %d\n", source, destination,
         dijkstra(graph, source, destination));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xea2(%rip),%rsi
mov    $0x100,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <dijkstra@plt>
mov    -0x118(%rbp),%esi
mov    -0x114(%rbp),%edx
mov    %eax,%ecx
lea    0xf5f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xec1(%rip),%rsi
mov    %rsp,%rbx
mov    $0x100,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <dijkstra@plt>
lea    0xf9b(%rip),%rdi
xor    %esi,%esi
mov    $0x4,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.graph = [8 x [8 x i32]] [[8 x i32] [i32 0, i32 4, i32 0, i32 0, i32 0, i32 0, i32 0, i32 8], [8 x i32] [i32 4, i32 0, i32 8, i32 0, i32 0, i32 0, i32 0, i32 11], [8 x i32] [i32 0, i32 8, i32 0, i32 7, i32 0, i32 4, i32 0, i32 0], [8 x i32] [i32 0, i32 0, i32 7, i32 0, i32 9, i32 14, i32 0, i32 0], [8 x i32] [i32 0, i32 0, i32 0, i32 9, i32 0, i32 10, i32 0, i32 0], [8 x i32] [i32 0, i32 0, i32 4, i32 14, i32 10, i32 0, i32 2, i32 0], [8 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, i32 0, i32 1], [8 x i32] [i32 8, i32 11, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0]]
@.str = [42 x i8] c"The minimum distance from %d to %d is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x [8 x i32]]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 4, i32* %3
%5 = bitcast [8 x [8 x i32]]* %4 to i8*
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %4, i64 0, i64 0
%9 = bitcast [8 x i32]* %8 to i32**
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 @dijkstra(i32** %9, i32 %10, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7, i32 %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.graph = [8 x [8 x i32]] [[8 x i32] [i32 0, i32 4, i32 0, i32 0, i32 0, i32 0, i32 0, i32 8], [8 x i32] [i32 4, i32 0, i32 8, i32 0, i32 0, i32 0, i32 0, i32 11], [8 x i32] [i32 0, i32 8, i32 0, i32 7, i32 0, i32 4, i32 0, i32 0], [8 x i32] [i32 0, i32 0, i32 7, i32 0, i32 9, i32 14, i32 0, i32 0], [8 x i32] [i32 0, i32 0, i32 0, i32 9, i32 0, i32 10, i32 0, i32 0], [8 x i32] [i32 0, i32 0, i32 4, i32 14, i32 10, i32 0, i32 2, i32 0], [8 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, i32 0, i32 1], [8 x i32] [i32 8, i32 11, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0]]
@.str = [42 x i8] c"The minimum distance from %d to %d is %d\0A\00"
define i32 @main() {
%1 = alloca [8 x [8 x i32]]
%2 = bitcast [8 x [8 x i32]]* %1 to i8*
%3 = bitcast [8 x [8 x i32]]* %1 to i32**
%4 = call i32 @dijkstra(i32** %3, i32 0, i32 4)
%5 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 0, i32 4, i32 %4)
ret i32 0
}