; LLVM IR from tangjz/acm-icpc :: codeforces/gym (104021M)

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

@inv = external dso_local global [1000001 x i32], align 16
@f = external dso_local global [1000001 x i32], align 16
@g = external dso_local global [1000001 x i32], align 16
@a = external dso_local global [1000001 x i32], align 16
@b = 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 [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
  store i32 0, ptr %1, align 4
  store i32 1, ptr @g, align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @f, i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr @f, align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @inv, i64 0, i64 1), align 4, !tbaa !5
  store i32 2, ptr getelementptr inbounds ([1000001 x i32], ptr @g, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %11

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

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

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sdiv i32 1000000007, %16
  %18 = sext i32 %17 to i64
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = srem i32 1000000007, %19
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = mul nsw i64 %18, %24
  %26 = srem i64 %25, 1000000007
  %27 = trunc i64 %26 to i32
  %28 = sub nsw i32 1000000007, %27
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %30
  store i32 %28, ptr %31, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = mul nsw i64 12, %33
  %35 = sub nsw i64 %34, 30
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = mul nsw i64 %35, %41
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = mul nsw i64 4, %44
  %46 = sub nsw i64 %45, 16
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 2
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = mul nsw i64 %46, %52
  %54 = sub nsw i64 %42, %53
  %55 = srem i64 %54, 1000000007
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sub nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %55, %61
  %63 = srem i64 %62, 1000000007
  %64 = trunc i64 %63 to i32
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %66
  store i32 %64, ptr %67, align 4, !tbaa !5
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = mul nsw i64 12, %69
  %71 = sub nsw i64 %70, 18
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = sub nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = mul nsw i64 %71, %77
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = mul nsw i64 4, %80
  %82 = sub nsw i64 %81, 8
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 2
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = mul nsw i64 %82, %88
  %90 = sub nsw i64 %78, %89
  %91 = srem i64 %90, 1000000007
  %92 = load i32, ptr %2, align 4, !tbaa !5
  %93 = sub nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = mul nsw i64 %91, %97
  %99 = srem i64 %98, 1000000007
  %100 = trunc i64 %99 to i32
  %101 = load i32, ptr %2, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %102
  store i32 %100, ptr %103, align 4, !tbaa !5
  %104 = load i32, ptr %2, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %105
  call void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4) %106)
  %107 = load i32, ptr %2, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %108
  call void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4) %109)
  br label %110

110:                                              ; preds = %15
  %111 = load i32, ptr %2, align 4, !tbaa !5
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !9

113:                                              ; preds = %14
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @a, ptr align 16 @g, i64 4000004, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @b, i8 -1, i64 4000004, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %191, %113
  %115 = load i32, ptr %3, align 4, !tbaa !5
  %116 = icmp slt i32 %115, 1000001
  br i1 %116, label %118, label %117

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

118:                                              ; preds = %114
  %119 = load i32, ptr %3, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = icmp eq i32 %122, -1
  br i1 %123, label %124, label %190

124:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %125 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %125, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %183, %124
  %127 = load i32, ptr %5, align 4, !tbaa !5
  %128 = icmp slt i32 %127, 1000001
  br i1 %128, label %130, label %129

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

130:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = load i32, ptr %3, align 4, !tbaa !5
  %133 = srem i32 %131, %132
  %134 = icmp sgt i32 %133, 0
  br i1 %134, label %135, label %140

135:                                              ; preds = %130
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  br label %145

140:                                              ; preds = %130
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  br label %145

145:                                              ; preds = %140, %135
  %146 = phi i32 [ %139, %135 ], [ %144, %140 ]
  store i32 %146, ptr %7, align 4, !tbaa !5
  %147 = load i32, ptr %5, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = load i32, ptr %3, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = sub nsw i64 %153, 1
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = mul nsw i64 %154, %156
  %158 = add nsw i64 %151, %157
  %159 = srem i64 %158, 1000000007
  %160 = trunc i64 %159 to i32
  %161 = load i32, ptr %5, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %162
  store i32 %160, ptr %163, align 4, !tbaa !5
  %164 = load i32, ptr %5, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = load i32, ptr %7, align 4, !tbaa !5
  %169 = add nsw i32 %167, %168
  %170 = load i32, ptr %5, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %171
  store i32 %169, ptr %172, align 4, !tbaa !5
  %173 = icmp sge i32 %169, 1000000007
  br i1 %173, label %174, label %181

174:                                              ; preds = %145
  %175 = load i32, ptr %5, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !5
  %179 = sub nsw i32 %178, 1000000007
  store i32 %179, ptr %177, align 4, !tbaa !5
  %180 = icmp ne i32 %179, 0
  br label %181

181:                                              ; preds = %174, %145
  %182 = phi i1 [ false, %145 ], [ %180, %174 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %183

183:                                              ; preds = %181
  %184 = load i32, ptr %3, align 4, !tbaa !5
  %185 = load i32, ptr %5, align 4, !tbaa !5
  %186 = add nsw i32 %185, %184
  store i32 %186, ptr %5, align 4, !tbaa !5
  %187 = load i32, ptr %6, align 4, !tbaa !5
  %188 = add nsw i32 %187, 1
  store i32 %188, ptr %6, align 4, !tbaa !5
  br label %126, !llvm.loop !11

189:                                              ; preds = %129
  br label %190

190:                                              ; preds = %189, %118
  br label %191

191:                                              ; preds = %190
  %192 = load i32, ptr %3, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %3, align 4, !tbaa !5
  br label %114, !llvm.loop !12

194:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %229, %194
  %196 = load i32, ptr %8, align 4, !tbaa !5
  %197 = icmp slt i32 %196, 1000001
  br i1 %197, label %199, label %198

198:                                              ; preds = %195
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %232

199:                                              ; preds = %195
  %200 = load i32, ptr %8, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = load i32, ptr %8, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !5
  %208 = add nsw i32 %203, %207
  %209 = load i32, ptr %8, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = sub nsw i32 %208, %212
  %214 = sext i32 %213 to i64
  %215 = load i32, ptr %8, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %216
  %218 = load i32, ptr %217, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = mul nsw i64 %214, %219
  %221 = srem i64 %220, 1000000007
  %222 = trunc i64 %221 to i32
  %223 = load i32, ptr %8, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %224
  store i32 %222, ptr %225, align 4, !tbaa !5
  %226 = load i32, ptr %8, align 4, !tbaa !5
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %227
  call void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4) %228)
  br label %229

229:                                              ; preds = %199
  %230 = load i32, ptr %8, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %8, align 4, !tbaa !5
  br label %195, !llvm.loop !13

232:                                              ; preds = %198
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %233 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %9)
  br label %234

234:                                              ; preds = %238, %232
  %235 = load i32, ptr %9, align 4, !tbaa !5
  %236 = add nsw i32 %235, -1
  store i32 %236, ptr %9, align 4, !tbaa !5
  %237 = icmp ne i32 %235, 0
  br i1 %237, label %238, label %245

238:                                              ; preds = %234
  %239 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %10)
  %240 = load i32, ptr %10, align 4, !tbaa !5
  %241 = sext i32 %240 to i64
  %242 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %241
  %243 = load i32, ptr %242, align 4, !tbaa !5
  %244 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %243)
  br label %234, !llvm.loop !14

245:                                              ; preds = %234
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  %246 = load i32, ptr %1, align 4
  ret i32 %246
}

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

declare i32 @printf(ptr noundef, ...) #5

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

@inv = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@f = external dso_local global [1000001 x i32], align 16
@g = external dso_local global [1000001 x i32], align 16
@a = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@b = 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 [4 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind 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 @g, align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 4), align 4, !tbaa !5
  store i32 1, ptr @f, align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  store i32 2, ptr getelementptr inbounds (i8, ptr @g, i64 4), align 4, !tbaa !5
  br label %4

3:                                                ; preds = %4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(4000004) @a, ptr noundef nonnull align 16 dereferenceable(4000004) @g, i64 4000004, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4000004) @b, i8 -1, i64 4000004, i1 false)
  br label %57

4:                                                ; preds = %0, %4
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next, %4 ]
  %5 = trunc nuw nsw i64 %indvars.iv to i32
  %6 = udiv i32 1000000007, %5
  %7 = zext nneg i32 %6 to i64
  %8 = urem i32 1000000007, %5
  %9 = zext nneg i32 %8 to i64
  %10 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = mul nsw i64 %12, %7
  %14 = srem i64 %13, 1000000007
  %15 = trunc nsw i64 %14 to i32
  %16 = sub nsw i32 1000000007, %15
  %17 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %indvars.iv
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = mul nuw nsw i64 %indvars.iv, 12
  %19 = add nsw i64 %18, -30
  %20 = add nsw i64 %indvars.iv, -1
  %21 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = mul nsw i64 %19, %23
  %25 = shl nuw nsw i64 %indvars.iv, 2
  %26 = add nsw i64 %25, -16
  %27 = add nsw i64 %indvars.iv, -2
  %28 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = mul nsw i64 %26, %30
  %32 = sub nsw i64 %24, %31
  %33 = srem i64 %32, 1000000007
  %34 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %20
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = mul nsw i64 %33, %36
  %38 = srem i64 %37, 1000000007
  %39 = trunc nsw i64 %38 to i32
  %40 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 %39, ptr %40, align 4, !tbaa !5
  %41 = add nsw i64 %18, -18
  %42 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %20
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = mul nsw i64 %41, %44
  %46 = add nsw i64 %25, -8
  %47 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %27
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %46, %49
  %51 = sub nsw i64 %45, %50
  %52 = srem i64 %51, 1000000007
  %53 = mul nsw i64 %52, %36
  %54 = srem i64 %53, 1000000007
  %55 = trunc nsw i64 %54 to i32
  %56 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %indvars.iv
  store i32 %55, ptr %56, align 4, !tbaa !5
  tail call void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4) %40)
  tail call void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4) %56)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1000001
  br i1 %exitcond.not, label %3, label %4, !llvm.loop !9

57:                                               ; preds = %3, %.loopexit
  %indvars.iv66 = phi i64 [ 2, %3 ], [ %indvars.iv.next67, %.loopexit ]
  %58 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %indvars.iv66
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp eq i32 %59, -1
  br i1 %60, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %57
  %61 = add nsw i64 %indvars.iv66, -1
  %62 = trunc nuw nsw i64 %indvars.iv66 to i32
  br label %63

63:                                               ; preds = %.lr.ph, %63
  %indvars.iv68 = phi i64 [ %indvars.iv66, %.lr.ph ], [ %indvars.iv.next69, %63 ]
  %indvars.iv64 = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next65, %63 ]
  %64 = trunc nuw nsw i64 %indvars.iv64 to i32
  %65 = urem i32 %64, %62
  %.not53 = icmp eq i32 %65, 0
  %66 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %indvars.iv64
  %67 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %indvars.iv64
  %.in = select i1 %.not53, ptr %67, ptr %66
  %68 = load i32, ptr %.in, align 4, !tbaa !5
  %69 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %indvars.iv68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = sext i32 %68 to i64
  %73 = mul nsw i64 %61, %72
  %74 = add nsw i64 %73, %71
  %75 = srem i64 %74, 1000000007
  %76 = trunc nsw i64 %75 to i32
  store i32 %76, ptr %69, align 4, !tbaa !5
  %77 = add nsw i32 %68, %76
  %78 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %indvars.iv68
  %79 = icmp sgt i32 %77, 1000000006
  %80 = add nsw i32 %77, -1000000007
  %storemerge = select i1 %79, i32 %80, i32 %77
  store i32 %storemerge, ptr %78, align 4, !tbaa !5
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, %indvars.iv66
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %81 = icmp ult i64 %indvars.iv.next69, 1000001
  br i1 %81, label %63, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %63, %57
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond74.not = icmp eq i64 %indvars.iv.next67, 1000001
  br i1 %exitcond74.not, label %.preheader, label %57, !llvm.loop !12

82:                                               ; preds = %.preheader
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %83 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %84 = load i32, ptr %1, align 4, !tbaa !5
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %1, align 4, !tbaa !5
  %.not61 = icmp eq i32 %84, 0
  br i1 %.not61, label %._crit_edge, label %.lr.ph62

.preheader:                                       ; preds = %.loopexit, %.preheader
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.preheader ], [ 1, %.loopexit ]
  %86 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv75
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %indvars.iv75
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = add nsw i32 %89, %87
  %91 = getelementptr inbounds [1000001 x i32], ptr @g, i64 0, i64 %indvars.iv75
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = sub i32 %90, %92
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1000001 x i32], ptr @inv, i64 0, i64 %indvars.iv75
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = mul nsw i64 %94, %97
  %99 = srem i64 %98, 1000000007
  %100 = trunc nsw i64 %99 to i32
  store i32 %100, ptr %86, align 4, !tbaa !5
  tail call void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4) %86)
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond78.not = icmp eq i64 %indvars.iv.next76, 1000001
  br i1 %exitcond78.not, label %82, label %.preheader, !llvm.loop !13

.lr.ph62:                                         ; preds = %82, %.lr.ph62
  %101 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %102 = load i32, ptr %2, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %105)
  %107 = load i32, ptr %1, align 4, !tbaa !5
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %107, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph62, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph62, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z7mod_fixRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

attributes #0 = { mustprogress norecurse 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass