; LLVM IR from tangjz/acm-icpc :: lydsy (4816)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@f = external dso_local global [1000001 x i32], align 16
@g = external dso_local global [1000001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; 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
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @f, i64 0, i64 2), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @f, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 3, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %41, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 1000001
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 2
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %23, %28
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !5
  %33 = icmp sge i32 %29, 1000000007
  br i1 %33, label %34, label %40

34:                                               ; preds = %18
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sub nsw i32 %38, 1000000007
  store i32 %39, ptr %37, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %34, %18
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

44:                                               ; preds = %17
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @g, i64 0, i64 2), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @g, i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr @g, align 16, !tbaa !5
  store i32 1, ptr @f, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 3, ptr %3, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %112, %44
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = icmp slt i32 %46, 1000001
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = call noundef i32 @_Z7mod_invi(i32 noundef %53)
  store i32 %54, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = add nsw i32 %55, %56
  store i32 %57, ptr %6, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %76, %49
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = icmp slt i32 %59, 1000001
  br i1 %60, label %62, label %61

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

62:                                               ; preds = %58
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = mul nsw i64 %67, %69
  %71 = srem i64 %70, 1000000007
  %72 = trunc i64 %71 to i32
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %74
  store i32 %72, ptr %75, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %62
  %77 = load i32, ptr %3, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = add nsw i32 %78, %77
  store i32 %79, ptr %6, align 4, !tbaa !5
  br label %58, !llvm.loop !11

80:                                               ; preds = %61
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = sub nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = load i32, ptr %3, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = mul nsw i64 %86, %91
  %93 = srem i64 %92, 1000000007
  %94 = trunc i64 %93 to i32
  %95 = load i32, ptr %3, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %96
  store i32 %94, ptr %97, align 4, !tbaa !5
  %98 = load i32, ptr %3, align 4, !tbaa !5
  %99 = sub nsw i32 %98, 1
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = mul nsw i64 %103, %105
  %107 = srem i64 %106, 1000000007
  %108 = trunc i64 %107 to i32
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %110
  store i32 %108, ptr %111, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %112

112:                                              ; preds = %80
  %113 = load i32, ptr %3, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %3, align 4, !tbaa !5
  br label %45, !llvm.loop !12

115:                                              ; preds = %48
  %116 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %117

117:                                              ; preds = %180, %115
  %118 = load i32, ptr @t, align 4, !tbaa !5
  %119 = add nsw i32 %118, -1
  store i32 %119, ptr @t, align 4, !tbaa !5
  %120 = icmp ne i32 %118, 0
  br i1 %120, label %121, label %183

121:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  %122 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  br label %123

123:                                              ; preds = %177, %121
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = load i32, ptr @n, align 4, !tbaa !5
  %126 = icmp sle i32 %124, %125
  br i1 %126, label %127, label %131

127:                                              ; preds = %123
  %128 = load i32, ptr %8, align 4, !tbaa !5
  %129 = load i32, ptr @m, align 4, !tbaa !5
  %130 = icmp sle i32 %128, %129
  br label %131

131:                                              ; preds = %127, %123
  %132 = phi i1 [ false, %123 ], [ %130, %127 ]
  br i1 %132, label %134, label %133

133:                                              ; preds = %131
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %180

134:                                              ; preds = %131
  %135 = load i32, ptr @n, align 4, !tbaa !5
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = sdiv i32 %135, %136
  store i32 %137, ptr %10, align 4, !tbaa !5
  %138 = load i32, ptr @m, align 4, !tbaa !5
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = sdiv i32 %138, %139
  store i32 %140, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %141 = load i32, ptr @n, align 4, !tbaa !5
  %142 = load i32, ptr %10, align 4, !tbaa !5
  %143 = sdiv i32 %141, %142
  store i32 %143, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %144 = load i32, ptr @m, align 4, !tbaa !5
  %145 = load i32, ptr %11, align 4, !tbaa !5
  %146 = sdiv i32 %144, %145
  store i32 %146, ptr %13, align 4, !tbaa !5
  %147 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %148 = load i32, ptr %147, align 4, !tbaa !5
  store i32 %148, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = load i32, ptr %9, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = load i32, ptr %8, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = mul nsw i64 %155, %161
  %163 = srem i64 %162, 1000000007
  %164 = trunc i64 %163 to i32
  %165 = load i32, ptr %10, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = load i32, ptr %11, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = mul nsw i64 %166, %168
  %170 = srem i64 %169, 1000000006
  %171 = trunc i64 %170 to i32
  %172 = call noundef i32 @_Z7mod_powii(i32 noundef %164, i32 noundef %171)
  %173 = sext i32 %172 to i64
  %174 = mul nsw i64 %150, %173
  %175 = srem i64 %174, 1000000007
  %176 = trunc i64 %175 to i32
  store i32 %176, ptr %7, align 4, !tbaa !5
  br label %177

177:                                              ; preds = %134
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %8, align 4, !tbaa !5
  br label %123, !llvm.loop !13

180:                                              ; preds = %133
  %181 = load i32, ptr %7, align 4, !tbaa !5
  %182 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %181)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %117, !llvm.loop !14

183:                                              ; preds = %117
  ret i32 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z7mod_invi(i32 noundef) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powii(i32 noundef, i32 noundef) #4

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 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 #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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@f = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@g = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 4), align 4, !tbaa !5
  br label %4

3:                                                ; preds = %4
  store i32 1, ptr getelementptr inbounds (i8, ptr @g, i64 8), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @g, i64 4), align 4, !tbaa !5
  store i32 1, ptr @g, align 16, !tbaa !5
  store i32 1, ptr @f, align 16, !tbaa !5
  br label %24

4:                                                ; preds = %4, %0
  %5 = phi i32 [ 1, %0 ], [ %spec.select.1, %4 ]
  %indvars.iv = phi i64 [ 3, %0 ], [ %indvars.iv.next.1, %4 ]
  %6 = add nsw i64 %indvars.iv, -2
  %7 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = add nsw i32 %8, %5
  %10 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv
  %11 = icmp sgt i32 %9, 1000000006
  %12 = add nsw i32 %9, -1000000007
  %spec.select = select i1 %11, i32 %12, i32 %9
  store i32 %spec.select, ptr %10, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = add nsw i64 %indvars.iv, -1
  %14 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = add nsw i32 %15, %spec.select
  %17 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv.next
  %18 = icmp sgt i32 %16, 1000000006
  %19 = add nsw i32 %16, -1000000007
  %spec.select.1 = select i1 %18, i32 %19, i32 %16
  store i32 %spec.select.1, ptr %17, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 1000001
  br i1 %exitcond.not.1, label %3, label %4, !llvm.loop !9

20:                                               ; preds = %._crit_edge
  %21 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %22 = load i32, ptr @t, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr @t, align 4, !tbaa !5
  %.not51 = icmp eq i32 %22, 0
  br i1 %.not51, label %._crit_edge54, label %.lr.ph53

24:                                               ; preds = %3, %._crit_edge
  %indvars.iv58 = phi i64 [ 3, %3 ], [ %indvars.iv.next59, %._crit_edge ]
  %indvars.iv56 = phi i64 [ 6, %3 ], [ %indvars.iv.next57, %._crit_edge ]
  %25 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv58
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = tail call noundef i32 @_Z7mod_invi(i32 noundef %26)
  %28 = icmp ult i64 %indvars.iv58, 500001
  %29 = sext i32 %27 to i64
  br i1 %28, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %24
  %30 = add nsw i64 %indvars.iv58, -1
  %31 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = load i32, ptr %25, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = mul nsw i64 %35, %33
  %37 = srem i64 %36, 1000000007
  %38 = trunc nsw i64 %37 to i32
  store i32 %38, ptr %25, align 4, !tbaa !5
  %39 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %30
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = mul nsw i64 %29, %41
  %43 = srem i64 %42, 1000000007
  %44 = trunc nsw i64 %43 to i32
  %45 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %indvars.iv58
  store i32 %44, ptr %45, align 4, !tbaa !5
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 2
  %exitcond64.not = icmp eq i64 %indvars.iv.next59, 1000001
  br i1 %exitcond64.not, label %20, label %24, !llvm.loop !11

.lr.ph:                                           ; preds = %24, %.lr.ph
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.lr.ph ], [ %indvars.iv56, %24 ]
  %46 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv60
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = mul nsw i64 %48, %29
  %50 = srem i64 %49, 1000000007
  %51 = trunc nsw i64 %50 to i32
  store i32 %51, ptr %46, align 4, !tbaa !5
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, %indvars.iv58
  %52 = icmp ult i64 %indvars.iv.next61, 1000001
  br i1 %52, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.lr.ph53:                                         ; preds = %20, %._crit_edge50
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = icmp sgt i32 %54, 2
  %56 = load i32, ptr @m, align 4
  %57 = icmp sgt i32 %56, 2
  %58 = select i1 %55, i1 %57, i1 false
  br i1 %58, label %.lr.ph49, label %._crit_edge50

._crit_edge50.loopexit:                           ; preds = %.lr.ph49
  %59 = trunc nsw i64 %91 to i32
  br label %._crit_edge50

._crit_edge50:                                    ; preds = %._crit_edge50.loopexit, %.lr.ph53
  %.038.lcssa = phi i32 [ 1, %.lr.ph53 ], [ %59, %._crit_edge50.loopexit ]
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.038.lcssa)
  %61 = load i32, ptr @t, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %61, 0
  br i1 %.not, label %._crit_edge54, label %.lr.ph53, !llvm.loop !13

.lr.ph49:                                         ; preds = %.lr.ph53, %.lr.ph49
  %63 = phi i32 [ %95, %.lr.ph49 ], [ %56, %.lr.ph53 ]
  %64 = phi i32 [ %93, %.lr.ph49 ], [ %54, %.lr.ph53 ]
  %.03747 = phi i32 [ %92, %.lr.ph49 ], [ 3, %.lr.ph53 ]
  %.03846 = phi i64 [ %91, %.lr.ph49 ], [ 1, %.lr.ph53 ]
  %65 = sdiv i32 %64, %.03747
  %66 = sdiv i32 %63, %.03747
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %67 = sdiv i32 %64, %65
  store i32 %67, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %68 = sdiv i32 %63, %66
  store i32 %68, ptr %2, align 4, !tbaa !5
  %69 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %70 = load i32, ptr %69, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = add nsw i32 %.03747, -1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = mul nsw i64 %79, %74
  %81 = srem i64 %80, 1000000007
  %82 = trunc nsw i64 %81 to i32
  %83 = sext i32 %65 to i64
  %84 = sext i32 %66 to i64
  %85 = mul nsw i64 %84, %83
  %86 = srem i64 %85, 1000000006
  %87 = trunc nsw i64 %86 to i32
  %88 = call noundef i32 @_Z7mod_powii(i32 noundef %82, i32 noundef %87)
  %89 = sext i32 %88 to i64
  %90 = mul nsw i64 %.03846, %89
  %91 = srem i64 %90, 1000000007
  %92 = add nsw i32 %70, 1
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = icmp slt i32 %70, %93
  %95 = load i32, ptr @m, align 4
  %96 = icmp slt i32 %70, %95
  %97 = select i1 %94, i1 %96, i1 false
  br i1 %97, label %.lr.ph49, label %._crit_edge50.loopexit, !llvm.loop !14

._crit_edge54:                                    ; preds = %._crit_edge50, %20
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z7mod_invi(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powii(i32 noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { inlinehint 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 #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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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