; LLVM IR from tangjz/acm-icpc :: 51nod (1147)

; 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 { i32, i32, [2 x [2 x i32]] }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@len = external dso_local global i32, align 4
@dig = external dso_local global [3001 x i32], align 16
@A = external dso_local global %struct.Matrix, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca %struct.Matrix, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.Matrix, align 4
  %11 = alloca %struct.Matrix, align 4
  %12 = alloca %struct.Matrix, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.Matrix, align 4
  %15 = alloca %struct.Matrix, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %19)
  store double %20, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %21 = load double, ptr %2, align 8, !tbaa !9
  %22 = fptosi double %21 to i32
  store i32 %22, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %23 = load double, ptr %2, align 8, !tbaa !9
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sitofp i32 %24 to double
  %26 = fsub double %23, %25
  store double %26, ptr %7, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %71, %0
  %28 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %28, ptr %6, align 4, !tbaa !5
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = mul nsw i32 %30, %31
  %33 = sub nsw i32 %29, %32
  store i32 %33, ptr %4, align 4, !tbaa !5
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %34, i32 noundef %35)
  store i32 %36, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = sdiv i32 %38, %37
  store i32 %39, ptr %6, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sdiv i32 %41, %40
  store i32 %42, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr @n, align 4, !tbaa !5
  %44 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %43)
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = sitofp i32 %45 to double
  %47 = fadd double %44, %46
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sitofp i32 %48 to double
  %50 = fmul double %47, %49
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sitofp i32 %51 to double
  %53 = fdiv double %50, %52
  store double %53, ptr %2, align 8, !tbaa !9
  %54 = load double, ptr %2, align 8, !tbaa !9
  %55 = fptosi double %54 to i64
  %56 = trunc i64 %55 to i32
  %57 = load i32, ptr @len, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @len, align 4, !tbaa !5
  %59 = sext i32 %57 to i64
  %60 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %59
  store i32 %56, ptr %60, align 4, !tbaa !5
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = load i32, ptr @len, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = mul nsw i32 %66, %67
  %69 = sub nsw i32 %61, %68
  %70 = call i32 @llvm.abs.i32(i32 %69, i1 true)
  store i32 %70, ptr %3, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %27
  %72 = load double, ptr %2, align 8, !tbaa !9
  %73 = load i32, ptr @len, align 4, !tbaa !5
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = sitofp i32 %77 to double
  %79 = fsub double %72, %78
  %80 = load double, ptr %7, align 8, !tbaa !9
  %81 = fsub double %79, %80
  %82 = call double @llvm.fabs.f64(double %81)
  %83 = fcmp oge double %82, 1.000000e-08
  br i1 %83, label %27, label %84, !llvm.loop !11

84:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #7
  %85 = getelementptr inbounds %struct.Matrix, ptr %8, i32 0, i32 0
  store i32 2, ptr %85, align 4, !tbaa !13
  %86 = getelementptr inbounds %struct.Matrix, ptr %8, i32 0, i32 1
  store i32 2, ptr %86, align 4, !tbaa !15
  %87 = getelementptr inbounds %struct.Matrix, ptr %8, i32 0, i32 2
  store i32 1, ptr %87, align 4, !tbaa !5
  %88 = getelementptr inbounds i32, ptr %87, i64 1
  store i32 0, ptr %88, align 4, !tbaa !5
  %89 = getelementptr inbounds [2 x i32], ptr %87, i64 1
  store i32 0, ptr %89, align 4, !tbaa !5
  %90 = getelementptr inbounds i32, ptr %89, i64 1
  store i32 1, ptr %90, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @A, ptr align 4 %8, i64 24, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %107, %84
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = load i32, ptr @len, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %110

96:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #7
  %97 = getelementptr inbounds %struct.Matrix, ptr %11, i32 0, i32 0
  store i32 2, ptr %97, align 4, !tbaa !13
  %98 = getelementptr inbounds %struct.Matrix, ptr %11, i32 0, i32 1
  store i32 2, ptr %98, align 4, !tbaa !15
  %99 = getelementptr inbounds %struct.Matrix, ptr %11, i32 0, i32 2
  store i32 0, ptr %99, align 4, !tbaa !5
  %100 = getelementptr inbounds i32, ptr %99, i64 1
  store i32 1, ptr %100, align 4, !tbaa !5
  %101 = getelementptr inbounds [2 x i32], ptr %99, i64 1
  store i32 1, ptr %101, align 4, !tbaa !5
  %102 = getelementptr inbounds i32, ptr %101, i64 1
  %103 = load i32, ptr %9, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  store i32 %106, ptr %102, align 4, !tbaa !5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind writable sret(%struct.Matrix) align 4 %10, ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %11)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @A, ptr align 4 %10, i64 24, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #7
  br label %107

107:                                              ; preds = %96
  %108 = load i32, ptr %9, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %9, align 4, !tbaa !5
  br label %91, !llvm.loop !18

110:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #7
  %111 = load i32, ptr @m, align 4, !tbaa !5
  %112 = load i32, ptr @len, align 4, !tbaa !5
  %113 = sdiv i32 %111, %112
  call void @_ZN6Matrix3powEi(ptr dead_on_unwind writable sret(%struct.Matrix) align 4 %12, ptr noundef nonnull align 4 dereferenceable(24) @A, i32 noundef %113)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @A, ptr align 4 %12, i64 24, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #7
  %114 = load i32, ptr @len, align 4, !tbaa !5
  %115 = load i32, ptr @m, align 4, !tbaa !5
  %116 = srem i32 %115, %114
  store i32 %116, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %133, %110
  %118 = load i32, ptr %13, align 4, !tbaa !5
  %119 = load i32, ptr @m, align 4, !tbaa !5
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %136

122:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #7
  %123 = getelementptr inbounds %struct.Matrix, ptr %15, i32 0, i32 0
  store i32 2, ptr %123, align 4, !tbaa !13
  %124 = getelementptr inbounds %struct.Matrix, ptr %15, i32 0, i32 1
  store i32 2, ptr %124, align 4, !tbaa !15
  %125 = getelementptr inbounds %struct.Matrix, ptr %15, i32 0, i32 2
  store i32 0, ptr %125, align 4, !tbaa !5
  %126 = getelementptr inbounds i32, ptr %125, i64 1
  store i32 1, ptr %126, align 4, !tbaa !5
  %127 = getelementptr inbounds [2 x i32], ptr %125, i64 1
  store i32 1, ptr %127, align 4, !tbaa !5
  %128 = getelementptr inbounds i32, ptr %127, i64 1
  %129 = load i32, ptr %13, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  store i32 %132, ptr %128, align 4, !tbaa !5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind writable sret(%struct.Matrix) align 4 %14, ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %15)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @A, ptr align 4 %14, i64 24, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #7
  br label %133

133:                                              ; preds = %122
  %134 = load i32, ptr %13, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %13, align 4, !tbaa !5
  br label %117, !llvm.loop !19

136:                                              ; preds = %121
  %137 = load i32, ptr getelementptr inbounds ([2 x [2 x i32]], ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), i64 0, i64 1), align 4, !tbaa !5
  store i32 %137, ptr %3, align 4, !tbaa !5
  %138 = load i32, ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), align 4, !tbaa !5
  store i32 %138, ptr %4, align 4, !tbaa !5
  %139 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %139, ptr %6, align 4, !tbaa !5
  %140 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %140, ptr %4, align 4, !tbaa !5
  %141 = load i32, ptr @n, align 4, !tbaa !5
  %142 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %141)
  %143 = fptosi double %142 to i64
  %144 = load i32, ptr %3, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = mul nsw i64 %143, %145
  %147 = load i32, ptr %6, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = add nsw i64 %146, %148
  %150 = srem i64 %149, 1000000007
  %151 = trunc i64 %150 to i32
  store i32 %151, ptr %3, align 4, !tbaa !5
  %152 = load i32, ptr %3, align 4, !tbaa !5
  %153 = load i32, ptr %4, align 4, !tbaa !5
  %154 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %152, i32 noundef %153)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  ret i32 0
}

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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #5

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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(24), ptr noundef nonnull align 4 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6Matrix3powEi(ptr dead_on_unwind noalias writable sret(%struct.Matrix) align 4, ptr noundef nonnull align 4 dereferenceable(24), i32 noundef) #4 align 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 = { 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 #4 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS6Matrix", !6, i64 0, !6, i64 4, !7, i64 8}
!15 = !{!14, !6, i64 4}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 16, !17}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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 { i32, i32, [2 x [2 x i32]] }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@len = external dso_local local_unnamed_addr global i32, align 4
@dig = external dso_local local_unnamed_addr global [3001 x i32], align 16
@A = external dso_local global %struct.Matrix, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 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 16
  %3 = alloca %struct.Matrix, align 4
  %4 = alloca %struct.Matrix, align 4
  %5 = alloca %struct.Matrix, align 16
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  store i32 %8, ptr @m, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %9)
  %11 = fptosi double %10 to i32
  %12 = sitofp i32 %11 to double
  %13 = fsub double %10, %12
  br label %14

14:                                               ; preds = %14, %0
  %.033 = phi i32 [ 1, %0 ], [ %20, %14 ]
  %.032 = phi i32 [ %11, %0 ], [ %37, %14 ]
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = mul nsw i32 %.032, %.032
  %17 = sub nsw i32 %15, %16
  %18 = tail call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %.033, i32 noundef %17)
  %19 = sdiv i32 %.033, %18
  %20 = sdiv i32 %17, %18
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %21)
  %23 = sitofp i32 %.032 to double
  %24 = fadd double %22, %23
  %25 = sitofp i32 %19 to double
  %26 = fmul double %24, %25
  %27 = sitofp i32 %20 to double
  %28 = fdiv double %26, %27
  %29 = fptosi double %28 to i64
  %30 = trunc i64 %29 to i32
  %31 = load i32, ptr @len, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr @len, align 4, !tbaa !5
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %33
  store i32 %30, ptr %34, align 4, !tbaa !5
  %35 = mul nsw i32 %20, %30
  %36 = sub nsw i32 %.032, %35
  %37 = tail call i32 @llvm.abs.i32(i32 %36, i1 true)
  %38 = sitofp i32 %30 to double
  %39 = fsub double %28, %38
  %40 = fsub double %39, %13
  %41 = tail call double @llvm.fabs.f64(double %40)
  %42 = fcmp ult double %41, 1.000000e-08
  br i1 %42, label %43, label %14, !llvm.loop !9

43:                                               ; preds = %14
  store <4 x i32> <i32 2, i32 2, i32 1, i32 0>, ptr @A, align 4
  store i32 0, ptr getelementptr inbounds (i8, ptr @A, i64 16), align 4
  store i32 1, ptr getelementptr inbounds (i8, ptr @A, i64 20), align 4, !tbaa !11
  %44 = icmp sgt i32 %31, -1
  br i1 %44, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %43
  %45 = getelementptr inbounds i8, ptr %2, i64 16
  %46 = getelementptr inbounds i8, ptr %2, i64 20
  br label %55

._crit_edge:                                      ; preds = %55, %43
  %.lcssa = phi i32 [ %32, %43 ], [ %58, %55 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #7
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = sdiv i32 %47, %.lcssa
  call void @_ZN6Matrix3powEi(ptr dead_on_unwind nonnull writable sret(%struct.Matrix) align 4 %3, ptr noundef nonnull align 4 dereferenceable(24) @A, i32 noundef %48)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %3, i64 24, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #7
  %49 = load i32, ptr @len, align 4, !tbaa !5
  %50 = load i32, ptr @m, align 4, !tbaa !5
  %51 = srem i32 %50, %49
  store i32 %51, ptr @m, align 4, !tbaa !5
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %.lr.ph37, label %._crit_edge38

.lr.ph37:                                         ; preds = %._crit_edge
  %53 = getelementptr inbounds i8, ptr %5, i64 16
  %54 = getelementptr inbounds i8, ptr %5, i64 20
  br label %73

55:                                               ; preds = %.lr.ph, %55
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %55 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #7
  store <4 x i32> <i32 2, i32 2, i32 0, i32 1>, ptr %2, align 16, !tbaa !5
  store i32 1, ptr %45, align 16, !tbaa !5
  %56 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %indvars.iv
  %57 = load i32, ptr %56, align 4, !tbaa !5
  store i32 %57, ptr %46, align 4, !tbaa !5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Matrix) align 4 %1, ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %1, i64 24, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = load i32, ptr @len, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = icmp slt i64 %indvars.iv.next, %59
  br i1 %60, label %55, label %._crit_edge, !llvm.loop !13

._crit_edge38:                                    ; preds = %73, %._crit_edge
  %61 = load i32, ptr getelementptr inbounds (i8, ptr @A, i64 16), align 4, !tbaa !5
  %62 = load i32, ptr getelementptr inbounds (i8, ptr @A, i64 8), align 4, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %63)
  %65 = fptosi double %64 to i64
  %66 = sext i32 %61 to i64
  %67 = mul nsw i64 %65, %66
  %68 = sext i32 %62 to i64
  %69 = add nsw i64 %67, %68
  %70 = srem i64 %69, 1000000007
  %71 = trunc nsw i64 %70 to i32
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %71, i32 noundef %61)
  ret i32 0

73:                                               ; preds = %.lr.ph37, %73
  %indvars.iv41 = phi i64 [ 0, %.lr.ph37 ], [ %indvars.iv.next42, %73 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #7
  store <4 x i32> <i32 2, i32 2, i32 0, i32 1>, ptr %5, align 16, !tbaa !5
  store i32 1, ptr %53, align 16, !tbaa !5
  %74 = getelementptr inbounds [3001 x i32], ptr @dig, i64 0, i64 %indvars.iv41
  %75 = load i32, ptr %74, align 4, !tbaa !5
  store i32 %75, ptr %54, align 4, !tbaa !5
  call void @_ZNK6MatrixmlERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Matrix) align 4 %4, ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) @A, ptr noundef nonnull align 4 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #7
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %76 = load i32, ptr @m, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = icmp slt i64 %indvars.iv.next42, %77
  br i1 %78, label %73, label %._crit_edge38, !llvm.loop !14
}

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #5

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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(24), ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6Matrix3powEi(ptr dead_on_unwind noalias writable sret(%struct.Matrix) align 4, ptr noundef nonnull align 4 dereferenceable(24), i32 noundef) local_unnamed_addr #4 align 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 = { 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 #4 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!7, !7, i64 0}
!12 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 16, !11}
!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,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass