#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 */
struct Graph {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ addEdge(struct Graph *, int, int, double);
struct Graph *createGraph(int);
int /*<<< orphan*/ dijkstra(struct Graph *, int, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(int argc, char const *argv[]) {
  printf("INPUT:\n");
  int vertices, total_edges;
  scanf("%d%d", &vertices, &total_edges);
  struct Graph *graph = createGraph(vertices);
  int src, dest;
  double weight;
  for (int i = 0; i < total_edges; i++) {
    scanf("%d%d%lf", &src, &dest, &weight);
    addEdge(graph, src - 1, dest - 1, weight);
  }
  int residing_hostel, total_hostels_csgo;
  scanf("%d%d", &residing_hostel, &total_hostels_csgo);
  int *hostels_csgo = (int *)malloc(total_hostels_csgo * sizeof(int));
  for (int j = 0; j < total_hostels_csgo; j++) {
    scanf("%d", (hostels_csgo + j));
  }
  int dist[vertices];
  dijkstra(graph, residing_hostel - 1, dist);
  printf("\nOUTPUT:\n");
  for (int i = 0; i < total_hostels_csgo; i++) {
    printf("%d\t%d\n", *(hostels_csgo + i), dist[*(hostels_csgo + i) - 1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x14(%rbp),%edi
call   1060 <createGraph@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11fb <main+0x9b>
lea    0xe4d(%rip),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
mov    -0x28(%rbp),%edx
sub    $0x1,%edx
movsd  -0x30(%rbp),%xmm0
call   1050 <addEdge@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ad <main+0x4d>
lea    0xe06(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
movslq -0x3c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1262 <main+0x102>
mov    -0x48(%rbp),%rsi
movslq -0x4c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    122b <main+0xcb>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x70(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%esi
sub    $0x1,%esi
call   1080 <dijkstra@plt>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    12f8 <main+0x198>
mov    -0x70(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq -0x64(%rbp),%rdx
mov    (%rcx,%rdx,4),%esi
mov    -0x48(%rbp),%rcx
movslq -0x64(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12ad <main+0x14d>
movl   $0x0,-0x4(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6c(%rip),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    -0x34(%rbp),%edi
call   1070 <createGraph@plt>
mov    %rax,%r15
cmpl   $0x0,-0x30(%rbp)
jle    120a <main+0x9a>
lea    -0x40(%rbp),%r12
lea    -0x3c(%rbp),%r13
lea    -0x50(%rbp),%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe2e(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    -0x40(%rbp),%esi
add    $0xffffffff,%esi
mov    -0x3c(%rbp),%edx
add    $0xffffffff,%edx
movsd  -0x50(%rbp),%xmm0
mov    %r15,%rdi
call   1060 <addEdge@plt>
add    $0x1,%r14d
cmp    -0x30(%rbp),%r14d
jl     11d0 <main+0x60>
mov    %r15,-0x48(%rbp)
lea    0xdeb(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    -0x2c(%rbp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
cmpl   $0x0,-0x2c(%rbp)
jle    126e <main+0xfe>
lea    0xdc3(%rip),%r12
mov    %r15,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x4,%r14
cmp    %rax,%rbx
jl     1250 <main+0xe0>
mov    %rsp,%r12
mov    -0x34(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x38(%rbp),%esi
add    $0xffffffff,%esi
mov    -0x48(%rbp),%rdi
mov    %r13,%rdx
call   1090 <dijkstra@plt>
lea    0xd79(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    12e0 <main+0x170>
lea    0xd59(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movslq (%r15,%rbx,4),%rsi
mov    -0x4(%r13,%rsi,4),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     12c0 <main+0x150>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Graph = type { i32 }
@.str = [8 x i8] c"INPUT:\0A\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [8 x i8] c"%d%d%lf\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"\0AOUTPUT:\0A\00"
@.str.5 = [7 x i8] c"%d\09%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 %struct.Graph*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%22 = load i32, i32* %6
%23 = call %struct.Graph* @createGraph(i32 %22)
store %struct.Graph* %23, %struct.Graph** %8
store i32 0, i32* %12
br label %24
24: ; preds = %37, %2
%25 = load i32, i32* %12
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %40
28: ; preds = %24
%29 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %10, double* %11)
%30 = load %struct.Graph*, %struct.Graph** %8
%31 = load i32, i32* %9
%32 = sub nsw i32 %31, 1
%33 = load i32, i32* %10
%34 = sub nsw i32 %33, 1
%35 = load double, double* %11
%36 = call i32 @addEdge(%struct.Graph* %30, i32 %32, i32 %34, double %35)
br label %37
37: ; preds = %28
%38 = load i32, i32* %12
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %24
40: ; preds = %24
%41 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %14)
%42 = load i32, i32* %14
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 4
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i32*
store i32* %47, i32** %15
store i32 0, i32* %16
br label %48
48: ; preds = %58, %40
%49 = load i32, i32* %16
%50 = load i32, i32* %14
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %61
52: ; preds = %48
%53 = load i32*, i32** %15
%54 = load i32, i32* %16
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %56)
br label %58
58: ; preds = %52
%59 = load i32, i32* %16
%60 = add nsw i32 %59, 1
store i32 %60, i32* %16
br label %48
61: ; preds = %48
%62 = load i32, i32* %6
%63 = zext i32 %62 to i64
%64 = call i8* @llvm.stacksave()
store i8* %64, i8** %17
%65 = alloca i32, i64 %63
store i64 %63, i64* %18
%66 = load %struct.Graph*, %struct.Graph** %8
%67 = load i32, i32* %13
%68 = sub nsw i32 %67, 1
%69 = call i32 @dijkstra(%struct.Graph* %66, i32 %68, i32* %65)
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %19
br label %71
71: ; preds = %91, %61
%72 = load i32, i32* %19
%73 = load i32, i32* %14
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %94
75: ; preds = %71
%76 = load i32*, i32** %15
%77 = load i32, i32* %19
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %76, i64 %78
%80 = load i32, i32* %79
%81 = load i32*, i32** %15
%82 = load i32, i32* %19
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
%85 = load i32, i32* %84
%86 = sub nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %65, i64 %87
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %80, i32 %89)
br label %91
91: ; preds = %75
%92 = load i32, i32* %19
%93 = add nsw i32 %92, 1
store i32 %93, i32* %19
br label %71
94: ; preds = %71
store i32 0, i32* %3
%95 = load i8*, i8** %17
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
%struct.Graph = type { i32 }
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [8 x i8] c"%d%d%lf\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [7 x i8] c"%d\09%d\0A\00"
@str = [7 x i8] c"INPUT:\00"
@str.6 = [9 x i8] c"\0AOUTPUT:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%14 = load i32, i32* %3
%15 = call %struct.Graph* @createGraph(i32 %14)
%16 = bitcast i32* %5 to i8*
%17 = bitcast i32* %6 to i8*
%18 = bitcast double* %7 to i8*
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %31, %2
%22 = bitcast i32* %8 to i8*
%23 = bitcast i32* %9 to i8*
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %8, i32* %9)
%25 = load i32, i32* %9
%26 = shl i32 %25, 2
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i32*
%29 = load i32, i32* %9
%30 = icmp sgt i32 %29, 0
br i1 %30, label %54, label %43
31: ; preds = %2, %31
%32 = phi i32 [ %40, %31 ], [ 0, %2 ]
%33 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %5, i32* %6, double* %7)
%34 = load i32, i32* %5
%35 = add nsw i32 %34, -1
%36 = load i32, i32* %6
%37 = add nsw i32 %36, -1
%38 = load double, double* %7
%39 = call i32 @addEdge(%struct.Graph* %15, i32 %35, i32 %37, double %38)
%40 = add nuw nsw i32 %32, 1
%41 = load i32, i32* %4
%42 = icmp slt i32 %40, %41
br i1 %42, label %31, label %21
43: ; preds = %54, %21
%44 = load i32, i32* %3
%45 = zext i32 %44 to i64
%46 = call i8* @llvm.stacksave()
%47 = alloca i32, i64 %45
%48 = load i32, i32* %8
%49 = add nsw i32 %48, -1
%50 = call i32 @dijkstra(%struct.Graph* %15, i32 %49, i32* %47)
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
%52 = load i32, i32* %9
%53 = icmp sgt i32 %52, 0
br i1 %53, label %63, label %62
54: ; preds = %21, %54
%55 = phi i64 [ %58, %54 ], [ 0, %21 ]
%56 = getelementptr inbounds i32, i32* %28, i64 %55
%57 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %56)
%58 = add nuw nsw i64 %55, 1
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = icmp slt i64 %58, %60
br i1 %61, label %54, label %43
62: ; preds = %63, %43
ret i32 0
63: ; preds = %43, %63
%64 = phi i64 [ %72, %63 ], [ 0, %43 ]
%65 = getelementptr inbounds i32, i32* %28, i64 %64
%66 = load i32, i32* %65
%67 = add nsw i32 %66, -1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %47, i64 %68
%70 = load i32, i32* %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %66, i32 %70)
%72 = add nuw nsw i64 %64, 1
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = icmp slt i64 %72, %74
br i1 %75, label %63, label %62
}