; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/302 Division 1/Problem A (A)

; 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 i32, align 4
@m = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@mod = external dso_local global i32, align 4
@a = external dso_local global [501 x i32], align 16
@dp = external dso_local global [501 x [501 x i32]], align 16
@res = external dso_local global i32, align 4
@_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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %15 = getelementptr i8, ptr %14, i64 -24
  %16 = load i64, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %16
  %18 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %17, ptr noundef null)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) @b)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) @mod)
  store i32 1, ptr @dp, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !8
  br label %23

23:                                               ; preds = %33, %0
  %24 = load i32, ptr %2, align 4, !tbaa !8
  %25 = load i32, ptr @n, align 4, !tbaa !8
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %36

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !8
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %30
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %31)
  br label %33

33:                                               ; preds = %28
  %34 = load i32, ptr %2, align 4, !tbaa !8
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !8
  br label %23, !llvm.loop !11

36:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !8
  br label %37

37:                                               ; preds = %108, %36
  %38 = load i32, ptr %3, align 4, !tbaa !8
  %39 = load i32, ptr @n, align 4, !tbaa !8
  %40 = icmp sle i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %111

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !8
  br label %43

43:                                               ; preds = %104, %42
  %44 = load i32, ptr %5, align 4, !tbaa !8
  %45 = load i32, ptr @m, align 4, !tbaa !8
  %46 = icmp sle i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %107

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %49 = load i32, ptr %3, align 4, !tbaa !8
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !8
  store i32 %52, ptr %6, align 4, !tbaa !8
  br label %53

53:                                               ; preds = %100, %48
  %54 = load i32, ptr %6, align 4, !tbaa !8
  %55 = load i32, ptr @b, align 4, !tbaa !8
  %56 = icmp sle i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %103

58:                                               ; preds = %53
  %59 = load i32, ptr %6, align 4, !tbaa !8
  %60 = load i32, ptr %3, align 4, !tbaa !8
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !8
  %64 = sub nsw i32 %59, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %65
  %67 = load i32, ptr %5, align 4, !tbaa !8
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [501 x i32], ptr %66, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !8
  %72 = load i32, ptr %6, align 4, !tbaa !8
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %73
  %75 = load i32, ptr %5, align 4, !tbaa !8
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [501 x i32], ptr %74, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !8
  %79 = add nsw i32 %78, %71
  store i32 %79, ptr %77, align 4, !tbaa !8
  %80 = load i32, ptr %6, align 4, !tbaa !8
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %81
  %83 = load i32, ptr %5, align 4, !tbaa !8
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [501 x i32], ptr %82, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !8
  %87 = load i32, ptr @mod, align 4, !tbaa !8
  %88 = icmp sge i32 %86, %87
  br i1 %88, label %89, label %99

89:                                               ; preds = %58
  %90 = load i32, ptr @mod, align 4, !tbaa !8
  %91 = load i32, ptr %6, align 4, !tbaa !8
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %92
  %94 = load i32, ptr %5, align 4, !tbaa !8
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [501 x i32], ptr %93, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !8
  %98 = sub nsw i32 %97, %90
  store i32 %98, ptr %96, align 4, !tbaa !8
  br label %99

99:                                               ; preds = %89, %58
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %6, align 4, !tbaa !8
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %6, align 4, !tbaa !8
  br label %53, !llvm.loop !13

103:                                              ; preds = %57
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %5, align 4, !tbaa !8
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %5, align 4, !tbaa !8
  br label %43, !llvm.loop !14

107:                                              ; preds = %47
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %3, align 4, !tbaa !8
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %3, align 4, !tbaa !8
  br label %37, !llvm.loop !15

111:                                              ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !8
  br label %112

112:                                              ; preds = %135, %111
  %113 = load i32, ptr %7, align 4, !tbaa !8
  %114 = load i32, ptr @b, align 4, !tbaa !8
  %115 = icmp sle i32 %113, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %112
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %138

117:                                              ; preds = %112
  %118 = load i32, ptr %7, align 4, !tbaa !8
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %119
  %121 = load i32, ptr @m, align 4, !tbaa !8
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [501 x i32], ptr %120, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !8
  %125 = load i32, ptr @res, align 4, !tbaa !8
  %126 = add nsw i32 %125, %124
  store i32 %126, ptr @res, align 4, !tbaa !8
  %127 = load i32, ptr @res, align 4, !tbaa !8
  %128 = load i32, ptr @mod, align 4, !tbaa !8
  %129 = icmp sge i32 %127, %128
  br i1 %129, label %130, label %134

130:                                              ; preds = %117
  %131 = load i32, ptr @mod, align 4, !tbaa !8
  %132 = load i32, ptr @res, align 4, !tbaa !8
  %133 = sub nsw i32 %132, %131
  store i32 %133, ptr @res, align 4, !tbaa !8
  br label %134

134:                                              ; preds = %130, %117
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %7, align 4, !tbaa !8
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %7, align 4, !tbaa !8
  br label %112, !llvm.loop !16

138:                                              ; preds = %116
  %139 = load i32, ptr @res, align 4, !tbaa !8
  %140 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %139)
  %141 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %140, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 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)) #5

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 = { "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 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !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 i32, align 4
@m = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@mod = external dso_local global i32, align 4
@a = external dso_local global [501 x i32], align 16
@dp = external dso_local local_unnamed_addr global [501 x [501 x i32]], align 16
@res = external dso_local local_unnamed_addr global i32, align 4
@_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 zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) @b)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 4 dereferenceable(4) @mod)
  store i32 1, ptr @dp, align 16, !tbaa !8
  %16 = load i32, ptr @n, align 4, !tbaa !8
  %.not38 = icmp slt i32 %16, 1
  br i1 %.not38, label %.preheader37.thread, label %.lr.ph

.preheader37.thread:                              ; preds = %0
  %.pre78 = load i32, ptr @b, align 4
  br label %.preheader

.preheader37:                                     ; preds = %.lr.ph
  %.not3047 = icmp slt i32 %24, 1
  %.pre = load i32, ptr @b, align 4
  br i1 %.not3047, label %.preheader, label %.preheader36.lr.ph

.preheader36.lr.ph:                               ; preds = %.preheader37
  %17 = load i32, ptr @m, align 4, !tbaa !8
  %.not3343 = icmp slt i32 %17, 1
  %18 = load i32, ptr @mod, align 4
  br i1 %.not3343, label %.preheader, label %.preheader36.preheader

.preheader36.preheader:                           ; preds = %.preheader36.lr.ph
  %19 = add i32 %.pre, 1
  %20 = add nuw i32 %17, 1
  %21 = add nuw i32 %24, 1
  %wide.trip.count68 = zext i32 %21 to i64
  %wide.trip.count = zext i32 %20 to i64
  br label %.preheader36

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %22 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv
  %23 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %22)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i32, ptr @n, align 4, !tbaa !8
  %25 = sext i32 %24 to i64
  %.not.not = icmp slt i64 %indvars.iv, %25
  br i1 %.not.not, label %.lr.ph, label %.preheader37, !llvm.loop !11

.preheader36:                                     ; preds = %.preheader36.preheader, %._crit_edge46
  %indvars.iv65 = phi i64 [ 1, %.preheader36.preheader ], [ %indvars.iv.next66, %._crit_edge46 ]
  %26 = getelementptr inbounds [501 x i32], ptr @a, i64 0, i64 %indvars.iv65
  %27 = load i32, ptr %26, align 4, !tbaa !8
  %.not3440 = icmp sgt i32 %27, %.pre
  br i1 %.not3440, label %._crit_edge46, label %.lr.ph42.preheader

.lr.ph42.preheader:                               ; preds = %.preheader36
  %28 = sext i32 %27 to i64
  %29 = add i32 %.pre, %27
  %30 = and i32 %29, 1
  %lcmp.mod.not.not = icmp eq i32 %30, 0
  %indvars.iv.next59.prol = add nsw i64 %28, 1
  %31 = icmp eq i32 %.pre, %27
  br label %.lr.ph42

.preheader:                                       ; preds = %._crit_edge46, %.preheader36.lr.ph, %.preheader37.thread, %.preheader37
  %.pre79 = phi i32 [ %.pre78, %.preheader37.thread ], [ %.pre, %.preheader37 ], [ %.pre, %.preheader36.lr.ph ], [ %.pre, %._crit_edge46 ]
  %.not3149 = icmp slt i32 %.pre79, 0
  %.pre75 = load i32, ptr @res, align 4, !tbaa !8
  br i1 %.not3149, label %.preheader._crit_edge, label %.lr.ph51

.lr.ph51:                                         ; preds = %.preheader
  %32 = load i32, ptr @m, align 4, !tbaa !8
  %33 = sext i32 %32 to i64
  %34 = load i32, ptr @mod, align 4, !tbaa !8
  %35 = add nuw i32 %.pre79, 1
  %wide.trip.count73 = zext i32 %35 to i64
  %xtraiter81 = and i64 %wide.trip.count73, 1
  %36 = icmp eq i32 %.pre79, 0
  br i1 %36, label %._crit_edge52.unr-lcssa, label %.lr.ph51.new

.lr.ph51.new:                                     ; preds = %.lr.ph51
  %unroll_iter = and i64 %wide.trip.count73, 4294967294
  br label %65

._crit_edge46:                                    ; preds = %._crit_edge, %.preheader36
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond69.not = icmp eq i64 %indvars.iv.next66, %wide.trip.count68
  br i1 %exitcond69.not, label %.preheader, label %.preheader36, !llvm.loop !13

.lr.ph42:                                         ; preds = %.lr.ph42.preheader, %._crit_edge
  %indvars.iv61 = phi i64 [ 1, %.lr.ph42.preheader ], [ %indvars.iv.next62, %._crit_edge ]
  %37 = add nsw i64 %indvars.iv61, -1
  br i1 %lcmp.mod.not.not, label %.prol.loopexit.unr-lcssa, label %.prol.loopexit

.prol.loopexit.unr-lcssa:                         ; preds = %.lr.ph42
  %38 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !8
  %40 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %28, i64 %indvars.iv61
  %41 = load i32, ptr %40, align 4, !tbaa !8
  %42 = add nsw i32 %41, %39
  %.not35.prol = icmp slt i32 %42, %18
  %43 = select i1 %.not35.prol, i32 0, i32 %18
  %spec.select80.prol = sub nsw i32 %42, %43
  store i32 %spec.select80.prol, ptr %40, align 4, !tbaa !8
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph42
  %indvars.iv58.unr = phi i64 [ %28, %.lr.ph42 ], [ %indvars.iv.next59.prol, %.prol.loopexit.unr-lcssa ]
  br i1 %31, label %._crit_edge, label %.lr.ph42.new

._crit_edge:                                      ; preds = %.lr.ph42.new, %.prol.loopexit
  %indvars.iv.next62 = add nuw nsw i64 %indvars.iv61, 1
  %exitcond64.not = icmp eq i64 %indvars.iv.next62, %wide.trip.count
  br i1 %exitcond64.not, label %._crit_edge46, label %.lr.ph42, !llvm.loop !14

.lr.ph42.new:                                     ; preds = %.prol.loopexit, %.lr.ph42.new
  %indvars.iv58 = phi i64 [ %indvars.iv.next59.1, %.lr.ph42.new ], [ %indvars.iv58.unr, %.prol.loopexit ]
  %44 = sub nsw i64 %indvars.iv58, %28
  %45 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %44, i64 %37
  %46 = load i32, ptr %45, align 4, !tbaa !8
  %47 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv58, i64 %indvars.iv61
  %48 = load i32, ptr %47, align 4, !tbaa !8
  %49 = add nsw i32 %48, %46
  %.not35 = icmp slt i32 %49, %18
  %50 = select i1 %.not35, i32 0, i32 %18
  %spec.select80 = sub nsw i32 %49, %50
  store i32 %spec.select80, ptr %47, align 4, !tbaa !8
  %indvars.iv.next59 = add nsw i64 %indvars.iv58, 1
  %51 = sub nsw i64 %indvars.iv.next59, %28
  %52 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %51, i64 %37
  %53 = load i32, ptr %52, align 4, !tbaa !8
  %54 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next59, i64 %indvars.iv61
  %55 = load i32, ptr %54, align 4, !tbaa !8
  %56 = add nsw i32 %55, %53
  %.not35.1 = icmp slt i32 %56, %18
  %57 = select i1 %.not35.1, i32 0, i32 %18
  %spec.select80.1 = sub nsw i32 %56, %57
  store i32 %spec.select80.1, ptr %54, align 4, !tbaa !8
  %indvars.iv.next59.1 = add nsw i64 %indvars.iv58, 2
  %lftr.wideiv.1 = trunc i64 %indvars.iv.next59.1 to i32
  %exitcond.not.1 = icmp eq i32 %19, %lftr.wideiv.1
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph42.new, !llvm.loop !15

._crit_edge52.unr-lcssa:                          ; preds = %65, %.lr.ph51
  %spec.select.lcssa.ph = phi i32 [ poison, %.lr.ph51 ], [ %spec.select.1, %65 ]
  %indvars.iv70.unr = phi i64 [ 0, %.lr.ph51 ], [ %indvars.iv.next71.1, %65 ]
  %.unr = phi i32 [ %.pre75, %.lr.ph51 ], [ %spec.select.1, %65 ]
  %lcmp.mod82.not = icmp eq i64 %xtraiter81, 0
  br i1 %lcmp.mod82.not, label %._crit_edge52, label %._crit_edge52.epilog-lcssa

._crit_edge52.epilog-lcssa:                       ; preds = %._crit_edge52.unr-lcssa
  %58 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv70.unr, i64 %33
  %59 = load i32, ptr %58, align 4, !tbaa !8
  %60 = add nsw i32 %.unr, %59
  %.not32.epil = icmp slt i32 %60, %34
  %61 = select i1 %.not32.epil, i32 0, i32 %34
  %spec.select.epil = sub nsw i32 %60, %61
  br label %._crit_edge52

._crit_edge52:                                    ; preds = %._crit_edge52.unr-lcssa, %._crit_edge52.epilog-lcssa
  %spec.select.lcssa = phi i32 [ %spec.select.lcssa.ph, %._crit_edge52.unr-lcssa ], [ %spec.select.epil, %._crit_edge52.epilog-lcssa ]
  store i32 %spec.select.lcssa, ptr @res, align 4, !tbaa !8
  br label %.preheader._crit_edge

.preheader._crit_edge:                            ; preds = %.preheader, %._crit_edge52
  %62 = phi i32 [ %spec.select.lcssa, %._crit_edge52 ], [ %.pre75, %.preheader ]
  %63 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %62)
  %64 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %63, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

65:                                               ; preds = %65, %.lr.ph51.new
  %indvars.iv70 = phi i64 [ 0, %.lr.ph51.new ], [ %indvars.iv.next71.1, %65 ]
  %66 = phi i32 [ %.pre75, %.lr.ph51.new ], [ %spec.select.1, %65 ]
  %niter = phi i64 [ 0, %.lr.ph51.new ], [ %niter.next.1, %65 ]
  %67 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv70, i64 %33
  %68 = load i32, ptr %67, align 4, !tbaa !8
  %69 = add nsw i32 %66, %68
  %.not32 = icmp slt i32 %69, %34
  %70 = select i1 %.not32, i32 0, i32 %34
  %spec.select = sub nsw i32 %69, %70
  %indvars.iv.next71 = or disjoint i64 %indvars.iv70, 1
  %71 = getelementptr inbounds [501 x [501 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next71, i64 %33
  %72 = load i32, ptr %71, align 4, !tbaa !8
  %73 = add nsw i32 %spec.select, %72
  %.not32.1 = icmp slt i32 %73, %34
  %74 = select i1 %.not32.1, i32 0, i32 %34
  %spec.select.1 = sub nsw i32 %73, %74
  %indvars.iv.next71.1 = add nuw nsw i64 %indvars.iv70, 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_edge52.unr-lcssa, label %65, !llvm.loop !16
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

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

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 = { "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 = { 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 #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 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 = !{!"int", !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}


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