; LLVM IR from eyangch/competitive-programming :: Codeforces/1750 (f)

; 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
@p2 = external dso_local global [5001 x i64], align 16
@ans = external dso_local global [5001 x i64], align 16
@dp = external dso_local global [5001 x i64], align 16
@sum = external dso_local global [5001 x i64], align 16
@_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
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %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
  store i32 0, ptr %1, align 4
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %17 = 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)
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(8) @M)
  store i64 1, ptr @p2, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 1, ptr %2, align 8, !tbaa !8
  br label %19

19:                                               ; preds = %34, %0
  %20 = load i64, ptr %2, align 8, !tbaa !8
  %21 = load i64, ptr @N, align 8, !tbaa !8
  %22 = icmp sle i64 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %37

24:                                               ; preds = %19
  %25 = load i64, ptr %2, align 8, !tbaa !8
  %26 = sub nsw i64 %25, 1
  %27 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !8
  %29 = mul nsw i64 %28, 2
  %30 = load i64, ptr @M, align 8, !tbaa !8
  %31 = srem i64 %29, %30
  %32 = load i64, ptr %2, align 8, !tbaa !8
  %33 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %32
  store i64 %31, ptr %33, align 8, !tbaa !8
  br label %34

34:                                               ; preds = %24
  %35 = load i64, ptr %2, align 8, !tbaa !8
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %2, align 8, !tbaa !8
  br label %19, !llvm.loop !11

37:                                               ; preds = %23
  store i64 1, ptr getelementptr inbounds ([5001 x i64], ptr @ans, i64 0, i64 1), align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 2, ptr %3, align 8, !tbaa !8
  br label %38

38:                                               ; preds = %48, %37
  %39 = load i64, ptr %3, align 8, !tbaa !8
  %40 = load i64, ptr @N, align 8, !tbaa !8
  %41 = icmp sle i64 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %51

43:                                               ; preds = %38
  %44 = load i64, ptr %3, align 8, !tbaa !8
  %45 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !8
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %45, align 8, !tbaa !8
  br label %48

48:                                               ; preds = %43
  %49 = load i64, ptr %3, align 8, !tbaa !8
  %50 = add nsw i64 %49, 1
  store i64 %50, ptr %3, align 8, !tbaa !8
  br label %38, !llvm.loop !13

51:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 2, ptr %4, align 8, !tbaa !8
  br label %52

52:                                               ; preds = %139, %51
  %53 = load i64, ptr %4, align 8, !tbaa !8
  %54 = load i64, ptr @N, align 8, !tbaa !8
  %55 = icmp sle i64 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %142

57:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store i64 1, ptr %6, align 8, !tbaa !8
  br label %58

58:                                               ; preds = %87, %57
  %59 = load i64, ptr %6, align 8, !tbaa !8
  %60 = load i64, ptr %4, align 8, !tbaa !8
  %61 = icmp slt i64 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %90

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %64 = load i64, ptr %4, align 8, !tbaa !8
  %65 = load i64, ptr %6, align 8, !tbaa !8
  %66 = mul nsw i64 2, %65
  %67 = sub nsw i64 %64, %66
  %68 = sub nsw i64 %67, 1
  store i64 %68, ptr %7, align 8, !tbaa !8
  %69 = load i64, ptr %6, align 8, !tbaa !8
  %70 = getelementptr inbounds [5001 x i64], ptr @ans, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !8
  %72 = load i64, ptr %7, align 8, !tbaa !8
  %73 = icmp sge i64 %72, 0
  br i1 %73, label %74, label %78

74:                                               ; preds = %63
  %75 = load i64, ptr %7, align 8, !tbaa !8
  %76 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !8
  br label %79

78:                                               ; preds = %63
  br label %79

79:                                               ; preds = %78, %74
  %80 = phi i64 [ %77, %74 ], [ 0, %78 ]
  %81 = add nsw i64 1, %80
  %82 = mul nsw i64 %71, %81
  %83 = load i64, ptr @M, align 8, !tbaa !8
  %84 = srem i64 %82, %83
  %85 = load i64, ptr %6, align 8, !tbaa !8
  %86 = getelementptr inbounds [5001 x i64], ptr @dp, i64 0, i64 %85
  store i64 %84, ptr %86, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %87

87:                                               ; preds = %79
  %88 = load i64, ptr %6, align 8, !tbaa !8
  %89 = add nsw i64 %88, 1
  store i64 %89, ptr %6, align 8, !tbaa !8
  br label %58, !llvm.loop !14

90:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %91 = load i64, ptr %4, align 8, !tbaa !8
  %92 = getelementptr inbounds i64, ptr @dp, i64 %91
  %93 = call noundef i64 @_ZSt10accumulateIPxxET0_T_S2_S1_(ptr noundef @dp, ptr noundef %92, i64 noundef 0)
  %94 = load i64, ptr @M, align 8, !tbaa !8
  %95 = srem i64 %93, %94
  store i64 %95, ptr %8, align 8, !tbaa !8
  %96 = load i64, ptr %4, align 8, !tbaa !8
  %97 = sub nsw i64 %96, 1
  %98 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !8
  %100 = load i64, ptr %8, align 8, !tbaa !8
  %101 = sub nsw i64 %99, %100
  %102 = load i64, ptr @M, align 8, !tbaa !8
  %103 = add nsw i64 %101, %102
  %104 = load i64, ptr @M, align 8, !tbaa !8
  %105 = srem i64 %103, %104
  %106 = load i64, ptr %4, align 8, !tbaa !8
  %107 = getelementptr inbounds [5001 x i64], ptr @dp, i64 0, i64 %106
  store i64 %105, ptr %107, align 8, !tbaa !8
  %108 = load i64, ptr %4, align 8, !tbaa !8
  %109 = getelementptr inbounds [5001 x i64], ptr @ans, i64 0, i64 %108
  store i64 %105, ptr %109, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %110 = load i64, ptr %4, align 8, !tbaa !8
  store i64 %110, ptr %10, align 8, !tbaa !8
  br label %111

111:                                              ; preds = %135, %90
  %112 = load i64, ptr %10, align 8, !tbaa !8
  %113 = load i64, ptr @N, align 8, !tbaa !8
  %114 = icmp sle i64 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %138

116:                                              ; preds = %111
  %117 = load i64, ptr %9, align 8, !tbaa !8
  %118 = load i64, ptr %10, align 8, !tbaa !8
  %119 = load i64, ptr %4, align 8, !tbaa !8
  %120 = sub nsw i64 %118, %119
  %121 = getelementptr inbounds [5001 x i64], ptr @dp, i64 0, i64 %120
  %122 = load i64, ptr %121, align 8, !tbaa !8
  %123 = add nsw i64 %117, %122
  %124 = load i64, ptr @M, align 8, !tbaa !8
  %125 = srem i64 %123, %124
  store i64 %125, ptr %9, align 8, !tbaa !8
  %126 = load i64, ptr %10, align 8, !tbaa !8
  %127 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %126
  %128 = load i64, ptr %127, align 8, !tbaa !8
  %129 = load i64, ptr %9, align 8, !tbaa !8
  %130 = add nsw i64 %128, %129
  %131 = load i64, ptr @M, align 8, !tbaa !8
  %132 = srem i64 %130, %131
  %133 = load i64, ptr %10, align 8, !tbaa !8
  %134 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %133
  store i64 %132, ptr %134, align 8, !tbaa !8
  br label %135

135:                                              ; preds = %116
  %136 = load i64, ptr %10, align 8, !tbaa !8
  %137 = add nsw i64 %136, 1
  store i64 %137, ptr %10, align 8, !tbaa !8
  br label %111, !llvm.loop !15

138:                                              ; preds = %115
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %139

139:                                              ; preds = %138
  %140 = load i64, ptr %4, align 8, !tbaa !8
  %141 = add nsw i64 %140, 1
  store i64 %141, ptr %4, align 8, !tbaa !8
  br label %52, !llvm.loop !16

142:                                              ; preds = %56
  %143 = load i64, ptr @N, align 8, !tbaa !8
  %144 = getelementptr inbounds [5001 x i64], ptr @ans, i64 0, i64 %143
  %145 = load i64, ptr %144, align 8, !tbaa !8
  %146 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %145)
  %147 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %146, i8 noundef signext 10)
  %148 = load i32, ptr %1, align 4
  ret i32 %148
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #2

; 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)) #3 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt10accumulateIPxxET0_T_S2_S1_(ptr noundef, ptr noundef, i64 noundef) #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #6

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 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 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 #2 = { "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 #3 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint 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 #6 = { 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 #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; 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
@p2 = external dso_local local_unnamed_addr global [5001 x i64], align 16
@ans = external dso_local local_unnamed_addr global [5001 x i64], align 16
@dp = external dso_local global [5001 x i64], align 16
@sum = external dso_local local_unnamed_addr global [5001 x i64], align 16
@_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 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %2 = getelementptr i8, ptr %1, i64 -24
  %3 = load i64, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %3
  %5 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %4, ptr noundef null)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = 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)
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(8) @M)
  store i64 1, ptr @p2, align 16, !tbaa !8
  %9 = load i64, ptr @N, align 8, !tbaa !8
  %.not45 = icmp slt i64 %9, 1
  br i1 %.not45, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  store i64 1, ptr getelementptr inbounds (i8, ptr @ans, i64 8), align 8, !tbaa !8
  br label %._crit_edge60

.lr.ph:                                           ; preds = %0
  %10 = load i64, ptr @M, align 8, !tbaa !8
  %xtraiter = and i64 %9, 1
  %11 = icmp eq i64 %9, 1
  br i1 %11, label %._crit_edge.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %9, 9223372036854775806
  br label %21

._crit_edge.unr-lcssa.loopexit:                   ; preds = %21
  %12 = shl nsw i64 %28, 1
  br label %._crit_edge.unr-lcssa

._crit_edge.unr-lcssa:                            ; preds = %._crit_edge.unr-lcssa.loopexit, %.lr.ph
  %.unr = phi i64 [ 2, %.lr.ph ], [ %12, %._crit_edge.unr-lcssa.loopexit ]
  %.03446.unr = phi i64 [ 1, %.lr.ph ], [ %30, %._crit_edge.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.epilog-lcssa

._crit_edge.epilog-lcssa:                         ; preds = %._crit_edge.unr-lcssa
  %13 = srem i64 %.unr, %10
  %14 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %.03446.unr
  store i64 %13, ptr %14, align 8, !tbaa !8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %._crit_edge.epilog-lcssa
  store i64 1, ptr getelementptr inbounds (i8, ptr @ans, i64 8), align 8, !tbaa !8
  %.not4047 = icmp eq i64 %9, 1
  br i1 %.not4047, label %._crit_edge60, label %.lr.ph50.preheader

.lr.ph50.preheader:                               ; preds = %._crit_edge
  %15 = add nsw i64 %9, -1
  %min.iters.check = icmp ult i64 %9, 5
  br i1 %min.iters.check, label %.lr.ph50.preheader72, label %vector.ph

.lr.ph50.preheader72:                             ; preds = %middle.block, %.lr.ph50.preheader
  %.03548.ph = phi i64 [ 2, %.lr.ph50.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph50

vector.ph:                                        ; preds = %.lr.ph50.preheader
  %n.vec = and i64 %15, -4
  %ind.end = or disjoint i64 %n.vec, 2
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 2
  %16 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %offset.idx
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load = load <2 x i64>, ptr %16, align 16, !tbaa !8
  %wide.load70 = load <2 x i64>, ptr %17, align 16, !tbaa !8
  %18 = add nsw <2 x i64> %wide.load, <i64 1, i64 1>
  %19 = add nsw <2 x i64> %wide.load70, <i64 1, i64 1>
  store <2 x i64> %18, ptr %16, align 16, !tbaa !8
  store <2 x i64> %19, ptr %17, align 16, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %15, %n.vec
  br i1 %cmp.n, label %.preheader43, label %.lr.ph50.preheader72

21:                                               ; preds = %21, %.lr.ph.new
  %22 = phi i64 [ 1, %.lr.ph.new ], [ %28, %21 ]
  %.03446 = phi i64 [ 1, %.lr.ph.new ], [ %30, %21 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %21 ]
  %23 = shl nsw i64 %22, 1
  %24 = srem i64 %23, %10
  %25 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %.03446
  store i64 %24, ptr %25, align 8, !tbaa !8
  %26 = add nuw i64 %.03446, 1
  %27 = shl nsw i64 %24, 1
  %28 = srem i64 %27, %10
  %29 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %26
  store i64 %28, ptr %29, align 8, !tbaa !8
  %30 = add nuw i64 %.03446, 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_edge.unr-lcssa.loopexit, label %21, !llvm.loop !15

.preheader43:                                     ; preds = %.lr.ph50, %middle.block
  br i1 %.not4047, label %._crit_edge60, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader43
  %.pre = load i64, ptr @M, align 8, !tbaa !8
  br label %.preheader

.lr.ph50:                                         ; preds = %.lr.ph50.preheader72, %.lr.ph50
  %.03548 = phi i64 [ %34, %.lr.ph50 ], [ %.03548.ph, %.lr.ph50.preheader72 ]
  %31 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %.03548
  %32 = load i64, ptr %31, align 8, !tbaa !8
  %33 = add nsw i64 %32, 1
  store i64 %33, ptr %31, align 8, !tbaa !8
  %34 = add nuw i64 %.03548, 1
  %exitcond63.not = icmp eq i64 %.03548, %9
  br i1 %exitcond63.not, label %.preheader43, label %.lr.ph50, !llvm.loop !16

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge57
  %35 = phi i64 [ %43, %._crit_edge57 ], [ %.pre, %.preheader.preheader ]
  %.03759 = phi i64 [ %70, %._crit_edge57 ], [ 2, %.preheader.preheader ]
  br label %53

._crit_edge60:                                    ; preds = %._crit_edge57, %._crit_edge, %._crit_edge.thread, %.preheader43
  %.lcssa = phi i64 [ %9, %.preheader43 ], [ %9, %._crit_edge.thread ], [ %9, %._crit_edge ], [ %52, %._crit_edge57 ]
  %36 = getelementptr inbounds [5001 x i64], ptr @ans, i64 0, i64 %.lcssa
  %37 = load i64, ptr %36, align 8, !tbaa !8
  %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 @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %38, i8 noundef signext 10)
  ret i32 0

40:                                               ; preds = %63
  %41 = getelementptr inbounds i64, ptr @dp, i64 %.03759
  %42 = tail call noundef i64 @_ZSt10accumulateIPxxET0_T_S2_S1_(ptr noundef nonnull @dp, ptr noundef nonnull %41, i64 noundef 0)
  %43 = load i64, ptr @M, align 8, !tbaa !8
  %44 = srem i64 %42, %43
  %45 = add nsw i64 %.03759, -1
  %46 = getelementptr inbounds [5001 x i64], ptr @p2, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !8
  %48 = sub i64 %43, %44
  %49 = add i64 %48, %47
  %50 = srem i64 %49, %43
  store i64 %50, ptr %41, align 8, !tbaa !8
  %51 = getelementptr inbounds [5001 x i64], ptr @ans, i64 0, i64 %.03759
  store i64 %50, ptr %51, align 8, !tbaa !8
  %52 = load i64, ptr @N, align 8, !tbaa !8
  %.not4252 = icmp sgt i64 %.03759, %52
  br i1 %.not4252, label %._crit_edge57, label %.lr.ph56

53:                                               ; preds = %.preheader, %63
  %.03651 = phi i64 [ 1, %.preheader ], [ %69, %63 ]
  %54 = shl nuw nsw i64 %.03651, 1
  %55 = xor i64 %54, -1
  %56 = add nsw i64 %.03759, %55
  %57 = getelementptr inbounds [5001 x i64], ptr @ans, i64 0, i64 %.03651
  %58 = load i64, ptr %57, align 8, !tbaa !8
  %59 = icmp sgt i64 %56, -1
  br i1 %59, label %60, label %63

60:                                               ; preds = %53
  %61 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %56
  %62 = load i64, ptr %61, align 8, !tbaa !8
  br label %63

63:                                               ; preds = %53, %60
  %64 = phi i64 [ %62, %60 ], [ 0, %53 ]
  %65 = add nsw i64 %64, 1
  %66 = mul nsw i64 %65, %58
  %67 = srem i64 %66, %35
  %68 = getelementptr inbounds [5001 x i64], ptr @dp, i64 0, i64 %.03651
  store i64 %67, ptr %68, align 8, !tbaa !8
  %69 = add nuw nsw i64 %.03651, 1
  %exitcond64.not = icmp eq i64 %69, %.03759
  br i1 %exitcond64.not, label %40, label %53, !llvm.loop !17

._crit_edge57:                                    ; preds = %.lr.ph56, %40
  %70 = add nuw nsw i64 %.03759, 1
  %.not41.not = icmp slt i64 %.03759, %52
  br i1 %.not41.not, label %.preheader, label %._crit_edge60, !llvm.loop !18

.lr.ph56:                                         ; preds = %40, %.lr.ph56
  %.054 = phi i64 [ %80, %.lr.ph56 ], [ %.03759, %40 ]
  %.03353 = phi i64 [ %75, %.lr.ph56 ], [ 0, %40 ]
  %71 = sub nuw nsw i64 %.054, %.03759
  %72 = getelementptr inbounds [5001 x i64], ptr @dp, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !8
  %74 = add nsw i64 %73, %.03353
  %75 = srem i64 %74, %43
  %76 = getelementptr inbounds [5001 x i64], ptr @sum, i64 0, i64 %.054
  %77 = load i64, ptr %76, align 8, !tbaa !8
  %78 = add nsw i64 %77, %75
  %79 = srem i64 %78, %43
  store i64 %79, ptr %76, align 8, !tbaa !8
  %80 = add nuw nsw i64 %.054, 1
  %.not42.not = icmp slt i64 %.054, %52
  br i1 %.not42.not, label %.lr.ph56, label %._crit_edge57, !llvm.loop !19
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

; 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 #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt10accumulateIPxxET0_T_S2_S1_(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

; 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 #3 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 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 #2 = { "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 #3 = { 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 = { inlinehint 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 #5 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14, !13}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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