; LLVM IR from ShahjalalShohag/code-library :: Dynamic Programming Optimizations (Digit DP)

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

@pw = external dso_local global [20 x [20 x i32]], align 16
@b = external dso_local global [1024 x [3000 x i32]], align 16
@cnt = external dso_local global [1024 x i32], align 16
@dp = external dso_local global [2 x [20 x [1024 x [2520 x i32]]]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5solvex(i64 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.memset.p0.i64(ptr align 16 @dp, i8 -1, i64 412876800, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %51, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 20
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %18
  %20 = getelementptr inbounds [20 x i32], ptr %19, i64 0, i64 0
  store i32 1, ptr %20, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %47, %16
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 20
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %21
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %27
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sub nsw i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [20 x i32], ptr %28, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = mul nsw i64 %34, 1
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = mul nsw i64 %35, %37
  %39 = srem i64 %38, 1000000007
  %40 = trunc i64 %39 to i32
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %42
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [20 x i32], ptr %43, i64 0, i64 %45
  store i32 %40, ptr %46, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %25
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !9

50:                                               ; preds = %24
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !11

54:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %68, %54
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = icmp slt i32 %56, 1024
  br i1 %57, label %59, label %58

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

59:                                               ; preds = %55
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = call i32 @llvm.ctpop.i32(i32 %60)
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = and i32 %62, 1
  %64 = sub nsw i32 %61, %63
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1024 x i32], ptr @cnt, i64 0, i64 %66
  store i32 %64, ptr %67, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %59
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !5
  br label %55, !llvm.loop !12

71:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %115, %71
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = icmp slt i32 %73, 1024
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %111, %76
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = icmp slt i32 %78, 2530
  br i1 %79, label %81, label %80

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

81:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %107, %81
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = icmp slt i32 %83, 10
  br i1 %84, label %86, label %85

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

86:                                               ; preds = %82
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = ashr i32 %87, %88
  %90 = and i32 %89, 1
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %106

92:                                               ; preds = %86
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = srem i32 %93, %94
  %96 = icmp eq i32 %95, 0
  %97 = zext i1 %96 to i32
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [1024 x [3000 x i32]], ptr @b, i64 0, i64 %99
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [3000 x i32], ptr %100, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = add nsw i32 %104, %97
  store i32 %105, ptr %103, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %92, %86
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %8, align 4, !tbaa !5
  br label %82, !llvm.loop !13

110:                                              ; preds = %85
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %7, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %7, align 4, !tbaa !5
  br label %77, !llvm.loop !14

114:                                              ; preds = %80
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %6, align 4, !tbaa !5
  br label %72, !llvm.loop !15

118:                                              ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %119 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %9)
  br label %120

120:                                              ; preds = %124, %118
  %121 = load i32, ptr %9, align 4, !tbaa !5
  %122 = add nsw i32 %121, -1
  store i32 %122, ptr %9, align 4, !tbaa !5
  %123 = icmp ne i32 %121, 0
  br i1 %123, label %124, label %137

124:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %125 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %126 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %125, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %127 = load i64, ptr %11, align 8, !tbaa !16
  %128 = call noundef i32 @_Z5solvex(i64 noundef %127)
  %129 = load i64, ptr %10, align 8, !tbaa !16
  %130 = sub nsw i64 %129, 1
  %131 = call noundef i32 @_Z5solvex(i64 noundef %130)
  %132 = sub nsw i32 %128, %131
  %133 = add nsw i32 %132, 1000000007
  %134 = srem i32 %133, 1000000007
  %135 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %134)
  %136 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %135, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %120, !llvm.loop !18

137:                                              ; preds = %120
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %138 = load i32, ptr %1, align 4
  ret i32 %138
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctpop.i32(i32) #4

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

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

; Function Attrs: 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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@pw = external dso_local local_unnamed_addr global [20 x [20 x i32]], align 16
@b = external dso_local local_unnamed_addr global [1024 x [3000 x i32]], align 16
@cnt = external dso_local local_unnamed_addr global [1024 x i32], align 16
@dp = external dso_local local_unnamed_addr global [2 x [20 x [1024 x [2520 x i32]]]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5solvex(i64 noundef) local_unnamed_addr #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
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(412876800) @dp, i8 -1, i64 412876800, i1 false)
  br label %4

