; LLVM IR from Aryansh-S/USACO :: algo_ds/DP/atcoder (h-grid1)

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

@h = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@dp = external dso_local global [1005 x [1005 x i32]], align 16
@g = external dso_local global [1005 x [1005 x i8]], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", 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
  store i32 0, ptr %1, align 4
  %7 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.2)
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %14

9:                                                ; preds = %0
  %10 = load ptr, ptr @stdin, align 8, !tbaa !5
  %11 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.2, ptr noundef %10)
  %12 = load ptr, ptr @stdout, align 8, !tbaa !5
  %13 = call ptr @freopen(ptr noundef @.str.3, ptr noundef @.str.4, ptr noundef %12)
  br label %14

14:                                               ; preds = %9, %0
  %15 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %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)
  call void @_Z2reIRiJS0_EEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) @h, ptr noundef nonnull align 4 dereferenceable(4) @w)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %43, %14
  %22 = load i32, ptr %2, align 4, !tbaa !11
  %23 = load i32, ptr @h, align 4, !tbaa !11
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %39, %26
  %28 = load i32, ptr %4, align 4, !tbaa !11
  %29 = load i32, ptr @w, align 4, !tbaa !11
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %42

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %34
  %36 = load i32, ptr %4, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1005 x i8], ptr %35, i64 0, i64 %37
  call void @_Z2reIRcJEEvOT_DpOT0_(ptr noundef nonnull align 1 dereferenceable(1) %38)
  br label %39

39:                                               ; preds = %32
  %40 = load i32, ptr %4, align 4, !tbaa !11
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !11
  br label %27, !llvm.loop !13

42:                                               ; preds = %31
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %2, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %2, align 4, !tbaa !11
  br label %21, !llvm.loop !15

46:                                               ; preds = %25
  store i32 1, ptr @dp, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %133, %46
  %48 = load i32, ptr %5, align 4, !tbaa !11
  %49 = load i32, ptr @h, align 4, !tbaa !11
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %52, label %51

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

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %53

53:                                               ; preds = %129, %52
  %54 = load i32, ptr %6, align 4, !tbaa !11
  %55 = load i32, ptr @w, align 4, !tbaa !11
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %58, label %57

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

58:                                               ; preds = %53
  %59 = load i32, ptr %5, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  %61 = load i32, ptr @h, align 4, !tbaa !11
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %63, label %93

63:                                               ; preds = %58
  %64 = load i32, ptr %5, align 4, !tbaa !11
  %65 = add nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %66
  %68 = load i32, ptr %6, align 4, !tbaa !11
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [1005 x i8], ptr %67, i64 0, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !16
  %72 = sext i8 %71 to i32
  %73 = icmp eq i32 %72, 46
  br i1 %73, label %74, label %93

74:                                               ; preds = %63
  %75 = load i32, ptr %5, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %76
  %78 = load i32, ptr %6, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1005 x i32], ptr %77, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !11
  %82 = load i32, ptr %5, align 4, !tbaa !11
  %83 = add nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %84
  %86 = load i32, ptr %6, align 4, !tbaa !11
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1005 x i32], ptr %85, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !11
  %90 = add nsw i32 %89, %81
  store i32 %90, ptr %88, align 4, !tbaa !11
  %91 = load i32, ptr %88, align 4, !tbaa !11
  %92 = srem i32 %91, 1000000007
  store i32 %92, ptr %88, align 4, !tbaa !11
  br label %93

93:                                               ; preds = %74, %63, %58
  %94 = load i32, ptr %6, align 4, !tbaa !11
  %95 = add nsw i32 %94, 1
  %96 = load i32, ptr @w, align 4, !tbaa !11
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %98, label %128

98:                                               ; preds = %93
  %99 = load i32, ptr %5, align 4, !tbaa !11
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %100
  %102 = load i32, ptr %6, align 4, !tbaa !11
  %103 = add nsw i32 %102, 1
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1005 x i8], ptr %101, i64 0, i64 %104
  %106 = load i8, ptr %105, align 1, !tbaa !16
  %107 = sext i8 %106 to i32
  %108 = icmp eq i32 %107, 46
  br i1 %108, label %109, label %128

109:                                              ; preds = %98
  %110 = load i32, ptr %5, align 4, !tbaa !11
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %111
  %113 = load i32, ptr %6, align 4, !tbaa !11
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1005 x i32], ptr %112, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !11
  %117 = load i32, ptr %5, align 4, !tbaa !11
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %118
  %120 = load i32, ptr %6, align 4, !tbaa !11
  %121 = add nsw i32 %120, 1
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [1005 x i32], ptr %119, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !11
  %125 = add nsw i32 %124, %116
  store i32 %125, ptr %123, align 4, !tbaa !11
  %126 = load i32, ptr %123, align 4, !tbaa !11
  %127 = srem i32 %126, 1000000007
  store i32 %127, ptr %123, align 4, !tbaa !11
  br label %128

128:                                              ; preds = %109, %98, %93
  br label %129

129:                                              ; preds = %128
  %130 = load i32, ptr %6, align 4, !tbaa !11
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %6, align 4, !tbaa !11
  br label %53, !llvm.loop !17

132:                                              ; preds = %57
  br label %133

133:                                              ; preds = %132
  %134 = load i32, ptr %5, align 4, !tbaa !11
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %5, align 4, !tbaa !11
  br label %47, !llvm.loop !18

136:                                              ; preds = %51
  %137 = load i32, ptr @h, align 4, !tbaa !11
  %138 = sub nsw i32 %137, 1
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %139
  %141 = load i32, ptr @w, align 4, !tbaa !11
  %142 = sub nsw i32 %141, 1
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1005 x i32], ptr %140, i64 0, i64 %143
  call void @_Z2prIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) %144)
  %145 = load i32, ptr %1, align 4
  ret i32 %145
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #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 zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2reIRcJEEvOT_DpOT0_(ptr noundef nonnull align 1 dereferenceable(1)) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2prIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4)) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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

@h = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@dp = external dso_local global [1005 x [1005 x i32]], align 16
@g = external dso_local global [1005 x [1005 x i8]], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2)
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %7, label %2

2:                                                ; preds = %0
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, ptr noundef %5)
  br label %7

7:                                                ; preds = %2, %0
  %8 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  %13 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  tail call void @_Z2reIRiJS0_EEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) @h, ptr noundef nonnull align 4 dereferenceable(4) @w)
  %14 = load i32, ptr @h, align 4, !tbaa !11
  %15 = icmp sgt i32 %14, 0
  %.pre64.pre = load i32, ptr @w, align 4, !tbaa !11
  %16 = icmp sgt i32 %.pre64.pre, 0
  %or.cond82 = select i1 %15, i1 %16, i1 false
  br i1 %or.cond82, label %.preheader31, label %._crit_edge39.sink.split

.preheader31:                                     ; preds = %7, %._crit_edge
  %17 = phi i32 [ %62, %._crit_edge ], [ %14, %7 ]
  %18 = phi i32 [ %63, %._crit_edge ], [ %.pre64.pre, %7 ]
  %indvars.iv48 = phi i64 [ %indvars.iv.next49, %._crit_edge ], [ 0, %7 ]
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

._crit_edge34:                                    ; preds = %._crit_edge
  store i32 1, ptr @dp, align 16, !tbaa !11
  %20 = icmp sgt i32 %62, 0
  %21 = icmp sgt i32 %63, 0
  %or.cond = and i1 %20, %21
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge39

.preheader.us.preheader:                          ; preds = %._crit_edge34
  %22 = zext nneg i32 %63 to i64
  %23 = zext nneg i32 %62 to i64
  %wide.trip.count62 = zext nneg i32 %62 to i64
  %wide.trip.count = zext nneg i32 %63 to i64
  %wide.trip.count57 = zext nneg i32 %63 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge37.us
  %indvars.iv59 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next60, %._crit_edge37.us ]
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %24 = icmp ult i64 %indvars.iv.next60, %23
  br i1 %24, label %.lr.ph36.split.us.us, label %.lr.ph36.split.us42

.lr.ph36.split.us42:                              ; preds = %.preheader.us, %37
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %37 ], [ 0, %.preheader.us ]
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %25 = icmp ult i64 %indvars.iv.next52, %22
  br i1 %25, label %26, label %37

26:                                               ; preds = %.lr.ph36.split.us42
  %27 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %indvars.iv59, i64 %indvars.iv.next52
  %28 = load i8, ptr %27, align 1, !tbaa !13
  %29 = icmp eq i8 %28, 46
  br i1 %29, label %30, label %37

30:                                               ; preds = %26
  %31 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %indvars.iv59, i64 %indvars.iv51
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %indvars.iv59, i64 %indvars.iv.next52
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = add nsw i32 %34, %32
  %36 = srem i32 %35, 1000000007
  store i32 %36, ptr %33, align 4, !tbaa !11
  br label %37

37:                                               ; preds = %30, %26, %.lr.ph36.split.us42
  %exitcond.not = icmp eq i64 %indvars.iv.next52, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge37.us, label %.lr.ph36.split.us42, !llvm.loop !14

._crit_edge37.us:                                 ; preds = %37, %61
  %exitcond63.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count62
  br i1 %exitcond63.not, label %._crit_edge39, label %.preheader.us, !llvm.loop !16

.lr.ph36.split.us.us:                             ; preds = %.preheader.us, %61
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %61 ], [ 0, %.preheader.us ]
  %38 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %indvars.iv.next60, i64 %indvars.iv54
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = icmp eq i8 %39, 46
  br i1 %40, label %41, label %48

41:                                               ; preds = %.lr.ph36.split.us.us
  %42 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %indvars.iv59, i64 %indvars.iv54
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next60, i64 %indvars.iv54
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = add nsw i32 %45, %43
  %47 = srem i32 %46, 1000000007
  store i32 %47, ptr %44, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %41, %.lr.ph36.split.us.us
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %49 = icmp ult i64 %indvars.iv.next55, %22
  br i1 %49, label %50, label %61

50:                                               ; preds = %48
  %51 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %indvars.iv59, i64 %indvars.iv.next55
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = icmp eq i8 %52, 46
  br i1 %53, label %54, label %61

54:                                               ; preds = %50
  %55 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %indvars.iv59, i64 %indvars.iv54
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %indvars.iv59, i64 %indvars.iv.next55
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = add nsw i32 %58, %56
  %60 = srem i32 %59, 1000000007
  store i32 %60, ptr %57, align 4, !tbaa !11
  br label %61

61:                                               ; preds = %54, %50, %48
  %exitcond58.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count57
  br i1 %exitcond58.not, label %._crit_edge37.us, label %.lr.ph36.split.us.us, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr @h, align 4, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader31
  %62 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %17, %.preheader31 ]
  %63 = phi i32 [ %67, %._crit_edge.loopexit ], [ %18, %.preheader31 ]
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %64 = sext i32 %62 to i64
  %65 = icmp slt i64 %indvars.iv.next49, %64
  br i1 %65, label %.preheader31, label %._crit_edge34, !llvm.loop !17

.lr.ph:                                           ; preds = %.preheader31, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader31 ]
  %66 = getelementptr inbounds [1005 x [1005 x i8]], ptr @g, i64 0, i64 %indvars.iv48, i64 %indvars.iv
  tail call void @_Z2reIRcJEEvOT_DpOT0_(ptr noundef nonnull align 1 dereferenceable(1) %66)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %67 = load i32, ptr @w, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv.next, %68
  br i1 %69, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !19

._crit_edge39.sink.split:                         ; preds = %7
  store i32 1, ptr @dp, align 16, !tbaa !11
  br label %._crit_edge39

._crit_edge39:                                    ; preds = %._crit_edge37.us, %._crit_edge39.sink.split, %._crit_edge34
  %.lcssa70 = phi i32 [ %62, %._crit_edge34 ], [ %14, %._crit_edge39.sink.split ], [ %62, %._crit_edge37.us ]
  %.pre6468 = phi i32 [ %63, %._crit_edge34 ], [ %.pre64.pre, %._crit_edge39.sink.split ], [ %63, %._crit_edge37.us ]
  %70 = add nsw i32 %.lcssa70, -1
  %71 = sext i32 %70 to i64
  %72 = add nsw i32 %.pre6468, -1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1005 x [1005 x i32]], ptr @dp, i64 0, i64 %71, i64 %73
  tail call void @_Z2prIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) %74)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2reIRcJEEvOT_DpOT0_(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2prIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #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" }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = distinct !{!19, !15}


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