; LLVM IR from tangjz/acm-icpc :: hdu (5238)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@seg = external dso_local global [131072 x [4 x [19 x i32]]], align 16
@mod_pow = external dso_local global [4 x [19 x [19 x i32]]], align 16
@_ZL3mod = external hidden constant [4 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3CRTPiPKii(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiii(i32 noundef, i32 noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7rebuildiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 [4 x i32], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

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

14:                                               ; preds = %11
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %80

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %73, %15
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [4 x i32], ptr @_ZL3mod, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp slt i32 %17, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %16
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 %26
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [19 x [19 x i32]], ptr %27, i64 0, i64 %29
  %31 = getelementptr inbounds [19 x i32], ptr %30, i64 0, i64 0
  store i32 1, ptr %31, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %69, %24
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4 x i32], ptr @_ZL3mod, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = icmp slt i32 %33, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %32
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 %43
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [19 x [19 x i32]], ptr %44, i64 0, i64 %46
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sub nsw i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [19 x i32], ptr %47, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = mul nsw i32 %52, %53
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [4 x i32], ptr @_ZL3mod, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = srem i32 %54, %58
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 %61
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [19 x [19 x i32]], ptr %62, i64 0, i64 %64
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [19 x i32], ptr %65, i64 0, i64 %67
  store i32 %59, ptr %68, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %41
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %5, align 4, !tbaa !5
  br label %32, !llvm.loop !9

72:                                               ; preds = %40
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !11

76:                                               ; preds = %23
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !12

80:                                               ; preds = %14
  %81 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %140, %80
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = load i32, ptr @t, align 4, !tbaa !5
  %85 = icmp sle i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %143

87:                                               ; preds = %82
  %88 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef @n, ptr noundef @m)
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %89)
  %91 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5buildiii(i32 noundef 1, i32 noundef 1, i32 noundef %91)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  br label %92

92:                                               ; preds = %136, %87
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr @m, align 4, !tbaa !5
  %95 = icmp sle i32 %93, %94
  br i1 %95, label %97, label %96

96:                                               ; preds = %92
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %139

97:                                               ; preds = %92
  %98 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %8, ptr noundef %9)
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = icmp eq i32 %99, 1
  br i1 %100, label %101, label %132

101:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %102 = load i32, ptr %9, align 4, !tbaa !5
  %103 = load i32, ptr @_ZL3mod, align 16, !tbaa !5
  %104 = srem i32 %102, %103
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds ([131072 x [4 x [19 x i32]]], ptr @seg, i64 0, i64 1), i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  store i32 %107, ptr %10, align 4, !tbaa !5
  %108 = getelementptr inbounds i32, ptr %10, i64 1
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @_ZL3mod, i64 0, i64 1), align 4, !tbaa !5
  %111 = srem i32 %109, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds ([4 x [19 x i32]], ptr getelementptr inbounds ([131072 x [4 x [19 x i32]]], ptr @seg, i64 0, i64 1), i64 0, i64 1), i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  store i32 %114, ptr %108, align 4, !tbaa !5
  %115 = getelementptr inbounds i32, ptr %10, i64 2
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @_ZL3mod, i64 0, i64 2), align 8, !tbaa !5
  %118 = srem i32 %116, %117
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds ([4 x [19 x i32]], ptr getelementptr inbounds ([131072 x [4 x [19 x i32]]], ptr @seg, i64 0, i64 1), i64 0, i64 2), i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  store i32 %121, ptr %115, align 4, !tbaa !5
  %122 = getelementptr inbounds i32, ptr %10, i64 3
  %123 = load i32, ptr %9, align 4, !tbaa !5
  %124 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @_ZL3mod, i64 0, i64 3), align 4, !tbaa !5
  %125 = srem i32 %123, %124
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds ([4 x [19 x i32]], ptr getelementptr inbounds ([131072 x [4 x [19 x i32]]], ptr @seg, i64 0, i64 1), i64 0, i64 3), i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  store i32 %128, ptr %122, align 4, !tbaa !5
  %129 = getelementptr inbounds [4 x i32], ptr %10, i64 0, i64 0
  %130 = call noundef i32 @_Z3CRTPiPKii(ptr noundef %129, ptr noundef @_ZL3mod, i32 noundef 4)
  %131 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %130)
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  br label %135

132:                                              ; preds = %97
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = load i32, ptr %9, align 4, !tbaa !5
  call void @_Z7rebuildiiii(i32 noundef 1, i32 noundef 1, i32 noundef %133, i32 noundef %134)
  br label %135

135:                                              ; preds = %132, %101
  br label %136

136:                                              ; preds = %135
  %137 = load i32, ptr %7, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %7, align 4, !tbaa !5
  br label %92, !llvm.loop !13

139:                                              ; preds = %96
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %6, align 4, !tbaa !5
  br label %82, !llvm.loop !14

143:                                              ; preds = %86
  ret i32 0
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 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 #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@seg = external dso_local local_unnamed_addr global [131072 x [4 x [19 x i32]]], align 16
@mod_pow = external dso_local local_unnamed_addr global [4 x [19 x [19 x i32]]], align 16
@_ZL3mod = external hidden constant [4 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3CRTPiPKii(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7rebuildiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
.preheader:
  %0 = alloca i32, align 4
  %1 = alloca i32, align 4
  %2 = alloca [4 x i32], align 16
  %3 = load i32, ptr @_ZL3mod, align 16
  %4 = icmp sgt i32 %3, 1
  br i1 %4, label %.lr.ph30, label %._crit_edge31

.lr.ph30:                                         ; preds = %.preheader
  %.not40 = icmp eq i32 %3, 2
  br i1 %.not40, label %.lr.ph30.split.preheader, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %.lr.ph30
  %5 = add nsw i32 %3, -1
  %wide.trip.count46 = zext nneg i32 %3 to i64
  %wide.trip.count = zext i32 %5 to i64
  %6 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %6, 1
  %7 = icmp eq i32 %5, 2
  %unroll_iter = and i64 %6, -2
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph.us

.lr.ph30.split.preheader:                         ; preds = %.lr.ph30
  store i32 1, ptr getelementptr inbounds (i8, ptr @mod_pow, i64 76), align 4, !tbaa !5
  br label %._crit_edge31

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv43 = phi i64 [ 1, %.lr.ph.us.preheader ], [ %indvars.iv.next44, %._crit_edge.us ]
  %8 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 0, i64 %indvars.iv43
  store i32 1, ptr %8, align 4, !tbaa !5
  %9 = trunc nuw nsw i64 %indvars.iv43 to i32
  br i1 %7, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %10 = phi i32 [ %15, %.lr.ph.us.new ], [ 1, %.lr.ph.us ]
  %indvars.iv = phi i64 [ %indvars.iv.next.162, %.lr.ph.us.new ], [ 1, %.lr.ph.us ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %11 = mul nsw i32 %10, %9
  %12 = srem i32 %11, %3
  %13 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 0, i64 %indvars.iv43, i64 %indvars.iv
  store i32 %12, ptr %13, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = mul nsw i32 %12, %9
  %15 = srem i32 %14, %3
  %16 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 0, i64 %indvars.iv43, i64 %indvars.iv.next
  store i32 %15, ptr %16, align 4, !tbaa !5
  %indvars.iv.next.162 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new, !llvm.loop !9

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.unr = phi i32 [ 1, %.lr.ph.us ], [ %15, %.lr.ph.us.new ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.us ], [ %indvars.iv.next.162, %.lr.ph.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %17 = mul nsw i32 %.unr, %9
  %18 = srem i32 %17, %3
  %19 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 0, i64 %indvars.iv43, i64 %indvars.iv.unr
  store i32 %18, ptr %19, align 4, !tbaa !5
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %exitcond47.not = icmp eq i64 %indvars.iv.next44, %wide.trip.count46
  br i1 %exitcond47.not, label %._crit_edge31, label %.lr.ph.us, !llvm.loop !11

.lr.ph38:                                         ; preds = %._crit_edge31.3
  %20 = getelementptr inbounds i8, ptr %2, i64 4
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  %22 = getelementptr inbounds i8, ptr %2, i64 12
  br label %76

._crit_edge31:                                    ; preds = %._crit_edge.us, %.lr.ph30.split.preheader, %.preheader
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL3mod, i64 4), align 4
  %24 = icmp sgt i32 %23, 1
  br i1 %24, label %.lr.ph30.1, label %._crit_edge31.1

.lr.ph30.1:                                       ; preds = %._crit_edge31
  %.not40.1 = icmp eq i32 %23, 2
  br i1 %.not40.1, label %.lr.ph30.split.preheader.1, label %.lr.ph.us.preheader.1

.lr.ph.us.preheader.1:                            ; preds = %.lr.ph30.1
  %25 = add nsw i32 %23, -1
  %wide.trip.count46.1 = zext nneg i32 %23 to i64
  %wide.trip.count.1 = zext i32 %25 to i64
  %26 = add nsw i64 %wide.trip.count.1, -1
  %xtraiter64 = and i64 %26, 1
  %27 = icmp eq i32 %25, 2
  %unroll_iter67 = and i64 %26, -2
  %lcmp.mod66.not = icmp eq i64 %xtraiter64, 0
  br label %.lr.ph.us.1

.lr.ph.us.1:                                      ; preds = %._crit_edge.us.1, %.lr.ph.us.preheader.1
  %indvars.iv43.1 = phi i64 [ 1, %.lr.ph.us.preheader.1 ], [ %indvars.iv.next44.1, %._crit_edge.us.1 ]
  %28 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 1, i64 %indvars.iv43.1
  store i32 1, ptr %28, align 4, !tbaa !5
  %29 = trunc nuw nsw i64 %indvars.iv43.1 to i32
  br i1 %27, label %._crit_edge.us.1.unr-lcssa, label %.lr.ph.us.1.new

.lr.ph.us.1.new:                                  ; preds = %.lr.ph.us.1, %.lr.ph.us.1.new
  %30 = phi i32 [ %35, %.lr.ph.us.1.new ], [ 1, %.lr.ph.us.1 ]
  %indvars.iv.1 = phi i64 [ %indvars.iv.next.1.1, %.lr.ph.us.1.new ], [ 1, %.lr.ph.us.1 ]
  %niter68 = phi i64 [ %niter68.next.1, %.lr.ph.us.1.new ], [ 0, %.lr.ph.us.1 ]
  %31 = mul nsw i32 %30, %29
  %32 = srem i32 %31, %23
  %33 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 1, i64 %indvars.iv43.1, i64 %indvars.iv.1
  store i32 %32, ptr %33, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.1, 1
  %34 = mul nsw i32 %32, %29
  %35 = srem i32 %34, %23
  %36 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 1, i64 %indvars.iv43.1, i64 %indvars.iv.next.1
  store i32 %35, ptr %36, align 4, !tbaa !5
  %indvars.iv.next.1.1 = add nuw nsw i64 %indvars.iv.1, 2
  %niter68.next.1 = add i64 %niter68, 2
  %niter68.ncmp.1 = icmp eq i64 %niter68.next.1, %unroll_iter67
  br i1 %niter68.ncmp.1, label %._crit_edge.us.1.unr-lcssa, label %.lr.ph.us.1.new, !llvm.loop !9

._crit_edge.us.1.unr-lcssa:                       ; preds = %.lr.ph.us.1.new, %.lr.ph.us.1
  %.unr65 = phi i32 [ 1, %.lr.ph.us.1 ], [ %35, %.lr.ph.us.1.new ]
  %indvars.iv.1.unr = phi i64 [ 1, %.lr.ph.us.1 ], [ %indvars.iv.next.1.1, %.lr.ph.us.1.new ]
  br i1 %lcmp.mod66.not, label %._crit_edge.us.1, label %._crit_edge.us.1.epilog-lcssa

._crit_edge.us.1.epilog-lcssa:                    ; preds = %._crit_edge.us.1.unr-lcssa
  %37 = mul nsw i32 %.unr65, %29
  %38 = srem i32 %37, %23
  %39 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 1, i64 %indvars.iv43.1, i64 %indvars.iv.1.unr
  store i32 %38, ptr %39, align 4, !tbaa !5
  br label %._crit_edge.us.1

._crit_edge.us.1:                                 ; preds = %._crit_edge.us.1.unr-lcssa, %._crit_edge.us.1.epilog-lcssa
  %indvars.iv.next44.1 = add nuw nsw i64 %indvars.iv43.1, 1
  %exitcond47.1.not = icmp eq i64 %indvars.iv.next44.1, %wide.trip.count46.1
  br i1 %exitcond47.1.not, label %._crit_edge31.1, label %.lr.ph.us.1, !llvm.loop !11

.lr.ph30.split.preheader.1:                       ; preds = %.lr.ph30.1
  store i32 1, ptr getelementptr inbounds (i8, ptr @mod_pow, i64 1520), align 16, !tbaa !5
  br label %._crit_edge31.1

._crit_edge31.1:                                  ; preds = %._crit_edge.us.1, %.lr.ph30.split.preheader.1, %._crit_edge31
  %40 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL3mod, i64 8), align 8
  %41 = icmp sgt i32 %40, 1
  br i1 %41, label %.lr.ph30.2, label %._crit_edge31.2

.lr.ph30.2:                                       ; preds = %._crit_edge31.1
  %.not40.2 = icmp eq i32 %40, 2
  br i1 %.not40.2, label %.lr.ph30.split.preheader.2, label %.lr.ph.us.preheader.2

.lr.ph.us.preheader.2:                            ; preds = %.lr.ph30.2
  %42 = add nsw i32 %40, -1
  %wide.trip.count46.2 = zext nneg i32 %40 to i64
  %wide.trip.count.2 = zext i32 %42 to i64
  %43 = add nsw i64 %wide.trip.count.2, -1
  %xtraiter70 = and i64 %43, 1
  %44 = icmp eq i32 %42, 2
  %unroll_iter73 = and i64 %43, -2
  %lcmp.mod72.not = icmp eq i64 %xtraiter70, 0
  br label %.lr.ph.us.2

.lr.ph.us.2:                                      ; preds = %._crit_edge.us.2, %.lr.ph.us.preheader.2
  %indvars.iv43.2 = phi i64 [ 1, %.lr.ph.us.preheader.2 ], [ %indvars.iv.next44.2, %._crit_edge.us.2 ]
  %45 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 2, i64 %indvars.iv43.2
  store i32 1, ptr %45, align 4, !tbaa !5
  %46 = trunc nuw nsw i64 %indvars.iv43.2 to i32
  br i1 %44, label %._crit_edge.us.2.unr-lcssa, label %.lr.ph.us.2.new

.lr.ph.us.2.new:                                  ; preds = %.lr.ph.us.2, %.lr.ph.us.2.new
  %47 = phi i32 [ %52, %.lr.ph.us.2.new ], [ 1, %.lr.ph.us.2 ]
  %indvars.iv.2 = phi i64 [ %indvars.iv.next.2.1, %.lr.ph.us.2.new ], [ 1, %.lr.ph.us.2 ]
  %niter74 = phi i64 [ %niter74.next.1, %.lr.ph.us.2.new ], [ 0, %.lr.ph.us.2 ]
  %48 = mul nsw i32 %47, %46
  %49 = srem i32 %48, %40
  %50 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 2, i64 %indvars.iv43.2, i64 %indvars.iv.2
  store i32 %49, ptr %50, align 4, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.2, 1
  %51 = mul nsw i32 %49, %46
  %52 = srem i32 %51, %40
  %53 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 2, i64 %indvars.iv43.2, i64 %indvars.iv.next.2
  store i32 %52, ptr %53, align 4, !tbaa !5
  %indvars.iv.next.2.1 = add nuw nsw i64 %indvars.iv.2, 2
  %niter74.next.1 = add i64 %niter74, 2
  %niter74.ncmp.1 = icmp eq i64 %niter74.next.1, %unroll_iter73
  br i1 %niter74.ncmp.1, label %._crit_edge.us.2.unr-lcssa, label %.lr.ph.us.2.new, !llvm.loop !9

._crit_edge.us.2.unr-lcssa:                       ; preds = %.lr.ph.us.2.new, %.lr.ph.us.2
  %.unr71 = phi i32 [ 1, %.lr.ph.us.2 ], [ %52, %.lr.ph.us.2.new ]
  %indvars.iv.2.unr = phi i64 [ 1, %.lr.ph.us.2 ], [ %indvars.iv.next.2.1, %.lr.ph.us.2.new ]
  br i1 %lcmp.mod72.not, label %._crit_edge.us.2, label %._crit_edge.us.2.epilog-lcssa

._crit_edge.us.2.epilog-lcssa:                    ; preds = %._crit_edge.us.2.unr-lcssa
  %54 = mul nsw i32 %.unr71, %46
  %55 = srem i32 %54, %40
  %56 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 2, i64 %indvars.iv43.2, i64 %indvars.iv.2.unr
  store i32 %55, ptr %56, align 4, !tbaa !5
  br label %._crit_edge.us.2

._crit_edge.us.2:                                 ; preds = %._crit_edge.us.2.unr-lcssa, %._crit_edge.us.2.epilog-lcssa
  %indvars.iv.next44.2 = add nuw nsw i64 %indvars.iv43.2, 1
  %exitcond47.2.not = icmp eq i64 %indvars.iv.next44.2, %wide.trip.count46.2
  br i1 %exitcond47.2.not, label %._crit_edge31.2, label %.lr.ph.us.2, !llvm.loop !11

.lr.ph30.split.preheader.2:                       ; preds = %.lr.ph30.2
  store i32 1, ptr getelementptr inbounds (i8, ptr @mod_pow, i64 2964), align 4, !tbaa !5
  br label %._crit_edge31.2

._crit_edge31.2:                                  ; preds = %._crit_edge.us.2, %.lr.ph30.split.preheader.2, %._crit_edge31.1
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL3mod, i64 12), align 4
  %58 = icmp sgt i32 %57, 1
  br i1 %58, label %.lr.ph30.3, label %._crit_edge31.3

.lr.ph30.3:                                       ; preds = %._crit_edge31.2
  %.not40.3 = icmp eq i32 %57, 2
  br i1 %.not40.3, label %.lr.ph30.split.preheader.3, label %.lr.ph.us.preheader.3

.lr.ph.us.preheader.3:                            ; preds = %.lr.ph30.3
  %59 = add nsw i32 %57, -1
  %wide.trip.count46.3 = zext nneg i32 %57 to i64
  %wide.trip.count.3 = zext i32 %59 to i64
  %60 = add nsw i64 %wide.trip.count.3, -1
  %xtraiter76 = and i64 %60, 1
  %61 = icmp eq i32 %59, 2
  %unroll_iter79 = and i64 %60, -2
  %lcmp.mod78.not = icmp eq i64 %xtraiter76, 0
  br label %.lr.ph.us.3

.lr.ph.us.3:                                      ; preds = %._crit_edge.us.3, %.lr.ph.us.preheader.3
  %indvars.iv43.3 = phi i64 [ 1, %.lr.ph.us.preheader.3 ], [ %indvars.iv.next44.3, %._crit_edge.us.3 ]
  %62 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 3, i64 %indvars.iv43.3
  store i32 1, ptr %62, align 4, !tbaa !5
  %63 = trunc nuw nsw i64 %indvars.iv43.3 to i32
  br i1 %61, label %._crit_edge.us.3.unr-lcssa, label %.lr.ph.us.3.new

.lr.ph.us.3.new:                                  ; preds = %.lr.ph.us.3, %.lr.ph.us.3.new
  %64 = phi i32 [ %69, %.lr.ph.us.3.new ], [ 1, %.lr.ph.us.3 ]
  %indvars.iv.3 = phi i64 [ %indvars.iv.next.3.1, %.lr.ph.us.3.new ], [ 1, %.lr.ph.us.3 ]
  %niter80 = phi i64 [ %niter80.next.1, %.lr.ph.us.3.new ], [ 0, %.lr.ph.us.3 ]
  %65 = mul nsw i32 %64, %63
  %66 = srem i32 %65, %57
  %67 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 3, i64 %indvars.iv43.3, i64 %indvars.iv.3
  store i32 %66, ptr %67, align 4, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.3, 1
  %68 = mul nsw i32 %66, %63
  %69 = srem i32 %68, %57
  %70 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 3, i64 %indvars.iv43.3, i64 %indvars.iv.next.3
  store i32 %69, ptr %70, align 4, !tbaa !5
  %indvars.iv.next.3.1 = add nuw nsw i64 %indvars.iv.3, 2
  %niter80.next.1 = add i64 %niter80, 2
  %niter80.ncmp.1 = icmp eq i64 %niter80.next.1, %unroll_iter79
  br i1 %niter80.ncmp.1, label %._crit_edge.us.3.unr-lcssa, label %.lr.ph.us.3.new, !llvm.loop !9

._crit_edge.us.3.unr-lcssa:                       ; preds = %.lr.ph.us.3.new, %.lr.ph.us.3
  %.unr77 = phi i32 [ 1, %.lr.ph.us.3 ], [ %69, %.lr.ph.us.3.new ]
  %indvars.iv.3.unr = phi i64 [ 1, %.lr.ph.us.3 ], [ %indvars.iv.next.3.1, %.lr.ph.us.3.new ]
  br i1 %lcmp.mod78.not, label %._crit_edge.us.3, label %._crit_edge.us.3.epilog-lcssa

._crit_edge.us.3.epilog-lcssa:                    ; preds = %._crit_edge.us.3.unr-lcssa
  %71 = mul nsw i32 %.unr77, %63
  %72 = srem i32 %71, %57
  %73 = getelementptr inbounds [4 x [19 x [19 x i32]]], ptr @mod_pow, i64 0, i64 3, i64 %indvars.iv43.3, i64 %indvars.iv.3.unr
  store i32 %72, ptr %73, align 4, !tbaa !5
  br label %._crit_edge.us.3

._crit_edge.us.3:                                 ; preds = %._crit_edge.us.3.unr-lcssa, %._crit_edge.us.3.epilog-lcssa
  %indvars.iv.next44.3 = add nuw nsw i64 %indvars.iv43.3, 1
  %exitcond47.3.not = icmp eq i64 %indvars.iv.next44.3, %wide.trip.count46.3
  br i1 %exitcond47.3.not, label %._crit_edge31.3, label %.lr.ph.us.3, !llvm.loop !11

.lr.ph30.split.preheader.3:                       ; preds = %.lr.ph30.3
  store i32 1, ptr getelementptr inbounds (i8, ptr @mod_pow, i64 4408), align 8, !tbaa !5
  br label %._crit_edge31.3

._crit_edge31.3:                                  ; preds = %._crit_edge.us.3, %.lr.ph30.split.preheader.3, %._crit_edge31.2
  %74 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @t)
  %75 = load i32, ptr @t, align 4, !tbaa !5
  %.not35 = icmp slt i32 %75, 1
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

._crit_edge39:                                    ; preds = %._crit_edge, %._crit_edge31.3
  ret i32 0

76:                                               ; preds = %.lr.ph38, %._crit_edge
  %.02336 = phi i32 [ 1, %.lr.ph38 ], [ %81, %._crit_edge ]
  %77 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %78 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.02336)
  %79 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5buildiii(i32 noundef 1, i32 noundef 1, i32 noundef %79)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %80 = load i32, ptr @m, align 4, !tbaa !5
  %.not2733 = icmp slt i32 %80, 1
  br i1 %.not2733, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %109, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #4
  %81 = add nuw nsw i32 %.02336, 1
  %82 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.02336, %82
  br i1 %.not.not, label %76, label %._crit_edge39, !llvm.loop !12

.lr.ph:                                           ; preds = %76, %109
  %.034 = phi i32 [ %110, %109 ], [ 1, %76 ]
  %83 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %0, ptr noundef nonnull %1)
  %84 = load i32, ptr %0, align 4, !tbaa !5
  %85 = icmp eq i32 %84, 1
  br i1 %85, label %86, label %106

86:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  %87 = load i32, ptr %1, align 4, !tbaa !5
  %88 = srem i32 %87, %3
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds (i8, ptr @seg, i64 304), i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  store i32 %91, ptr %2, align 16, !tbaa !5
  %92 = srem i32 %87, %23
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds (i8, ptr @seg, i64 380), i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  store i32 %95, ptr %20, align 4, !tbaa !5
  %96 = srem i32 %87, %40
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds (i8, ptr @seg, i64 456), i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  store i32 %99, ptr %21, align 8, !tbaa !5
  %100 = srem i32 %87, %57
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [19 x i32], ptr getelementptr inbounds (i8, ptr @seg, i64 532), i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  store i32 %103, ptr %22, align 4, !tbaa !5
  %104 = call noundef i32 @_Z3CRTPiPKii(ptr noundef nonnull %2, ptr noundef nonnull @_ZL3mod, i32 noundef 4)
  %105 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %104)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  br label %109

106:                                              ; preds = %.lr.ph
  %107 = load i32, ptr @n, align 4, !tbaa !5
  %108 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z7rebuildiiii(i32 noundef 1, i32 noundef 1, i32 noundef %107, i32 noundef %108)
  br label %109

109:                                              ; preds = %86, %106
  %110 = add nuw nsw i32 %.034, 1
  %111 = load i32, ptr @m, align 4, !tbaa !5
  %.not27.not = icmp slt i32 %.034, %111
  br i1 %.not27.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { 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}


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