; LLVM IR from UtkarshPathrabe/Competitive-Coding :: Model Algorithms/Graphs/Count All Possible Walks from a Source to a Destination wit_df3ab979 (EEiii)

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z10countWalksRSt6vectorIS_IiSaIiEESaIS1_EEiii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #3
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %10, align 4, !tbaa !9
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = call ptr @llvm.stacksave.p0()
  store ptr %23, ptr %11, align 8
  %24 = mul nuw i64 2, %22
  %25 = alloca i32, i64 %24, align 16
  store i64 %22, ptr %12, align 8
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = icmp eq i32 %26, %27
  br i1 %28, label %29, label %33

29:                                               ; preds = %4
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %148

33:                                               ; preds = %29, %4
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = sub nsw i32 %35, 1
  %37 = icmp sgt i32 %34, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %148

39:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %59, %39
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %62

45:                                               ; preds = %40
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %46, i64 noundef %48) #3
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %51) #3
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = mul nsw i64 0, %22
  %55 = getelementptr inbounds i32, ptr %25, i64 %54
  %56 = load i32, ptr %14, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  store i32 %53, ptr %58, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %45
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %14, align 4, !tbaa !9
  br label %40, !llvm.loop !11

62:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %134, %62
  %64 = load i32, ptr %15, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = icmp slt i32 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %137

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %130, %68
  %70 = load i32, ptr %16, align 4, !tbaa !9
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = icmp slt i32 %70, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  store i32 8, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %133

74:                                               ; preds = %69
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = sub nsw i32 %75, 1
  %77 = srem i32 %76, 2
  %78 = sext i32 %77 to i64
  %79 = mul nsw i64 %78, %22
  %80 = getelementptr inbounds i32, ptr %25, i64 %79
  %81 = load i32, ptr %16, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds i32, ptr %80, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !9
  %85 = icmp sgt i32 %84, 0
  br i1 %85, label %86, label %129

86:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %125, %86
  %88 = load i32, ptr %17, align 4, !tbaa !9
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %87
  store i32 11, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %128

92:                                               ; preds = %87
  %93 = load i32, ptr %15, align 4, !tbaa !9
  %94 = sub nsw i32 %93, 1
  %95 = srem i32 %94, 2
  %96 = sext i32 %95 to i64
  %97 = mul nsw i64 %96, %22
  %98 = getelementptr inbounds i32, ptr %25, i64 %97
  %99 = load i32, ptr %16, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds i32, ptr %98, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !9
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr %16, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %103, i64 noundef %105) #3
  %107 = load i32, ptr %17, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %106, i64 noundef %108) #3
  %110 = load i32, ptr %109, align 4, !tbaa !9
  %111 = icmp sgt i32 %110, 0
  %112 = zext i1 %111 to i64
  %113 = select i1 %111, i32 1, i32 0
  %114 = mul nsw i32 %102, %113
  %115 = load i32, ptr %15, align 4, !tbaa !9
  %116 = srem i32 %115, 2
  %117 = sext i32 %116 to i64
  %118 = mul nsw i64 %117, %22
  %119 = getelementptr inbounds i32, ptr %25, i64 %118
  %120 = load i32, ptr %17, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !9
  %124 = add nsw i32 %123, %114
  store i32 %124, ptr %122, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %92
  %126 = load i32, ptr %17, align 4, !tbaa !9
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %17, align 4, !tbaa !9
  br label %87, !llvm.loop !13

128:                                              ; preds = %91
  br label %129

129:                                              ; preds = %128, %74
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %16, align 4, !tbaa !9
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %16, align 4, !tbaa !9
  br label %69, !llvm.loop !14

133:                                              ; preds = %73
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %15, align 4, !tbaa !9
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %15, align 4, !tbaa !9
  br label %63, !llvm.loop !15

137:                                              ; preds = %67
  %138 = load i32, ptr %9, align 4, !tbaa !9
  %139 = sub nsw i32 %138, 1
  %140 = srem i32 %139, 2
  %141 = sext i32 %140 to i64
  %142 = mul nsw i64 %141, %22
  %143 = getelementptr inbounds i32, ptr %25, i64 %142
  %144 = load i32, ptr %8, align 4, !tbaa !9
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds i32, ptr %143, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !9
  store i32 %147, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %148

148:                                              ; preds = %137, %38, %32
  %149 = load ptr, ptr %11, align 8
  call void @llvm.stackrestore.p0(ptr %149)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %150 = load i32, ptr %5, align 4
  ret i32 %150
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; 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) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
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}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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 nounwind uwtable
define dso_local noundef i32 @_Z10countWalksRSt6vectorIS_IiSaIiEESaIS1_EEiii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call noundef i64 @_ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %6 = trunc i64 %5 to i32
  %7 = and i64 %5, 4294967295
  %8 = shl nuw nsw i64 %7, 1
  %9 = alloca i32, i64 %8, align 16
  %10 = icmp ne i32 %1, %2
  %11 = icmp eq i32 %3, 0
  %or.cond.not45 = or i1 %10, %11
  %.not = icmp sgt i32 %6, %3
  %or.cond42 = and i1 %or.cond.not45, %.not
  br i1 %or.cond42, label %.preheader48, label %50

.preheader48:                                     ; preds = %4
  %12 = icmp slt i32 %6, 1
  br i1 %12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader48
  %13 = sext i32 %1 to i64
  %wide.trip.count = and i64 %5, 2147483647
  br label %37

.preheader47:                                     ; preds = %37
  %14 = icmp slt i32 %3, 2
  %brmerge = or i1 %14, %12
  br i1 %brmerge, label %._crit_edge, label %.preheader46.us.preheader

.preheader46.us.preheader:                        ; preds = %.preheader47
  %wide.trip.count66 = and i64 %5, 2147483647
  br label %.preheader46.us

.preheader46.us:                                  ; preds = %.preheader46.us.preheader, %._crit_edge.split.us.us
  %.03754.us = phi i32 [ %36, %._crit_edge.split.us.us ], [ 1, %.preheader46.us.preheader ]
  %15 = and i32 %.03754.us, 1
  %.urem = xor i32 %15, 1
  %16 = zext nneg i32 %.urem to i64
  %17 = mul nuw nsw i64 %7, %16
  %18 = getelementptr inbounds i32, ptr %9, i64 %17
  %19 = and i32 %.03754.us, 1
  %20 = zext nneg i32 %19 to i64
  %21 = mul nuw nsw i64 %7, %20
  %22 = getelementptr inbounds i32, ptr %9, i64 %21
  br label %23

23:                                               ; preds = %..loopexit_crit_edge.us.us, %.preheader46.us
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %..loopexit_crit_edge.us.us ], [ 0, %.preheader46.us ]
  %24 = getelementptr inbounds i32, ptr %18, i64 %indvars.iv63
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.preheader.us.us, label %..loopexit_crit_edge.us.us

..loopexit_crit_edge.us.us:                       ; preds = %.preheader.us.us, %23
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %exitcond67.not = icmp eq i64 %indvars.iv.next64, %wide.trip.count66
  br i1 %exitcond67.not, label %._crit_edge.split.us.us, label %23, !llvm.loop !9

.preheader.us.us:                                 ; preds = %23, %.preheader.us.us
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %.preheader.us.us ], [ 0, %23 ]
  %27 = load i32, ptr %24, align 4, !tbaa !5
  %28 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv63) #1
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %indvars.iv58) #1
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp sgt i32 %30, 0
  %32 = select i1 %31, i32 %27, i32 0
  %33 = getelementptr inbounds i32, ptr %22, i64 %indvars.iv58
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = add nsw i32 %32, %34
  store i32 %35, ptr %33, align 4, !tbaa !5
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond62.not = icmp eq i64 %indvars.iv.next59, %wide.trip.count66
  br i1 %exitcond62.not, label %..loopexit_crit_edge.us.us, label %.preheader.us.us, !llvm.loop !11

._crit_edge.split.us.us:                          ; preds = %..loopexit_crit_edge.us.us
  %36 = add nuw nsw i32 %.03754.us, 1
  %exitcond68.not = icmp eq i32 %36, %3
  br i1 %exitcond68.not, label %._crit_edge, label %.preheader46.us, !llvm.loop !12

37:                                               ; preds = %.lr.ph, %37
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %37 ]
  %38 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %13) #1
  %39 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %indvars.iv) #1
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  store i32 %40, ptr %41, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader47, label %37, !llvm.loop !13

._crit_edge:                                      ; preds = %._crit_edge.split.us.us, %.preheader47, %.preheader48
  %42 = add nsw i32 %3, -1
  %43 = srem i32 %42, 2
  %44 = sext i32 %43 to i64
  %45 = mul nsw i64 %7, %44
  %46 = getelementptr inbounds i32, ptr %9, i64 %45
  %47 = sext i32 %2 to i64
  %48 = getelementptr inbounds i32, ptr %46, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %4, %._crit_edge
  %.039 = phi i32 [ %49, %._crit_edge ], [ 0, %4 ]
  ret i32 %.039
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: ADCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass