; LLVM IR from DionysiosB/CodeForces :: CodeforcesEDU/BinarySearch3B-SplittingAnArray.ll (Z5checkRKSt6vectorIxSaIxEExx)

; 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 zeroext i1 @_Z5checkRKSt6vectorIxSaIxEExx(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %12 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %12, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %55, %3
  %14 = load i64, ptr %10, align 8, !tbaa !11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #2
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  store i32 2, ptr %11, align 4
  br label %58

19:                                               ; preds = %13
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i64, ptr %10, align 8, !tbaa !11
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %20, i64 noundef %21) #2
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = icmp sgt i64 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %19
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %58

27:                                               ; preds = %19
  %28 = load i64, ptr %9, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i64, ptr %10, align 8, !tbaa !11
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %30) #2
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = add nsw i64 %28, %32
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = icmp sle i64 %33, %34
  br i1 %35, label %36, label %43

36:                                               ; preds = %27
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i64, ptr %10, align 8, !tbaa !11
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %38) #2
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = load i64, ptr %9, align 8, !tbaa !9
  %42 = add nsw i64 %41, %40
  store i64 %42, ptr %9, align 8, !tbaa !9
  br label %50

43:                                               ; preds = %27
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = add nsw i64 %44, -1
  store i64 %45, ptr %8, align 8, !tbaa !9
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i64, ptr %10, align 8, !tbaa !11
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %46, i64 noundef %47) #2
  %49 = load i64, ptr %48, align 8, !tbaa !9
  store i64 %49, ptr %9, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %43, %36
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %58

54:                                               ; preds = %50
  br label %55

55:                                               ; preds = %54
  %56 = load i64, ptr %10, align 8, !tbaa !11
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %10, align 8, !tbaa !11
  br label %13, !llvm.loop !13

58:                                               ; preds = %53, %26, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %59 = load i32, ptr %11, align 4
  switch i32 %59, label %68 [
    i32 2, label %60
  ]

60:                                               ; preds = %58
  %61 = load i64, ptr %9, align 8, !tbaa !9
  %62 = icmp sgt i64 %61, 0
  br i1 %62, label %63, label %67

63:                                               ; preds = %60
  %64 = load i64, ptr %8, align 8, !tbaa !9
  %65 = icmp sle i64 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %63
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %68

67:                                               ; preds = %63, %60
  store i1 true, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %68

68:                                               ; preds = %67, %66, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %69 = load i1, ptr %4, align 1
  ret i1 %69
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(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

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 = { 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 = distinct !{!13, !14}
!14 = !{!"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
define dso_local noundef zeroext i1 @_Z5checkRKSt6vectorIxSaIxEExx(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not3037.not = icmp eq i64 %4, 0
  br i1 %.not3037.not, label %._crit_edge, label %.lr.ph

5:                                                ; preds = %23
  %6 = add nuw nsw i64 %.02240, 1
  %7 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not30 = icmp ult i64 %6, %7
  br i1 %.not30, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !5

.lr.ph:                                           ; preds = %3, %5
  %.02240 = phi i64 [ %6, %5 ], [ 0, %3 ]
  %.02339 = phi i64 [ %.1, %5 ], [ 0, %3 ]
  %.02438 = phi i64 [ %.125, %5 ], [ %1, %3 ]
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.02240) #1
  %9 = load i64, ptr %8, align 8, !tbaa !7
  %10 = icmp sgt i64 %9, %2
  br i1 %10, label %.thread, label %11

11:                                               ; preds = %.lr.ph
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.02240) #1
  %13 = load i64, ptr %12, align 8, !tbaa !7
  %14 = add nsw i64 %13, %.02339
  %.not = icmp sgt i64 %14, %2
  br i1 %.not, label %19, label %15

15:                                               ; preds = %11
  %16 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.02240) #1
  %17 = load i64, ptr %16, align 8, !tbaa !7
  %18 = add nsw i64 %17, %.02339
  br label %23

19:                                               ; preds = %11
  %20 = add nsw i64 %.02438, -1
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.02240) #1
  %22 = load i64, ptr %21, align 8, !tbaa !7
  br label %23

23:                                               ; preds = %19, %15
  %.125 = phi i64 [ %.02438, %15 ], [ %20, %19 ]
  %.1 = phi i64 [ %18, %15 ], [ %22, %19 ]
  %24 = icmp slt i64 %.125, 0
  br i1 %24, label %.thread, label %5

._crit_edge.loopexit:                             ; preds = %5
  %25 = icmp slt i64 %.1, 1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.024.lcssa = phi i64 [ %1, %3 ], [ %.125, %._crit_edge.loopexit ]
  %.023.lcssa = phi i1 [ true, %3 ], [ %25, %._crit_edge.loopexit ]
  %26 = icmp sgt i64 %.024.lcssa, 0
  %or.cond.not = or i1 %26, %.023.lcssa
  br label %.thread

.thread:                                          ; preds = %.lr.ph, %23, %._crit_edge
  %.128 = phi i1 [ %or.cond.not, %._crit_edge ], [ false, %23 ], [ false, %.lr.ph ]
  ret i1 %.128
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(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(8) ptr @_ZNKSt6vectorIxSaIxEEixEm(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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass