; LLVM IR from Lakhankumawat/LearnCPP :: G-GraphAlgorithms/MultistageGraphShortestPath.ll (Z12shortestPathPA12_i)

; 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"

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z12shortestPathPA12_i(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca [12 x i32], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %7 = getelementptr inbounds [12 x i32], ptr %3, i64 0, i64 11
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 10, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %55, %1
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp sge i32 %9, 0
  br i1 %10, label %11, label %58

11:                                               ; preds = %8
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [12 x i32], ptr %3, i64 0, i64 %13
  store i32 2147483647, ptr %14, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %51, %11
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = icmp slt i32 %16, 12
  br i1 %17, label %18, label %54

18:                                               ; preds = %15
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [12 x i32], ptr %19, i64 %21
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [12 x i32], ptr %22, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 2147483647
  br i1 %27, label %28, label %29

28:                                               ; preds = %18
  br label %51

29:                                               ; preds = %18
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [12 x i32], ptr %3, i64 0, i64 %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [12 x i32], ptr %33, i64 %35
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [12 x i32], ptr %36, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [12 x i32], ptr %3, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = add nsw i32 %40, %44
  store i32 %45, ptr %6, align 4, !tbaa !9
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %32, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [12 x i32], ptr %3, i64 0, i64 %49
  store i32 %47, ptr %50, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %51

51:                                               ; preds = %29, %28
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %5, align 4, !tbaa !9
  br label %15, !llvm.loop !11

54:                                               ; preds = %15
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %4, align 4, !tbaa !9
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !13

58:                                               ; preds = %8
  %59 = getelementptr inbounds [12 x i32], ptr %3, i64 0, i64 0
  %60 = load i32, ptr %59, align 16, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #3
  ret i32 %60
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { inlinehint mustprogress 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 #3 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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"

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z12shortestPathPA12_i(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca [12 x i32], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #3
  %4 = getelementptr inbounds i8, ptr %2, i64 44
  store i32 0, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 4
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = getelementptr inbounds i8, ptr %2, i64 12
  %8 = getelementptr inbounds i8, ptr %2, i64 16
  %9 = getelementptr inbounds i8, ptr %2, i64 20
  %10 = getelementptr inbounds i8, ptr %2, i64 24
  %11 = getelementptr inbounds i8, ptr %2, i64 28
  %12 = getelementptr inbounds i8, ptr %2, i64 32
  %13 = getelementptr inbounds i8, ptr %2, i64 36
  %14 = getelementptr inbounds i8, ptr %2, i64 40
  br label %15

15:                                               ; preds = %1, %115
  %indvars.iv = phi i64 [ 10, %1 ], [ %indvars.iv.next, %115 ]
  %16 = getelementptr inbounds [12 x i32], ptr %2, i64 0, i64 %indvars.iv
  store i32 2147483647, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 1
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 2147483647
  br i1 %19, label %25, label %20

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = add nsw i32 %21, %18
  store i32 %22, ptr %3, align 4, !tbaa !5
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %25

25:                                               ; preds = %15, %20
  %26 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 2
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 2147483647
  br i1 %28, label %34, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %30 = load i32, ptr %6, align 8, !tbaa !5
  %31 = add nsw i32 %30, %27
  store i32 %31, ptr %3, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %33 = load i32, ptr %32, align 4, !tbaa !5
  store i32 %33, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %34

34:                                               ; preds = %29, %25
  %35 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 3
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp eq i32 %36, 2147483647
  br i1 %37, label %43, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = add nsw i32 %39, %36
  store i32 %40, ptr %3, align 4, !tbaa !5
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %42 = load i32, ptr %41, align 4, !tbaa !5
  store i32 %42, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %43

43:                                               ; preds = %38, %34
  %44 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 4
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = icmp eq i32 %45, 2147483647
  br i1 %46, label %52, label %47

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %48 = load i32, ptr %8, align 16, !tbaa !5
  %49 = add nsw i32 %48, %45
  store i32 %49, ptr %3, align 4, !tbaa !5
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %51 = load i32, ptr %50, align 4, !tbaa !5
  store i32 %51, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %52

52:                                               ; preds = %47, %43
  %53 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 5
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = icmp eq i32 %54, 2147483647
  br i1 %55, label %61, label %56

56:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = add nsw i32 %57, %54
  store i32 %58, ptr %3, align 4, !tbaa !5
  %59 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %60 = load i32, ptr %59, align 4, !tbaa !5
  store i32 %60, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %61

61:                                               ; preds = %56, %52
  %62 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 6
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp eq i32 %63, 2147483647
  br i1 %64, label %70, label %65

65:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %66 = load i32, ptr %10, align 8, !tbaa !5
  %67 = add nsw i32 %66, %63
  store i32 %67, ptr %3, align 4, !tbaa !5
  %68 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %69 = load i32, ptr %68, align 4, !tbaa !5
  store i32 %69, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %70

70:                                               ; preds = %65, %61
  %71 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 7
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp eq i32 %72, 2147483647
  br i1 %73, label %79, label %74

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %75 = load i32, ptr %11, align 4, !tbaa !5
  %76 = add nsw i32 %75, %72
  store i32 %76, ptr %3, align 4, !tbaa !5
  %77 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %79

79:                                               ; preds = %74, %70
  %80 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 8
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = icmp eq i32 %81, 2147483647
  br i1 %82, label %88, label %83

83:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %84 = load i32, ptr %12, align 16, !tbaa !5
  %85 = add nsw i32 %84, %81
  store i32 %85, ptr %3, align 4, !tbaa !5
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %87 = load i32, ptr %86, align 4, !tbaa !5
  store i32 %87, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %88

88:                                               ; preds = %83, %79
  %89 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 9
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = icmp eq i32 %90, 2147483647
  br i1 %91, label %97, label %92

92:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %93 = load i32, ptr %13, align 4, !tbaa !5
  %94 = add nsw i32 %93, %90
  store i32 %94, ptr %3, align 4, !tbaa !5
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %96 = load i32, ptr %95, align 4, !tbaa !5
  store i32 %96, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %97

97:                                               ; preds = %92, %88
  %98 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 10
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp eq i32 %99, 2147483647
  br i1 %100, label %106, label %101

101:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %102 = load i32, ptr %14, align 8, !tbaa !5
  %103 = add nsw i32 %102, %99
  store i32 %103, ptr %3, align 4, !tbaa !5
  %104 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %105 = load i32, ptr %104, align 4, !tbaa !5
  store i32 %105, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %106

106:                                              ; preds = %101, %97
  %107 = getelementptr inbounds [12 x i32], ptr %0, i64 %indvars.iv, i64 11
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = icmp eq i32 %108, 2147483647
  br i1 %109, label %115, label %110

110:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %111 = load i32, ptr %4, align 4, !tbaa !5
  %112 = add nsw i32 %111, %108
  store i32 %112, ptr %3, align 4, !tbaa !5
  %113 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %114 = load i32, ptr %113, align 4, !tbaa !5
  store i32 %114, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %115

115:                                              ; preds = %110, %106
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not = icmp eq i64 %indvars.iv, 0
  br i1 %.not, label %116, label %15, !llvm.loop !9

116:                                              ; preds = %115
  %117 = load i32, ptr %2, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #3
  ret i32 %117
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { inlinehint mustprogress 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 #3 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass