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

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

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

14:                                               ; preds = %31, %0
  %15 = load i32, ptr %2, align 4, !tbaa !9
  %16 = load i32, ptr @n, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %34

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = mul nsw i64 %24, %26
  %28 = load i32, ptr %2, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %29
  store i64 %27, ptr %30, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %19
  %32 = load i32, ptr %2, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !9
  br label %14, !llvm.loop !11

34:                                               ; preds = %18
  br label %35

35:                                               ; preds = %199, %34
  %36 = load i32, ptr @q, align 4, !tbaa !9
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr @q, align 4, !tbaa !9
  %38 = icmp ne i32 %36, 0
  br i1 %38, label %39, label %200

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #4
  %40 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 0
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %40)
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 21, i1 false)
  %42 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 0
  %43 = load i8, ptr %42, align 1, !tbaa !13
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %44, 80
  br i1 %45, label %46, label %131

46:                                               ; preds = %39
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @val)
  %48 = load i64, ptr @val, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr @val, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %105, %46
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = load i32, ptr @n, align 4, !tbaa !9
  %53 = icmp sle i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %108

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %56 = load i64, ptr @val, align 8, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !9
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = sub nsw i32 %57, %58
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !5
  %63 = sdiv i64 %56, %62
  %64 = trunc i64 %63 to i32
  store i32 %64, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %86, %55
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = load i32, ptr @n, align 4, !tbaa !9
  %68 = icmp sle i32 %66, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %65
  store i32 10, ptr %5, align 4
  br label %89

70:                                               ; preds = %65
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !14, !range !16, !noundef !17
  %75 = trunc i8 %74 to i1
  br i1 %75, label %85, label %76

76:                                               ; preds = %70
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = add nsw i32 %77, -1
  store i32 %78, ptr %6, align 4, !tbaa !9
  %79 = icmp ne i32 %77, 0
  br i1 %79, label %85, label %80

80:                                               ; preds = %76
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = load i32, ptr %4, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %83
  store i32 %81, ptr %84, align 4, !tbaa !9
  store i32 10, ptr %5, align 4
  br label %89

85:                                               ; preds = %76, %70
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %7, align 4, !tbaa !9
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %7, align 4, !tbaa !9
  br label %65, !llvm.loop !18

89:                                               ; preds = %80, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %4, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %95
  store i8 1, ptr %96, align 1, !tbaa !14
  %97 = load i32, ptr @n, align 4, !tbaa !9
  %98 = load i32, ptr %4, align 4, !tbaa !9
  %99 = sub nsw i32 %97, %98
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %100
  %102 = load i64, ptr %101, align 8, !tbaa !5
  %103 = load i64, ptr @val, align 8, !tbaa !5
  %104 = srem i64 %103, %102
  store i64 %104, ptr @val, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %105

105:                                              ; preds = %90
  %106 = load i32, ptr %4, align 4, !tbaa !9
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %4, align 4, !tbaa !9
  br label %50, !llvm.loop !19

108:                                              ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %127, %108
  %110 = load i32, ptr %8, align 4, !tbaa !9
  %111 = load i32, ptr @n, align 4, !tbaa !9
  %112 = icmp sle i32 %110, %111
  br i1 %112, label %114, label %113

113:                                              ; preds = %109
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %130

114:                                              ; preds = %109
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = load i32, ptr %8, align 4, !tbaa !9
  %120 = load i32, ptr @n, align 4, !tbaa !9
  %121 = icmp eq i32 %119, %120
  %122 = zext i1 %121 to i64
  %123 = getelementptr inbounds [3 x i8], ptr @.str.4, i64 0, i64 %122
  %124 = load i8, ptr %123, align 1, !tbaa !13
  %125 = sext i8 %124 to i32
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %118, i32 noundef %125)
  br label %127

127:                                              ; preds = %114
  %128 = load i32, ptr %8, align 4, !tbaa !9
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %8, align 4, !tbaa !9
  br label %109, !llvm.loop !20

130:                                              ; preds = %113
  br label %199

131:                                              ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %132

132:                                              ; preds = %142, %131
  %133 = load i32, ptr %9, align 4, !tbaa !9
  %134 = load i32, ptr @n, align 4, !tbaa !9
  %135 = icmp sle i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  store i32 16, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %145

137:                                              ; preds = %132
  %138 = load i32, ptr %9, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds i32, ptr @seq, i64 %139
  %141 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %140)
  br label %142

142:                                              ; preds = %137
  %143 = load i32, ptr %9, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %9, align 4, !tbaa !9
  br label %132, !llvm.loop !21

145:                                              ; preds = %136
  store i64 0, ptr @val, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %146

146:                                              ; preds = %191, %145
  %147 = load i32, ptr %10, align 4, !tbaa !9
  %148 = load i32, ptr @n, align 4, !tbaa !9
  %149 = icmp sle i32 %147, %148
  br i1 %149, label %151, label %150

150:                                              ; preds = %146
  store i32 19, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %194

151:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %152

152:                                              ; preds = %170, %151
  %153 = load i32, ptr %12, align 4, !tbaa !9
  %154 = load i32, ptr %10, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !9
  %158 = icmp slt i32 %153, %157
  br i1 %158, label %160, label %159

159:                                              ; preds = %152
  store i32 22, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %173

160:                                              ; preds = %152
  %161 = load i32, ptr %12, align 4, !tbaa !9
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %162
  %164 = load i8, ptr %163, align 1, !tbaa !14, !range !16, !noundef !17
  %165 = trunc i8 %164 to i1
  br i1 %165, label %169, label %166

166:                                              ; preds = %160
  %167 = load i32, ptr %11, align 4, !tbaa !9
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %11, align 4, !tbaa !9
  br label %169

169:                                              ; preds = %166, %160
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %12, align 4, !tbaa !9
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %12, align 4, !tbaa !9
  br label %152, !llvm.loop !22

173:                                              ; preds = %159
  %174 = load i32, ptr %11, align 4, !tbaa !9
  %175 = sext i32 %174 to i64
  %176 = load i32, ptr @n, align 4, !tbaa !9
  %177 = load i32, ptr %10, align 4, !tbaa !9
  %178 = sub nsw i32 %176, %177
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %179
  %181 = load i64, ptr %180, align 8, !tbaa !5
  %182 = mul nsw i64 %175, %181
  %183 = load i64, ptr @val, align 8, !tbaa !5
  %184 = add nsw i64 %183, %182
  store i64 %184, ptr @val, align 8, !tbaa !5
  %185 = load i32, ptr %10, align 4, !tbaa !9
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !9
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %189
  store i8 1, ptr %190, align 1, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %191

191:                                              ; preds = %173
  %192 = load i32, ptr %10, align 4, !tbaa !9
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %10, align 4, !tbaa !9
  br label %146, !llvm.loop !23

194:                                              ; preds = %150
  %195 = load i64, ptr @val, align 8, !tbaa !5
  %196 = add nsw i64 %195, 1
  store i64 %196, ptr @val, align 8, !tbaa !5
  %197 = load i64, ptr @val, align 8, !tbaa !5
  %198 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef %197)
  br label %199

199:                                              ; preds = %194, %130
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #4
  br label %35, !llvm.loop !24

200:                                              ; preds = %35
  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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}


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

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@seq = external dso_local global [21 x i32], align 16
@val = external dso_local global i64, align 8
@fact = external dso_local local_unnamed_addr global [21 x i64], align 16
@vis = external dso_local local_unnamed_addr global [21 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [2 x i8], align 1
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @q)
  store i64 1, ptr @fact, align 16, !tbaa !5
  %3 = load i32, ptr @n, align 4, !tbaa !9
  %4 = icmp sgt i32 %3, 1
  br i1 %4, label %.lr.ph.preheader, label %.preheader53

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext nneg i32 %3 to i64
  %5 = add nsw i64 %wide.trip.count, -1
  %6 = add nsw i64 %wide.trip.count, -2
  %xtraiter = and i64 %5, 3
  %7 = icmp ult i64 %6, 3
  br i1 %7, label %.preheader53.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %5, -4
  br label %.lr.ph

.preheader53.loopexit.unr-lcssa:                  ; preds = %.lr.ph, %.lr.ph.preheader
  %.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %20, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader53, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader53.loopexit.unr-lcssa, %.lr.ph.epil
  %8 = phi i64 [ %9, %.lr.ph.epil ], [ %.unr, %.preheader53.loopexit.unr-lcssa ]
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader53.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader53.loopexit.unr-lcssa ]
  %9 = mul nuw nsw i64 %8, %indvars.iv.epil
  %10 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %indvars.iv.epil
  store i64 %9, ptr %10, align 8, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader53, label %.lr.ph.epil, !llvm.loop !11

.preheader53:                                     ; preds = %.preheader53.loopexit.unr-lcssa, %.lr.ph.epil, %0
  %11 = load i32, ptr @q, align 4, !tbaa !9
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @q, align 4, !tbaa !9
  %.not84 = icmp eq i32 %11, 0
  br i1 %.not84, label %._crit_edge86, label %.lr.ph85

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %13 = phi i64 [ 1, %.lr.ph.preheader.new ], [ %20, %.lr.ph ]
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %14 = mul nuw nsw i64 %13, %indvars.iv
  %15 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %indvars.iv
  store i64 %14, ptr %15, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = mul nuw nsw i64 %14, %indvars.iv.next
  %17 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %indvars.iv.next
  store i64 %16, ptr %17, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %18 = mul nuw nsw i64 %16, %indvars.iv.next.1
  %19 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %indvars.iv.next.1
  store i64 %18, ptr %19, align 8, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %20 = mul nuw nsw i64 %18, %indvars.iv.next.2
  %21 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %indvars.iv.next.2
  store i64 %20, ptr %21, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader53.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !13

.lr.ph85:                                         ; preds = %.preheader53, %.loopexit51
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %1) #5
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(21) @vis, i8 0, i64 21, i1 false)
  %23 = load i8, ptr %1, align 1, !tbaa !15
  %24 = icmp eq i8 %23, 80
  br i1 %24, label %26, label %.preheader52

.preheader52:                                     ; preds = %.lr.ph85
  %25 = load i32, ptr @n, align 4, !tbaa !9
  %.not4457 = icmp slt i32 %25, 1
  br i1 %.not4457, label %._crit_edge.thread, label %.lr.ph59

26:                                               ; preds = %.lr.ph85
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @val)
  %28 = load i64, ptr @val, align 8, !tbaa !5
  %29 = add nsw i64 %28, -1
  store i64 %29, ptr @val, align 8, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !9
  %.not4676 = icmp slt i32 %30, 1
  br i1 %.not4676, label %.loopexit51, label %.lr.ph79.preheader

.lr.ph79.preheader:                               ; preds = %26
  %31 = add nuw i32 %30, 1
  %32 = zext nneg i32 %30 to i64
  %wide.trip.count113 = zext i32 %31 to i64
  br label %.lr.ph79

.preheader50:                                     ; preds = %.loopexit
  store i64 %38, ptr @val, align 8, !tbaa !5
  br i1 %.not4676, label %.loopexit51, label %.lr.ph83

.lr.ph79:                                         ; preds = %.lr.ph79.preheader, %.loopexit
  %indvars.iv110 = phi i64 [ 1, %.lr.ph79.preheader ], [ %indvars.iv.next111, %.loopexit ]
  %33 = phi i64 [ %29, %.lr.ph79.preheader ], [ %38, %.loopexit ]
  %34 = sub nsw i64 %32, %indvars.iv110
  %35 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = sdiv i64 %33, %36
  %38 = srem i64 %33, %36
  %39 = trunc i64 %37 to i32
  br label %40

40:                                               ; preds = %.lr.ph79, %49
  %indvars.iv105 = phi i64 [ 1, %.lr.ph79 ], [ %indvars.iv.next106, %49 ]
  %.03871 = phi i32 [ %39, %.lr.ph79 ], [ %.139, %49 ]
  %41 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %indvars.iv105
  %42 = load i8, ptr %41, align 1, !tbaa !16, !range !18, !noundef !19
  %43 = trunc nuw i8 %42 to i1
  br i1 %43, label %49, label %44

44:                                               ; preds = %40
  %45 = add nsw i32 %.03871, -1
  %.not49 = icmp eq i32 %.03871, 0
  br i1 %.not49, label %46, label %49

46:                                               ; preds = %44
  %47 = trunc nuw nsw i64 %indvars.iv105 to i32
  %48 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %indvars.iv110
  store i32 %47, ptr %48, align 4, !tbaa !9
  br label %.loopexit

49:                                               ; preds = %40, %44
  %.139 = phi i32 [ %.03871, %40 ], [ %45, %44 ]
  %indvars.iv.next106 = add nuw nsw i64 %indvars.iv105, 1
  %exitcond109.not = icmp eq i64 %indvars.iv.next106, %wide.trip.count113
  br i1 %exitcond109.not, label %.loopexit.loopexit, label %40, !llvm.loop !20

.loopexit.loopexit:                               ; preds = %49
  %.phi.trans.insert = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %indvars.iv110
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !9
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %46
  %50 = phi i32 [ %.pre, %.loopexit.loopexit ], [ %47, %46 ]
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %51
  store i8 1, ptr %52, align 1, !tbaa !16
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %exitcond114.not = icmp eq i64 %indvars.iv.next111, %wide.trip.count113
  br i1 %exitcond114.not, label %.preheader50, label %.lr.ph79, !llvm.loop !21

.lr.ph83:                                         ; preds = %.preheader50, %.lr.ph83
  %indvars.iv115 = phi i64 [ %indvars.iv.next116, %.lr.ph83 ], [ 1, %.preheader50 ]
  %53 = phi i32 [ %63, %.lr.ph83 ], [ %30, %.preheader50 ]
  %54 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %indvars.iv115
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = zext i32 %53 to i64
  %57 = icmp eq i64 %indvars.iv115, %56
  %58 = zext i1 %57 to i64
  %59 = getelementptr inbounds [3 x i8], ptr @.str.4, i64 0, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !15
  %61 = sext i8 %60 to i32
  %62 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %55, i32 noundef %61)
  %indvars.iv.next116 = add nuw nsw i64 %indvars.iv115, 1
  %63 = load i32, ptr @n, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %.not47.not = icmp slt i64 %indvars.iv115, %64
  br i1 %.not47.not, label %.lr.ph83, label %.loopexit51, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph59
  %.not4566 = icmp slt i32 %69, 1
  br i1 %.not4566, label %._crit_edge.thread, label %.preheader.preheader

.preheader.preheader:                             ; preds = %._crit_edge
  %65 = zext nneg i32 %69 to i64
  %66 = add nuw i32 %69, 1
  %wide.trip.count103 = zext i32 %66 to i64
  br label %.preheader

.lr.ph59:                                         ; preds = %.preheader52, %.lr.ph59
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %.lr.ph59 ], [ 1, %.preheader52 ]
  %67 = getelementptr inbounds i32, ptr @seq, i64 %indvars.iv92
  %68 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %67)
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %69 = load i32, ptr @n, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %.not44.not = icmp slt i64 %indvars.iv92, %70
  br i1 %.not44.not, label %.lr.ph59, label %._crit_edge, !llvm.loop !23

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge63
  %indvars.iv100 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next101, %._crit_edge63 ]
  %71 = phi i64 [ 0, %.preheader.preheader ], [ %94, %._crit_edge63 ]
  %72 = getelementptr inbounds [21 x i32], ptr @seq, i64 0, i64 %indvars.iv100
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = icmp sgt i32 %73, 1
  br i1 %74, label %.lr.ph62.preheader, label %._crit_edge63

.lr.ph62.preheader:                               ; preds = %.preheader
  %wide.trip.count98 = zext nneg i32 %73 to i64
  %75 = add nsw i64 %wide.trip.count98, -1
  %min.iters.check = icmp ult i32 %73, 9
  br i1 %min.iters.check, label %.lr.ph62.preheader128, label %vector.ph

.lr.ph62.preheader128:                            ; preds = %middle.block, %.lr.ph62.preheader
  %indvars.iv95.ph = phi i64 [ 1, %.lr.ph62.preheader ], [ %ind.end, %middle.block ]
  %.03360.ph = phi i32 [ 0, %.lr.ph62.preheader ], [ %85, %middle.block ]
  br label %.lr.ph62

vector.ph:                                        ; preds = %.lr.ph62.preheader
  %n.vec = and i64 %75, -8
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %82, %vector.body ]
  %vec.phi126 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %83, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %76 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %offset.idx
  %77 = getelementptr inbounds i8, ptr %76, i64 4
  %wide.load = load <4 x i8>, ptr %76, align 1, !tbaa !16
  %wide.load127 = load <4 x i8>, ptr %77, align 1, !tbaa !16
  %78 = xor <4 x i8> %wide.load, <i8 1, i8 1, i8 1, i8 1>
  %79 = xor <4 x i8> %wide.load127, <i8 1, i8 1, i8 1, i8 1>
  %80 = zext <4 x i8> %78 to <4 x i32>
  %81 = zext <4 x i8> %79 to <4 x i32>
  %82 = add <4 x i32> %vec.phi, %80
  %83 = add <4 x i32> %vec.phi126, %81
  %index.next = add nuw i64 %index, 8
  %84 = icmp eq i64 %index.next, %n.vec
  br i1 %84, label %middle.block, label %vector.body, !llvm.loop !24

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %83, %82
  %85 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %75, %n.vec
  br i1 %cmp.n, label %._crit_edge63, label %.lr.ph62.preheader128

._crit_edge.thread:                               ; preds = %._crit_edge63, %.preheader52, %._crit_edge
  %86 = phi i64 [ 0, %._crit_edge ], [ 0, %.preheader52 ], [ %94, %._crit_edge63 ]
  %87 = add nsw i64 %86, 1
  store i64 %87, ptr @val, align 8, !tbaa !5
  %88 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef %87)
  br label %.loopexit51

._crit_edge63:                                    ; preds = %.lr.ph62, %middle.block, %.preheader
  %.033.lcssa = phi i32 [ 0, %.preheader ], [ %85, %middle.block ], [ %spec.select, %.lr.ph62 ]
  %89 = sext i32 %.033.lcssa to i64
  %90 = sub nsw i64 %65, %indvars.iv100
  %91 = getelementptr inbounds [21 x i64], ptr @fact, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !5
  %93 = mul nsw i64 %92, %89
  %94 = add nsw i64 %71, %93
  %95 = sext i32 %73 to i64
  %96 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %95
  store i8 1, ptr %96, align 1, !tbaa !16
  %indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, 1
  %exitcond104.not = icmp eq i64 %indvars.iv.next101, %wide.trip.count103
  br i1 %exitcond104.not, label %._crit_edge.thread, label %.preheader, !llvm.loop !27

.lr.ph62:                                         ; preds = %.lr.ph62.preheader128, %.lr.ph62
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %.lr.ph62 ], [ %indvars.iv95.ph, %.lr.ph62.preheader128 ]
  %.03360 = phi i32 [ %spec.select, %.lr.ph62 ], [ %.03360.ph, %.lr.ph62.preheader128 ]
  %97 = getelementptr inbounds [21 x i8], ptr @vis, i64 0, i64 %indvars.iv95
  %98 = load i8, ptr %97, align 1, !tbaa !16, !range !18, !noundef !19
  %99 = xor i8 %98, 1
  %not. = zext nneg i8 %99 to i32
  %spec.select = add nuw nsw i32 %.03360, %not.
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %exitcond99.not = icmp eq i64 %indvars.iv.next96, %wide.trip.count98
  br i1 %exitcond99.not, label %._crit_edge63, label %.lr.ph62, !llvm.loop !28

.loopexit51:                                      ; preds = %.lr.ph83, %26, %.preheader50, %._crit_edge.thread
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %1) #5
  %100 = load i32, ptr @q, align 4, !tbaa !9
  %101 = add nsw i32 %100, -1
  store i32 %101, ptr @q, align 4, !tbaa !9
  %.not = icmp eq i32 %100, 0
  br i1 %.not, label %._crit_edge86, label %.lr.ph85, !llvm.loop !29

._crit_edge86:                                    ; preds = %.loopexit51, %.preheader53
  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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; 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.vector.reduce.add.v4i32(<4 x i32>) #4

attributes #0 = { mustprogress nofree norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}
!24 = distinct !{!24, !14, !25, !26}
!25 = !{!"llvm.loop.isvectorized", i32 1}
!26 = !{!"llvm.loop.unroll.runtime.disable"}
!27 = distinct !{!27, !14}
!28 = distinct !{!28, !14, !26, !25}
!29 = distinct !{!29, !14}


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