; LLVM IR from kazunetakahashi/atcoder :: 2019/0113_keyence2019 (D)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@A = external dso_local global [1010 x i32], align 16
@B = external dso_local global [1010 x i32], align 16
@ans = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = 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)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(4) @M)
  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 = %21, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @N, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %18
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %19)
  br label %21

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

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

25:                                               ; preds = %35, %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr @M, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %25
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %32
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %33)
  br label %35

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %3, align 4, !tbaa !5
  br label %25, !llvm.loop !11

38:                                               ; preds = %29
  %39 = load i32, ptr @N, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr @A, i64 %40
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @A, ptr noundef %41)
  %42 = load i32, ptr @N, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr @A, i64 %43
  call void @_ZSt7reverseIPiEvT_S1_(ptr noundef @A, ptr noundef %44)
  %45 = load i32, ptr @M, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i32, ptr @B, i64 %46
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @B, ptr noundef %47)
  %48 = load i32, ptr @M, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr @B, i64 %49
  call void @_ZSt7reverseIPiEvT_S1_(ptr noundef @B, ptr noundef %50)
  %51 = load i32, ptr @N, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %52
  store i32 0, ptr %53, align 4, !tbaa !5
  %54 = load i32, ptr @M, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %55
  store i32 0, ptr %56, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %57 = load i32, ptr @N, align 4, !tbaa !5
  %58 = load i32, ptr @M, align 4, !tbaa !5
  %59 = mul nsw i32 %57, %58
  store i32 %59, ptr %7, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %148, %38
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = icmp sge i32 %61, 1
  br i1 %62, label %64, label %63

63:                                               ; preds = %60
  store i32 8, ptr %8, align 4
  br label %151

64:                                               ; preds = %60
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp eq i32 %65, %69
  br i1 %70, label %71, label %85

71:                                               ; preds = %64
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = icmp eq i32 %72, %76
  br i1 %77, label %78, label %85

78:                                               ; preds = %71
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %4, align 4, !tbaa !5
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %5, align 4, !tbaa !5
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %6, align 4, !tbaa !5
  br label %147

85:                                               ; preds = %71, %64
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = icmp eq i32 %86, %90
  br i1 %91, label %92, label %103

92:                                               ; preds = %85
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = load i64, ptr @ans, align 8, !tbaa !12
  %96 = mul nsw i64 %95, %94
  store i64 %96, ptr @ans, align 8, !tbaa !12
  %97 = load i64, ptr @ans, align 8, !tbaa !12
  %98 = srem i64 %97, 1000000007
  store i64 %98, ptr @ans, align 8, !tbaa !12
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %4, align 4, !tbaa !5
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %6, align 4, !tbaa !5
  br label %146

103:                                              ; preds = %85
  %104 = load i32, ptr %7, align 4, !tbaa !5
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = icmp eq i32 %104, %108
  br i1 %109, label %110, label %121

110:                                              ; preds = %103
  %111 = load i32, ptr %4, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = load i64, ptr @ans, align 8, !tbaa !12
  %114 = mul nsw i64 %113, %112
  store i64 %114, ptr @ans, align 8, !tbaa !12
  %115 = load i64, ptr @ans, align 8, !tbaa !12
  %116 = srem i64 %115, 1000000007
  store i64 %116, ptr @ans, align 8, !tbaa !12
  %117 = load i32, ptr %5, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %5, align 4, !tbaa !5
  %119 = load i32, ptr %6, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %6, align 4, !tbaa !5
  br label %145

121:                                              ; preds = %103
  %122 = load i32, ptr %4, align 4, !tbaa !5
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = mul nsw i32 %122, %123
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = sub nsw i32 %124, %125
  %127 = icmp sgt i32 %126, 0
  br i1 %127, label %128, label %141

128:                                              ; preds = %121
  %129 = load i32, ptr %4, align 4, !tbaa !5
  %130 = load i32, ptr %5, align 4, !tbaa !5
  %131 = mul nsw i32 %129, %130
  %132 = load i32, ptr %6, align 4, !tbaa !5
  %133 = sub nsw i32 %131, %132
  %134 = sext i32 %133 to i64
  %135 = load i64, ptr @ans, align 8, !tbaa !12
  %136 = mul nsw i64 %135, %134
  store i64 %136, ptr @ans, align 8, !tbaa !12
  %137 = load i64, ptr @ans, align 8, !tbaa !12
  %138 = srem i64 %137, 1000000007
  store i64 %138, ptr @ans, align 8, !tbaa !12
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %6, align 4, !tbaa !5
  br label %144

141:                                              ; preds = %121
  %142 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  %143 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %142, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %151

144:                                              ; preds = %128
  br label %145

145:                                              ; preds = %144, %110
  br label %146

146:                                              ; preds = %145, %92
  br label %147

147:                                              ; preds = %146, %78
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = add nsw i32 %149, -1
  store i32 %150, ptr %7, align 4, !tbaa !5
  br label %60, !llvm.loop !14

151:                                              ; preds = %141, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %152 = load i32, ptr %8, align 4
  switch i32 %152, label %157 [
    i32 8, label %153
  ]

153:                                              ; preds = %151
  %154 = load i64, ptr @ans, align 8, !tbaa !12
  %155 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %154)
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %155, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %8, align 4
  br label %157

157:                                              ; preds = %153, %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %158 = load i32, ptr %8, align 4
  switch i32 %158, label %161 [
    i32 0, label %159
    i32 1, label %159
  ]

159:                                              ; preds = %157, %157
  %160 = load i32, ptr %1, align 4
  ret i32 %160

161:                                              ; preds = %157
  unreachable
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPiEvT_S1_(ptr noundef, ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !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" }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@A = external dso_local global [1010 x i32], align 16
@B = external dso_local global [1010 x i32], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %3 = load i32, ptr @N, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %0
  %5 = phi i32 [ %3, %0 ], [ %10, %.lr.ph ]
  %6 = load i32, ptr @M, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph46, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %8 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %indvars.iv
  %9 = 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) %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %indvars.iv.next, %11
  br i1 %12, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph46
  %.pre = load i32, ptr @N, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %13 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %.preheader ]
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr @A, i64 %14
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @A, ptr noundef nonnull %15)
  %16 = load i32, ptr @N, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr @A, i64 %17
  tail call void @_ZSt7reverseIPiEvT_S1_(ptr noundef nonnull @A, ptr noundef nonnull %18)
  %19 = load i32, ptr @M, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr @B, i64 %20
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @B, ptr noundef nonnull %21)
  %22 = load i32, ptr @M, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr @B, i64 %23
  tail call void @_ZSt7reverseIPiEvT_S1_(ptr noundef nonnull @B, ptr noundef nonnull %24)
  %25 = load i32, ptr @N, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %26
  store i32 0, ptr %27, align 4, !tbaa !5
  %28 = load i32, ptr @M, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %29
  store i32 0, ptr %30, align 4, !tbaa !5
  %31 = mul nsw i32 %28, %25
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !11
  %32 = icmp slt i32 %31, 1
  br i1 %32, label %.critedge, label %.lr.ph52

.lr.ph46:                                         ; preds = %.preheader, %.lr.ph46
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %.lr.ph46 ], [ 0, %.preheader ]
  %33 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %indvars.iv54
  %34 = 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) %33)
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %35 = load i32, ptr @M, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next55, %36
  br i1 %37, label %.lr.ph46, label %._crit_edge.loopexit, !llvm.loop !13

.lr.ph52:                                         ; preds = %._crit_edge, %70
  %.03450 = phi i32 [ %72, %70 ], [ %31, %._crit_edge ]
  %.03549 = phi i32 [ %.1, %70 ], [ 0, %._crit_edge ]
  %.03648 = phi i32 [ %.137, %70 ], [ 0, %._crit_edge ]
  %.03847 = phi i32 [ %.139, %70 ], [ 0, %._crit_edge ]
  %38 = phi i64 [ %71, %70 ], [ %ans.promoted, %._crit_edge ]
  %39 = sext i32 %.03847 to i64
  %40 = getelementptr inbounds [1010 x i32], ptr @A, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = icmp eq i32 %.03450, %41
  %43 = sext i32 %.03648 to i64
  %44 = getelementptr inbounds [1010 x i32], ptr @B, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = icmp eq i32 %.03450, %45
  br i1 %42, label %47, label %55

47:                                               ; preds = %.lr.ph52
  br i1 %46, label %48, label %51

48:                                               ; preds = %47
  %49 = add nsw i32 %.03847, 1
  %50 = add nsw i32 %.03648, 1
  br label %70

51:                                               ; preds = %47
  %52 = mul nsw i64 %38, %43
  %53 = srem i64 %52, 1000000007
  store i64 %53, ptr @ans, align 8, !tbaa !11
  %54 = add nsw i32 %.03847, 1
  br label %70

55:                                               ; preds = %.lr.ph52
  br i1 %46, label %56, label %60

56:                                               ; preds = %55
  %57 = mul nsw i64 %38, %39
  %58 = srem i64 %57, 1000000007
  store i64 %58, ptr @ans, align 8, !tbaa !11
  %59 = add nsw i32 %.03648, 1
  br label %70

60:                                               ; preds = %55
  %61 = mul nsw i32 %.03648, %.03847
  %62 = sub nsw i32 %61, %.03549
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %64, label %68

64:                                               ; preds = %60
  %65 = zext nneg i32 %62 to i64
  %66 = mul nsw i64 %38, %65
  %67 = srem i64 %66, 1000000007
  store i64 %67, ptr @ans, align 8, !tbaa !11
  br label %70

68:                                               ; preds = %60
  %69 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  br label %75

70:                                               ; preds = %48, %56, %64, %51
  %71 = phi i64 [ %38, %48 ], [ %53, %51 ], [ %58, %56 ], [ %67, %64 ]
  %.139 = phi i32 [ %49, %48 ], [ %54, %51 ], [ %.03847, %56 ], [ %.03847, %64 ]
  %.137 = phi i32 [ %50, %48 ], [ %.03648, %51 ], [ %59, %56 ], [ %.03648, %64 ]
  %.1 = add nuw nsw i32 %.03549, 1
  %72 = add nsw i32 %.03450, -1
  %exitcond = icmp eq i32 %.1, %31
  br i1 %exitcond, label %.critedge, label %.lr.ph52, !llvm.loop !14

.critedge:                                        ; preds = %70, %._crit_edge
  %73 = phi i64 [ %ans.promoted, %._crit_edge ], [ %71, %70 ]
  %74 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %73)
  br label %75

75:                                               ; preds = %68, %.critedge
  %.sink = phi ptr [ %69, %68 ], [ %74, %.critedge ]
  %76 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  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 #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

!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 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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