#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ check_input(int *);
int /*<<< orphan*/ dijkstra(int **, int, int, int *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ print_path(int, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int /*<<< orphan*/ stderr;
int str_to_int(char *);
char *strtok(char *, char *);
int main() {
  char buf[1000];
  char *buffer;
  int weight[12][12], precede[12], dist;
  FILE *File = fopen("matrix.txt", "r");
  if (File == NULL) {
    fprintf(stderr, "%s\n", "No file given!");
    exit(EXIT_FAILURE);
  }
  int c, i = 0;
  while ((c = fgetc(File)) != EOF) {
    if ((c >= '0' && c <= '9') || (c == ' '))
      buf[i++] = c;
    else if (c == '\t' || c == '\n' || c == '\r')
      buf[i++] = ' ';
  }
  buf[i] = '\0';
  fclose(File);
  buffer = strtok(buf, " ");
  for (int i = 0; i < 12; i++) {
    for (int j = 0; j < 12; j++) {
      weight[i][j] = str_to_int(buffer);
      buffer = strtok(NULL, " ");
    }
  }
  for (int i = 0; i < 12; i++) {
    for (int j = 0; j < 12; j++) {
      printf("%4d ", weight[i][j]);
    }
    printf("\n");
  }
  printf("\nEnter the starting node and the end node : ");
  int start, stop;
  scanf(" %d %d", &start, &stop);
  int values[] = {start, stop};
  check_input(values);
  dijkstra(weight, start, stop, &dist, precede);
  print_path(start, stop, precede);
  printf("The shortest distance from node %d to %d is : %d\n", start, stop,
         dist);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe27(%rip),%rdi
lea    0xe2b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x680(%rbp)
cmpq   $0x0,-0x680(%rbp)
jne    1224 <main+0x64>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
lea    0xe00(%rip),%rdx
call   1080 <fprintf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
movl   $0x0,-0x688(%rbp)
mov    -0x680(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x684(%rbp)
mov    0x2da1(%rip),%rcx
cmp    (%rcx),%eax
je     12e9 <main+0x129>
cmpl   $0x30,-0x684(%rbp)
jl     1269 <main+0xa9>
cmpl   $0x39,-0x684(%rbp)
jle    1276 <main+0xb6>
cmpl   $0x20,-0x684(%rbp)
jne    129d <main+0xdd>
mov    -0x684(%rbp),%eax
mov    %al,%cl
mov    -0x688(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x688(%rbp)
cltq
mov    %cl,-0x3f0(%rbp,%rax,1)
jmp    12e4 <main+0x124>
cmpl   $0x9,-0x684(%rbp)
je     12c4 <main+0x104>
cmpl   $0xa,-0x684(%rbp)
je     12c4 <main+0x104>
cmpl   $0xd,-0x684(%rbp)
jne    12df <main+0x11f>
mov    -0x688(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x688(%rbp)
cltq
movb   $0x20,-0x3f0(%rbp,%rax,1)
20
jmp    12e4 <main+0x124>
jmp    122e <main+0x6e>
movslq -0x688(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
mov    -0x680(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x3f0(%rbp),%rdi
lea    0xd3e(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x3f8(%rbp)
movl   $0x0,-0x68c(%rbp)
cmpl   $0xc,-0x68c(%rbp)
jge    13bd <main+0x1fd>
movl   $0x0,-0x690(%rbp)
cmpl   $0xc,-0x690(%rbp)
jge    13a4 <main+0x1e4>
mov    -0x3f8(%rbp),%rdi
call   1050 <str_to_int@plt>
mov    %eax,%edx
movslq -0x68c(%rbp),%rcx
lea    -0x640(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movslq -0x690(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
mov    %eax,%edi
lea    0xccc(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x3f8(%rbp)
mov    -0x690(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x690(%rbp)
jmp    133f <main+0x17f>
jmp    13a9 <main+0x1e9>
mov    -0x68c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68c(%rbp)
jmp    1328 <main+0x168>
movl   $0x0,-0x694(%rbp)
cmpl   $0xc,-0x694(%rbp)
jge    144e <main+0x28e>
movl   $0x0,-0x698(%rbp)
cmpl   $0xc,-0x698(%rbp)
jge    142c <main+0x26c>
movslq -0x694(%rbp),%rcx
lea    -0x640(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movslq -0x698(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x698(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x698(%rbp)
jmp    13de <main+0x21e>
lea    0xc56(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x694(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x694(%rbp)
jmp    13c7 <main+0x207>
lea    0xbd0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbef(%rip),%rdi
lea    -0x69c(%rbp),%rsi
lea    -0x6a0(%rbp),%rdx
call   10a0 <scanf@plt>
mov    -0x69c(%rbp),%eax
mov    %eax,-0x6a8(%rbp)
mov    -0x6a0(%rbp),%eax
mov    %eax,-0x6a4(%rbp)
lea    -0x6a8(%rbp),%rdi
call   1040 <check_input@plt>
lea    -0x640(%rbp),%rdi
mov    -0x69c(%rbp),%esi
mov    -0x6a0(%rbp),%edx
lea    -0x670(%rbp),%r8
lea    -0x674(%rbp),%rcx
call   10b0 <dijkstra@plt>
mov    -0x69c(%rbp),%edi
mov    -0x6a0(%rbp),%esi
lea    -0x670(%rbp),%rdx
call   1090 <print_path@plt>
mov    -0x69c(%rbp),%esi
mov    -0x6a0(%rbp),%edx
mov    -0x674(%rbp),%ecx
lea    0xb68(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x6b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x678,%rsp
lea    0xe1c(%rip),%rdi
lea    0xe20(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     152a <main+0x35a>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <fgetc@plt>
mov    0x2ddd(%rip),%r14
xor    %ebp,%ebp
cmp    (%r14),%eax
jne    14dc <main+0x30c>
movslq %ebp,%rax
movb   $0x0,0x290(%rsp,%rax,1)
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe20(%rip),%r14
lea    0x290(%rsp),%rdi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    $0x2c,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,-0xc(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,-0x8(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,-0x4(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x4(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x8(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0xc(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x10(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x14(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x18(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x1c(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
call   1060 <str_to_int@plt>
mov    %eax,0x20(%rsp,%rbx,1)
xor    %edi,%edi
mov    %r14,%rsi
call   10e0 <strtok@plt>
add    $0x30,%rbx
cmp    $0x26c,%rbx
jne    1250 <main+0x80>
mov    $0x2c,%ebx
lea    0xcac(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0xc(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x8(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x4(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x14(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x1c(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x20(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rbx
cmp    $0x26c,%rbx
jne    1380 <main+0x1b0>
lea    0xbdc(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbfb(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   10b0 <scanf@plt>
mov    0x10(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x1c(%rsp)
lea    0x18(%rsp),%rdi
call   1050 <check_input@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0x20(%rsp),%rdi
lea    0x14(%rsp),%rcx
lea    0x260(%rsp),%rbx
mov    %rbx,%r8
call   10c0 <dijkstra@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %rbx,%rdx
call   10a0 <print_path@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0xb94(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x678,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
mov    $0x2600,%r15d
jmp    150e <main+0x33e>
cs nopw 0x0(%rax,%rax,1)
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %al,0x290(%rsp,%rcx,1)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
cmp    (%r14),%eax
je     1216 <main+0x46>
cmp    $0x20,%eax
je     14f0 <main+0x320>
lea    -0x30(%rax),%ecx
cmp    $0x9,%ecx
jbe    14f0 <main+0x320>
cmp    $0xd,%eax
ja     14fd <main+0x32d>
bt     %eax,%r15d
mov    $0x20,%al
jb     14f0 <main+0x320>
jmp    14fd <main+0x32d>
mov    0x2aa7(%rip),%rax
mov    (%rax),%edi
lea    0xad3(%rip),%rsi
lea    0xad0(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2a83(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"matrix.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [15 x i8] c"No file given!\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@.str.4 = [2 x i8] c" \00"
@.str.5 = [5 x i8] c"%4d \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [45 x i8] c"\0AEnter the starting node and the end node : \00"
@.str.8 = [7 x i8] c" %d %d\00"
@.str.9 = [50 x i8] c"The shortest distance from node %d to %d is : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i8*
%4 = alloca [12 x [12 x i32]]
%5 = alloca [12 x i32]
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [2 x i32]
store i32 0, i32* %1
%17 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %0
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %0
store i32 0, i32* %9
br label %26
26: ; preds = %62, %25
%27 = load i32*, i32** %7
%28 = call i32 @fgetc(i32* %27)
store i32 %28, i32* %8
%29 = load i32, i32* @EOF
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %63
31: ; preds = %26
%32 = load i32, i32* %8
%33 = icmp sge i32 %32, 48
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %8
%36 = icmp sle i32 %35, 57
br i1 %36, label %40, label %37
37: ; preds = %34, %31
%38 = load i32, i32* %8
%39 = icmp eq i32 %38, 32
br i1 %39, label %40, label %47
40: ; preds = %37, %34
%41 = load i32, i32* %8
%42 = trunc i32 %41 to i8
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %45
store i8 %42, i8* %46
br label %62
47: ; preds = %37
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 9
br i1 %49, label %56, label %50
50: ; preds = %47
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 10
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = load i32, i32* %8
%55 = icmp eq i32 %54, 13
br i1 %55, label %56, label %61
56: ; preds = %53, %50, %47
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %59
store i8 32, i8* %60
br label %61
61: ; preds = %56, %53
br label %62
62: ; preds = %61, %40
br label %26
63: ; preds = %26
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %65
store i8 0, i8* %66
%67 = load i32*, i32** %7
%68 = call i32 @fclose(i32* %67)
%69 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%70 = call i8* @strtok(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %70, i8** %3
store i32 0, i32* %10
br label %71
71: ; preds = %92, %63
%72 = load i32, i32* %10
%73 = icmp slt i32 %72, 12
br i1 %73, label %74, label %95
74: ; preds = %71
store i32 0, i32* %11
br label %75
75: ; preds = %88, %74
%76 = load i32, i32* %11
%77 = icmp slt i32 %76, 12
br i1 %77, label %78, label %91
78: ; preds = %75
%79 = load i8*, i8** %3
%80 = call i32 @str_to_int(i8* %79)
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %4, i64 0, i64 %82
%84 = load i32, i32* %11
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [12 x i32], [12 x i32]* %83, i64 0, i64 %85
store i32 %80, i32* %86
%87 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %87, i8** %3
br label %88
88: ; preds = %78
%89 = load i32, i32* %11
%90 = add nsw i32 %89, 1
store i32 %90, i32* %11
br label %75
91: ; preds = %75
br label %92
92: ; preds = %91
%93 = load i32, i32* %10
%94 = add nsw i32 %93, 1
store i32 %94, i32* %10
br label %71
95: ; preds = %71
store i32 0, i32* %12
br label %96
96: ; preds = %117, %95
%97 = load i32, i32* %12
%98 = icmp slt i32 %97, 12
br i1 %98, label %99, label %120
99: ; preds = %96
store i32 0, i32* %13
br label %100
100: ; preds = %112, %99
%101 = load i32, i32* %13
%102 = icmp slt i32 %101, 12
br i1 %102, label %103, label %115
103: ; preds = %100
%104 = load i32, i32* %12
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %4, i64 0, i64 %105
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [12 x i32], [12 x i32]* %106, i64 0, i64 %108
%110 = load i32, i32* %109
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %110)
br label %112
112: ; preds = %103
%113 = load i32, i32* %13
%114 = add nsw i32 %113, 1
store i32 %114, i32* %13
br label %100
115: ; preds = %100
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %117
117: ; preds = %115
%118 = load i32, i32* %12
%119 = add nsw i32 %118, 1
store i32 %119, i32* %12
br label %96
120: ; preds = %96
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%122 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32* %14, i32* %15)
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%124 = load i32, i32* %14
store i32 %124, i32* %123
%125 = getelementptr inbounds i32, i32* %123, i64 1
%126 = load i32, i32* %15
store i32 %126, i32* %125
%127 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%128 = call i32 @check_input(i32* %127)
%129 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %4, i64 0, i64 0
%130 = bitcast [12 x i32]* %129 to i32**
%131 = load i32, i32* %14
%132 = load i32, i32* %15
%133 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%134 = call i32 @dijkstra(i32** %130, i32 %131, i32 %132, i32* %6, i32* %133)
%135 = load i32, i32* %14
%136 = load i32, i32* %15
%137 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%138 = call i32 @print_path(i32 %135, i32 %136, i32* %137)
%139 = load i32, i32* %14
%140 = load i32, i32* %15
%141 = load i32, i32* %6
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i32 %139, i32 %140, i32 %141)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"matrix.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [15 x i8] c"No file given!\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@.str.4 = [2 x i8] c" \00"
@.str.5 = [5 x i8] c"%4d \00"
@.str.7 = [45 x i8] c"\0AEnter the starting node and the end node : \00"
@.str.8 = [7 x i8] c" %d %d\00"
@.str.9 = [50 x i8] c"The shortest distance from node %d to %d is : %d\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [12 x [12 x i32]]
%3 = alloca [12 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i32]
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%9 = bitcast [12 x [12 x i32]]* %2 to i8*
%10 = bitcast [12 x i32]* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %0
%15 = tail call i32 @fgetc(i32* %12)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %43, label %23
18: ; preds = %0
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %14, %38
%24 = phi i32 [ %40, %38 ], [ %15, %14 ]
%25 = phi i32 [ %39, %38 ], [ 0, %14 ]
%26 = add i32 %24, -48
%27 = icmp ult i32 %26, 10
%28 = icmp eq i32 %24, 32
%29 = or i1 %28, %27
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = trunc i32 %24 to i8
br label %33
32: ; preds = %23
switch i32 %24, label %38 [
i32 13, label %33
i32 10, label %33
i32 9, label %33
]
33: ; preds = %32, %32, %32, %30
%34 = phi i8 [ %31, %30 ], [ 32, %32 ], [ 32, %32 ], [ 32, %32 ]
%35 = add nsw i32 %25, 1
%36 = sext i32 %25 to i64
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %36
store i8 %34, i8* %37
br label %38
38: ; preds = %33, %32
%39 = phi i32 [ %25, %32 ], [ %35, %33 ]
%40 = tail call i32 @fgetc(i32* %12)
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %23
43: ; preds = %38, %14
%44 = phi i32 [ 0, %14 ], [ %39, %38 ]
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %45
store i8 0, i8* %46
%47 = tail call i32 @fclose(i32* %12)
%48 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %43, %49
%50 = phi i64 [ 0, %43 ], [ %88, %49 ]
%51 = phi i8* [ %48, %43 ], [ %87, %49 ]
%52 = call i32 @str_to_int(i8* %51)
%53 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 0
store i32 %52, i32* %53
%54 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%55 = call i32 @str_to_int(i8* %54)
%56 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 1
store i32 %55, i32* %56
%57 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 @str_to_int(i8* %57)
%59 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 2
store i32 %58, i32* %59
%60 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 @str_to_int(i8* %60)
%62 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 3
store i32 %61, i32* %62
%63 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @str_to_int(i8* %63)
%65 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 4
store i32 %64, i32* %65
%66 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%67 = call i32 @str_to_int(i8* %66)
%68 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 5
store i32 %67, i32* %68
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%70 = call i32 @str_to_int(i8* %69)
%71 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 6
store i32 %70, i32* %71
%72 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%73 = call i32 @str_to_int(i8* %72)
%74 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 7
store i32 %73, i32* %74
%75 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 @str_to_int(i8* %75)
%77 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 8
store i32 %76, i32* %77
%78 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%79 = call i32 @str_to_int(i8* %78)
%80 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 9
store i32 %79, i32* %80
%81 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%82 = call i32 @str_to_int(i8* %81)
%83 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 10
store i32 %82, i32* %83
%84 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%85 = call i32 @str_to_int(i8* %84)
%86 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %50, i64 11
store i32 %85, i32* %86
%87 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%88 = add nuw nsw i64 %50, 1
%89 = icmp eq i64 %88, 12
br i1 %89, label %90, label %49
90: ; preds = %49, %90
%91 = phi i64 [ %129, %90 ], [ 0, %49 ]
%92 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 0
%93 = load i32, i32* %92
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %93)
%95 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 1
%96 = load i32, i32* %95
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %96)
%98 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 2
%99 = load i32, i32* %98
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %99)
%101 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 3
%102 = load i32, i32* %101
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %102)
%104 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 4
%105 = load i32, i32* %104
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %105)
%107 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 5
%108 = load i32, i32* %107
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %108)
%110 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 6
%111 = load i32, i32* %110
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %111)
%113 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 7
%114 = load i32, i32* %113
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %114)
%116 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 8
%117 = load i32, i32* %116
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %117)
%119 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 9
%120 = load i32, i32* %119
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %120)
%122 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 10
%123 = load i32, i32* %122
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %123)
%125 = getelementptr inbounds [12 x [12 x i32]], [12 x [12 x i32]]* %2, i64 0, i64 %91, i64 11
%126 = load i32, i32* %125
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %126)
%128 = call i32 @putchar(i32 10)
%129 = add nuw nsw i64 %91, 1
%130 = icmp eq i64 %129, 12
br i1 %130, label %131, label %90
131: ; preds = %90
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%133 = bitcast i32* %5 to i8*
%134 = bitcast i32* %6 to i8*
%135 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32* %5, i32* %6)
%136 = bitcast [2 x i32]* %7 to i8*
%137 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%138 = load i32, i32* %5
store i32 %138, i32* %137
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%140 = load i32, i32* %6
store i32 %140, i32* %139
%141 = call i32 @check_input(i32* %137)
%142 = bitcast [12 x [12 x i32]]* %2 to i32**
%143 = load i32, i32* %5
%144 = load i32, i32* %6
%145 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%146 = call i32 @dijkstra(i32** %142, i32 %143, i32 %144, i32* %4, i32* %145)
%147 = load i32, i32* %5
%148 = load i32, i32* %6
%149 = call i32 @print_path(i32 %147, i32 %148, i32* %145)
%150 = load i32, i32* %5
%151 = load i32, i32* %6
%152 = load i32, i32* %4
%153 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i32 %150, i32 %151, i32 %152)
ret i32 0
}