; LLVM IR from HarshCasper/NeoAlgo :: C-Plus-Plus/dp/townPlanning.ll (Z13checkRowValidRSt6vectorIS_IcSaIcEESaIS1_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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z2onii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z13checkRowValidRSt6vectorIS_IcSaIcEESaIS1_EEiii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca i1, align 1
  %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 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) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %62, %4
  %13 = load i32, ptr %10, align 4, !tbaa !9
  %14 = load i32, ptr %9, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %11, align 4
  br label %65

17:                                               ; preds = %12
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = call noundef zeroext i1 @_Z2onii(i32 noundef %18, i32 noundef %19)
  br i1 %20, label %21, label %33

21:                                               ; preds = %17
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IcSaIcEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %24) #2
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #2
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %30, 84
  br i1 %31, label %32, label %33

32:                                               ; preds = %21
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %65

33:                                               ; preds = %21, %17
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %36, label %46

36:                                               ; preds = %33
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = sub nsw i32 %37, 1
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = call noundef zeroext i1 @_Z2onii(i32 noundef %38, i32 noundef %39)
  br i1 %40, label %41, label %46

41:                                               ; preds = %36
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = call noundef zeroext i1 @_Z2onii(i32 noundef %42, i32 noundef %43)
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %65

46:                                               ; preds = %41, %36, %33
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = sub nsw i32 %48, 1
  %50 = icmp slt i32 %47, %49
  br i1 %50, label %51, label %61

51:                                               ; preds = %46
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = call noundef zeroext i1 @_Z2onii(i32 noundef %53, i32 noundef %54)
  br i1 %55, label %56, label %61

56:                                               ; preds = %51
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = call noundef zeroext i1 @_Z2onii(i32 noundef %57, i32 noundef %58)
  br i1 %59, label %60, label %61

60:                                               ; preds = %56
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %65

61:                                               ; preds = %56, %51, %46
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %10, align 4, !tbaa !9
  br label %12, !llvm.loop !12

65:                                               ; preds = %60, %45, %32, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %66 = load i32, ptr %11, align 4
  switch i32 %66, label %70 [
    i32 2, label %67
    i32 1, label %68
  ]

67:                                               ; preds = %65
  store i1 true, ptr %5, align 1
  br label %68

68:                                               ; preds = %67, %65
  %69 = load i1, ptr %5, align 1
  ret i1 %69

70:                                               ; preds = %65
  unreachable
}

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

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

attributes #0 = { 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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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
declare dso_local noundef zeroext i1 @_Z2onii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z13checkRowValidRSt6vectorIS_IcSaIcEESaIS1_EEiii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = sext i32 %1 to i64
  %6 = icmp slt i32 %3, 1
  br i1 %6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = add nsw i32 %3, -1
  %8 = zext nneg i32 %7 to i64
  %9 = zext nneg i32 %3 to i64
  %wide.trip.count = zext nneg i32 %3 to i64
  %10 = tail call noundef zeroext i1 @_Z2onii(i32 noundef 0, i32 noundef %2)
  br i1 %10, label %11, label %16

11:                                               ; preds = %.lr.ph
  %12 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IcSaIcEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #1
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef 0) #1
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = icmp eq i8 %14, 84
  br i1 %15, label %._crit_edge, label %16

16:                                               ; preds = %.lr.ph, %11
  %.not = icmp eq i32 %3, 1
  br i1 %.not, label %._crit_edge, label %17

17:                                               ; preds = %16
  %18 = tail call noundef zeroext i1 @_Z2onii(i32 noundef 1, i32 noundef %2)
  br i1 %18, label %19, label %.peel.next.preheader

19:                                               ; preds = %17
  %20 = tail call noundef zeroext i1 @_Z2onii(i32 noundef 0, i32 noundef %2)
  br i1 %20, label %._crit_edge, label %.peel.next.preheader

.peel.next.preheader:                             ; preds = %19, %17
  br label %.peel.next

.peel.next:                                       ; preds = %.peel.next.preheader, %._crit_edge34
  %indvars.iv = phi i64 [ %37, %._crit_edge34 ], [ 1, %.peel.next.preheader ]
  %21 = phi i1 [ %43, %._crit_edge34 ], [ false, %.peel.next.preheader ]
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  %23 = tail call noundef zeroext i1 @_Z2onii(i32 noundef %22, i32 noundef %2)
  br i1 %23, label %24, label %29

24:                                               ; preds = %.peel.next
  %25 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IcSaIcEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #1
  %26 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %indvars.iv) #1
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = icmp eq i8 %27, 84
  br i1 %28, label %._crit_edge, label %29

29:                                               ; preds = %.peel.next, %24
  %30 = trunc i64 %indvars.iv to i32
  %31 = add i32 %30, -1
  %32 = tail call noundef zeroext i1 @_Z2onii(i32 noundef %31, i32 noundef %2)
  br i1 %32, label %33, label %35

33:                                               ; preds = %29
  %34 = tail call noundef zeroext i1 @_Z2onii(i32 noundef %22, i32 noundef %2)
  br i1 %34, label %._crit_edge, label %35

35:                                               ; preds = %33, %29
  %36 = icmp ult i64 %indvars.iv, %8
  %37 = add nuw nsw i64 %indvars.iv, 1
  br i1 %36, label %38, label %._crit_edge34

38:                                               ; preds = %35
  %39 = trunc nuw nsw i64 %37 to i32
  %40 = tail call noundef zeroext i1 @_Z2onii(i32 noundef %39, i32 noundef %2)
  br i1 %40, label %41, label %._crit_edge34

41:                                               ; preds = %38
  %42 = tail call noundef zeroext i1 @_Z2onii(i32 noundef %22, i32 noundef %2)
  br i1 %42, label %._crit_edge, label %._crit_edge34

._crit_edge34:                                    ; preds = %35, %38, %41
  %43 = icmp uge i64 %37, %9
  %exitcond = icmp eq i64 %37, %wide.trip.count
  br i1 %exitcond, label %._crit_edge, label %.peel.next, !llvm.loop !8

._crit_edge:                                      ; preds = %._crit_edge34, %24, %33, %41, %16, %11, %19, %4
  %.lcssa = phi i1 [ true, %4 ], [ false, %11 ], [ false, %19 ], [ true, %16 ], [ %43, %._crit_edge34 ], [ %21, %24 ], [ %21, %33 ], [ %21, %41 ]
  ret i1 %.lcssa
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IcSaIcEESaIS1_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 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9, !10}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass