; LLVM IR from DionysiosB/CodeForces :: 1200-1299/1229A-MarcinAndTrainingCamp.ll (Z8arrogantxSt6vectorIxSaIxEE)

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

16:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %77

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %71, %17
  %19 = load i64, ptr %8, align 8, !tbaa !5
  %20 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #2
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %7, align 4
  br label %74

23:                                               ; preds = %18
  %24 = load i64, ptr %8, align 8, !tbaa !5
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %24) #2
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = icmp slt i64 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  br label %71

29:                                               ; preds = %23
  %30 = load i64, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %4, align 8, !tbaa !5
  %32 = icmp eq i64 %30, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %29
  br label %71

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %35 = load i64, ptr %4, align 8, !tbaa !5
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %35) #2
  %37 = load i64, ptr %36, align 8, !tbaa !5
  store i64 %37, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %38 = load i64, ptr %8, align 8, !tbaa !5
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %38) #2
  %40 = load i64, ptr %39, align 8, !tbaa !5
  store i64 %40, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #2
  store i8 0, ptr %11, align 1, !tbaa !13
  br label %41

41:                                               ; preds = %58, %34
  %42 = load i64, ptr %9, align 8, !tbaa !5
  %43 = icmp sgt i64 %42, 0
  br i1 %43, label %47, label %44

44:                                               ; preds = %41
  %45 = load i64, ptr %10, align 8, !tbaa !5
  %46 = icmp sgt i64 %45, 0
  br label %47

47:                                               ; preds = %44, %41
  %48 = phi i1 [ true, %41 ], [ %46, %44 ]
  br i1 %48, label %49, label %63

49:                                               ; preds = %47
  %50 = load i64, ptr %9, align 8, !tbaa !5
  %51 = and i64 %50, 1
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %58

53:                                               ; preds = %49
  %54 = load i64, ptr %10, align 8, !tbaa !5
  %55 = srem i64 %54, 2
  %56 = icmp eq i64 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  store i8 1, ptr %11, align 1, !tbaa !13
  br label %63

58:                                               ; preds = %53, %49
  %59 = load i64, ptr %9, align 8, !tbaa !5
  %60 = sdiv i64 %59, 2
  store i64 %60, ptr %9, align 8, !tbaa !5
  %61 = load i64, ptr %10, align 8, !tbaa !5
  %62 = sdiv i64 %61, 2
  store i64 %62, ptr %10, align 8, !tbaa !5
  br label %41, !llvm.loop !15

63:                                               ; preds = %57, %47
  %64 = load i8, ptr %11, align 1, !tbaa !13, !range !17, !noundef !18
  %65 = trunc i8 %64 to i1
  br i1 %65, label %67, label %66

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

67:                                               ; preds = %63
  store i32 0, ptr %7, align 4
  br label %68

68:                                               ; preds = %67, %66
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %69 = load i32, ptr %7, align 4
  switch i32 %69, label %74 [
    i32 0, label %70
  ]

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70, %33, %28
  %72 = load i64, ptr %8, align 8, !tbaa !5
  %73 = add nsw i64 %72, 1
  store i64 %73, ptr %8, align 8, !tbaa !5
  br label %18, !llvm.loop !19

74:                                               ; preds = %68, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %75 = load i32, ptr %7, align 4
  switch i32 %75, label %77 [
    i32 2, label %76
  ]

76:                                               ; preds = %74
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %77

77:                                               ; preds = %76, %74, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %78 = load i1, ptr %3, align 1
  ret i1 %78
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !16}


; 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 @_Z8arrogantxSt6vectorIxSaIxEE(i64 noundef %0, ptr noundef nonnull %1) local_unnamed_addr #0 {
  %3 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %0) #1
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = icmp slt i64 %4, 0
  br i1 %5, label %.critedge, label %.preheader

.preheader:                                       ; preds = %2
  %6 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #1
  %.not2533 = icmp eq i64 %6, 0
  br i1 %.not2533, label %.critedge, label %.lr.ph35

.lr.ph35:                                         ; preds = %.preheader, %.loopexit
  %.02034 = phi i64 [ %28, %.loopexit ], [ 0, %.preheader ]
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.02034) #1
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = icmp slt i64 %8, 0
  %10 = icmp eq i64 %.02034, %0
  %or.cond = or i1 %9, %10
  br i1 %or.cond, label %.loopexit, label %11

11:                                               ; preds = %.lr.ph35
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %0) #1
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.02034) #1
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = icmp sgt i64 %13, 0
  %17 = icmp sgt i64 %15, 0
  %18 = select i1 %16, i1 true, i1 %17
  br i1 %18, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %11, %22
  %.01831 = phi i64 [ %24, %22 ], [ %15, %11 ]
  %.01930 = phi i64 [ %23, %22 ], [ %13, %11 ]
  %19 = and i64 %.01930, 1
  %.not = icmp ne i64 %19, 0
  %20 = and i64 %.01831, 1
  %21 = icmp eq i64 %20, 0
  %or.cond27 = select i1 %.not, i1 %21, i1 false
  br i1 %or.cond27, label %.loopexit, label %22

22:                                               ; preds = %.lr.ph
  %23 = sdiv i64 %.01930, 2
  %24 = sdiv i64 %.01831, 2
  %25 = icmp sgt i64 %.01930, 1
  %26 = icmp sgt i64 %.01831, 1
  %27 = select i1 %25, i1 true, i1 %26
  br i1 %27, label %.lr.ph, label %.critedge, !llvm.loop !9

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph35
  %28 = add nuw nsw i64 %.02034, 1
  %29 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #1
  %.not25.not = icmp ult i64 %28, %29
  br i1 %.not25.not, label %.lr.ph35, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %.loopexit, %11, %22, %.preheader, %2
  %.4 = phi i1 [ false, %2 ], [ true, %.preheader ], [ false, %22 ], [ false, %11 ], [ true, %.loopexit ]
  ret i1 %.4
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) 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 = !{!"long long", !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}


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