; LLVM IR from AdarshGaur/Competitive-Programming :: Codeforces/Codeforces Round #825 (Div. 2) /C1. Good Subarrays (Easy Version).ll (Z5solvev)

; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i64, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %9 = load i64, ptr %1, align 8, !tbaa !5
  %10 = call ptr @llvm.stacksave.p0()
  store ptr %10, ptr %2, align 8
  %11 = alloca i64, i64 %9, align 16
  store i64 %9, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %21, %0
  %13 = load i64, ptr %4, align 8, !tbaa !5
  %14 = load i64, ptr %1, align 8, !tbaa !5
  %15 = icmp slt i64 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %24

17:                                               ; preds = %12
  %18 = load i64, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i64, ptr %11, i64 %18
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %19)
  br label %21

21:                                               ; preds = %17
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = add nsw i64 %22, 1
  store i64 %23, ptr %4, align 8, !tbaa !5
  br label %12, !llvm.loop !9

24:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %47, %24
  %26 = load i64, ptr %7, align 8, !tbaa !5
  %27 = load i64, ptr %1, align 8, !tbaa !5
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %50

30:                                               ; preds = %25
  %31 = load i64, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds i64, ptr %11, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = load i64, ptr %5, align 8, !tbaa !5
  %35 = icmp sgt i64 %33, %34
  br i1 %35, label %36, label %39

36:                                               ; preds = %30
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %5, align 8, !tbaa !5
  br label %43

39:                                               ; preds = %30
  %40 = load i64, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds i64, ptr %11, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !5
  store i64 %42, ptr %5, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %39, %36
  %44 = load i64, ptr %5, align 8, !tbaa !5
  %45 = load i64, ptr %6, align 8, !tbaa !5
  %46 = add nsw i64 %45, %44
  store i64 %46, ptr %6, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %43
  %48 = load i64, ptr %7, align 8, !tbaa !5
  %49 = add nsw i64 %48, 1
  store i64 %49, ptr %7, align 8, !tbaa !5
  br label %25, !llvm.loop !11

50:                                               ; preds = %29
  %51 = load i64, ptr %6, align 8, !tbaa !5
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %51)
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %52, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %54 = load ptr, ptr %2, align 8
  call void @llvm.stackrestore.p0(ptr %54)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { inlinehint 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 #4 = { 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", !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}


; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = call ptr @llvm.stacksave.p0()
  %5 = alloca i64, i64 %3, align 16
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %8 = icmp sgt i64 %13, 0
  br i1 %8, label %.lr.ph20.preheader, label %._crit_edge

.lr.ph20.preheader:                               ; preds = %.preheader
  %xtraiter = and i64 %13, 3
  %9 = icmp ult i64 %13, 4
  br i1 %9, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph20.preheader.new

.lr.ph20.preheader.new:                           ; preds = %.lr.ph20.preheader
  %unroll_iter = and i64 %13, 9223372036854775804
  br label %.lr.ph20

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01416 = phi i64 [ %12, %.lr.ph ], [ 0, %0 ]
  %10 = getelementptr inbounds i64, ptr %5, i64 %.01416
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %12 = add nuw nsw i64 %.01416, 1
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = icmp slt i64 %12, %13
  br i1 %14, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph20, %.lr.ph20.preheader
  %.lcssa.ph = phi i64 [ poison, %.lr.ph20.preheader ], [ %45, %.lr.ph20 ]
  %.019.unr = phi i64 [ 0, %.lr.ph20.preheader ], [ %46, %.lr.ph20 ]
  %.01218.unr = phi i64 [ 0, %.lr.ph20.preheader ], [ %45, %.lr.ph20 ]
  %.01317.unr = phi i64 [ 0, %.lr.ph20.preheader ], [ %.1.3, %.lr.ph20 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph20.epil

.lr.ph20.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph20.epil
  %.019.epil = phi i64 [ %20, %.lr.ph20.epil ], [ %.019.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01218.epil = phi i64 [ %19, %.lr.ph20.epil ], [ %.01218.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01317.epil = phi i64 [ %.1.epil, %.lr.ph20.epil ], [ %.01317.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph20.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %15 = getelementptr inbounds i64, ptr %5, i64 %.019.epil
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = icmp sgt i64 %16, %.01317.epil
  %18 = add nsw i64 %.01317.epil, 1
  %.1.epil = select i1 %17, i64 %18, i64 %16
  %19 = add nsw i64 %.1.epil, %.01218.epil
  %20 = add nuw nsw i64 %.019.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph20.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph20.epil, %0, %.preheader
  %.012.lcssa = phi i64 [ 0, %.preheader ], [ 0, %0 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %19, %.lr.ph20.epil ]
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.012.lcssa)
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef nonnull @.str)
  call void @llvm.stackrestore.p0(ptr %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret void

.lr.ph20:                                         ; preds = %.lr.ph20, %.lr.ph20.preheader.new
  %.019 = phi i64 [ 0, %.lr.ph20.preheader.new ], [ %46, %.lr.ph20 ]
  %.01218 = phi i64 [ 0, %.lr.ph20.preheader.new ], [ %45, %.lr.ph20 ]
  %.01317 = phi i64 [ 0, %.lr.ph20.preheader.new ], [ %.1.3, %.lr.ph20 ]
  %niter = phi i64 [ 0, %.lr.ph20.preheader.new ], [ %niter.next.3, %.lr.ph20 ]
  %23 = getelementptr inbounds i64, ptr %5, i64 %.019
  %24 = load i64, ptr %23, align 16, !tbaa !5
  %25 = icmp sgt i64 %24, %.01317
  %26 = add nsw i64 %.01317, 1
  %.1 = select i1 %25, i64 %26, i64 %24
  %27 = add nsw i64 %.1, %.01218
  %28 = or disjoint i64 %.019, 1
  %29 = getelementptr inbounds i64, ptr %5, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = icmp sgt i64 %30, %.1
  %32 = add nsw i64 %.1, 1
  %.1.1 = select i1 %31, i64 %32, i64 %30
  %33 = add nsw i64 %.1.1, %27
  %34 = or disjoint i64 %.019, 2
  %35 = getelementptr inbounds i64, ptr %5, i64 %34
  %36 = load i64, ptr %35, align 16, !tbaa !5
  %37 = icmp sgt i64 %36, %.1.1
  %38 = add nsw i64 %.1.1, 1
  %.1.2 = select i1 %37, i64 %38, i64 %36
  %39 = add nsw i64 %.1.2, %33
  %40 = or disjoint i64 %.019, 3
  %41 = getelementptr inbounds i64, ptr %5, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = icmp sgt i64 %42, %.1.2
  %44 = add nsw i64 %.1.2, 1
  %.1.3 = select i1 %43, i64 %44, i64 %42
  %45 = add nsw i64 %.1.3, %39
  %46 = add nuw nsw i64 %.019, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph20, !llvm.loop !13
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { inlinehint 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 #4 = { 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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}


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