; LLVM IR from manishbisht/Competitive-Programming :: Codeforces/Codeforces Round #358 (Div. 2) (Alyona and Numbers)

; 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
@m = external dso_local global i64, align 8
@i = external dso_local global i64, align 8
@c = external dso_local global i64, align 8
@temp = 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)
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) @m)
  store i64 1, ptr @i, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %24, %0
  %5 = load i64, ptr @i, align 8, !tbaa !5
  %6 = load i64, ptr @n, align 8, !tbaa !5
  %7 = icmp sle i64 %5, %6
  br i1 %7, label %8, label %27

8:                                                ; preds = %4
  %9 = load i64, ptr @m, align 8, !tbaa !5
  %10 = load i64, ptr @i, align 8, !tbaa !5
  %11 = add nsw i64 %9, %10
  store i64 %11, ptr @temp, align 8, !tbaa !5
  %12 = load i64, ptr @c, align 8, !tbaa !5
  %13 = load i64, ptr @temp, align 8, !tbaa !5
  %14 = sdiv i64 %13, 5
  %15 = add nsw i64 %12, %14
  store i64 %15, ptr @c, align 8, !tbaa !5
  %16 = load i64, ptr @i, align 8, !tbaa !5
  %17 = icmp sge i64 %16, 5
  br i1 %17, label %18, label %23

18:                                               ; preds = %8
  %19 = load i64, ptr @c, align 8, !tbaa !5
  %20 = load i64, ptr @i, align 8, !tbaa !5
  %21 = sdiv i64 %20, 5
  %22 = sub nsw i64 %19, %21
  store i64 %22, ptr @c, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %18, %8
  br label %24

24:                                               ; preds = %23
  %25 = load i64, ptr @i, align 8, !tbaa !5
  %26 = add nsw i64 %25, 1
  store i64 %26, ptr @i, align 8, !tbaa !5
  br label %4, !llvm.loop !9

27:                                               ; preds = %4
  %28 = load i64, ptr @c, align 8, !tbaa !5
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %28)
  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

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

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


; 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
@m = external dso_local global i64, align 8
@i = external dso_local local_unnamed_addr global i64, align 8
@c = external dso_local local_unnamed_addr global i64, align 8
@temp = 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)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) @m)
  %3 = load i64, ptr @n, align 8, !tbaa !5
  %.not4 = icmp slt i64 %3, 1
  %.pre = load i64, ptr @c, align 8, !tbaa !5
  br i1 %.not4, label %._crit_edge19, label %4

4:                                                ; preds = %0
  %5 = load i64, ptr @m, align 8, !tbaa !5
  %6 = add nuw i64 %3, 1
  %7 = add nsw i64 %5, 1
  %8 = sdiv i64 %7, 5
  %9 = add nsw i64 %.pre, %8
  %exitcond.peel.not = icmp eq i64 %6, 2
  br i1 %exitcond.peel.not, label %._crit_edge, label %10

10:                                               ; preds = %4
  %11 = add nsw i64 %5, 2
  %12 = sdiv i64 %11, 5
  %13 = add nsw i64 %9, %12
  %exitcond.peel10.not = icmp eq i64 %6, 3
  br i1 %exitcond.peel10.not, label %._crit_edge, label %14

14:                                               ; preds = %10
  %15 = add nsw i64 %5, 3
  %16 = sdiv i64 %15, 5
  %17 = add nsw i64 %13, %16
  %exitcond.peel13.not = icmp eq i64 %6, 4
  br i1 %exitcond.peel13.not, label %._crit_edge, label %18

18:                                               ; preds = %14
  %19 = add nsw i64 %5, 4
  %20 = sdiv i64 %19, 5
  %21 = add nsw i64 %17, %20
  %exitcond.peel16.not = icmp eq i64 %6, 5
  br i1 %exitcond.peel16.not, label %._crit_edge, label %.peel.next14.preheader

.peel.next14.preheader:                           ; preds = %18
  %xtraiter = and i64 %3, 1
  %22 = icmp eq i64 %3, 5
  br i1 %22, label %._crit_edge.loopexit.unr-lcssa, label %.peel.next14.preheader.new

.peel.next14.preheader.new:                       ; preds = %.peel.next14.preheader
  %23 = and i64 %3, 9223372036854775806
  %24 = add nsw i64 %23, -6
  br label %.peel.next14

.peel.next14:                                     ; preds = %.peel.next14, %.peel.next14.preheader.new
  %storemerge6 = phi i64 [ 5, %.peel.next14.preheader.new ], [ %36, %.peel.next14 ]
  %storemerge235 = phi i64 [ %21, %.peel.next14.preheader.new ], [ %35, %.peel.next14 ]
  %niter = phi i64 [ 0, %.peel.next14.preheader.new ], [ %niter.next.1, %.peel.next14 ]
  %25 = add nsw i64 %5, %storemerge6
  %26 = sdiv i64 %25, 5
  %27 = add nsw i64 %storemerge235, %26
  %28 = udiv i64 %storemerge6, 5
  %29 = add nuw i64 %storemerge6, 1
  %30 = add nsw i64 %5, %29
  %31 = sdiv i64 %30, 5
  %32 = udiv i64 %29, 5
  %33 = add i64 %27, %31
  %34 = add nuw nsw i64 %28, %32
  %35 = sub i64 %33, %34
  %36 = add nuw i64 %storemerge6, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %24
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.peel.next14, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.peel.next14, %.peel.next14.preheader
  %.lcssa.ph = phi i64 [ poison, %.peel.next14.preheader ], [ %35, %.peel.next14 ]
  %storemerge6.unr = phi i64 [ 5, %.peel.next14.preheader ], [ %36, %.peel.next14 ]
  %storemerge235.unr = phi i64 [ %21, %.peel.next14.preheader ], [ %35, %.peel.next14 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.peel.next14.epil

.peel.next14.epil:                                ; preds = %._crit_edge.loopexit.unr-lcssa
  %37 = add nsw i64 %5, %storemerge6.unr
  %38 = sdiv i64 %37, 5
  %39 = add nsw i64 %storemerge235.unr, %38
  %40 = udiv i64 %storemerge6.unr, 5
  %41 = sub nsw i64 %39, %40
  br label %._crit_edge

._crit_edge:                                      ; preds = %.peel.next14.epil, %._crit_edge.loopexit.unr-lcssa, %18, %14, %10, %4
  %storemerge2.lcssa = phi i64 [ %9, %4 ], [ %13, %10 ], [ %17, %14 ], [ %21, %18 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %41, %.peel.next14.epil ]
  %42 = add i64 %3, %5
  store i64 %42, ptr @temp, align 8, !tbaa !5
  store i64 %storemerge2.lcssa, ptr @c, align 8, !tbaa !5
  br label %._crit_edge19

._crit_edge19:                                    ; preds = %0, %._crit_edge
  %43 = phi i64 [ %storemerge2.lcssa, %._crit_edge ], [ %.pre, %0 ]
  %storemerge.lcssa = phi i64 [ %6, %._crit_edge ], [ 1, %0 ]
  store i64 %storemerge.lcssa, ptr @i, align 8, !tbaa !5
  %44 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %43)
  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

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

!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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass