; LLVM IR from abeaumont/competitive-programming :: codechef/july18a (nmnmx)

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

@b = external dso_local global [5001 x [5001 x i64]], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [5001 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 uwtable
declare dso_local noundef i64 @_Z6modpowxx(i64 noundef, i64 noundef) #0

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

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

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

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

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

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %17
  %19 = getelementptr inbounds [5001 x i64], ptr %18, i64 0, i64 0
  store i64 1, ptr %19, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !11

23:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %70, %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = icmp sle i32 %25, 5000
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %24
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [5001 x i64], ptr %31, i64 0, i64 %33
  store i64 1, ptr %34, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %66, %28
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sub nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %43
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [5001 x i64], ptr %44, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %52
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [5001 x i64], ptr %53, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = add nsw i64 %49, %57
  %59 = srem i64 %58, 1000000006
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %61
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [5001 x i64], ptr %62, i64 0, i64 %64
  store i64 %59, ptr %65, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %40
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %5, align 4, !tbaa !5
  br label %35, !llvm.loop !13

69:                                               ; preds = %39
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %3, align 4, !tbaa !5
  br label %24, !llvm.loop !14

73:                                               ; preds = %27
  %74 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @t)
  br label %75

75:                                               ; preds = %179, %73
  %76 = load i32, ptr @t, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr @t, align 4, !tbaa !5
  %78 = icmp ne i32 %76, 0
  br i1 %78, label %79, label %183

79:                                               ; preds = %75
  %80 = 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)
  %81 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %80, ptr noundef nonnull align 4 dereferenceable(4) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %92, %79
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %95

87:                                               ; preds = %82
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %89
  %91 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %90)
  br label %92

92:                                               ; preds = %87
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %6, align 4, !tbaa !5
  br label %82, !llvm.loop !15

95:                                               ; preds = %86
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i32, ptr @a, i64 %97
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @a, ptr noundef %98)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %99 = load i32, ptr @n, align 4, !tbaa !5
  %100 = sub nsw i32 %99, 1
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %101
  %103 = load i32, ptr @k, align 4, !tbaa !5
  %104 = sub nsw i32 %103, 1
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [5001 x i64], ptr %102, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !9
  store i64 %107, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 1, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %170, %95
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = load i32, ptr @n, align 4, !tbaa !5
  %111 = sub nsw i32 %110, 1
  %112 = icmp slt i32 %109, %111
  br i1 %112, label %114, label %113

113:                                              ; preds = %108
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %173

114:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %115 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %115, ptr %10, align 8, !tbaa !9
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = load i32, ptr @k, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  %119 = icmp sge i32 %116, %118
  br i1 %119, label %120, label %132

120:                                              ; preds = %114
  %121 = load i64, ptr %10, align 8, !tbaa !9
  %122 = load i32, ptr %9, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %123
  %125 = load i32, ptr @k, align 4, !tbaa !5
  %126 = sub nsw i32 %125, 1
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [5001 x i64], ptr %124, i64 0, i64 %127
  %129 = load i64, ptr %128, align 8, !tbaa !9
  %130 = sub nsw i64 %121, %129
  %131 = srem i64 %130, 1000000006
  store i64 %131, ptr %10, align 8, !tbaa !9
  br label %132

132:                                              ; preds = %120, %114
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = load i32, ptr @k, align 4, !tbaa !5
  %135 = add nsw i32 %133, %134
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = icmp sle i32 %135, %136
  br i1 %137, label %138, label %153

138:                                              ; preds = %132
  %139 = load i64, ptr %10, align 8, !tbaa !9
  %140 = load i32, ptr @n, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = sub nsw i32 %140, %141
  %143 = sub nsw i32 %142, 1
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %144
  %146 = load i32, ptr @k, align 4, !tbaa !5
  %147 = sub nsw i32 %146, 1
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [5001 x i64], ptr %145, i64 0, i64 %148
  %150 = load i64, ptr %149, align 8, !tbaa !9
  %151 = sub nsw i64 %139, %150
  %152 = srem i64 %151, 1000000006
  store i64 %152, ptr %10, align 8, !tbaa !9
  br label %153

153:                                              ; preds = %138, %132
  %154 = load i64, ptr %10, align 8, !tbaa !9
  %155 = icmp slt i64 %154, 0
  br i1 %155, label %156, label %159

156:                                              ; preds = %153
  %157 = load i64, ptr %10, align 8, !tbaa !9
  %158 = add nsw i64 %157, 1000000006
  store i64 %158, ptr %10, align 8, !tbaa !9
  br label %159

159:                                              ; preds = %156, %153
  %160 = load i64, ptr %8, align 8, !tbaa !9
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = load i64, ptr %10, align 8, !tbaa !9
  %167 = call noundef i64 @_Z6modpowxx(i64 noundef %165, i64 noundef %166)
  %168 = mul nsw i64 %160, %167
  %169 = srem i64 %168, 1000000007
  store i64 %169, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %170

170:                                              ; preds = %159
  %171 = load i32, ptr %9, align 4, !tbaa !5
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %9, align 4, !tbaa !5
  br label %108, !llvm.loop !16

173:                                              ; preds = %113
  %174 = load i64, ptr %8, align 8, !tbaa !9
  %175 = icmp slt i64 %174, 0
  br i1 %175, label %176, label %179

176:                                              ; preds = %173
  %177 = load i64, ptr %8, align 8, !tbaa !9
  %178 = add nsw i64 %177, 1000000007
  store i64 %178, ptr %8, align 8, !tbaa !9
  br label %179

179:                                              ; preds = %176, %173
  %180 = load i64, ptr %8, align 8, !tbaa !9
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %180)
  %182 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %181, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %75, !llvm.loop !17

183:                                              ; preds = %75
  %184 = load i32, ptr %1, align 4
  ret i32 %184
}

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 dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #4

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !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}
!17 = distinct !{!17, !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" }

@b = external dso_local local_unnamed_addr global [5001 x [5001 x i64]], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [5001 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 uwtable
declare dso_local noundef i64 @_Z6modpowxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  br label %1

1:                                                ; preds = %1, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.2, %1 ]
  %2 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv
  store i64 1, ptr %2, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %3 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv.next
  store i64 1, ptr %3, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %4 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv.next.1
  store i64 1, ptr %4, align 8, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %exitcond.not.2 = icmp eq i64 %indvars.iv.next.2, 5001
  br i1 %exitcond.not.2, label %.preheader, label %1, !llvm.loop !9

5:                                                ; preds = %._crit_edge
  %6 = 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) @t)
  %7 = load i32, ptr @t, align 4, !tbaa !11
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @t, align 4, !tbaa !11
  %.not63 = icmp eq i32 %7, 0
  br i1 %.not63, label %._crit_edge66, label %.lr.ph65

.preheader:                                       ; preds = %1, %._crit_edge
  %indvar = phi i64 [ %indvar.next, %._crit_edge ], [ 0, %1 ]
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %._crit_edge ], [ 1, %1 ]
  %9 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv74, i64 %indvars.iv74
  store i64 1, ptr %9, align 8, !tbaa !5
  %10 = icmp ugt i64 %indvars.iv74, 1
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %11 = add nsw i64 %indvars.iv74, -1
  %.phi.trans.insert = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %11, i64 0
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !5
  %xtraiter = and i64 %indvar, 1
  %12 = icmp eq i64 %indvar, 1
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %indvar, -2
  br label %18

._crit_edge.loopexit.unr-lcssa:                   ; preds = %18, %.lr.ph
  %.unr = phi i64 [ %.pre, %.lr.ph ], [ %26, %18 ]
  %indvars.iv70.unr = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next71.1, %18 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %13 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %11, i64 %indvars.iv70.unr
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = add nsw i64 %14, %.unr
  %16 = srem i64 %15, 1000000006
  %17 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv74, i64 %indvars.iv70.unr
  store i64 %16, ptr %17, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.preheader
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %exitcond77.not = icmp eq i64 %indvars.iv.next75, 5001
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond77.not, label %5, label %.preheader, !llvm.loop !13

18:                                               ; preds = %18, %.lr.ph.new
  %19 = phi i64 [ %.pre, %.lr.ph.new ], [ %26, %18 ]
  %indvars.iv70 = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next71.1, %18 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %18 ]
  %20 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %11, i64 %indvars.iv70
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = add nsw i64 %21, %19
  %23 = srem i64 %22, 1000000006
  %24 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv74, i64 %indvars.iv70
  store i64 %23, ptr %24, align 8, !tbaa !5
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %25 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %11, i64 %indvars.iv.next71
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = add nsw i64 %26, %21
  %28 = srem i64 %27, 1000000006
  %29 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv74, i64 %indvars.iv.next71
  store i64 %28, ptr %29, align 8, !tbaa !5
  %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_edge.loopexit.unr-lcssa, label %18, !llvm.loop !14

.lr.ph65:                                         ; preds = %5, %._crit_edge61.thread
  %30 = 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)
  %31 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 4 dereferenceable(4) @k)
  %32 = load i32, ptr @n, align 4, !tbaa !11
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph55, label %.lr.ph65.._crit_edge56_crit_edge

.lr.ph65.._crit_edge56_crit_edge:                 ; preds = %.lr.ph65
  %.pre84 = sext i32 %32 to i64
  br label %._crit_edge56

._crit_edge56:                                    ; preds = %.lr.ph55, %.lr.ph65.._crit_edge56_crit_edge
  %.pre-phi = phi i64 [ %.pre84, %.lr.ph65.._crit_edge56_crit_edge ], [ %47, %.lr.ph55 ]
  %34 = getelementptr inbounds i32, ptr @a, i64 %.pre-phi
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %34)
  %35 = load i32, ptr @n, align 4, !tbaa !11
  %36 = add nsw i32 %35, -1
  %37 = sext i32 %36 to i64
  %38 = load i32, ptr @k, align 4, !tbaa !11
  %39 = add nsw i32 %38, -1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %37, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = icmp sgt i32 %35, 2
  br i1 %43, label %.lr.ph60, label %._crit_edge61.thread

.lr.ph55:                                         ; preds = %.lr.ph65, %.lr.ph55
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph55 ], [ 0, %.lr.ph65 ]
  %44 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %indvars.iv78
  %45 = 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) %44)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %46 = load i32, ptr @n, align 4, !tbaa !11
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next79, %47
  br i1 %48, label %.lr.ph55, label %._crit_edge56, !llvm.loop !15

._crit_edge61:                                    ; preds = %76
  %49 = icmp slt i64 %84, 0
  %50 = add nsw i64 %84, 1000000007
  %spec.select = select i1 %49, i64 %50, i64 %84
  br label %._crit_edge61.thread

._crit_edge61.thread:                             ; preds = %._crit_edge61, %._crit_edge56
  %51 = phi i64 [ 1, %._crit_edge56 ], [ %spec.select, %._crit_edge61 ]
  %52 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %51)
  %53 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %52, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %54 = load i32, ptr @t, align 4, !tbaa !11
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr @t, align 4, !tbaa !11
  %.not = icmp eq i32 %54, 0
  br i1 %.not, label %._crit_edge66, label %.lr.ph65, !llvm.loop !16

.lr.ph60:                                         ; preds = %._crit_edge56, %76
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %76 ], [ 1, %._crit_edge56 ]
  %56 = phi i32 [ %85, %76 ], [ %35, %._crit_edge56 ]
  %.03857 = phi i64 [ %84, %76 ], [ 1, %._crit_edge56 ]
  %57 = load i32, ptr @k, align 4, !tbaa !11
  %58 = add nsw i32 %57, -1
  %59 = sext i32 %58 to i64
  %.not47 = icmp slt i64 %indvars.iv81, %59
  br i1 %.not47, label %65, label %60

60:                                               ; preds = %.lr.ph60
  %61 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %indvars.iv81, i64 %59
  %62 = load i64, ptr %61, align 8, !tbaa !5
  %63 = sub nsw i64 %42, %62
  %64 = srem i64 %63, 1000000006
  br label %65

65:                                               ; preds = %60, %.lr.ph60
  %.0 = phi i64 [ %64, %60 ], [ %42, %.lr.ph60 ]
  %66 = trunc nuw nsw i64 %indvars.iv81 to i32
  %67 = add nsw i32 %57, %66
  %.not48 = icmp sgt i32 %67, %56
  br i1 %.not48, label %76, label %68

68:                                               ; preds = %65
  %69 = xor i32 %66, -1
  %70 = add i32 %56, %69
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [5001 x [5001 x i64]], ptr @b, i64 0, i64 %71, i64 %59
  %73 = load i64, ptr %72, align 8, !tbaa !5
  %74 = sub nsw i64 %.0, %73
  %75 = srem i64 %74, 1000000006
  br label %76

76:                                               ; preds = %68, %65
  %.1 = phi i64 [ %75, %68 ], [ %.0, %65 ]
  %77 = icmp slt i64 %.1, 0
  %78 = add nsw i64 %.1, 1000000006
  %spec.select49 = select i1 %77, i64 %78, i64 %.1
  %79 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %indvars.iv81
  %80 = load i32, ptr %79, align 4, !tbaa !11
  %81 = sext i32 %80 to i64
  %82 = tail call noundef i64 @_Z6modpowxx(i64 noundef %81, i64 noundef %spec.select49)
  %83 = mul i64 %82, %.03857
  %84 = srem i64 %83, 1000000007
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %85 = load i32, ptr @n, align 4, !tbaa !11
  %86 = add nsw i32 %85, -1
  %87 = sext i32 %86 to i64
  %88 = icmp slt i64 %indvars.iv.next82, %87
  br i1 %88, label %.lr.ph60, label %._crit_edge61, !llvm.loop !17

._crit_edge66:                                    ; preds = %._crit_edge61.thread, %5
  ret i32 0
}

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 dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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