4:                                                ; preds = %0, %4
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %4 ]
  %5 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv
  store i32 1, ptr %5, align 16, !tbaa !5
  %6 = urem i64 %indvars.iv, 1000000007
  %7 = trunc nuw nsw i64 %6 to i32
  %8 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 1
  store i32 %7, ptr %8, align 4, !tbaa !5
  %9 = mul nuw nsw i64 %6, %indvars.iv
  %10 = urem i64 %9, 1000000007
  %11 = trunc nuw nsw i64 %10 to i32
  %12 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 2
  store i32 %11, ptr %12, align 8, !tbaa !5
  %13 = mul nuw nsw i64 %10, %indvars.iv
  %14 = urem i64 %13, 1000000007
  %15 = trunc nuw nsw i64 %14 to i32
  %16 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 3
  store i32 %15, ptr %16, align 4, !tbaa !5
  %17 = mul nuw nsw i64 %14, %indvars.iv
  %18 = urem i64 %17, 1000000007
  %19 = trunc nuw nsw i64 %18 to i32
  %20 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 4
  store i32 %19, ptr %20, align 16, !tbaa !5
  %21 = mul nuw nsw i64 %18, %indvars.iv
  %22 = urem i64 %21, 1000000007
  %23 = trunc nuw nsw i64 %22 to i32
  %24 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 5
  store i32 %23, ptr %24, align 4, !tbaa !5
  %25 = mul nuw nsw i64 %22, %indvars.iv
  %26 = urem i64 %25, 1000000007
  %27 = trunc nuw nsw i64 %26 to i32
  %28 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 6
  store i32 %27, ptr %28, align 8, !tbaa !5
  %29 = mul nuw nsw i64 %26, %indvars.iv
  %30 = urem i64 %29, 1000000007
  %31 = trunc nuw nsw i64 %30 to i32
  %32 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 7
  store i32 %31, ptr %32, align 4, !tbaa !5
  %33 = mul nuw nsw i64 %30, %indvars.iv
  %34 = urem i64 %33, 1000000007
  %35 = trunc nuw nsw i64 %34 to i32
  %36 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 8
  store i32 %35, ptr %36, align 16, !tbaa !5
  %37 = mul nuw nsw i64 %34, %indvars.iv
  %38 = urem i64 %37, 1000000007
  %39 = trunc nuw nsw i64 %38 to i32
  %40 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 9
  store i32 %39, ptr %40, align 4, !tbaa !5
  %41 = mul nuw nsw i64 %38, %indvars.iv
  %42 = urem i64 %41, 1000000007
  %43 = trunc nuw nsw i64 %42 to i32
  %44 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 10
  store i32 %43, ptr %44, align 8, !tbaa !5
  %45 = mul nuw nsw i64 %42, %indvars.iv
  %46 = urem i64 %45, 1000000007
  %47 = trunc nuw nsw i64 %46 to i32
  %48 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 11
  store i32 %47, ptr %48, align 4, !tbaa !5
  %49 = mul nuw nsw i64 %46, %indvars.iv
  %50 = urem i64 %49, 1000000007
  %51 = trunc nuw nsw i64 %50 to i32
  %52 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 12
  store i32 %51, ptr %52, align 16, !tbaa !5
  %53 = mul nuw nsw i64 %50, %indvars.iv
  %54 = urem i64 %53, 1000000007
  %55 = trunc nuw nsw i64 %54 to i32
  %56 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 13
  store i32 %55, ptr %56, align 4, !tbaa !5
  %57 = mul nuw nsw i64 %54, %indvars.iv
  %58 = urem i64 %57, 1000000007
  %59 = trunc nuw nsw i64 %58 to i32
  %60 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 14
  store i32 %59, ptr %60, align 8, !tbaa !5
  %61 = mul nuw nsw i64 %58, %indvars.iv
  %62 = urem i64 %61, 1000000007
  %63 = trunc nuw nsw i64 %62 to i32
  %64 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 15
  store i32 %63, ptr %64, align 4, !tbaa !5
  %65 = mul nuw nsw i64 %62, %indvars.iv
  %66 = urem i64 %65, 1000000007
  %67 = trunc nuw nsw i64 %66 to i32
  %68 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 16
  store i32 %67, ptr %68, align 16, !tbaa !5
  %69 = mul nuw nsw i64 %66, %indvars.iv
  %70 = urem i64 %69, 1000000007
  %71 = trunc nuw nsw i64 %70 to i32
  %72 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 17
  store i32 %71, ptr %72, align 4, !tbaa !5
  %73 = mul nuw nsw i64 %70, %indvars.iv
  %74 = urem i64 %73, 1000000007
  %75 = trunc nuw nsw i64 %74 to i32
  %76 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 18
  store i32 %75, ptr %76, align 8, !tbaa !5
  %77 = mul nuw nsw i64 %74, %indvars.iv
  %78 = urem i64 %77, 1000000007
  %79 = trunc nuw nsw i64 %78 to i32
  %80 = getelementptr inbounds [20 x [20 x i32]], ptr @pw, i64 0, i64 %indvars.iv, i64 19
  store i32 %79, ptr %80, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 20
  br i1 %exitcond.not, label %vector.body, label %4, !llvm.loop !9

vector.body:                                      ; preds = %4, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %4 ]
  %vec.ind = phi <4 x i32> [ %vec.ind.next, %vector.body ], [ <i32 1, i32 2, i32 3, i32 4>, %4 ]
  %offset.idx = or disjoint i64 %index, 1
  %81 = tail call range(i32 0, 33) <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %vec.ind)
  %82 = and <4 x i32> %vec.ind, <i32 1, i32 1, i32 1, i32 1>
  %83 = sub nsw <4 x i32> %81, %82
  %84 = getelementptr inbounds [1024 x i32], ptr @cnt, i64 0, i64 %offset.idx
  store <4 x i32> %83, ptr %84, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %85 = icmp eq i64 %index.next, 1020
  br i1 %85, label %.preheader36, label %vector.body, !llvm.loop !11

.preheader36:                                     ; preds = %vector.body
  store i32 8, ptr getelementptr inbounds (i8, ptr @cnt, i64 4084), align 4, !tbaa !5
  store i32 9, ptr getelementptr inbounds (i8, ptr @cnt, i64 4088), align 8, !tbaa !5
  store i32 9, ptr getelementptr inbounds (i8, ptr @cnt, i64 4092), align 4, !tbaa !5
  br label %.preheader34

.preheader34:                                     ; preds = %.preheader36, %105
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %105 ], [ 1, %.preheader36 ]
  %86 = trunc nuw nsw i64 %indvars.iv55 to i32
  %87 = and i32 %86, 2
  %.not33 = icmp eq i32 %87, 0
  %88 = insertelement <8 x i32> poison, i32 %86, i64 0
  %89 = shufflevector <8 x i32> %88, <8 x i32> poison, <8 x i32> zeroinitializer
  %90 = and <8 x i32> %89, <i32 512, i32 256, i32 128, i32 64, i32 32, i32 16, i32 8, i32 4>
  %91 = icmp eq <8 x i32> %90, zeroinitializer
  %92 = extractelement <8 x i1> %91, i64 0
  %93 = extractelement <8 x i1> %91, i64 1
  %94 = extractelement <8 x i1> %91, i64 2
  %95 = extractelement <8 x i1> %91, i64 3
  %96 = extractelement <8 x i1> %91, i64 4
  %97 = extractelement <8 x i1> %91, i64 5
  %98 = extractelement <8 x i1> %91, i64 6
  %99 = extractelement <8 x i1> %91, i64 7
  br label %.preheader

100:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %101 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %102 = load i32, ptr %1, align 4, !tbaa !5
  %103 = add nsw i32 %102, -1
  store i32 %103, ptr %1, align 4, !tbaa !5
  %.not43 = icmp eq i32 %102, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %.preheader34, %170
  %indvars.iv51 = phi i64 [ 0, %.preheader34 ], [ %indvars.iv.next52, %170 ]
  %104 = getelementptr inbounds [1024 x [3000 x i32]], ptr @b, i64 0, i64 %indvars.iv55, i64 %indvars.iv51
  br i1 %.not33, label %109, label %106

105:                                              ; preds = %170
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %exitcond58.not = icmp eq i64 %indvars.iv.next56, 1024
  br i1 %exitcond58.not, label %100, label %.preheader34, !llvm.loop !14

106:                                              ; preds = %.preheader
  %107 = load i32, ptr %104, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %104, align 4, !tbaa !5
  br label %109

109:                                              ; preds = %.preheader, %106
  br i1 %99, label %116, label %110

110:                                              ; preds = %109
  %111 = trunc i64 %indvars.iv51 to i32
  %112 = and i32 %111, 1
  %113 = xor i32 %112, 1
  %114 = load i32, ptr %104, align 4, !tbaa !5
  %115 = add nsw i32 %114, %113
  store i32 %115, ptr %104, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %110, %109
  br i1 %98, label %124, label %117

117:                                              ; preds = %116
  %118 = trunc nuw nsw i64 %indvars.iv51 to i32
  %119 = urem i32 %118, 3
  %120 = icmp eq i32 %119, 0
  %121 = zext i1 %120 to i32
  %122 = load i32, ptr %104, align 4, !tbaa !5
  %123 = add nsw i32 %122, %121
  store i32 %123, ptr %104, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %117, %116
  br i1 %97, label %131, label %125

125:                                              ; preds = %124
  %126 = and i64 %indvars.iv51, 3
  %127 = icmp eq i64 %126, 0
  %128 = zext i1 %127 to i32
  %129 = load i32, ptr %104, align 4, !tbaa !5
  %130 = add nsw i32 %129, %128
  store i32 %130, ptr %104, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %125, %124
  br i1 %96, label %139, label %132

132:                                              ; preds = %131
  %133 = trunc nuw nsw i64 %indvars.iv51 to i32
  %134 = urem i32 %133, 5
  %135 = icmp eq i32 %134, 0
  %136 = zext i1 %135 to i32
  %137 = load i32, ptr %104, align 4, !tbaa !5
  %138 = add nsw i32 %137, %136
  store i32 %138, ptr %104, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %132, %131
  br i1 %95, label %147, label %140

140:                                              ; preds = %139
  %141 = trunc nuw nsw i64 %indvars.iv51 to i32
  %142 = urem i32 %141, 6
  %143 = icmp eq i32 %142, 0
  %144 = zext i1 %143 to i32
  %145 = load i32, ptr %104, align 4, !tbaa !5
  %146 = add nsw i32 %145, %144
  store i32 %146, ptr %104, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %140, %139
  br i1 %94, label %155, label %148

148:                                              ; preds = %147
  %149 = trunc nuw nsw i64 %indvars.iv51 to i32
  %150 = urem i32 %149, 7
  %151 = icmp eq i32 %150, 0
  %152 = zext i1 %151 to i32
  %153 = load i32, ptr %104, align 4, !tbaa !5
  %154 = add nsw i32 %153, %152
  store i32 %154, ptr %104, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %148, %147
  br i1 %93, label %162, label %156

156:                                              ; preds = %155
  %157 = and i64 %indvars.iv51, 7
  %158 = icmp eq i64 %157, 0
  %159 = zext i1 %158 to i32
  %160 = load i32, ptr %104, align 4, !tbaa !5
  %161 = add nsw i32 %160, %159
  store i32 %161, ptr %104, align 4, !tbaa !5
  br label %162

162:                                              ; preds = %156, %155
  br i1 %92, label %170, label %163

163:                                              ; preds = %162
  %164 = trunc nuw nsw i64 %indvars.iv51 to i32
  %165 = urem i32 %164, 9
  %166 = icmp eq i32 %165, 0
  %167 = zext i1 %166 to i32
  %168 = load i32, ptr %104, align 4, !tbaa !5
  %169 = add nsw i32 %168, %167
  store i32 %169, ptr %104, align 4, !tbaa !5
  br label %170

170:                                              ; preds = %163, %162
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond54.not = icmp eq i64 %indvars.iv.next52, 2530
  br i1 %exitcond54.not, label %105, label %.preheader, !llvm.loop !15

.lr.ph:                                           ; preds = %100, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %171 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %172 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %171, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %173 = load i64, ptr %3, align 8, !tbaa !16
  %174 = call noundef i32 @_Z5solvex(i64 noundef %173)
  %175 = load i64, ptr %2, align 8, !tbaa !16
  %176 = add nsw i64 %175, -1
  %177 = call noundef i32 @_Z5solvex(i64 noundef %176)
  %178 = add i32 %174, 1000000007
  %179 = sub i32 %178, %177
  %180 = srem i32 %179, 1000000007
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %180)
  %182 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %181, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %183 = load i32, ptr %1, align 4, !tbaa !5
  %184 = add nsw i32 %183, -1
  store i32 %184, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %183, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 #4

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

; Function Attrs: 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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.ctpop.v4i32(<4 x i32>) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass