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

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

%struct.Matrix = type { [5 x [5 x i32]] }

@A = external dso_local global %struct.Matrix, align 4
@B = external dso_local global %struct.Matrix, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@coeff = external dso_local global [5 x i32], align 16
@bit = external dso_local global [2 x [500001 x i32]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 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 %struct.Matrix, align 4
  %3 = alloca %struct.Matrix, 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
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  store i32 1, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 2), i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @A, i64 0, i64 3), i64 0, i64 3), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @A, i64 0, i64 2), i64 0, i64 2), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @A, i64 0, i64 1), i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr @A, align 4, !tbaa !5
  store i32 1000000006, ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 2), align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = sub nsw i64 %18, 3
  %20 = mul nsw i64 %16, %19
  %21 = sdiv i64 %20, 2
  %22 = add nsw i64 %21, 1000000007
  %23 = srem i64 %22, 1000000007
  %24 = trunc i64 %23 to i32
  store i32 %24, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 1), i64 0, i64 1), align 4, !tbaa !5
  store i32 %24, ptr @B, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = sub nsw i64 %28, 5
  %30 = mul nsw i64 %26, %29
  %31 = sdiv i64 %30, 2
  %32 = add nsw i64 %31, 1000000007
  %33 = srem i64 %32, 1000000007
  %34 = trunc i64 %33 to i32
  store i32 %34, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 2), i64 0, i64 2), align 4, !tbaa !5
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = sub nsw i64 %38, 1
  %40 = mul nsw i64 %36, %39
  %41 = sdiv i64 %40, 2
  %42 = srem i64 %41, 1000000007
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 3), i64 0, i64 3), align 4, !tbaa !5
  store i32 %43, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 1), i64 0, i64 3), align 4, !tbaa !5
  store i32 %43, ptr getelementptr inbounds ([5 x i32], ptr @B, i64 0, i64 3), align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %44, ptr getelementptr inbounds ([5 x i32], ptr getelementptr inbounds ([5 x [5 x i32]], ptr @B, i64 0, i64 2), i64 0, i64 3), align 4, !tbaa !5
  br label %45

45:                                               ; preds = %54, %0
  %46 = load i32, ptr @m, align 4, !tbaa !5
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %48, label %57

48:                                               ; preds = %45
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %50 = and i32 %49, 1
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 100, ptr %2) #5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind writable sret(%struct.Matrix) align 4 %2, ptr noundef nonnull align 4 dereferenceable(100) @A, ptr noundef nonnull align 4 dereferenceable(100) @B)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @A, ptr align 4 %2, i64 100, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 100, ptr %2) #5
  br label %53

53:                                               ; preds = %52, %48
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr @m, align 4, !tbaa !5
  %56 = ashr i32 %55, 1
  store i32 %56, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 100, ptr %3) #5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind writable sret(%struct.Matrix) align 4 %3, ptr noundef nonnull align 4 dereferenceable(100) @B, ptr noundef nonnull align 4 dereferenceable(100) @B)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @B, ptr align 4 %3, i64 100, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 100, ptr %3) #5
  br label %45, !llvm.loop !11

57:                                               ; preds = %45
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @coeff, ptr align 4 getelementptr inbounds ([5 x [5 x i32]], ptr @A, i64 0, i64 2), i64 16, i1 false)
  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
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  br label %58

58:                                               ; preds = %196, %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = icmp sle i32 %59, %60
  br i1 %61, label %63, label %62

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

63:                                               ; preds = %58
  %64 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  store i32 %66, ptr %12, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %91, %63
  %68 = load i32, ptr %12, align 4, !tbaa !5
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %71, label %70

70:                                               ; preds = %67
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %98

71:                                               ; preds = %67
  %72 = load i32, ptr %12, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [500001 x i32], ptr @bit, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load i32, ptr %10, align 4, !tbaa !5
  %77 = add nsw i32 %76, %75
  store i32 %77, ptr %10, align 4, !tbaa !5
  %78 = load i32, ptr %12, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [500001 x i32], ptr getelementptr inbounds ([2 x [500001 x i32]], ptr @bit, i64 0, i64 1), i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr %11, align 4, !tbaa !5
  %83 = add nsw i32 %82, %81
  store i32 %83, ptr %11, align 4, !tbaa !5
  %84 = icmp sge i32 %83, 1000000007
  br i1 %84, label %85, label %89

85:                                               ; preds = %71
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = sub nsw i32 %86, 1000000007
  store i32 %87, ptr %11, align 4, !tbaa !5
  %88 = icmp ne i32 %87, 0
  br label %89

89:                                               ; preds = %85, %71
  %90 = phi i1 [ false, %71 ], [ %88, %85 ]
  br label %91

91:                                               ; preds = %89
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = load i32, ptr %12, align 4, !tbaa !5
  %94 = sub nsw i32 0, %93
  %95 = and i32 %92, %94
  %96 = load i32, ptr %12, align 4, !tbaa !5
  %97 = sub nsw i32 %96, %95
  store i32 %97, ptr %12, align 4, !tbaa !5
  br label %67, !llvm.loop !13

98:                                               ; preds = %70
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = load i32, ptr @coeff, align 16, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = load i32, ptr %10, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = mul nsw i64 %104, %106
  %108 = srem i64 %107, 1000000007
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = add nsw i64 %108, %110
  %112 = load i32, ptr %11, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = sub nsw i64 %111, %113
  %115 = mul nsw i64 %102, %114
  %116 = add nsw i64 %100, %115
  %117 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @coeff, i64 0, i64 1), align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = load i32, ptr %11, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = load i32, ptr %5, align 4, !tbaa !5
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = sub nsw i32 %121, %122
  %124 = sext i32 %123 to i64
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = mul nsw i64 %124, %126
  %128 = srem i64 %127, 1000000007
  %129 = add nsw i64 %120, %128
  %130 = mul nsw i64 %118, %129
  %131 = add nsw i64 %116, %130
  %132 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @coeff, i64 0, i64 2), align 8, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = load i32, ptr %5, align 4, !tbaa !5
  %135 = load i32, ptr %10, align 4, !tbaa !5
  %136 = sub nsw i32 %134, %135
  %137 = sext i32 %136 to i64
  %138 = mul nsw i64 %133, %137
  %139 = add nsw i64 %131, %138
  %140 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @coeff, i64 0, i64 3), align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = load i32, ptr %5, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = mul nsw i64 %141, %143
  %145 = add nsw i64 %139, %144
  %146 = srem i64 %145, 1000000007
  %147 = trunc i64 %146 to i32
  store i32 %147, ptr %4, align 4, !tbaa !5
  %148 = load i32, ptr %5, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %5, align 4, !tbaa !5
  %150 = load i32, ptr %7, align 4, !tbaa !5
  %151 = load i32, ptr %6, align 4, !tbaa !5
  %152 = add nsw i32 %151, %150
  store i32 %152, ptr %6, align 4, !tbaa !5
  %153 = icmp sge i32 %152, 1000000007
  br i1 %153, label %154, label %158

154:                                              ; preds = %98
  %155 = load i32, ptr %6, align 4, !tbaa !5
  %156 = sub nsw i32 %155, 1000000007
  store i32 %156, ptr %6, align 4, !tbaa !5
  %157 = icmp ne i32 %156, 0
  br label %158

158:                                              ; preds = %154, %98
  %159 = phi i1 [ false, %98 ], [ %157, %154 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %160 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %160, ptr %13, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %188, %158
  %162 = load i32, ptr %13, align 4, !tbaa !5
  %163 = load i32, ptr @n, align 4, !tbaa !5
  %164 = icmp sle i32 %162, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %161
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %195

166:                                              ; preds = %161
  %167 = load i32, ptr %13, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [500001 x i32], ptr @bit, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %169, align 4, !tbaa !5
  %172 = load i32, ptr %7, align 4, !tbaa !5
  %173 = load i32, ptr %13, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [500001 x i32], ptr getelementptr inbounds ([2 x [500001 x i32]], ptr @bit, i64 0, i64 1), i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = add nsw i32 %176, %172
  store i32 %177, ptr %175, align 4, !tbaa !5
  %178 = icmp sge i32 %177, 1000000007
  br i1 %178, label %179, label %186

179:                                              ; preds = %166
  %180 = load i32, ptr %13, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [500001 x i32], ptr getelementptr inbounds ([2 x [500001 x i32]], ptr @bit, i64 0, i64 1), i64 0, i64 %181
  %183 = load i32, ptr %182, align 4, !tbaa !5
  %184 = sub nsw i32 %183, 1000000007
  store i32 %184, ptr %182, align 4, !tbaa !5
  %185 = icmp ne i32 %184, 0
  br label %186

186:                                              ; preds = %179, %166
  %187 = phi i1 [ false, %166 ], [ %185, %179 ]
  br label %188

188:                                              ; preds = %186
  %189 = load i32, ptr %13, align 4, !tbaa !5
  %190 = load i32, ptr %13, align 4, !tbaa !5
  %191 = sub nsw i32 0, %190
  %192 = and i32 %189, %191
  %193 = load i32, ptr %13, align 4, !tbaa !5
  %194 = add nsw i32 %193, %192
  store i32 %194, ptr %13, align 4, !tbaa !5
  br label %161, !llvm.loop !14

195:                                              ; preds = %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %7, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %7, align 4, !tbaa !5
  br label %58, !llvm.loop !15

199:                                              ; preds = %62
  %200 = load i32, ptr %4, align 4, !tbaa !5
  %201 = icmp slt i32 %200, 0
  br i1 %201, label %202, label %205

202:                                              ; preds = %199
  %203 = load i32, ptr %4, align 4, !tbaa !5
  %204 = add nsw i32 %203, 1000000007
  br label %207

205:                                              ; preds = %199
  %206 = load i32, ptr %4, align 4, !tbaa !5
  br label %207

207:                                              ; preds = %205, %202
  %208 = phi i32 [ %204, %202 ], [ %206, %205 ]
  %209 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %208)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  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
  %210 = load i32, ptr %1, align 4
  ret i32 %210
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind noalias writable sret(%struct.Matrix) align 4, ptr noundef nonnull align 4 dereferenceable(100), ptr noundef nonnull align 4 dereferenceable(100)) #3 align 2

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

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

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

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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 100, !10}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.Matrix = type { [5 x [5 x i32]] }

@A = external dso_local global %struct.Matrix, align 4
@B = external dso_local global %struct.Matrix, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@coeff = external dso_local local_unnamed_addr global [5 x i32], align 16
@bit = external dso_local local_unnamed_addr global [2 x [500001 x i32]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = 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 %struct.Matrix, align 4
  %2 = alloca %struct.Matrix, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  store i32 1, ptr getelementptr inbounds (i8, ptr @B, i64 44), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @A, i64 72), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @A, i64 48), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @A, i64 24), align 4, !tbaa !5
  store i32 1, ptr @A, align 4, !tbaa !5
  store i32 1000000006, ptr getelementptr inbounds (i8, ptr @B, i64 40), align 4, !tbaa !5
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = add nsw i64 %6, -3
  %8 = mul nsw i64 %7, %6
  %9 = sdiv i64 %8, 2
  %10 = add nsw i64 %9, 1000000007
  %11 = srem i64 %10, 1000000007
  %12 = trunc nsw i64 %11 to i32
  store i32 %12, ptr getelementptr inbounds (i8, ptr @B, i64 24), align 4, !tbaa !5
  store i32 %12, ptr @B, align 4, !tbaa !5
  %13 = add nsw i64 %6, -5
  %14 = mul nsw i64 %13, %6
  %15 = sdiv i64 %14, 2
  %16 = add nsw i64 %15, 1000000007
  %17 = srem i64 %16, 1000000007
  %18 = trunc nsw i64 %17 to i32
  store i32 %18, ptr getelementptr inbounds (i8, ptr @B, i64 48), align 4, !tbaa !5
  %19 = add nsw i64 %6, -1
  %20 = mul nsw i64 %19, %6
  %21 = sdiv i64 %20, 2
  %22 = srem i64 %21, 1000000007
  %23 = trunc nsw i64 %22 to i32
  store i32 %23, ptr getelementptr inbounds (i8, ptr @B, i64 72), align 4, !tbaa !5
  store i32 %23, ptr getelementptr inbounds (i8, ptr @B, i64 32), align 4, !tbaa !5
  store i32 %23, ptr getelementptr inbounds (i8, ptr @B, i64 12), align 4, !tbaa !5
  store i32 %5, ptr getelementptr inbounds (i8, ptr @B, i64 52), align 4, !tbaa !5
  %24 = load i32, ptr @m, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %29
  %26 = phi i32 [ %32, %29 ], [ %24, %0 ]
  %27 = and i32 %26, 1
  %.not55 = icmp eq i32 %27, 0
  br i1 %.not55, label %29, label %28

28:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %1) #5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Matrix) align 4 %1, ptr noundef nonnull align 4 dereferenceable(100) @A, ptr noundef nonnull align 4 dereferenceable(100) @B)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) @A, ptr noundef nonnull align 4 dereferenceable(100) %1, i64 100, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %1) #5
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %.lr.ph, %28
  %30 = phi i32 [ %26, %.lr.ph ], [ %.pre, %28 ]
  %31 = ashr i32 %30, 1
  store i32 %31, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %2) #5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Matrix) align 4 %2, ptr noundef nonnull align 4 dereferenceable(100) @B, ptr noundef nonnull align 4 dereferenceable(100) @B)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) @B, ptr noundef nonnull align 4 dereferenceable(100) %2, i64 100, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %2) #5
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %29
  %.pre85 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %34 = phi i32 [ %.pre85, %._crit_edge.loopexit ], [ %5, %0 ]
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) @coeff, ptr noundef nonnull align 4 dereferenceable(16) getelementptr inbounds (i8, ptr @A, i64 40), i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %.not70 = icmp slt i32 %34, 1
  br i1 %.not70, label %._crit_edge77.thread, label %.lr.ph76

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

._crit_edge77:                                    ; preds = %._crit_edge69
  %35 = trunc nsw i64 %74 to i32
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %36 = icmp slt i64 %74, 0
  %37 = add nsw i32 %35, 1000000007
  %spec.select90 = select i1 %36, i32 %37, i32 %35
  br label %38

38:                                               ; preds = %._crit_edge77, %._crit_edge77.thread
  %39 = phi i32 [ 0, %._crit_edge77.thread ], [ %spec.select90, %._crit_edge77 ]
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %39)
  ret i32 0

.lr.ph76:                                         ; preds = %._crit_edge, %._crit_edge69
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %._crit_edge69 ], [ 0, %._crit_edge ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge69 ], [ 1, %._crit_edge ]
  %.04373 = phi i32 [ %spec.select, %._crit_edge69 ], [ 0, %._crit_edge ]
  %.04671 = phi i64 [ %74, %._crit_edge69 ], [ 0, %._crit_edge ]
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = icmp sgt i32 %42, 1
  br i1 %43, label %.lr.ph62.preheader, label %._crit_edge63

.lr.ph62.preheader:                               ; preds = %.lr.ph76
  %44 = add nsw i32 %42, -1
  br label %.lr.ph62

._crit_edge63:                                    ; preds = %.lr.ph62, %.lr.ph76
  %.041.lcssa = phi i32 [ 0, %.lr.ph76 ], [ %83, %.lr.ph62 ]
  %.040.lcssa = phi i32 [ 0, %.lr.ph76 ], [ %spec.select56, %.lr.ph62 ]
  %45 = load i32, ptr @coeff, align 16, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = sext i32 %.041.lcssa to i64
  %48 = mul nsw i64 %indvars.iv, %47
  %49 = srem i64 %48, 1000000007
  %50 = sext i32 %.04373 to i64
  %51 = sext i32 %.040.lcssa to i64
  %52 = sub nsw i64 %50, %51
  %53 = add nsw i64 %52, %49
  %54 = mul nsw i64 %53, %46
  %55 = add nsw i64 %54, %.04671
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @coeff, i64 4), align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = trunc nuw nsw i64 %indvars.iv80 to i32
  %59 = sub nsw i32 %58, %.041.lcssa
  %60 = sext i32 %59 to i64
  %61 = mul nsw i64 %indvars.iv, %60
  %62 = srem i64 %61, 1000000007
  %63 = add nsw i64 %62, %51
  %64 = mul nsw i64 %63, %57
  %65 = add nsw i64 %55, %64
  %66 = load i32, ptr getelementptr inbounds (i8, ptr @coeff, i64 8), align 8, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = mul nsw i64 %67, %60
  %69 = add nsw i64 %65, %68
  %70 = load i32, ptr getelementptr inbounds (i8, ptr @coeff, i64 12), align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = mul nsw i64 %indvars.iv80, %71
  %73 = add nsw i64 %69, %72
  %.fr91 = freeze i64 %73
  %74 = srem i64 %.fr91, 1000000007
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %75 = trunc nuw nsw i64 %indvars.iv to i32
  %76 = add nsw i32 %.04373, %75
  %77 = icmp sgt i32 %76, 1000000006
  %78 = add nsw i32 %76, -1000000007
  %spec.select = select i1 %77, i32 %78, i32 %76
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %.not5365 = icmp sgt i32 %42, %79
  br i1 %.not5365, label %._crit_edge69, label %.lr.ph68

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %.lr.ph62
  %.03960 = phi i32 [ %89, %.lr.ph62 ], [ %44, %.lr.ph62.preheader ]
  %.04059 = phi i32 [ %spec.select56, %.lr.ph62 ], [ 0, %.lr.ph62.preheader ]
  %.04158 = phi i32 [ %83, %.lr.ph62 ], [ 0, %.lr.ph62.preheader ]
  %80 = zext nneg i32 %.03960 to i64
  %81 = getelementptr inbounds [500001 x i32], ptr @bit, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = add nsw i32 %82, %.04158
  %84 = getelementptr inbounds [500001 x i32], ptr getelementptr inbounds (i8, ptr @bit, i64 2000004), i64 0, i64 %80
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = add nsw i32 %85, %.04059
  %87 = icmp sgt i32 %86, 1000000006
  %88 = add nsw i32 %86, -1000000007
  %spec.select56 = select i1 %87, i32 %88, i32 %86
  %.not54 = add nsw i32 %.03960, -1
  %89 = and i32 %.not54, %.03960
  %.not = icmp eq i32 %89, 0
  br i1 %.not, label %._crit_edge63, label %.lr.ph62, !llvm.loop !13

._crit_edge69:                                    ; preds = %.lr.ph68, %._crit_edge63
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %90 = sext i32 %79 to i64
  %.not.not = icmp slt i64 %indvars.iv, %90
  br i1 %.not.not, label %.lr.ph76, label %._crit_edge77, !llvm.loop !14

.lr.ph68:                                         ; preds = %._crit_edge63, %.lr.ph68
  %.066 = phi i32 [ %102, %.lr.ph68 ], [ %42, %._crit_edge63 ]
  %91 = sext i32 %.066 to i64
  %92 = getelementptr inbounds [500001 x i32], ptr @bit, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %92, align 4, !tbaa !5
  %95 = getelementptr inbounds [500001 x i32], ptr getelementptr inbounds (i8, ptr @bit, i64 2000004), i64 0, i64 %91
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = add nsw i32 %96, %75
  %98 = icmp sgt i32 %97, 1000000006
  %99 = add nsw i32 %97, -1000000007
  %spec.select57 = select i1 %98, i32 %99, i32 %97
  store i32 %spec.select57, ptr %95, align 4, !tbaa !5
  %100 = sub nsw i32 0, %.066
  %101 = and i32 %.066, %100
  %102 = add nsw i32 %101, %.066
  %.not53 = icmp sgt i32 %102, %79
  br i1 %.not53, label %._crit_edge69, label %.lr.ph68, !llvm.loop !15
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind noalias writable sret(%struct.Matrix) align 4, ptr noundef nonnull align 4 dereferenceable(100), ptr noundef nonnull align 4 dereferenceable(100)) local_unnamed_addr #3 align 2

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

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

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

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 100, !10}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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