; LLVM IR from HarshCasper/NeoAlgo :: C/ds (Dijsktra)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %1)
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = call ptr @llvm.stacksave.p0()
  store ptr %23, ptr %2, align 8
  %24 = mul nuw i64 %20, %22
  %25 = alloca i32, i64 %24, align 16
  store i64 %20, ptr %3, align 8
  store i64 %22, ptr %4, align 8
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = zext i32 %26 to i64
  %28 = alloca i32, i64 %27, align 16
  store i64 %27, ptr %5, align 8
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = mul nuw i64 %30, %32
  %34 = alloca i32, i64 %33, align 16
  store i64 %30, ptr %6, align 8
  store i64 %32, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 1, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %8)
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %60, %0
  %39 = load i32, ptr %15, align 4, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %42, label %63

42:                                               ; preds = %38
  store i32 1, ptr %16, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %56, %42
  %44 = load i32, ptr %16, align 4, !tbaa !5
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = icmp sle i32 %44, %45
  br i1 %46, label %47, label %59

47:                                               ; preds = %43
  %48 = load i32, ptr %15, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %49, %22
  %51 = getelementptr inbounds i32, ptr %25, i64 %50
  %52 = load i32, ptr %16, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %54)
  br label %56

56:                                               ; preds = %47
  %57 = load i32, ptr %16, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %16, align 4, !tbaa !5
  br label %43, !llvm.loop !9

59:                                               ; preds = %43
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %15, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %15, align 4, !tbaa !5
  br label %38, !llvm.loop !11

63:                                               ; preds = %38
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %65 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9)
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %10)
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %91, %63
  %70 = load i32, ptr %15, align 4, !tbaa !5
  %71 = load i32, ptr %10, align 4, !tbaa !5
  %72 = icmp sle i32 %70, %71
  br i1 %72, label %73, label %94

73:                                               ; preds = %69
  store i32 1, ptr %16, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %87, %73
  %75 = load i32, ptr %16, align 4, !tbaa !5
  %76 = load i32, ptr %8, align 4, !tbaa !5
  %77 = icmp sle i32 %75, %76
  br i1 %77, label %78, label %90

78:                                               ; preds = %74
  %79 = load i32, ptr %15, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = mul nsw i64 %80, %32
  %82 = getelementptr inbounds i32, ptr %34, i64 %81
  %83 = load i32, ptr %16, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  %86 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %85)
  br label %87

87:                                               ; preds = %78
  %88 = load i32, ptr %16, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %16, align 4, !tbaa !5
  br label %74, !llvm.loop !12

90:                                               ; preds = %74
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %15, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %15, align 4, !tbaa !5
  br label %69, !llvm.loop !13

94:                                               ; preds = %69
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = load i32, ptr %9, align 4, !tbaa !5
  %97 = load i32, ptr %10, align 4, !tbaa !5
  call void @dijkstra_algo(ptr noundef %25, ptr noundef %28, ptr noundef %34, i32 noundef %95, i32 noundef %96, i32 noundef %97)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %98 = load ptr, ptr %2, align 8
  call void @llvm.stackrestore.p0(ptr %98)
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @printf(ptr noundef, ...) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; Function Attrs: nounwind uwtable
declare dso_local void @dijkstra_algo(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = zext i32 %7 to i64
  %9 = call ptr @llvm.stacksave.p0()
  %10 = mul nuw i64 %8, %8
  %11 = alloca i32, i64 %10, align 16
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = zext i32 %12 to i64
  %14 = alloca i32, i64 %13, align 16
  %15 = mul nuw i64 %13, %13
  %16 = alloca i32, i64 %15, align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %.not21 = icmp slt i32 %20, 1
  br i1 %.not21, label %._crit_edge23, label %.preheader18

.preheader18:                                     ; preds = %0, %._crit_edge
  %21 = phi i32 [ %29, %._crit_edge ], [ %20, %0 ]
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %._crit_edge ], [ 1, %0 ]
  %.not1719 = icmp slt i32 %21, 1
  br i1 %.not1719, label %.preheader18.._crit_edge_crit_edge, label %.lr.ph

.preheader18.._crit_edge_crit_edge:               ; preds = %.preheader18
  %.pre45 = sext i32 %21 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.preheader18
  %22 = mul nuw nsw i64 %indvars.iv35, %8
  %23 = getelementptr inbounds i32, ptr %11, i64 %22
  br label %24

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %25 = getelementptr inbounds i32, ptr %23, i64 %indvars.iv
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %.not17.not = icmp slt i64 %indvars.iv, %28
  br i1 %.not17.not, label %24, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %24, %.preheader18.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre45, %.preheader18.._crit_edge_crit_edge ], [ %28, %24 ]
  %29 = phi i32 [ %21, %.preheader18.._crit_edge_crit_edge ], [ %27, %24 ]
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %.not.not = icmp slt i64 %indvars.iv35, %.pre-phi
  br i1 %.not.not, label %.preheader18, label %._crit_edge23, !llvm.loop !11

._crit_edge23:                                    ; preds = %._crit_edge, %0
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %4)
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %.not1528 = icmp slt i32 %35, 1
  %.pre44 = load i32, ptr %2, align 4, !tbaa !5
  %36 = icmp slt i32 %.pre44, 1
  %or.cond = select i1 %.not1528, i1 true, i1 %36
  br i1 %or.cond, label %._crit_edge30, label %.preheader

.preheader:                                       ; preds = %._crit_edge23, %._crit_edge27
  %37 = phi i32 [ %46, %._crit_edge27 ], [ %35, %._crit_edge23 ]
  %38 = phi i32 [ %47, %._crit_edge27 ], [ %.pre44, %._crit_edge23 ]
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %._crit_edge27 ], [ 1, %._crit_edge23 ]
  %.not1624 = icmp slt i32 %38, 1
  br i1 %.not1624, label %._crit_edge27, label %.lr.ph26

.lr.ph26:                                         ; preds = %.preheader
  %39 = mul nuw nsw i64 %indvars.iv41, %13
  %40 = getelementptr inbounds i32, ptr %16, i64 %39
  br label %41

41:                                               ; preds = %.lr.ph26, %41
  %indvars.iv38 = phi i64 [ 1, %.lr.ph26 ], [ %indvars.iv.next39, %41 ]
  %42 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv38
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %42)
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %.not16.not = icmp slt i64 %indvars.iv38, %45
  br i1 %.not16.not, label %41, label %._crit_edge27.loopexit, !llvm.loop !13

._crit_edge27.loopexit:                           ; preds = %41
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge27.loopexit, %.preheader
  %46 = phi i32 [ %.pre, %._crit_edge27.loopexit ], [ %37, %.preheader ]
  %47 = phi i32 [ %44, %._crit_edge27.loopexit ], [ %38, %.preheader ]
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %48 = sext i32 %46 to i64
  %.not15.not = icmp slt i64 %indvars.iv41, %48
  br i1 %.not15.not, label %.preheader, label %._crit_edge30, !llvm.loop !14

._crit_edge30:                                    ; preds = %._crit_edge27, %._crit_edge23
  %49 = phi i32 [ %.pre44, %._crit_edge23 ], [ %47, %._crit_edge27 ]
  %.lcssa = phi i32 [ %35, %._crit_edge23 ], [ %46, %._crit_edge27 ]
  %50 = load i32, ptr %3, align 4, !tbaa !5
  call void @dijkstra_algo(ptr noundef nonnull %11, ptr noundef nonnull %14, ptr noundef nonnull %16, i32 noundef %49, i32 noundef %50, i32 noundef %.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.stackrestore.p0(ptr %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; Function Attrs: nounwind uwtable
declare dso_local void @dijkstra_algo(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12}
!12 = !{!"llvm.loop.unswitch.partial.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass