; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2021.12 (hilo)

; 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
@X = external dso_local global i32, align 4
@H = external dso_local global [2 x i32], align 4
@sH = external dso_local global [5005 x [5005 x [2 x i32]]], align 16
@Fi = external dso_local global [5006 x i32], align 16
@F = external dso_local global [5006 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 nounwind uwtable
declare dso_local noundef i32 @_Z3invi(i32 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 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 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  store i32 1, ptr @F, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !8
  br label %13

13:                                               ; preds = %32, %0
  %14 = load i32, ptr %2, align 4, !tbaa !8
  %15 = icmp sle i32 %14, 5005
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %35

17:                                               ; preds = %13
  %18 = load i32, ptr %2, align 4, !tbaa !8
  %19 = sub nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !8
  %23 = sext i32 %22 to i64
  %24 = load i32, ptr %2, align 4, !tbaa !8
  %25 = sext i32 %24 to i64
  %26 = mul nsw i64 %23, %25
  %27 = srem i64 %26, 1000000007
  %28 = trunc i64 %27 to i32
  %29 = load i32, ptr %2, align 4, !tbaa !8
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %30
  store i32 %28, ptr %31, align 4, !tbaa !8
  br label %32

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

35:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %36

36:                                               ; preds = %49, %35
  %37 = load i32, ptr %3, align 4, !tbaa !8
  %38 = icmp sle i32 %37, 5005
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %52

40:                                               ; preds = %36
  %41 = load i32, ptr %3, align 4, !tbaa !8
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !8
  %45 = call noundef i32 @_Z3invi(i32 noundef %44)
  %46 = load i32, ptr %3, align 4, !tbaa !8
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [5006 x i32], ptr @Fi, i64 0, i64 %47
  store i32 %45, ptr %48, align 4, !tbaa !8
  br label %49

49:                                               ; preds = %40
  %50 = load i32, ptr %3, align 4, !tbaa !8
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %3, align 4, !tbaa !8
  br label %36, !llvm.loop !13

52:                                               ; preds = %39
  %53 = 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)
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %53, ptr noundef nonnull align 4 dereferenceable(4) @X)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %55 = load i32, ptr @X, align 4, !tbaa !8
  store i32 %55, ptr %4, align 4, !tbaa !8
  br label %56

56:                                               ; preds = %201, %52
  %57 = load i32, ptr %4, align 4, !tbaa !8
  %58 = icmp sge i32 %57, 0
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %61 = load i32, ptr @X, align 4, !tbaa !8
  store i32 %61, ptr %6, align 4, !tbaa !8
  br label %62

62:                                               ; preds = %197, %60
  %63 = load i32, ptr %6, align 4, !tbaa !8
  %64 = load i32, ptr @N, align 4, !tbaa !8
  %65 = icmp sle i32 %63, %64
  br i1 %65, label %67, label %66

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

67:                                               ; preds = %62
  %68 = load i32, ptr %4, align 4, !tbaa !8
  %69 = load i32, ptr %6, align 4, !tbaa !8
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  br label %197

72:                                               ; preds = %67
  %73 = load i32, ptr %4, align 4, !tbaa !8
  %74 = add nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %75
  %77 = load i32, ptr %6, align 4, !tbaa !8
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [5005 x [2 x i32]], ptr %76, i64 0, i64 %78
  %80 = getelementptr inbounds [2 x i32], ptr %79, i64 0, i64 0
  %81 = load i32, ptr %80, align 8, !tbaa !8
  %82 = sext i32 %81 to i64
  %83 = load i32, ptr %6, align 4, !tbaa !8
  %84 = load i32, ptr %4, align 4, !tbaa !8
  %85 = sub nsw i32 %83, %84
  %86 = sub nsw i32 %85, 1
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !8
  %90 = sext i32 %89 to i64
  %91 = mul nsw i64 %82, %90
  %92 = srem i64 %91, 1000000007
  %93 = trunc i64 %92 to i32
  store i32 %93, ptr @H, align 4, !tbaa !8
  %94 = load i32, ptr %4, align 4, !tbaa !8
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %95
  %97 = load i32, ptr %6, align 4, !tbaa !8
  %98 = sub nsw i32 %97, 1
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [5005 x [2 x i32]], ptr %96, i64 0, i64 %99
  %101 = getelementptr inbounds [2 x i32], ptr %100, i64 0, i64 1
  %102 = load i32, ptr %101, align 4, !tbaa !8
  %103 = sext i32 %102 to i64
  %104 = load i32, ptr %6, align 4, !tbaa !8
  %105 = load i32, ptr %4, align 4, !tbaa !8
  %106 = sub nsw i32 %104, %105
  %107 = sub nsw i32 %106, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !8
  %111 = sext i32 %110 to i64
  %112 = mul nsw i64 %103, %111
  %113 = srem i64 %112, 1000000007
  %114 = trunc i64 %113 to i32
  store i32 %114, ptr getelementptr inbounds ([2 x i32], ptr @H, i64 0, i64 1), align 4, !tbaa !8
  %115 = load i32, ptr %4, align 4, !tbaa !8
  %116 = add nsw i32 %115, 1
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %117
  %119 = load i32, ptr %6, align 4, !tbaa !8
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [5005 x [2 x i32]], ptr %118, i64 0, i64 %120
  %122 = getelementptr inbounds [2 x i32], ptr %121, i64 0, i64 0
  %123 = load i32, ptr %122, align 8, !tbaa !8
  %124 = sext i32 %123 to i64
  %125 = load i32, ptr @H, align 4, !tbaa !8
  %126 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @H, i64 0, i64 1), align 4, !tbaa !8
  %127 = srem i32 %126, 1000000007
  %128 = add nsw i32 %125, %127
  %129 = sext i32 %128 to i64
  %130 = load i32, ptr %6, align 4, !tbaa !8
  %131 = load i32, ptr %4, align 4, !tbaa !8
  %132 = sub nsw i32 %130, %131
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [5006 x i32], ptr @Fi, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !8
  %136 = sext i32 %135 to i64
  %137 = mul nsw i64 %129, %136
  %138 = add nsw i64 %124, %137
  %139 = srem i64 %138, 1000000007
  %140 = trunc i64 %139 to i32
  %141 = load i32, ptr %4, align 4, !tbaa !8
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %142
  %144 = load i32, ptr %6, align 4, !tbaa !8
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [5005 x [2 x i32]], ptr %143, i64 0, i64 %145
  %147 = getelementptr inbounds [2 x i32], ptr %146, i64 0, i64 0
  store i32 %140, ptr %147, align 8, !tbaa !8
  %148 = load i32, ptr %4, align 4, !tbaa !8
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %149
  %151 = load i32, ptr %6, align 4, !tbaa !8
  %152 = sub nsw i32 %151, 1
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [5005 x [2 x i32]], ptr %150, i64 0, i64 %153
  %155 = getelementptr inbounds [2 x i32], ptr %154, i64 0, i64 1
  %156 = load i32, ptr %155, align 4, !tbaa !8
  %157 = sext i32 %156 to i64
  %158 = load i32, ptr @H, align 4, !tbaa !8
  %159 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @H, i64 0, i64 1), align 4, !tbaa !8
  %160 = add nsw i32 %158, %159
  %161 = srem i32 %160, 1000000007
  %162 = sext i32 %161 to i64
  %163 = load i32, ptr %6, align 4, !tbaa !8
  %164 = load i32, ptr %4, align 4, !tbaa !8
  %165 = sub nsw i32 %163, %164
  %166 = sub nsw i32 %165, 1
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !8
  %170 = sext i32 %169 to i64
  %171 = load i32, ptr @X, align 4, !tbaa !8
  %172 = load i32, ptr %4, align 4, !tbaa !8
  %173 = sub nsw i32 %171, %172
  %174 = sext i32 %173 to i64
  %175 = mul nsw i64 %170, %174
  %176 = srem i64 %175, 1000000007
  %177 = add nsw i64 %162, %176
  %178 = srem i64 %177, 1000000007
  %179 = load i32, ptr %6, align 4, !tbaa !8
  %180 = load i32, ptr %4, align 4, !tbaa !8
  %181 = sub nsw i32 %179, %180
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [5006 x i32], ptr @Fi, i64 0, i64 %182
  %184 = load i32, ptr %183, align 4, !tbaa !8
  %185 = sext i32 %184 to i64
  %186 = mul nsw i64 %178, %185
  %187 = add nsw i64 %157, %186
  %188 = srem i64 %187, 1000000007
  %189 = trunc i64 %188 to i32
  %190 = load i32, ptr %4, align 4, !tbaa !8
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %191
  %193 = load i32, ptr %6, align 4, !tbaa !8
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [5005 x [2 x i32]], ptr %192, i64 0, i64 %194
  %196 = getelementptr inbounds [2 x i32], ptr %195, i64 0, i64 1
  store i32 %189, ptr %196, align 4, !tbaa !8
  br label %197

197:                                              ; preds = %72, %71
  %198 = load i32, ptr %6, align 4, !tbaa !8
  %199 = add nsw i32 %198, 1
  store i32 %199, ptr %6, align 4, !tbaa !8
  br label %62, !llvm.loop !14

200:                                              ; preds = %66
  br label %201

201:                                              ; preds = %200
  %202 = load i32, ptr %4, align 4, !tbaa !8
  %203 = add nsw i32 %202, -1
  store i32 %203, ptr %4, align 4, !tbaa !8
  br label %56, !llvm.loop !15

204:                                              ; preds = %59
  %205 = load i32, ptr @H, align 4, !tbaa !8
  %206 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @H, i64 0, i64 1), align 4, !tbaa !8
  %207 = add nsw i32 %205, %206
  %208 = srem i32 %207, 1000000007
  %209 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %208)
  %210 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %209, i8 noundef signext 10)
  %211 = load i32, ptr %1, align 4
  ret i32 %211
}

; 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

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

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

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

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


; 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
@X = external dso_local global i32, align 4
@H = external dso_local local_unnamed_addr global [2 x i32], align 4
@sH = external dso_local local_unnamed_addr global [5005 x [5005 x [2 x i32]]], align 16
@Fi = external dso_local local_unnamed_addr global [5006 x i32], align 16
@F = external dso_local local_unnamed_addr global [5006 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 nounwind uwtable
declare dso_local noundef i32 @_Z3invi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %2 = getelementptr i8, ptr %1, i64 -24
  %3 = load i64, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %3
  %5 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %4, ptr noundef null)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  store i32 1, ptr @F, align 16, !tbaa !8
  br label %7

7:                                                ; preds = %13, %0
  %8 = phi i64 [ 1, %0 ], [ %15, %13 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %13 ]
  %9 = mul nsw i64 %8, %indvars.iv
  %10 = srem i64 %9, 1000000007
  %11 = trunc nsw i64 %10 to i32
  %12 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %indvars.iv
  store i32 %11, ptr %12, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 5006
  br i1 %exitcond.not, label %.preheader42, label %13, !llvm.loop !11

13:                                               ; preds = %7
  %14 = mul nsw i64 %10, %indvars.iv.next
  %15 = srem i64 %14, 1000000007
  %16 = trunc nsw i64 %15 to i32
  %17 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %indvars.iv.next
  store i32 %16, ptr %17, align 4, !tbaa !8
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %7

18:                                               ; preds = %.preheader42
  %19 = 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)
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) @X)
  %21 = load i32, ptr @X, align 4, !tbaa !8
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %.preheader.lr.ph, label %._crit_edge48

.preheader.lr.ph:                                 ; preds = %18
  %23 = load i32, ptr @N, align 4, !tbaa !8
  %.not45 = icmp sgt i32 %21, %23
  br i1 %.not45, label %._crit_edge48, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %24 = zext nneg i32 %21 to i64
  %25 = add nuw i32 %23, 1
  br label %.preheader

.preheader42:                                     ; preds = %7, %.preheader42
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %.preheader42 ], [ 0, %7 ]
  %26 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %indvars.iv51
  %27 = load i32, ptr %26, align 4, !tbaa !8
  %28 = tail call noundef i32 @_Z3invi(i32 noundef %27)
  %29 = getelementptr inbounds [5006 x i32], ptr @Fi, i64 0, i64 %indvars.iv51
  store i32 %28, ptr %29, align 4, !tbaa !8
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond54.not = icmp eq i64 %indvars.iv.next52, 5006
  br i1 %exitcond54.not, label %18, label %.preheader42, !llvm.loop !13

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %indvars.iv59 = phi i64 [ %24, %.preheader.preheader ], [ %indvars.iv.next60, %._crit_edge ]
  %30 = add nuw nsw i64 %indvars.iv59, 1
  %31 = sub nuw nsw i64 %24, %indvars.iv59
  br label %39

._crit_edge48:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %18
  %32 = load i32, ptr @H, align 4, !tbaa !8
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @H, i64 4), align 4, !tbaa !8
  %34 = add nsw i32 %33, %32
  %35 = srem i32 %34, 1000000007
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %35)
  %37 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %36, i8 noundef signext 10)
  ret i32 0

._crit_edge:                                      ; preds = %80
  %indvars.iv.next60 = add nsw i64 %indvars.iv59, -1
  %38 = icmp sgt i64 %indvars.iv59, 0
  br i1 %38, label %.preheader, label %._crit_edge48, !llvm.loop !14

39:                                               ; preds = %.preheader, %80
  %indvars.iv55 = phi i64 [ %24, %.preheader ], [ %indvars.iv.next56, %80 ]
  %40 = icmp eq i64 %indvars.iv55, %indvars.iv59
  br i1 %40, label %80, label %41

41:                                               ; preds = %39
  %42 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %30, i64 %indvars.iv55
  %43 = load i32, ptr %42, align 8, !tbaa !8
  %44 = sext i32 %43 to i64
  %45 = sub nsw i64 %indvars.iv55, %indvars.iv59
  %46 = add nsw i64 %45, -1
  %47 = getelementptr inbounds [5006 x i32], ptr @F, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !8
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %49, %44
  %51 = srem i64 %50, 1000000007
  %52 = trunc nsw i64 %51 to i32
  store i32 %52, ptr @H, align 4, !tbaa !8
  %53 = add nsw i64 %indvars.iv55, -1
  %54 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %indvars.iv59, i64 %53, i64 1
  %55 = load i32, ptr %54, align 4, !tbaa !8
  %56 = sext i32 %55 to i64
  %57 = mul nsw i64 %56, %49
  %58 = srem i64 %57, 1000000007
  %59 = trunc nsw i64 %58 to i32
  store i32 %59, ptr getelementptr inbounds (i8, ptr @H, i64 4), align 4, !tbaa !8
  %60 = add nsw i64 %58, %51
  %61 = getelementptr inbounds [5006 x i32], ptr @Fi, i64 0, i64 %45
  %62 = load i32, ptr %61, align 4, !tbaa !8
  %63 = sext i32 %62 to i64
  %64 = mul nsw i64 %60, %63
  %65 = add nsw i64 %64, %44
  %66 = srem i64 %65, 1000000007
  %67 = trunc nsw i64 %66 to i32
  %68 = getelementptr inbounds [5005 x [5005 x [2 x i32]]], ptr @sH, i64 0, i64 %indvars.iv59, i64 %indvars.iv55
  store i32 %67, ptr %68, align 8, !tbaa !8
  %69 = add nsw i32 %59, %52
  %70 = srem i32 %69, 1000000007
  %71 = mul nsw i64 %31, %49
  %72 = srem i64 %71, 1000000007
  %73 = trunc nsw i64 %72 to i32
  %.lhs.trunc = add nsw i32 %70, %73
  %74 = srem i32 %.lhs.trunc, 1000000007
  %.sext = sext i32 %74 to i64
  %75 = mul nsw i64 %.sext, %63
  %76 = add nsw i64 %75, %56
  %77 = srem i64 %76, 1000000007
  %78 = trunc nsw i64 %77 to i32
  %79 = getelementptr inbounds i8, ptr %68, i64 4
  store i32 %78, ptr %79, align 4, !tbaa !8
  br label %80

80:                                               ; preds = %39, %41
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next56 to i32
  %exitcond58.not = icmp eq i32 %25, %lftr.wideiv
  br i1 %exitcond58.not, label %._crit_edge, label %39, !llvm.loop !15
}

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #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 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 #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 = { 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}


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