; LLVM IR from tangjz/acm-icpc :: codeforces/complete (819C)

; 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.Factor = type { i64, i32, [23 x i32], [23 x i32] }

@t = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@d = external dso_local global [2000001 x i32], align 16
@pr = external dso_local global [2000001 x i32], align 16
@tr = external dso_local global [65 x [65 x i32]], align 16
@ex = external dso_local global [65 x i32], align 16
@ans = external dso_local global i64, align 8
@N = external dso_local global %struct.Factor, align 8
@M = external dso_local global %struct.Factor, align 8
@S = external dso_local global %struct.Factor, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3pfsixi(i32 noundef, i64 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsix(i32 noundef, i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 2147483647, ptr getelementptr inbounds ([2000001 x i32], ptr @d, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %64, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 2000001
  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 %67

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [2000001 x i32], ptr @d, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %30, label %21

21:                                               ; preds = %15
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2000001 x i32], ptr @d, i64 0, i64 %24
  store i32 %22, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr @tot, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @tot, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = getelementptr inbounds [2000001 x i32], ptr @pr, i64 0, i64 %28
  store i32 %22, ptr %29, align 4, !tbaa !5
  br label %30

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

31:                                               ; preds = %59, %30
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2000001 x i32], ptr @pr, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = mul nsw i32 %32, %36
  store i32 %37, ptr %5, align 4, !tbaa !5
  %38 = icmp slt i32 %37, 2000001
  br i1 %38, label %40, label %39

39:                                               ; preds = %31
  store i32 5, ptr %3, align 4
  br label %62

40:                                               ; preds = %31
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2000001 x i32], ptr @pr, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [2000001 x i32], ptr @d, i64 0, i64 %46
  store i32 %44, ptr %47, align 4, !tbaa !5
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2000001 x i32], ptr @d, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [2000001 x i32], ptr @pr, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = icmp eq i32 %51, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %40
  store i32 5, ptr %3, align 4
  br label %62

58:                                               ; preds = %40
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %31, !llvm.loop !9

62:                                               ; preds = %57, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !11

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

68:                                               ; preds = %116, %67
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = icmp slt i32 %69, 65
  br i1 %70, label %72, label %71

71:                                               ; preds = %68
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %119

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

73:                                               ; preds = %112, %72
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = icmp slt i32 %74, 65
  br i1 %75, label %77, label %76

76:                                               ; preds = %73
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %115

77:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %108, %77
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = icmp sle i32 %79, %80
  br i1 %81, label %82, label %86

82:                                               ; preds = %78
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = icmp sle i32 %83, %84
  br label %86

86:                                               ; preds = %82, %78
  %87 = phi i1 [ false, %78 ], [ %85, %82 ]
  br i1 %87, label %89, label %88

88:                                               ; preds = %86
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %111

89:                                               ; preds = %86
  %90 = load i32, ptr %8, align 4, !tbaa !5
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = icmp eq i32 %90, %91
  %93 = zext i1 %92 to i32
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = sub nsw i32 %95, 1
  %97 = icmp eq i32 %94, %96
  %98 = zext i1 %97 to i32
  %99 = sub nsw i32 %93, %98
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [65 x [65 x i32]], ptr @tr, i64 0, i64 %101
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [65 x i32], ptr %102, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = add nsw i32 %106, %99
  store i32 %107, ptr %105, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %89
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %8, align 4, !tbaa !5
  br label %78, !llvm.loop !12

111:                                              ; preds = %88
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %7, align 4, !tbaa !5
  br label %73, !llvm.loop !13

115:                                              ; preds = %76
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %6, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %6, align 4, !tbaa !5
  br label %68, !llvm.loop !14

119:                                              ; preds = %71
  %120 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %121

121:                                              ; preds = %180, %119
  %122 = load i32, ptr @t, align 4, !tbaa !5
  %123 = add nsw i32 %122, -1
  store i32 %123, ptr @t, align 4, !tbaa !5
  %124 = icmp ne i32 %122, 0
  br i1 %124, label %125, label %183

125:                                              ; preds = %121
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200) @N, i32 noundef 1)
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200) @M, i32 noundef 1)
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200) @S, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %177, %125
  %127 = load i32, ptr %9, align 4, !tbaa !5
  %128 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @N, i32 0, i32 1), align 8, !tbaa !15
  %129 = icmp slt i32 %127, %128
  br i1 %129, label %131, label %130

130:                                              ; preds = %126
  store i32 19, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %180

131:                                              ; preds = %126
  br label %132

132:                                              ; preds = %149, %131
  %133 = load i32, ptr %10, align 4, !tbaa !5
  %134 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @S, i32 0, i32 1), align 8, !tbaa !15
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %136, label %146

136:                                              ; preds = %132
  %137 = load i32, ptr %10, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (%struct.Factor, ptr @S, i32 0, i32 2), i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (%struct.Factor, ptr @N, i32 0, i32 2), i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = icmp slt i32 %140, %144
  br label %146

146:                                              ; preds = %136, %132
  %147 = phi i1 [ false, %132 ], [ %145, %136 ]
  br i1 %147, label %148, label %152

148:                                              ; preds = %146
  br label %149

149:                                              ; preds = %148
  %150 = load i32, ptr %10, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %10, align 4, !tbaa !5
  br label %132, !llvm.loop !18

152:                                              ; preds = %146
  %153 = load i32, ptr %10, align 4, !tbaa !5
  %154 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @S, i32 0, i32 1), align 8, !tbaa !15
  %155 = icmp slt i32 %153, %154
  br i1 %155, label %156, label %171

156:                                              ; preds = %152
  %157 = load i32, ptr %10, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (%struct.Factor, ptr @S, i32 0, i32 2), i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (%struct.Factor, ptr @N, i32 0, i32 2), i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = icmp eq i32 %160, %164
  br i1 %165, label %166, label %171

166:                                              ; preds = %156
  %167 = load i32, ptr %10, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (%struct.Factor, ptr @S, i32 0, i32 3), i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  br label %172

171:                                              ; preds = %156, %152
  br label %172

172:                                              ; preds = %171, %166
  %173 = phi i32 [ %170, %166 ], [ 0, %171 ]
  %174 = load i32, ptr %9, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [65 x i32], ptr @ex, i64 0, i64 %175
  store i32 %173, ptr %176, align 4, !tbaa !5
  br label %177

177:                                              ; preds = %172
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %9, align 4, !tbaa !5
  br label %126, !llvm.loop !19

180:                                              ; preds = %130
  store i64 0, ptr @ans, align 8, !tbaa !20
  call void @_Z3pfsixi(i32 noundef 0, i64 noundef 1, i32 noundef 1)
  call void @_Z3dfsix(i32 noundef 0, i64 noundef 1)
  %181 = load i64, ptr @ans, align 8, !tbaa !20
  %182 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %181)
  br label %121, !llvm.loop !21

183:                                              ; preds = %121
  ret i32 0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200), i32 noundef) #0 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTS6Factor", !17, i64 0, !6, i64 8, !7, i64 12, !7, i64 104}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = !{!17, !17, i64 0}
!21 = distinct !{!21, !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"

%struct.Factor = type { i64, i32, [23 x i32], [23 x i32] }

@t = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@d = external dso_local local_unnamed_addr global [2000001 x i32], align 16
@pr = external dso_local local_unnamed_addr global [2000001 x i32], align 16
@tr = external dso_local local_unnamed_addr global [65 x [65 x i32]], align 16
@ex = external dso_local local_unnamed_addr global [65 x i32], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@N = external dso_local global %struct.Factor, align 8
@M = external dso_local global %struct.Factor, align 8
@S = external dso_local global %struct.Factor, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3pfsixi(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsix(i32 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  store i32 2147483647, ptr getelementptr inbounds (i8, ptr @d, i64 4), align 4, !tbaa !5
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %1

1:                                                ; preds = %0, %._crit_edge
  %indvars.iv70 = phi i64 [ 2, %0 ], [ %indvars.iv.next71, %._crit_edge ]
  %2 = phi i32 [ %tot.promoted, %0 ], [ %10, %._crit_edge ]
  %3 = getelementptr inbounds [2000001 x i32], ptr @d, i64 0, i64 %indvars.iv70
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %.not45 = icmp eq i32 %4, 0
  %5 = trunc nuw nsw i64 %indvars.iv70 to i32
  br i1 %.not45, label %6, label %._crit_edge91

6:                                                ; preds = %1
  store i32 %5, ptr %3, align 4, !tbaa !5
  %7 = add nsw i32 %2, 1
  store i32 %7, ptr @tot, align 4, !tbaa !5
  %8 = sext i32 %2 to i64
  %9 = getelementptr inbounds [2000001 x i32], ptr @pr, i64 0, i64 %8
  store i32 %5, ptr %9, align 4, !tbaa !5
  br label %._crit_edge91

._crit_edge91:                                    ; preds = %1, %6
  %10 = phi i32 [ %7, %6 ], [ %2, %1 ]
  %11 = load i32, ptr @pr, align 16, !tbaa !5
  %12 = mul nsw i32 %11, %5
  %13 = icmp slt i32 %12, 2000001
  br i1 %13, label %.lr.ph, label %._crit_edge

14:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = getelementptr inbounds [2000001 x i32], ptr @pr, i64 0, i64 %indvars.iv.next
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = mul nsw i32 %16, %5
  %18 = icmp slt i32 %17, 2000001
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph:                                           ; preds = %._crit_edge91, %14
  %indvars.iv = phi i64 [ %indvars.iv.next, %14 ], [ 0, %._crit_edge91 ]
  %19 = phi i32 [ %17, %14 ], [ %12, %._crit_edge91 ]
  %20 = phi i32 [ %16, %14 ], [ %11, %._crit_edge91 ]
  %21 = sext i32 %19 to i64
  %22 = getelementptr inbounds [2000001 x i32], ptr @d, i64 0, i64 %21
  store i32 %20, ptr %22, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = icmp eq i32 %23, %20
  br i1 %24, label %._crit_edge, label %14

._crit_edge:                                      ; preds = %14, %.lr.ph, %._crit_edge91
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next71, 2000001
  br i1 %exitcond.not, label %.preheader47, label %1, !llvm.loop !11

.preheader47:                                     ; preds = %._crit_edge, %141
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %141 ], [ 0, %._crit_edge ]
  %25 = trunc i64 %indvars.iv78 to i32
  %26 = trunc nuw nsw i64 %indvars.iv78 to i32
  br label %.preheader46

27:                                               ; preds = %141
  %28 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %29 = load i32, ptr @t, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr @t, align 4, !tbaa !5
  %.not62 = icmp eq i32 %29, 0
  br i1 %.not62, label %._crit_edge65, label %.lr.ph64

.preheader46:                                     ; preds = %.preheader47, %.loopexit
  %indvars.iv74 = phi i64 [ 0, %.preheader47 ], [ %indvars.iv.next75, %.loopexit ]
  %31 = trunc i64 %indvars.iv74 to i32
  %umin94 = tail call i32 @llvm.umin.i32(i32 %25, i32 %31)
  %32 = add nuw nsw i32 %umin94, 1
  %33 = trunc nuw nsw i64 %indvars.iv74 to i32
  %umin = tail call i32 @llvm.umin.i32(i32 %26, i32 %33)
  %34 = getelementptr inbounds [65 x [65 x i32]], ptr @tr, i64 0, i64 %indvars.iv78, i64 %indvars.iv74
  %.promoted = load i32, ptr %34, align 4, !tbaa !5
  %35 = trunc i64 %indvars.iv74 to i32
  %36 = add i32 %35, -1
  %min.iters.check = icmp ult i32 %umin94, 7
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader46
  %.03954.ph = phi i32 [ 0, %.preheader46 ], [ %n.vec, %middle.block ]
  %.ph = phi i32 [ %.promoted, %.preheader46 ], [ %140, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.preheader46
  %n.vec = and i32 %32, -8
  %broadcast.splatinsert = insertelement <4 x i64> poison, i64 %indvars.iv74, i64 0
  %broadcast.splat = shufflevector <4 x i64> %broadcast.splatinsert, <4 x i64> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert97 = insertelement <4 x i32> poison, i32 %36, i64 0
  %broadcast.splat98 = shufflevector <4 x i32> %broadcast.splatinsert97, <4 x i32> poison, <4 x i32> zeroinitializer
  %37 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.promoted, i64 0
  %38 = icmp eq <4 x i64> %broadcast.splat, <i64 0, i64 1, i64 2, i64 3>
  %39 = icmp eq <4 x i64> %broadcast.splat, <i64 4, i64 5, i64 6, i64 7>
  %40 = zext <4 x i1> %38 to <4 x i32>
  %41 = zext <4 x i1> %39 to <4 x i32>
  %42 = icmp eq <4 x i32> %broadcast.splat98, <i32 0, i32 1, i32 2, i32 3>
  %43 = icmp eq <4 x i32> %broadcast.splat98, <i32 4, i32 5, i32 6, i32 7>
  %44 = sext <4 x i1> %42 to <4 x i32>
  %45 = sext <4 x i1> %43 to <4 x i32>
  %46 = add nsw <4 x i32> %44, %40
  %47 = add nsw <4 x i32> %45, %41
  %48 = add <4 x i32> %46, %37
  %49 = icmp eq i32 %n.vec, 8
  br i1 %49, label %middle.block, label %vector.body.1, !llvm.loop !12

vector.body.1:                                    ; preds = %vector.ph
  %50 = icmp eq <4 x i64> %broadcast.splat, <i64 8, i64 9, i64 10, i64 11>
  %51 = icmp eq <4 x i64> %broadcast.splat, <i64 12, i64 13, i64 14, i64 15>
  %52 = zext <4 x i1> %50 to <4 x i32>
  %53 = zext <4 x i1> %51 to <4 x i32>
  %54 = icmp eq <4 x i32> %broadcast.splat98, <i32 8, i32 9, i32 10, i32 11>
  %55 = icmp eq <4 x i32> %broadcast.splat98, <i32 12, i32 13, i32 14, i32 15>
  %56 = sext <4 x i1> %54 to <4 x i32>
  %57 = sext <4 x i1> %55 to <4 x i32>
  %58 = add nsw <4 x i32> %56, %52
  %59 = add nsw <4 x i32> %57, %53
  %60 = add <4 x i32> %58, %48
  %61 = add nsw <4 x i32> %59, %47
  %62 = icmp eq i32 %n.vec, 16
  br i1 %62, label %middle.block, label %vector.body.2, !llvm.loop !12

vector.body.2:                                    ; preds = %vector.body.1
  %63 = icmp eq <4 x i64> %broadcast.splat, <i64 16, i64 17, i64 18, i64 19>
  %64 = icmp eq <4 x i64> %broadcast.splat, <i64 20, i64 21, i64 22, i64 23>
  %65 = zext <4 x i1> %63 to <4 x i32>
  %66 = zext <4 x i1> %64 to <4 x i32>
  %67 = icmp eq <4 x i32> %broadcast.splat98, <i32 16, i32 17, i32 18, i32 19>
  %68 = icmp eq <4 x i32> %broadcast.splat98, <i32 20, i32 21, i32 22, i32 23>
  %69 = sext <4 x i1> %67 to <4 x i32>
  %70 = sext <4 x i1> %68 to <4 x i32>
  %71 = add nsw <4 x i32> %69, %65
  %72 = add nsw <4 x i32> %70, %66
  %73 = add <4 x i32> %71, %60
  %74 = add nsw <4 x i32> %72, %61
  %75 = icmp eq i32 %n.vec, 24
  br i1 %75, label %middle.block, label %vector.body.3, !llvm.loop !12

vector.body.3:                                    ; preds = %vector.body.2
  %76 = icmp eq <4 x i64> %broadcast.splat, <i64 24, i64 25, i64 26, i64 27>
  %77 = icmp eq <4 x i64> %broadcast.splat, <i64 28, i64 29, i64 30, i64 31>
  %78 = zext <4 x i1> %76 to <4 x i32>
  %79 = zext <4 x i1> %77 to <4 x i32>
  %80 = icmp eq <4 x i32> %broadcast.splat98, <i32 24, i32 25, i32 26, i32 27>
  %81 = icmp eq <4 x i32> %broadcast.splat98, <i32 28, i32 29, i32 30, i32 31>
  %82 = sext <4 x i1> %80 to <4 x i32>
  %83 = sext <4 x i1> %81 to <4 x i32>
  %84 = add nsw <4 x i32> %82, %78
  %85 = add nsw <4 x i32> %83, %79
  %86 = add <4 x i32> %84, %73
  %87 = add nsw <4 x i32> %85, %74
  %88 = icmp eq i32 %n.vec, 32
  br i1 %88, label %middle.block, label %vector.body.4, !llvm.loop !12

vector.body.4:                                    ; preds = %vector.body.3
  %89 = icmp eq <4 x i64> %broadcast.splat, <i64 32, i64 33, i64 34, i64 35>
  %90 = icmp eq <4 x i64> %broadcast.splat, <i64 36, i64 37, i64 38, i64 39>
  %91 = zext <4 x i1> %89 to <4 x i32>
  %92 = zext <4 x i1> %90 to <4 x i32>
  %93 = icmp eq <4 x i32> %broadcast.splat98, <i32 32, i32 33, i32 34, i32 35>
  %94 = icmp eq <4 x i32> %broadcast.splat98, <i32 36, i32 37, i32 38, i32 39>
  %95 = sext <4 x i1> %93 to <4 x i32>
  %96 = sext <4 x i1> %94 to <4 x i32>
  %97 = add nsw <4 x i32> %95, %91
  %98 = add nsw <4 x i32> %96, %92
  %99 = add <4 x i32> %97, %86
  %100 = add nsw <4 x i32> %98, %87
  %101 = icmp eq i32 %n.vec, 40
  br i1 %101, label %middle.block, label %vector.body.5, !llvm.loop !12

vector.body.5:                                    ; preds = %vector.body.4
  %102 = icmp eq <4 x i64> %broadcast.splat, <i64 40, i64 41, i64 42, i64 43>
  %103 = icmp eq <4 x i64> %broadcast.splat, <i64 44, i64 45, i64 46, i64 47>
  %104 = zext <4 x i1> %102 to <4 x i32>
  %105 = zext <4 x i1> %103 to <4 x i32>
  %106 = icmp eq <4 x i32> %broadcast.splat98, <i32 40, i32 41, i32 42, i32 43>
  %107 = icmp eq <4 x i32> %broadcast.splat98, <i32 44, i32 45, i32 46, i32 47>
  %108 = sext <4 x i1> %106 to <4 x i32>
  %109 = sext <4 x i1> %107 to <4 x i32>
  %110 = add nsw <4 x i32> %108, %104
  %111 = add nsw <4 x i32> %109, %105
  %112 = add <4 x i32> %110, %99
  %113 = add nsw <4 x i32> %111, %100
  %114 = icmp eq i32 %n.vec, 48
  br i1 %114, label %middle.block, label %vector.body.6, !llvm.loop !12

vector.body.6:                                    ; preds = %vector.body.5
  %115 = icmp eq <4 x i64> %broadcast.splat, <i64 48, i64 49, i64 50, i64 51>
  %116 = icmp eq <4 x i64> %broadcast.splat, <i64 52, i64 53, i64 54, i64 55>
  %117 = zext <4 x i1> %115 to <4 x i32>
  %118 = zext <4 x i1> %116 to <4 x i32>
  %119 = icmp eq <4 x i32> %broadcast.splat98, <i32 48, i32 49, i32 50, i32 51>
  %120 = icmp eq <4 x i32> %broadcast.splat98, <i32 52, i32 53, i32 54, i32 55>
  %121 = sext <4 x i1> %119 to <4 x i32>
  %122 = sext <4 x i1> %120 to <4 x i32>
  %123 = add nsw <4 x i32> %121, %117
  %124 = add nsw <4 x i32> %122, %118
  %125 = add <4 x i32> %123, %112
  %126 = add <4 x i32> %124, %113
  %127 = icmp eq i32 %n.vec, 56
  br i1 %127, label %middle.block, label %vector.body.7, !llvm.loop !12

vector.body.7:                                    ; preds = %vector.body.6
  %128 = icmp eq <4 x i64> %broadcast.splat, <i64 56, i64 57, i64 58, i64 59>
  %129 = icmp eq <4 x i64> %broadcast.splat, <i64 60, i64 61, i64 62, i64 63>
  %130 = zext <4 x i1> %128 to <4 x i32>
  %131 = zext <4 x i1> %129 to <4 x i32>
  %132 = icmp eq <4 x i32> %broadcast.splat98, <i32 56, i32 57, i32 58, i32 59>
  %133 = icmp eq <4 x i32> %broadcast.splat98, <i32 60, i32 61, i32 62, i32 63>
  %134 = sext <4 x i1> %132 to <4 x i32>
  %135 = sext <4 x i1> %133 to <4 x i32>
  %136 = add nsw <4 x i32> %134, %130
  %137 = add nsw <4 x i32> %135, %131
  %138 = add <4 x i32> %136, %125
  %139 = add <4 x i32> %137, %126
  br label %middle.block

middle.block:                                     ; preds = %vector.body.7, %vector.body.6, %vector.body.5, %vector.body.4, %vector.body.3, %vector.body.2, %vector.body.1, %vector.ph
  %.lcssa101 = phi <4 x i32> [ %48, %vector.ph ], [ %60, %vector.body.1 ], [ %73, %vector.body.2 ], [ %86, %vector.body.3 ], [ %99, %vector.body.4 ], [ %112, %vector.body.5 ], [ %125, %vector.body.6 ], [ %138, %vector.body.7 ]
  %.lcssa100 = phi <4 x i32> [ %47, %vector.ph ], [ %61, %vector.body.1 ], [ %74, %vector.body.2 ], [ %87, %vector.body.3 ], [ %100, %vector.body.4 ], [ %113, %vector.body.5 ], [ %126, %vector.body.6 ], [ %139, %vector.body.7 ]
  %bin.rdx = add <4 x i32> %.lcssa100, %.lcssa101
  %140 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i32 %32, %n.vec
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

141:                                              ; preds = %.loopexit
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond81.not = icmp eq i64 %indvars.iv.next79, 65
  br i1 %exitcond81.not, label %27, label %.preheader47, !llvm.loop !15

.loopexit:                                        ; preds = %scalar.ph, %middle.block
  %.lcssa = phi i32 [ %140, %middle.block ], [ %148, %scalar.ph ]
  store i32 %.lcssa, ptr %34, align 4, !tbaa !5
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %exitcond77.not = icmp eq i64 %indvars.iv.next75, 65
  br i1 %exitcond77.not, label %141, label %.preheader46, !llvm.loop !16

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.03954 = phi i32 [ %149, %scalar.ph ], [ %.03954.ph, %scalar.ph.preheader ]
  %142 = phi i32 [ %148, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %143 = zext nneg i32 %.03954 to i64
  %144 = icmp eq i64 %indvars.iv74, %143
  %145 = zext i1 %144 to i32
  %146 = icmp eq i32 %.03954, %36
  %.neg = sext i1 %146 to i32
  %147 = add nsw i32 %.neg, %145
  %148 = add nsw i32 %147, %142
  %149 = add nuw nsw i32 %.03954, 1
  %exitcond73.not = icmp eq i32 %.03954, %umin
  br i1 %exitcond73.not, label %.loopexit, label %scalar.ph, !llvm.loop !17

.lr.ph64:                                         ; preds = %27, %._crit_edge61
  tail call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200) @N, i32 noundef 1)
  tail call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200) @M, i32 noundef 1)
  tail call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200) @S, i32 noundef 2)
  %150 = load i32, ptr getelementptr inbounds (i8, ptr @N, i64 8), align 8, !tbaa !18
  %151 = icmp sgt i32 %150, 0
  br i1 %151, label %.preheader.lr.ph, label %._crit_edge61

.preheader.lr.ph:                                 ; preds = %.lr.ph64
  %152 = load i32, ptr getelementptr inbounds (i8, ptr @S, i64 8), align 8, !tbaa !18
  %wide.trip.count89 = zext nneg i32 %150 to i64
  %wide.trip.count = sext i32 %152 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %.critedge
  %indvars.iv86 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next87, %.critedge ]
  %.060 = phi i32 [ 0, %.preheader.lr.ph ], [ %.150, %.critedge ]
  %153 = icmp slt i32 %.060, %152
  br i1 %153, label %.lr.ph58, label %.critedge

.lr.ph58:                                         ; preds = %.preheader
  %154 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (i8, ptr @N, i64 12), i64 0, i64 %indvars.iv86
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = sext i32 %.060 to i64
  br label %161

._crit_edge61:                                    ; preds = %.critedge, %.lr.ph64
  store i64 0, ptr @ans, align 8, !tbaa !21
  tail call void @_Z3pfsixi(i32 noundef 0, i64 noundef 1, i32 noundef 1)
  tail call void @_Z3dfsix(i32 noundef 0, i64 noundef 1)
  %157 = load i64, ptr @ans, align 8, !tbaa !21
  %158 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %157)
  %159 = load i32, ptr @t, align 4, !tbaa !5
  %160 = add nsw i32 %159, -1
  store i32 %160, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %159, 0
  br i1 %.not, label %._crit_edge65, label %.lr.ph64, !llvm.loop !22

161:                                              ; preds = %.lr.ph58, %165
  %indvars.iv82 = phi i64 [ %156, %.lr.ph58 ], [ %indvars.iv.next83, %165 ]
  %162 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (i8, ptr @S, i64 12), i64 0, i64 %indvars.iv82
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = icmp slt i32 %163, %155
  br i1 %164, label %165, label %166

165:                                              ; preds = %161
  %indvars.iv.next83 = add nsw i64 %indvars.iv82, 1
  %exitcond85.not = icmp eq i64 %indvars.iv.next83, %wide.trip.count
  br i1 %exitcond85.not, label %.critedge, label %161, !llvm.loop !23

166:                                              ; preds = %161
  %167 = trunc nsw i64 %indvars.iv82 to i32
  %sext = shl i64 %indvars.iv82, 32
  %168 = ashr exact i64 %sext, 32
  %169 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (i8, ptr @S, i64 12), i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = icmp eq i32 %170, %155
  br i1 %171, label %172, label %.critedge

172:                                              ; preds = %166
  %173 = getelementptr inbounds [23 x i32], ptr getelementptr inbounds (i8, ptr @S, i64 104), i64 0, i64 %168
  %174 = load i32, ptr %173, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %165, %.preheader, %166, %172
  %.150 = phi i32 [ %167, %172 ], [ %167, %166 ], [ %.060, %.preheader ], [ %152, %165 ]
  %175 = phi i32 [ %174, %172 ], [ 0, %166 ], [ 0, %.preheader ], [ 0, %165 ]
  %176 = getelementptr inbounds [65 x i32], ptr @ex, i64 0, i64 %indvars.iv86
  store i32 %175, ptr %176, align 4, !tbaa !5
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond90.not = icmp eq i64 %indvars.iv.next87, %wide.trip.count89
  br i1 %exitcond90.not, label %._crit_edge61, label %.preheader, !llvm.loop !24

._crit_edge65:                                    ; preds = %._crit_edge61, %27
  ret i32 0
}

; 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 @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(200), i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3

attributes #0 = { 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 #1 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !14}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !14, !13}
!18 = !{!19, !6, i64 8}
!19 = !{!"_ZTS6Factor", !20, i64 0, !6, i64 8, !7, i64 12, !7, i64 104}
!20 = !{!"long long", !7, i64 0}
!21 = !{!20, !20, i64 0}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}


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