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

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

@A = external dso_local global %struct.Matrix, align 4
@p = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@seq = external dso_local global [128 x i32], align 16
@ans = external dso_local global i32, align 4
@vis = external dso_local global [1024 x i8], align 16
@.str = external hidden unnamed_addr constant [5 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 %struct.Matrix, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @p, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %11 = load i32, ptr @p, align 4, !tbaa !5
  %12 = shl i32 1, %11
  store i32 %12, ptr %3, align 4, !tbaa !5
  br label %13

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

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

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = ashr i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !9, !range !11, !noundef !12
  %24 = trunc i8 %23 to i1
  br i1 %24, label %29, label %25

25:                                               ; preds = %18
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = and i32 %26, 3
  %28 = icmp eq i32 %27, 3
  br label %29

29:                                               ; preds = %25, %18
  %30 = phi i1 [ true, %18 ], [ %28, %25 ]
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %32
  %34 = zext i1 %30 to i8
  store i8 %34, ptr %33, align 1, !tbaa !9
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !9, !range !11, !noundef !12
  %39 = trunc i8 %38 to i1
  br i1 %39, label %60, label %40

40:                                               ; preds = %29
  %41 = load i32, ptr @p, align 4, !tbaa !5
  %42 = icmp sgt i32 %41, 1
  br i1 %42, label %43, label %54

43:                                               ; preds = %40
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = load i32, ptr @p, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = shl i32 1, %46
  %48 = and i32 %44, %47
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %54

50:                                               ; preds = %43
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = and i32 %51, 1
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %60, label %54

54:                                               ; preds = %50, %43, %40
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr @n, align 4, !tbaa !5
  %58 = sext i32 %56 to i64
  %59 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %58
  store i32 %55, ptr %59, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %54, %50, %29
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !13

64:                                               ; preds = %17
  %65 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %65, ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 1), align 4, !tbaa !15
  store i32 %65, ptr @A, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %100, %64
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %103

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %96, %71
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

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

77:                                               ; preds = %72
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = and i32 %81, %85
  %87 = icmp ne i32 %86, 0
  %88 = xor i1 %87, true
  %89 = zext i1 %88 to i32
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [128 x [128 x i32]], ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), i64 0, i64 %91
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [128 x i32], ptr %92, i64 0, i64 %94
  store i32 %89, ptr %95, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %77
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %6, align 4, !tbaa !5
  br label %72, !llvm.loop !18

99:                                               ; preds = %76
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %4, align 4, !tbaa !5
  br label %66, !llvm.loop !19

103:                                              ; preds = %70
  %104 = load i32, ptr @q, align 4, !tbaa !5
  %105 = icmp eq i32 %104, 1
  br i1 %105, label %106, label %108

106:                                              ; preds = %103
  %107 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %107, ptr @ans, align 4, !tbaa !5
  br label %158

108:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 65544, ptr %7) #5
  %109 = load i32, ptr @q, align 4, !tbaa !5
  %110 = sub nsw i32 %109, 1
  call void @_ZNK6Matrix3powEi(ptr dead_on_unwind writable sret(%struct.Matrix) align 4 %7, ptr noundef nonnull align 4 dereferenceable(65544) @A, i32 noundef %110)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @A, ptr align 4 %7, i64 65544, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 65544, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %154, %108
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = load i32, ptr @n, align 4, !tbaa !5
  %114 = icmp slt i32 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %157

116:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %150, %116
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = load i32, ptr @n, align 4, !tbaa !5
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %117
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %153

122:                                              ; preds = %117
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = load i32, ptr %9, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = and i32 %126, %130
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %149, label %133

133:                                              ; preds = %122
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [128 x [128 x i32]], ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), i64 0, i64 %135
  %137 = load i32, ptr %9, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [128 x i32], ptr %136, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr @ans, align 4, !tbaa !5
  %142 = add nsw i32 %141, %140
  store i32 %142, ptr @ans, align 4, !tbaa !5
  %143 = load i32, ptr @ans, align 4, !tbaa !5
  %144 = icmp sge i32 %143, 19921107
  br i1 %144, label %145, label %148

145:                                              ; preds = %133
  %146 = load i32, ptr @ans, align 4, !tbaa !5
  %147 = sub nsw i32 %146, 19921107
  store i32 %147, ptr @ans, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %145, %133
  br label %149

149:                                              ; preds = %148, %122
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %9, align 4, !tbaa !5
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %9, align 4, !tbaa !5
  br label %117, !llvm.loop !22

153:                                              ; preds = %121
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %8, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %8, align 4, !tbaa !5
  br label %111, !llvm.loop !23

157:                                              ; preds = %115
  br label %158

158:                                              ; preds = %157, %106
  %159 = load i32, ptr @ans, align 4, !tbaa !5
  %160 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %159)
  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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6Matrix3powEi(ptr dead_on_unwind noalias writable sret(%struct.Matrix) align 4, ptr noundef nonnull align 4 dereferenceable(65544), i32 noundef) #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

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 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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 4}
!16 = !{!"_ZTS6Matrix", !6, i64 0, !6, i64 4, !7, i64 8}
!17 = !{!16, !6, i64 0}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 65536, !21}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}


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

@A = external dso_local global %struct.Matrix, align 4
@p = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@n = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [128 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [1024 x i8], align 16
@.str = external hidden unnamed_addr constant [5 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() local_unnamed_addr #0 {
  %1 = alloca %struct.Matrix, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @p, ptr noundef nonnull @q)
  %3 = load i32, ptr @p, align 4, !tbaa !5
  %.fr53 = freeze i32 %3
  %.not = icmp eq i32 %.fr53, 31
  br i1 %.not, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

.lr.ph:                                           ; preds = %0
  %4 = shl nuw i32 1, %.fr53
  %n.promoted = load i32, ptr @n, align 4, !tbaa !5
  %5 = icmp sgt i32 %.fr53, 1
  %6 = add nsw i32 %.fr53, -1
  %7 = shl nuw i32 1, %6
  %8 = or i32 %7, 1
  %smax59 = tail call i32 @llvm.smax.i32(i32 %4, i32 1)
  %wide.trip.count60 = zext nneg i32 %smax59 to i64
  br i1 %5, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %26
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %26 ], [ 0, %.lr.ph ]
  %9 = phi i32 [ %27, %26 ], [ %n.promoted, %.lr.ph ]
  %10 = trunc nuw nsw i64 %indvars.iv56 to i32
  %11 = lshr i64 %indvars.iv56, 1
  %12 = and i64 %11, 2147483647
  %13 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc nuw i8 %14 to i1
  %16 = and i32 %10, 3
  %17 = icmp eq i32 %16, 3
  %18 = or i1 %17, %15
  %19 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %indvars.iv56
  %20 = zext i1 %18 to i8
  store i8 %20, ptr %19, align 1, !tbaa !9
  %21 = and i32 %8, %10
  %or.cond.not.us = icmp eq i32 %21, %8
  %or.cond = select i1 %18, i1 true, i1 %or.cond.not.us
  br i1 %or.cond, label %26, label %22

22:                                               ; preds = %.lr.ph.split.us
  %23 = add nsw i32 %9, 1
  store i32 %23, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %9 to i64
  %25 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %24
  store i32 %10, ptr %25, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %22, %.lr.ph.split.us
  %27 = phi i32 [ %9, %.lr.ph.split.us ], [ %23, %22 ]
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond61.not = icmp eq i64 %indvars.iv.next57, %wide.trip.count60
  br i1 %exitcond61.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !13

._crit_edge:                                      ; preds = %64, %26, %.._crit_edge_crit_edge
  %28 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %27, %26 ], [ %65, %64 ]
  store i32 %28, ptr getelementptr inbounds (i8, ptr @A, i64 4), align 4, !tbaa !15
  store i32 %28, ptr @A, align 4, !tbaa !17
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.preheader36.us.preheader, label %._crit_edge42

.preheader36.us.preheader:                        ; preds = %._crit_edge
  %wide.trip.count70 = zext nneg i32 %28 to i64
  %min.iters.check = icmp ult i32 %28, 8
  %n.vec = and i64 %wide.trip.count70, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count70
  br label %.preheader36.us

.preheader36.us:                                  ; preds = %.preheader36.us.preheader, %._crit_edge40.us
  %indvars.iv67 = phi i64 [ 0, %.preheader36.us.preheader ], [ %indvars.iv.next68, %._crit_edge40.us ]
  %30 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %indvars.iv67
  %31 = load i32, ptr %30, align 4, !tbaa !5
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader36.us
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %31, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %32 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %index
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %wide.load = load <4 x i32>, ptr %32, align 16, !tbaa !5
  %wide.load86 = load <4 x i32>, ptr %33, align 16, !tbaa !5
  %34 = and <4 x i32> %wide.load, %broadcast.splat
  %35 = and <4 x i32> %wide.load86, %broadcast.splat
  %36 = icmp eq <4 x i32> %34, zeroinitializer
  %37 = icmp eq <4 x i32> %35, zeroinitializer
  %38 = zext <4 x i1> %36 to <4 x i32>
  %39 = zext <4 x i1> %37 to <4 x i32>
  %40 = getelementptr inbounds [128 x [128 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %indvars.iv67, i64 %index
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  store <4 x i32> %38, ptr %40, align 4, !tbaa !5
  store <4 x i32> %39, ptr %41, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %42 = icmp eq i64 %index.next, %n.vec
  br i1 %42, label %middle.block, label %vector.body, !llvm.loop !18

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge40.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader36.us
  %indvars.iv62.ph = phi i64 [ 0, %.preheader36.us ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %scalar.ph ], [ %indvars.iv62.ph, %scalar.ph.preheader ]
  %43 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %indvars.iv62
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = and i32 %44, %31
  %.not33.us = icmp eq i32 %45, 0
  %46 = zext i1 %.not33.us to i32
  %47 = getelementptr inbounds [128 x [128 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %indvars.iv67, i64 %indvars.iv62
  store i32 %46, ptr %47, align 4, !tbaa !5
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %exitcond66.not = icmp eq i64 %indvars.iv.next63, %wide.trip.count70
  br i1 %exitcond66.not, label %._crit_edge40.us, label %scalar.ph, !llvm.loop !21

._crit_edge40.us:                                 ; preds = %scalar.ph, %middle.block
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond71.not = icmp eq i64 %indvars.iv.next68, %wide.trip.count70
  br i1 %exitcond71.not, label %._crit_edge42, label %.preheader36.us, !llvm.loop !22

.lr.ph.split:                                     ; preds = %.lr.ph, %64
  %indvars.iv = phi i64 [ %indvars.iv.next, %64 ], [ 0, %.lr.ph ]
  %48 = phi i32 [ %65, %64 ], [ %n.promoted, %.lr.ph ]
  %49 = trunc nuw nsw i64 %indvars.iv to i32
  %50 = lshr i64 %indvars.iv, 1
  %51 = and i64 %50, 2147483647
  %52 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !9, !range !11, !noundef !12
  %54 = trunc nuw i8 %53 to i1
  %55 = and i32 %49, 3
  %56 = icmp eq i32 %55, 3
  %57 = or i1 %56, %54
  %58 = getelementptr inbounds [1024 x i8], ptr @vis, i64 0, i64 %indvars.iv
  %59 = zext i1 %57 to i8
  store i8 %59, ptr %58, align 1, !tbaa !9
  br i1 %57, label %64, label %60

60:                                               ; preds = %.lr.ph.split
  %61 = add nsw i32 %48, 1
  store i32 %61, ptr @n, align 4, !tbaa !5
  %62 = sext i32 %48 to i64
  %63 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %62
  store i32 %49, ptr %63, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %.lr.ph.split, %60
  %65 = phi i32 [ %48, %.lr.ph.split ], [ %61, %60 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count60
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !13

._crit_edge42:                                    ; preds = %._crit_edge40.us, %._crit_edge
  %66 = load i32, ptr @q, align 4, !tbaa !5
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %68, label %69

68:                                               ; preds = %._crit_edge42
  store i32 %28, ptr @ans, align 4, !tbaa !5
  br label %.loopexit

69:                                               ; preds = %._crit_edge42
  call void @llvm.lifetime.start.p0(i64 65544, ptr nonnull %1) #6
  %70 = add nsw i32 %66, -1
  call void @_ZNK6Matrix3powEi(ptr dead_on_unwind nonnull writable sret(%struct.Matrix) align 4 %1, ptr noundef nonnull align 4 dereferenceable(65544) @A, i32 noundef %70)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(65544) @A, ptr noundef nonnull align 4 dereferenceable(65544) %1, i64 65544, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 65544, ptr nonnull %1) #6
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %ans.promoted46 = load i32, ptr @ans, align 4, !tbaa !5
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.preheader.us.preheader, label %.loopexit

.preheader.us.preheader:                          ; preds = %69
  %wide.trip.count80 = zext nneg i32 %71 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge45.us
  %indvars.iv77 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next78, %._crit_edge45.us ]
  %ans.promoted5051.us = phi i32 [ %ans.promoted46, %.preheader.us.preheader ], [ %ans.promoted48.us, %._crit_edge45.us ]
  %73 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %indvars.iv77
  %74 = load i32, ptr %73, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %.preheader.us, %87
  %indvars.iv72 = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next73, %87 ]
  %ans.promoted49.us = phi i32 [ %ans.promoted5051.us, %.preheader.us ], [ %ans.promoted48.us, %87 ]
  %76 = phi i32 [ %ans.promoted5051.us, %.preheader.us ], [ %88, %87 ]
  %77 = getelementptr inbounds [128 x i32], ptr @seq, i64 0, i64 %indvars.iv72
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = and i32 %78, %74
  %.not.us = icmp eq i32 %79, 0
  br i1 %.not.us, label %80, label %87

80:                                               ; preds = %75
  %81 = getelementptr inbounds [128 x [128 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %indvars.iv77, i64 %indvars.iv72
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = add nsw i32 %76, %82
  store i32 %83, ptr @ans, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 19921106
  br i1 %84, label %85, label %87

85:                                               ; preds = %80
  %86 = add nsw i32 %83, -19921107
  store i32 %86, ptr @ans, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %85, %80, %75
  %ans.promoted48.us = phi i32 [ %ans.promoted49.us, %75 ], [ %86, %85 ], [ %83, %80 ]
  %88 = phi i32 [ %76, %75 ], [ %86, %85 ], [ %83, %80 ]
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %exitcond76.not = icmp eq i64 %indvars.iv.next73, %wide.trip.count80
  br i1 %exitcond76.not, label %._crit_edge45.us, label %75, !llvm.loop !25

._crit_edge45.us:                                 ; preds = %87
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond81.not = icmp eq i64 %indvars.iv.next78, %wide.trip.count80
  br i1 %exitcond81.not, label %.loopexit, label %.preheader.us, !llvm.loop !26

.loopexit:                                        ; preds = %._crit_edge45.us, %69, %68
  %89 = phi i32 [ %ans.promoted46, %69 ], [ %28, %68 ], [ %ans.promoted48.us, %._crit_edge45.us ]
  %90 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %89)
  ret i32 0
}

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6Matrix3powEi(ptr dead_on_unwind noalias writable sret(%struct.Matrix) align 4, ptr noundef nonnull align 4 dereferenceable(65544), i32 noundef) 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 = { 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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 4}
!16 = !{!"_ZTS6Matrix", !6, i64 0, !6, i64 4, !7, i64 8}
!17 = !{!16, !6, i64 0}
!18 = distinct !{!18, !14, !19, !20}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !14, !20, !19}
!22 = distinct !{!22, !14}
!23 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 65536, !24}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !14}
!26 = distinct !{!26, !14}


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