; LLVM IR from manishbisht/Competitive-Programming :: Codeforces/Educational Codeforces Round 15 (Maximum Increase)

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

@n = external dso_local global i64, align 8
@i = external dso_local global i64, align 8
@a = external dso_local global [100000 x i64], align 16
@temp = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %3

3:                                                ; preds = %11, %0
  %4 = load i64, ptr @i, align 8, !tbaa !5
  %5 = load i64, ptr @n, align 8, !tbaa !5
  %6 = icmp slt i64 %4, %5
  br i1 %6, label %7, label %14

7:                                                ; preds = %3
  %8 = load i64, ptr @i, align 8, !tbaa !5
  %9 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %8
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %9)
  br label %11

11:                                               ; preds = %7
  %12 = load i64, ptr @i, align 8, !tbaa !5
  %13 = add nsw i64 %12, 1
  store i64 %13, ptr @i, align 8, !tbaa !5
  br label %3, !llvm.loop !9

14:                                               ; preds = %3
  store i64 0, ptr @temp, align 8, !tbaa !5
  store i64 0, ptr @ans, align 8, !tbaa !5
  store i64 1, ptr @i, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %39, %14
  %16 = load i64, ptr @i, align 8, !tbaa !5
  %17 = load i64, ptr @n, align 8, !tbaa !5
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %19, label %42

19:                                               ; preds = %15
  %20 = load i64, ptr @i, align 8, !tbaa !5
  %21 = sub nsw i64 %20, 1
  %22 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = load i64, ptr @i, align 8, !tbaa !5
  %25 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = icmp slt i64 %23, %26
  br i1 %27, label %28, label %31

28:                                               ; preds = %19
  %29 = load i64, ptr @temp, align 8, !tbaa !5
  %30 = add nsw i64 %29, 1
  store i64 %30, ptr @temp, align 8, !tbaa !5
  br label %32

31:                                               ; preds = %19
  store i64 0, ptr @temp, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %31, %28
  %33 = load i64, ptr @ans, align 8, !tbaa !5
  %34 = load i64, ptr @temp, align 8, !tbaa !5
  %35 = icmp slt i64 %33, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = load i64, ptr @temp, align 8, !tbaa !5
  store i64 %37, ptr @ans, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %36, %32
  br label %39

39:                                               ; preds = %38
  %40 = load i64, ptr @i, align 8, !tbaa !5
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr @i, align 8, !tbaa !5
  br label %15, !llvm.loop !11

42:                                               ; preds = %15
  %43 = load i64, ptr @ans, align 8, !tbaa !5
  %44 = add nsw i64 %43, 1
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %44)
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

attributes #0 = { mustprogress norecurse 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 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 = { 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" }

!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}


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

@n = external dso_local global i64, align 8
@i = external dso_local local_unnamed_addr global i64, align 8
@a = external dso_local global [100000 x i64], align 16
@temp = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  store i64 0, ptr @i, align 8, !tbaa !5
  %2 = load i64, ptr @n, align 8, !tbaa !5
  %3 = icmp sgt i64 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  store i64 0, ptr @temp, align 8, !tbaa !5
  store i64 0, ptr @ans, align 8, !tbaa !5
  br label %36

.lr.ph:                                           ; preds = %0, %.lr.ph
  %storemerge5 = phi i64 [ %7, %.lr.ph ], [ 0, %0 ]
  %4 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %storemerge5
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %6 = load i64, ptr @i, align 8, !tbaa !5
  %7 = add nsw i64 %6, 1
  store i64 %7, ptr @i, align 8, !tbaa !5
  %8 = load i64, ptr @n, align 8, !tbaa !5
  %9 = icmp slt i64 %7, %8
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  store i64 0, ptr @temp, align 8, !tbaa !5
  store i64 0, ptr @ans, align 8, !tbaa !5
  %10 = icmp sgt i64 %8, 1
  br i1 %10, label %.lr.ph13.preheader, label %36

.lr.ph13.preheader:                               ; preds = %._crit_edge
  %.pre = load i64, ptr @a, align 16, !tbaa !5
  %11 = add nsw i64 %8, -1
  %xtraiter = and i64 %11, 1
  %12 = icmp eq i64 %8, 2
  br i1 %12, label %._crit_edge14.unr-lcssa, label %.lr.ph13.preheader.new

.lr.ph13.preheader.new:                           ; preds = %.lr.ph13.preheader
  %unroll_iter = and i64 %11, -2
  br label %.lr.ph13

.lr.ph13:                                         ; preds = %27, %.lr.ph13.preheader.new
  %13 = phi i64 [ %.pre, %.lr.ph13.preheader.new ], [ %22, %27 ]
  %storemerge311 = phi i64 [ 1, %.lr.ph13.preheader.new ], [ %28, %27 ]
  %storemerge4610 = phi i64 [ 0, %.lr.ph13.preheader.new ], [ %storemerge4.1, %27 ]
  %storemerge489 = phi i64 [ 0, %.lr.ph13.preheader.new ], [ %storemerge47.1, %27 ]
  %niter = phi i64 [ 0, %.lr.ph13.preheader.new ], [ %niter.next.1, %27 ]
  %14 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %storemerge311
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = icmp slt i64 %13, %15
  %17 = add nsw i64 %storemerge4610, 1
  %storemerge4 = select i1 %16, i64 %17, i64 0
  %18 = icmp slt i64 %storemerge489, %storemerge4
  br i1 %18, label %19, label %.lr.ph13.1

19:                                               ; preds = %.lr.ph13
  store i64 %storemerge4, ptr @ans, align 8, !tbaa !5
  br label %.lr.ph13.1

.lr.ph13.1:                                       ; preds = %.lr.ph13, %19
  %storemerge47 = phi i64 [ %storemerge489, %.lr.ph13 ], [ %storemerge4, %19 ]
  %20 = add nuw nsw i64 %storemerge311, 1
  %21 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = icmp slt i64 %15, %22
  %24 = add nsw i64 %storemerge4, 1
  %storemerge4.1 = select i1 %23, i64 %24, i64 0
  %25 = icmp slt i64 %storemerge47, %storemerge4.1
  br i1 %25, label %26, label %27

26:                                               ; preds = %.lr.ph13.1
  store i64 %storemerge4.1, ptr @ans, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %26, %.lr.ph13.1
  %storemerge47.1 = phi i64 [ %storemerge47, %.lr.ph13.1 ], [ %storemerge4.1, %26 ]
  %28 = add nuw nsw i64 %storemerge311, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge14.unr-lcssa.loopexit, label %.lr.ph13, !llvm.loop !11

._crit_edge14.unr-lcssa.loopexit:                 ; preds = %27
  %29 = add nsw i64 %storemerge4.1, 1
  br label %._crit_edge14.unr-lcssa

._crit_edge14.unr-lcssa:                          ; preds = %._crit_edge14.unr-lcssa.loopexit, %.lr.ph13.preheader
  %storemerge47.lcssa.ph = phi i64 [ poison, %.lr.ph13.preheader ], [ %storemerge47.1, %._crit_edge14.unr-lcssa.loopexit ]
  %storemerge4.lcssa.ph = phi i64 [ poison, %.lr.ph13.preheader ], [ %storemerge4.1, %._crit_edge14.unr-lcssa.loopexit ]
  %.unr = phi i64 [ %.pre, %.lr.ph13.preheader ], [ %22, %._crit_edge14.unr-lcssa.loopexit ]
  %storemerge311.unr = phi i64 [ 1, %.lr.ph13.preheader ], [ %28, %._crit_edge14.unr-lcssa.loopexit ]
  %storemerge4610.unr = phi i64 [ 1, %.lr.ph13.preheader ], [ %29, %._crit_edge14.unr-lcssa.loopexit ]
  %storemerge489.unr = phi i64 [ 0, %.lr.ph13.preheader ], [ %storemerge47.1, %._crit_edge14.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge14, label %.lr.ph13.epil

.lr.ph13.epil:                                    ; preds = %._crit_edge14.unr-lcssa
  %30 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %storemerge311.unr
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = icmp slt i64 %.unr, %31
  %storemerge4.epil = select i1 %32, i64 %storemerge4610.unr, i64 0
  %33 = icmp slt i64 %storemerge489.unr, %storemerge4.epil
  br i1 %33, label %34, label %._crit_edge14

34:                                               ; preds = %.lr.ph13.epil
  store i64 %storemerge4.epil, ptr @ans, align 8, !tbaa !5
  br label %._crit_edge14

._crit_edge14:                                    ; preds = %.lr.ph13.epil, %34, %._crit_edge14.unr-lcssa
  %storemerge47.lcssa = phi i64 [ %storemerge47.lcssa.ph, %._crit_edge14.unr-lcssa ], [ %storemerge489.unr, %.lr.ph13.epil ], [ %storemerge4.epil, %34 ]
  %storemerge4.lcssa = phi i64 [ %storemerge4.lcssa.ph, %._crit_edge14.unr-lcssa ], [ %storemerge4.epil, %34 ], [ %storemerge4.epil, %.lr.ph13.epil ]
  store i64 %storemerge4.lcssa, ptr @temp, align 8, !tbaa !5
  %35 = add nsw i64 %storemerge47.lcssa, 1
  br label %36

36:                                               ; preds = %._crit_edge.thread, %._crit_edge14, %._crit_edge
  %37 = phi i64 [ %35, %._crit_edge14 ], [ 1, %._crit_edge ], [ 1, %._crit_edge.thread ]
  %storemerge3.lcssa = phi i64 [ %8, %._crit_edge14 ], [ 1, %._crit_edge ], [ 1, %._crit_edge.thread ]
  store i64 %storemerge3.lcssa, ptr @i, align 8, !tbaa !5
  %38 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %37)
  %39 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

attributes #0 = { mustprogress norecurse 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 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 = { 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" }

!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: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass