; LLVM IR from DionysiosB/CodeForces :: 0900-0999/913D-TooEasyProblems.ll (Z5checkSt6vectorI4probSaIS0_EExx)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl" }
%"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl" = type { %"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl_data" }
%"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.prob = type { i64, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5checkSt6vectorI4probSaIS0_EExx(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) #0 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i1, align 1
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %16 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %16, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  store i1 false, ptr %11, align 1
  call void @_ZNSt6vectorI4probSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %59, %4
  %18 = load i64, ptr %12, align 8, !tbaa !11
  %19 = call noundef i64 @_ZNKSt6vectorI4probSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %13, align 4
  br label %62

22:                                               ; preds = %17
  %23 = load i64, ptr %12, align 8, !tbaa !11
  %24 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %23) #3
  %25 = getelementptr inbounds %struct.prob, ptr %24, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !13
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %22
  br label %59

30:                                               ; preds = %22
  %31 = load i64, ptr %12, align 8, !tbaa !11
  %32 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %31) #3
  %33 = getelementptr inbounds %struct.prob, ptr %32, i32 0, i32 1
  %34 = load i64, ptr %33, align 8, !tbaa !15
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = icmp sgt i64 %34, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %30
  store i32 2, ptr %13, align 4
  br label %62

38:                                               ; preds = %30
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = add nsw i64 %39, 1
  store i64 %40, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %12, align 8, !tbaa !11
  %42 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %41) #3
  %43 = getelementptr inbounds %struct.prob, ptr %42, i32 0, i32 1
  %44 = load i64, ptr %43, align 8, !tbaa !15
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = sub nsw i64 %45, %44
  store i64 %46, ptr %9, align 8, !tbaa !9
  %47 = load i64, ptr %12, align 8, !tbaa !11
  %48 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %47) #3
  invoke void @_ZNSt6vectorI4probSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %48)
          to label %49 unwind label %54

49:                                               ; preds = %38
  %50 = load i64, ptr %10, align 8, !tbaa !9
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = icmp sge i64 %50, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %49
  store i32 2, ptr %13, align 4
  br label %62

54:                                               ; preds = %38
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %14, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @_ZNSt6vectorI4probSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %67

58:                                               ; preds = %49
  br label %59

59:                                               ; preds = %58, %29
  %60 = load i64, ptr %12, align 8, !tbaa !11
  %61 = add nsw i64 %60, 1
  store i64 %61, ptr %12, align 8, !tbaa !11
  br label %17, !llvm.loop !16

62:                                               ; preds = %53, %37, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %63

63:                                               ; preds = %62
  store i1 true, ptr %11, align 1
  store i32 1, ptr %13, align 4
  %64 = load i1, ptr %11, align 1
  br i1 %64, label %66, label %65

65:                                               ; preds = %63
  call void @_ZNSt6vectorI4probSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br label %66

66:                                               ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void

67:                                               ; preds = %54
  %68 = load ptr, ptr %14, align 8
  %69 = load i32, ptr %15, align 4
  %70 = insertvalue { ptr, i32 } poison, ptr %68, 0
  %71 = insertvalue { ptr, i32 } %70, i32 %69, 1
  resume { ptr, i32 } %71
}

; 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 void @_ZNSt6vectorI4probSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4probSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS4prob", !10, i64 0, !10, i64 8, !10, i64 16}
!15 = !{!14, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl" }
%"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl" = type { %"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl_data" }
%"struct.std::_Vector_base<prob, std::allocator<prob>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5checkSt6vectorI4probSaIS0_EExx(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::vector") align 8 %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNSt6vectorI4probSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %5 = tail call noundef i64 @_ZNKSt6vectorI4probSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #2
  %.not25 = icmp eq i64 %5, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %24
  %.022 = phi i64 [ %.1, %24 ], [ %2, %4 ]
  %.01521 = phi i64 [ %.116, %24 ], [ 0, %4 ]
  %.01720 = phi i64 [ %25, %24 ], [ 0, %4 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01720) #2
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = icmp slt i64 %7, %3
  br i1 %8, label %24, label %9

9:                                                ; preds = %.lr.ph
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01720) #2
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !10
  %13 = icmp sgt i64 %12, %.022
  br i1 %13, label %._crit_edge, label %14

14:                                               ; preds = %9
  %15 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01720) #2
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load i64, ptr %16, align 8, !tbaa !10
  %18 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorI4probSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01720) #2
  invoke void @_ZNSt6vectorI4probSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %18)
          to label %19 unwind label %22

19:                                               ; preds = %14
  %20 = sub nsw i64 %.022, %17
  %21 = add nsw i64 %.01521, 1
  %.not = icmp slt i64 %21, %3
  br i1 %.not, label %24, label %._crit_edge

22:                                               ; preds = %14
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt6vectorI4probSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  resume { ptr, i32 } %23

24:                                               ; preds = %19, %.lr.ph
  %.116 = phi i64 [ %.01521, %.lr.ph ], [ %21, %19 ]
  %.1 = phi i64 [ %.022, %.lr.ph ], [ %20, %19 ]
  %25 = add nuw nsw i64 %.01720, 1
  %26 = tail call noundef i64 @_ZNKSt6vectorI4probSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #2
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %19, %9, %24, %4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4probSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4probSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

attributes #0 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTS4prob", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass