; LLVM IR from eyangch/competitive-programming :: Codeforces/1525 (e)

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

@MOD = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@d = external dso_local global [20 x [50000 x i64]], align 16
@v = external dso_local global [21 x i64], align 16
@f = external dso_local global [21 x i64], align 16
@_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 nounwind uwtable
declare dso_local noundef i64 @_Z4bpowxx(i64 noundef, i64 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %15 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %16 = getelementptr i8, ptr %15, i64 -24
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %17
  %19 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %18, ptr noundef null)
  %20 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %21 = 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)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %23

23:                                               ; preds = %50, %0
  %24 = load i64, ptr %2, align 8, !tbaa !8
  %25 = load i64, ptr @N, align 8, !tbaa !8
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %53

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %29

29:                                               ; preds = %46, %28
  %30 = load i64, ptr %4, align 8, !tbaa !8
  %31 = load i64, ptr @M, align 8, !tbaa !8
  %32 = icmp slt i64 %30, %31
  br i1 %32, label %34, label %33

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

34:                                               ; preds = %29
  %35 = load i64, ptr %2, align 8, !tbaa !8
  %36 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %35
  %37 = load i64, ptr %4, align 8, !tbaa !8
  %38 = getelementptr inbounds [50000 x i64], ptr %36, i64 0, i64 %37
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %38)
  %40 = load i64, ptr %2, align 8, !tbaa !8
  %41 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %40
  %42 = load i64, ptr %4, align 8, !tbaa !8
  %43 = getelementptr inbounds [50000 x i64], ptr %41, i64 0, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !8
  %45 = add nsw i64 %44, -1
  store i64 %45, ptr %43, align 8, !tbaa !8
  br label %46

46:                                               ; preds = %34
  %47 = load i64, ptr %4, align 8, !tbaa !8
  %48 = add nsw i64 %47, 1
  store i64 %48, ptr %4, align 8, !tbaa !8
  br label %29, !llvm.loop !11

49:                                               ; preds = %33
  br label %50

50:                                               ; preds = %49
  %51 = load i64, ptr %2, align 8, !tbaa !8
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %2, align 8, !tbaa !8
  br label %23, !llvm.loop !13

53:                                               ; preds = %27
  store i64 1, ptr @f, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 1, ptr %5, align 8, !tbaa !8
  br label %54

54:                                               ; preds = %67, %53
  %55 = load i64, ptr %5, align 8, !tbaa !8
  %56 = icmp slt i64 %55, 21
  br i1 %56, label %58, label %57

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

58:                                               ; preds = %54
  %59 = load i64, ptr %5, align 8, !tbaa !8
  %60 = sub nsw i64 %59, 1
  %61 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = load i64, ptr %5, align 8, !tbaa !8
  %64 = mul nsw i64 %62, %63
  %65 = load i64, ptr %5, align 8, !tbaa !8
  %66 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %65
  store i64 %64, ptr %66, align 8, !tbaa !8
  br label %67

67:                                               ; preds = %58
  %68 = load i64, ptr %5, align 8, !tbaa !8
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %5, align 8, !tbaa !8
  br label %54, !llvm.loop !14

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

71:                                               ; preds = %151, %70
  %72 = load i64, ptr %7, align 8, !tbaa !8
  %73 = load i64, ptr @M, align 8, !tbaa !8
  %74 = icmp slt i64 %72, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %71
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %154

76:                                               ; preds = %71
  %77 = load i64, ptr @N, align 8, !tbaa !8
  %78 = getelementptr inbounds i64, ptr @v, i64 %77
  %79 = getelementptr inbounds i64, ptr %78, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !15
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @v, ptr noundef %79, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !8
  br label %80

80:                                               ; preds = %94, %76
  %81 = load i64, ptr %9, align 8, !tbaa !8
  %82 = load i64, ptr @N, align 8, !tbaa !8
  %83 = icmp slt i64 %81, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %80
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %97

85:                                               ; preds = %80
  %86 = load i64, ptr %9, align 8, !tbaa !8
  %87 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %86
  %88 = load i64, ptr %7, align 8, !tbaa !8
  %89 = getelementptr inbounds [50000 x i64], ptr %87, i64 0, i64 %88
  %90 = load i64, ptr %89, align 8, !tbaa !8
  %91 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = add nsw i64 %92, 1
  store i64 %93, ptr %91, align 8, !tbaa !8
  br label %94

94:                                               ; preds = %85
  %95 = load i64, ptr %9, align 8, !tbaa !8
  %96 = add nsw i64 %95, 1
  store i64 %96, ptr %9, align 8, !tbaa !8
  br label %80, !llvm.loop !17

97:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %98 = load i64, ptr @N, align 8, !tbaa !8
  %99 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !8
  store i64 %100, ptr %10, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %101 = load i64, ptr @N, align 8, !tbaa !8
  %102 = sub nsw i64 %101, 1
  store i64 %102, ptr %11, align 8, !tbaa !8
  br label %103

103:                                              ; preds = %126, %97
  %104 = load i64, ptr %11, align 8, !tbaa !8
  %105 = icmp sgt i64 %104, 0
  br i1 %105, label %107, label %106

106:                                              ; preds = %103
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %129

107:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 0, ptr %12, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %108 = load i64, ptr %11, align 8, !tbaa !8
  %109 = add nsw i64 %108, 1
  %110 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !8
  %112 = sub nsw i64 %111, 1
  store i64 %112, ptr %13, align 8, !tbaa !8
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %114 = load i64, ptr %113, align 8, !tbaa !8
  %115 = load i64, ptr %11, align 8, !tbaa !8
  %116 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !8
  %118 = add nsw i64 %117, %114
  store i64 %118, ptr %116, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %119 = load i64, ptr %10, align 8, !tbaa !8
  %120 = load i64, ptr %11, align 8, !tbaa !8
  %121 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %120
  %122 = load i64, ptr %121, align 8, !tbaa !8
  %123 = mul nsw i64 %119, %122
  %124 = load i64, ptr @MOD, align 8, !tbaa !8
  %125 = srem i64 %123, %124
  store i64 %125, ptr %10, align 8, !tbaa !8
  br label %126

126:                                              ; preds = %107
  %127 = load i64, ptr %11, align 8, !tbaa !8
  %128 = add nsw i64 %127, -1
  store i64 %128, ptr %11, align 8, !tbaa !8
  br label %103, !llvm.loop !18

129:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %130 = load i64, ptr @N, align 8, !tbaa !8
  %131 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %130
  %132 = load i64, ptr %131, align 8, !tbaa !8
  %133 = load i64, ptr %10, align 8, !tbaa !8
  %134 = sub nsw i64 %132, %133
  %135 = load i64, ptr @MOD, align 8, !tbaa !8
  %136 = srem i64 %134, %135
  store i64 %136, ptr %14, align 8, !tbaa !8
  %137 = load i64, ptr %6, align 8, !tbaa !8
  %138 = load i64, ptr %14, align 8, !tbaa !8
  %139 = load i64, ptr @N, align 8, !tbaa !8
  %140 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %139
  %141 = load i64, ptr %140, align 8, !tbaa !8
  %142 = load i64, ptr @MOD, align 8, !tbaa !8
  %143 = sub nsw i64 %142, 2
  %144 = call noundef i64 @_Z4bpowxx(i64 noundef %141, i64 noundef %143)
  %145 = mul nsw i64 %138, %144
  %146 = load i64, ptr @MOD, align 8, !tbaa !8
  %147 = srem i64 %145, %146
  %148 = add nsw i64 %137, %147
  %149 = load i64, ptr @MOD, align 8, !tbaa !8
  %150 = srem i64 %148, %149
  store i64 %150, ptr %6, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %151

151:                                              ; preds = %129
  %152 = load i64, ptr %7, align 8, !tbaa !8
  %153 = add nsw i64 %152, 1
  store i64 %153, ptr %7, align 8, !tbaa !8
  br label %71, !llvm.loop !19

154:                                              ; preds = %75
  %155 = load i64, ptr %6, align 8, !tbaa !8
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %155)
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %156, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  %158 = load i32, ptr %1, align 4
  ret i32 %158
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; 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) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #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" }
attributes #6 = { 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 #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 = !{!16, !16, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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" }

@MOD = external dso_local local_unnamed_addr global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@d = external dso_local global [20 x [50000 x i64]], align 16
@v = external dso_local global [21 x i64], align 16
@f = external dso_local local_unnamed_addr global [21 x i64], align 16
@_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 nounwind uwtable
declare dso_local noundef i64 @_Z4bpowxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  %9 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %10 = 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)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %12 = load i64, ptr @N, align 8, !tbaa !8
  %13 = icmp sgt i64 %12, 0
  %.pre59 = load i64, ptr @M, align 8, !tbaa !8
  %14 = icmp sgt i64 %.pre59, 0
  %or.cond = select i1 %13, i1 %14, i1 false
  br i1 %or.cond, label %.preheader38, label %._crit_edge41

.preheader38:                                     ; preds = %0, %._crit_edge
  %15 = phi i64 [ %20, %._crit_edge ], [ %12, %0 ]
  %16 = phi i64 [ %21, %._crit_edge ], [ %.pre59, %0 ]
  %.040 = phi i64 [ %22, %._crit_edge ], [ 0, %0 ]
  %17 = icmp sgt i64 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge41:                                    ; preds = %._crit_edge, %0
  %18 = phi i64 [ %.pre59, %0 ], [ %21, %._crit_edge ]
  store i64 1, ptr @f, align 16, !tbaa !8
  store i64 1, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !8
  store i64 2, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !8
  store i64 6, ptr getelementptr inbounds (i8, ptr @f, i64 24), align 8, !tbaa !8
  store i64 24, ptr getelementptr inbounds (i8, ptr @f, i64 32), align 16, !tbaa !8
  store i64 120, ptr getelementptr inbounds (i8, ptr @f, i64 40), align 8, !tbaa !8
  store i64 720, ptr getelementptr inbounds (i8, ptr @f, i64 48), align 16, !tbaa !8
  store i64 5040, ptr getelementptr inbounds (i8, ptr @f, i64 56), align 8, !tbaa !8
  store i64 40320, ptr getelementptr inbounds (i8, ptr @f, i64 64), align 16, !tbaa !8
  store i64 362880, ptr getelementptr inbounds (i8, ptr @f, i64 72), align 8, !tbaa !8
  store i64 3628800, ptr getelementptr inbounds (i8, ptr @f, i64 80), align 16, !tbaa !8
  store i64 39916800, ptr getelementptr inbounds (i8, ptr @f, i64 88), align 8, !tbaa !8
  store i64 479001600, ptr getelementptr inbounds (i8, ptr @f, i64 96), align 16, !tbaa !8
  store i64 6227020800, ptr getelementptr inbounds (i8, ptr @f, i64 104), align 8, !tbaa !8
  store i64 87178291200, ptr getelementptr inbounds (i8, ptr @f, i64 112), align 16, !tbaa !8
  store i64 1307674368000, ptr getelementptr inbounds (i8, ptr @f, i64 120), align 8, !tbaa !8
  store i64 20922789888000, ptr getelementptr inbounds (i8, ptr @f, i64 128), align 16, !tbaa !8
  store i64 355687428096000, ptr getelementptr inbounds (i8, ptr @f, i64 136), align 8, !tbaa !8
  store i64 6402373705728000, ptr getelementptr inbounds (i8, ptr @f, i64 144), align 16, !tbaa !8
  store i64 121645100408832000, ptr getelementptr inbounds (i8, ptr @f, i64 152), align 8, !tbaa !8
  store i64 2432902008176640000, ptr getelementptr inbounds (i8, ptr @f, i64 160), align 16, !tbaa !8
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %.lr.ph55, label %._crit_edge56

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader38
  %20 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %15, %.preheader38 ]
  %21 = phi i64 [ %29, %._crit_edge.loopexit ], [ %16, %.preheader38 ]
  %22 = add nuw nsw i64 %.040, 1
  %23 = icmp slt i64 %22, %20
  br i1 %23, label %.preheader38, label %._crit_edge41, !llvm.loop !11

.lr.ph:                                           ; preds = %.preheader38, %.lr.ph
  %.03639 = phi i64 [ %28, %.lr.ph ], [ 0, %.preheader38 ]
  %24 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %.040, i64 %.03639
  %25 = 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) %24)
  %26 = load i64, ptr %24, align 8, !tbaa !8
  %27 = add nsw i64 %26, -1
  store i64 %27, ptr %24, align 8, !tbaa !8
  %28 = add nuw nsw i64 %.03639, 1
  %29 = load i64, ptr @M, align 8, !tbaa !8
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !14

._crit_edge56:                                    ; preds = %._crit_edge51, %._crit_edge41
  %.034.lcssa = phi i64 [ 0, %._crit_edge41 ], [ %71, %._crit_edge51 ]
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.034.lcssa)
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %31, ptr noundef nonnull @.str)
  ret i32 0

.lr.ph55:                                         ; preds = %._crit_edge41, %._crit_edge51
  %.03354 = phi i64 [ %72, %._crit_edge51 ], [ 0, %._crit_edge41 ]
  %.03453 = phi i64 [ %71, %._crit_edge51 ], [ 0, %._crit_edge41 ]
  %33 = load i64, ptr @N, align 8, !tbaa !8
  %gep = getelementptr i64, ptr getelementptr inbounds (i8, ptr @v, i64 8), i64 %33
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 0, ptr %1, align 4, !tbaa !15
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @v, ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %34 = load i64, ptr @N, align 8, !tbaa !8
  %35 = icmp sgt i64 %34, 0
  br i1 %35, label %.lr.ph45.preheader, label %._crit_edge46.thread

.lr.ph45.preheader:                               ; preds = %.lr.ph55
  %xtraiter = and i64 %34, 1
  %36 = icmp eq i64 %34, 1
  br i1 %36, label %._crit_edge46.unr-lcssa, label %.lr.ph45.preheader.new

.lr.ph45.preheader.new:                           ; preds = %.lr.ph45.preheader
  %unroll_iter = and i64 %34, 9223372036854775806
  br label %.lr.ph45

._crit_edge46.thread:                             ; preds = %.lr.ph55
  %37 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %34
  %38 = load i64, ptr %37, align 8, !tbaa !8
  br label %._crit_edge46.._crit_edge51_crit_edge

._crit_edge46.unr-lcssa:                          ; preds = %.lr.ph45, %.lr.ph45.preheader
  %.03243.unr = phi i64 [ 0, %.lr.ph45.preheader ], [ %58, %.lr.ph45 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge46, label %.lr.ph45.epil

.lr.ph45.epil:                                    ; preds = %._crit_edge46.unr-lcssa
  %39 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %.03243.unr, i64 %.03354
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !8
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %41, align 8, !tbaa !8
  br label %._crit_edge46

._crit_edge46:                                    ; preds = %._crit_edge46.unr-lcssa, %.lr.ph45.epil
  %44 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %34
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %.not = icmp eq i64 %34, 1
  br i1 %.not, label %._crit_edge46.._crit_edge51_crit_edge, label %.lr.ph50

._crit_edge46.._crit_edge51_crit_edge:            ; preds = %._crit_edge46.thread, %._crit_edge46
  %46 = phi i64 [ %38, %._crit_edge46.thread ], [ %45, %._crit_edge46 ]
  %.pre61 = load i64, ptr @MOD, align 8, !tbaa !8
  br label %._crit_edge51

.lr.ph45:                                         ; preds = %.lr.ph45, %.lr.ph45.preheader.new
  %.03243 = phi i64 [ 0, %.lr.ph45.preheader.new ], [ %58, %.lr.ph45 ]
  %niter = phi i64 [ 0, %.lr.ph45.preheader.new ], [ %niter.next.1, %.lr.ph45 ]
  %47 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %.03243, i64 %.03354
  %48 = load i64, ptr %47, align 8, !tbaa !8
  %49 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !8
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %49, align 8, !tbaa !8
  %52 = or disjoint i64 %.03243, 1
  %53 = getelementptr inbounds [20 x [50000 x i64]], ptr @d, i64 0, i64 %52, i64 %.03354
  %54 = load i64, ptr %53, align 8, !tbaa !8
  %55 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !8
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %55, align 8, !tbaa !8
  %58 = add nuw nsw i64 %.03243, 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_edge46.unr-lcssa, label %.lr.ph45, !llvm.loop !17

._crit_edge51.loopexit:                           ; preds = %.lr.ph50
  %.pre60 = load i64, ptr @N, align 8, !tbaa !8
  br label %._crit_edge51

._crit_edge51:                                    ; preds = %._crit_edge46.._crit_edge51_crit_edge, %._crit_edge51.loopexit
  %59 = phi i64 [ %.pre61, %._crit_edge46.._crit_edge51_crit_edge ], [ %83, %._crit_edge51.loopexit ]
  %60 = phi i64 [ %34, %._crit_edge46.._crit_edge51_crit_edge ], [ %.pre60, %._crit_edge51.loopexit ]
  %.031.lcssa = phi i64 [ %46, %._crit_edge46.._crit_edge51_crit_edge ], [ %84, %._crit_edge51.loopexit ]
  %61 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = sub nsw i64 %62, %.031.lcssa
  %64 = srem i64 %63, %59
  %65 = add nsw i64 %59, -2
  %66 = call noundef i64 @_Z4bpowxx(i64 noundef %62, i64 noundef %65)
  %67 = mul nsw i64 %66, %64
  %68 = load i64, ptr @MOD, align 8, !tbaa !8
  %69 = srem i64 %67, %68
  %70 = add nsw i64 %69, %.03453
  %71 = srem i64 %70, %68
  %72 = add nuw nsw i64 %.03354, 1
  %73 = load i64, ptr @M, align 8, !tbaa !8
  %74 = icmp slt i64 %72, %73
  br i1 %74, label %.lr.ph55, label %._crit_edge56, !llvm.loop !18

.lr.ph50:                                         ; preds = %._crit_edge46, %.lr.ph50
  %75 = phi i64 [ %81, %.lr.ph50 ], [ %45, %._crit_edge46 ]
  %.030.in48 = phi i64 [ %.030, %.lr.ph50 ], [ %34, %._crit_edge46 ]
  %.03147 = phi i64 [ %84, %.lr.ph50 ], [ %45, %._crit_edge46 ]
  %.030 = add nsw i64 %.030.in48, -1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %76 = add nsw i64 %75, -1
  store i64 %76, ptr %3, align 8, !tbaa !8
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %78 = load i64, ptr %77, align 8, !tbaa !8
  %79 = getelementptr inbounds [21 x i64], ptr @v, i64 0, i64 %.030
  %80 = load i64, ptr %79, align 8, !tbaa !8
  %81 = add nsw i64 %80, %78
  store i64 %81, ptr %79, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %82 = mul nsw i64 %81, %.03147
  %83 = load i64, ptr @MOD, align 8, !tbaa !8
  %84 = srem i64 %82, %83
  %85 = icmp ugt i64 %.030.in48, 2
  br i1 %85, label %.lr.ph50, label %._crit_edge51.loopexit, !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 #0 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; 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 #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 #4 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #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" }
attributes #6 = { 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 #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, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.unswitch.partial.disable"}
!14 = distinct !{!14, !12}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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