; LLVM IR from tangjz/acm-icpc :: codeforces/complete (908E)

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

@m = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@f = external dso_local global [1001 x i32], align 16
@g = external dso_local global [1001 x i32], align 16
@seq = external dso_local global [1001 x i64], align 16
@buf = external dso_local global [1001 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 [4 x i8], align 1

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

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

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

17:                                               ; preds = %30, %15
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp sge i32 %18, 1
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %28
  store i32 %26, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %21
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !9

33:                                               ; preds = %20
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  store i32 %37, ptr @g, align 16, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1001 x i32], ptr @f, i64 0, i64 %39
  store i32 %37, ptr %40, 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 %41

41:                                               ; preds = %67, %33
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i32 %55, %51
  store i32 %56, ptr %54, align 4, !tbaa !5
  %57 = icmp sge i32 %56, 1000000007
  br i1 %57, label %58, label %65

58:                                               ; preds = %46
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1000000007
  store i32 %63, ptr %61, align 4, !tbaa !5
  %64 = icmp ne i32 %63, 0
  br label %65

65:                                               ; preds = %58, %46
  %66 = phi i1 [ false, %46 ], [ %64, %58 ]
  br label %67

67:                                               ; preds = %65
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %5, align 4, !tbaa !5
  br label %41, !llvm.loop !11

70:                                               ; preds = %45
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !12

74:                                               ; preds = %14
  %75 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %108, %74
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %81, label %80

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

81:                                               ; preds = %76
  %82 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @buf)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %104, %81
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = load i32, ptr @m, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %107

88:                                               ; preds = %83
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1001 x i8], ptr @buf, i64 0, i64 %90
  %92 = load i8, ptr %91, align 1, !tbaa !13
  %93 = sext i8 %92 to i32
  %94 = icmp eq i32 %93, 49
  %95 = zext i1 %94 to i64
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = zext i32 %96 to i64
  %98 = shl i64 %95, %97
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %100
  %102 = load i64, ptr %101, align 8, !tbaa !14
  %103 = or i64 %102, %98
  store i64 %103, ptr %101, align 8, !tbaa !14
  br label %104

104:                                              ; preds = %88
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %7, align 4, !tbaa !5
  br label %83, !llvm.loop !16

107:                                              ; preds = %87
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %6, align 4, !tbaa !5
  br label %76, !llvm.loop !17

111:                                              ; preds = %80
  %112 = load i32, ptr @m, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds i64, ptr @seq, i64 %113
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @seq, ptr noundef %114)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !5
  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 %115

115:                                              ; preds = %154, %111
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = load i32, ptr @m, align 4, !tbaa !5
  %118 = icmp slt i32 %116, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %115
  store i32 17, 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 %156

120:                                              ; preds = %115
  br label %121

121:                                              ; preds = %138, %120
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = load i32, ptr @m, align 4, !tbaa !5
  %124 = icmp slt i32 %122, %123
  br i1 %124, label %125, label %135

125:                                              ; preds = %121
  %126 = load i32, ptr %9, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %127
  %129 = load i64, ptr %128, align 8, !tbaa !14
  %130 = load i32, ptr %10, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %131
  %133 = load i64, ptr %132, align 8, !tbaa !14
  %134 = icmp eq i64 %129, %133
  br label %135

135:                                              ; preds = %125, %121
  %136 = phi i1 [ false, %121 ], [ %134, %125 ]
  br i1 %136, label %137, label %141

137:                                              ; preds = %135
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %10, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %10, align 4, !tbaa !5
  br label %121, !llvm.loop !18

141:                                              ; preds = %135
  %142 = load i32, ptr %8, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = load i32, ptr %10, align 4, !tbaa !5
  %145 = load i32, ptr %9, align 4, !tbaa !5
  %146 = sub nsw i32 %144, %145
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1001 x i32], ptr @f, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = mul nsw i64 %143, %150
  %152 = srem i64 %151, 1000000007
  %153 = trunc i64 %152 to i32
  store i32 %153, ptr %8, align 4, !tbaa !5
  br label %154

154:                                              ; preds = %141
  %155 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %155, ptr %9, align 4, !tbaa !5
  br label %115, !llvm.loop !19

156:                                              ; preds = %119
  %157 = load i32, ptr %8, align 4, !tbaa !5
  %158 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %157)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %159 = load i32, ptr %1, align 4
  ret i32 %159
}

; 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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !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"

@m = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@f = external dso_local local_unnamed_addr global [1001 x i32], align 16
@g = external dso_local local_unnamed_addr global [1001 x i32], align 16
@seq = external dso_local global [1001 x i64], align 16
@buf = external dso_local global [1001 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 [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  store i32 1, ptr @g, align 16, !tbaa !5
  store i32 1, ptr @f, align 16, !tbaa !5
  br label %.preheader41

.preheader41:                                     ; preds = %0, %29
  %indvar = phi i64 [ 0, %0 ], [ %indvar.next, %29 ]
  %indvars.iv63 = phi i64 [ 2, %0 ], [ %indvars.iv.next64, %29 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %29 ]
  %min.iters.check = icmp ult i64 %indvars.iv, 16
  %1 = icmp ugt i64 %indvar, 4294967295
  %or.cond = select i1 %min.iters.check, i1 true, i1 %1
  br i1 %or.cond, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader41
  %indvars.iv54.ph = phi i64 [ %indvars.iv, %.preheader41 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.preheader41
  %n.vec = and i64 %indvars.iv, 9223372036854775800
  %ind.end = and i64 %indvars.iv, 7
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = sub i64 %indvars.iv, %index
  %2 = add i64 %offset.idx, 4294967295
  %3 = and i64 %2, 4294967295
  %4 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %3
  %5 = getelementptr inbounds i8, ptr %4, i64 -12
  %6 = getelementptr inbounds i8, ptr %4, i64 -28
  %wide.load = load <4 x i32>, ptr %5, align 4, !tbaa !5
  %wide.load95 = load <4 x i32>, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %offset.idx
  %8 = getelementptr inbounds i8, ptr %7, i64 -12
  %9 = getelementptr inbounds i8, ptr %7, i64 -28
  store <4 x i32> %wide.load, ptr %8, align 4, !tbaa !5
  store <4 x i32> %wide.load95, ptr %9, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %10 = icmp eq i64 %index.next, %n.vec
  br i1 %10, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %indvars.iv, %n.vec
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

11:                                               ; preds = %29
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m, ptr noundef nonnull @n)
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph48, label %.._crit_edge49_crit_edge

.._crit_edge49_crit_edge:                         ; preds = %11
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %._crit_edge49

.loopexit:                                        ; preds = %scalar.ph, %middle.block
  %15 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr @g, align 16, !tbaa !5
  %17 = getelementptr inbounds [1001 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 %16, ptr %17, align 4, !tbaa !5
  %xtraiter = and i64 %indvars.iv, 1
  %18 = icmp eq i64 %indvar, 0
  br i1 %18, label %.unr-lcssa, label %.loopexit.new

.loopexit.new:                                    ; preds = %.loopexit
  %unroll_iter = and i64 %indvars.iv, 9223372036854775806
  br label %30

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %scalar.ph ], [ %indvars.iv54.ph, %scalar.ph.preheader ]
  %indvars.iv.next55 = add nsw i64 %indvars.iv54, -1
  %19 = and i64 %indvars.iv.next55, 4294967295
  %20 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %indvars.iv54
  store i32 %21, ptr %22, align 4, !tbaa !5
  %23 = icmp sgt i64 %indvars.iv54, 1
  br i1 %23, label %scalar.ph, label %.loopexit, !llvm.loop !13

.unr-lcssa:                                       ; preds = %30, %.loopexit
  %.unr = phi i32 [ %16, %.loopexit ], [ %spec.select.1, %30 ]
  %indvars.iv57.unr = phi i64 [ 1, %.loopexit ], [ %indvars.iv.next58.1, %30 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %29, label %.epilog-lcssa

.epilog-lcssa:                                    ; preds = %.unr-lcssa
  %24 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %indvars.iv57.unr
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, %.unr
  %27 = icmp sgt i32 %26, 1000000006
  %28 = add nsw i32 %26, -1000000007
  %spec.select.epil = select i1 %27, i32 %28, i32 %26
  store i32 %spec.select.epil, ptr %24, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %.unr-lcssa, %.epilog-lcssa
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %exitcond69.not = icmp eq i64 %indvars.iv.next64, 1002
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond69.not, label %11, label %.preheader41, !llvm.loop !14

30:                                               ; preds = %30, %.loopexit.new
  %31 = phi i32 [ %16, %.loopexit.new ], [ %spec.select.1, %30 ]
  %indvars.iv57 = phi i64 [ 1, %.loopexit.new ], [ %indvars.iv.next58.1, %30 ]
  %niter = phi i64 [ 0, %.loopexit.new ], [ %niter.next.1, %30 ]
  %32 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %indvars.iv57
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add nsw i32 %33, %31
  %35 = icmp sgt i32 %34, 1000000006
  %36 = add nsw i32 %34, -1000000007
  %spec.select = select i1 %35, i32 %36, i32 %34
  store i32 %spec.select, ptr %32, align 4, !tbaa !5
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %37 = getelementptr inbounds [1001 x i32], ptr @g, i64 0, i64 %indvars.iv.next58
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = add nsw i32 %38, %spec.select
  %40 = icmp sgt i32 %39, 1000000006
  %41 = add nsw i32 %39, -1000000007
  %spec.select.1 = select i1 %40, i32 %41, i32 %39
  store i32 %spec.select.1, ptr %37, align 4, !tbaa !5
  %indvars.iv.next58.1 = add nuw nsw i64 %indvars.iv57, 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 %.unr-lcssa, label %30, !llvm.loop !15

._crit_edge49:                                    ; preds = %._crit_edge, %.._crit_edge49_crit_edge
  %42 = phi i32 [ %.pre, %.._crit_edge49_crit_edge ], [ %49, %._crit_edge ]
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i64, ptr @seq, i64 %43
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @seq, ptr noundef nonnull %44)
  %45 = load i32, ptr @m, align 4, !tbaa !5
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.preheader.preheader, label %._crit_edge53

.preheader.preheader:                             ; preds = %._crit_edge49
  %47 = zext nneg i32 %45 to i64
  br label %.preheader

.lr.ph48:                                         ; preds = %11, %._crit_edge
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %._crit_edge ], [ 0, %11 ]
  %48 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @buf)
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %50 = icmp sgt i32 %49, 0
  br i1 %50, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph48
  %wide.trip.count = zext nneg i32 %49 to i64
  %min.iters.check101 = icmp ult i32 %49, 4
  br i1 %min.iters.check101, label %scalar.ph100.preheader, label %vector.ph102

scalar.ph100.preheader:                           ; preds = %middle.block99, %.lr.ph
  %indvars.iv70.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec104, %middle.block99 ]
  br label %scalar.ph100

vector.ph102:                                     ; preds = %.lr.ph
  %n.vec104 = and i64 %wide.trip.count, 2147483644
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %indvars.iv75, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body106

vector.body106:                                   ; preds = %vector.body106, %vector.ph102
  %index107 = phi i64 [ 0, %vector.ph102 ], [ %index.next112, %vector.body106 ]
  %51 = getelementptr inbounds [1001 x i8], ptr @buf, i64 0, i64 %index107
  %52 = getelementptr inbounds i8, ptr %51, i64 2
  %wide.load108 = load <2 x i8>, ptr %51, align 4, !tbaa !16
  %wide.load109 = load <2 x i8>, ptr %52, align 2, !tbaa !16
  %53 = icmp eq <2 x i8> %wide.load108, <i8 49, i8 49>
  %54 = icmp eq <2 x i8> %wide.load109, <i8 49, i8 49>
  %55 = zext <2 x i1> %53 to <2 x i64>
  %56 = zext <2 x i1> %54 to <2 x i64>
  %57 = shl nuw <2 x i64> %55, %broadcast.splat
  %58 = shl nuw <2 x i64> %56, %broadcast.splat
  %59 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %index107
  %60 = getelementptr inbounds i8, ptr %59, i64 16
  %wide.load110 = load <2 x i64>, ptr %59, align 16, !tbaa !17
  %wide.load111 = load <2 x i64>, ptr %60, align 16, !tbaa !17
  %61 = or <2 x i64> %57, %wide.load110
  %62 = or <2 x i64> %58, %wide.load111
  store <2 x i64> %61, ptr %59, align 16, !tbaa !17
  store <2 x i64> %62, ptr %60, align 16, !tbaa !17
  %index.next112 = add nuw i64 %index107, 4
  %63 = icmp eq i64 %index.next112, %n.vec104
  br i1 %63, label %middle.block99, label %vector.body106, !llvm.loop !19

middle.block99:                                   ; preds = %vector.body106
  %cmp.n113 = icmp eq i64 %n.vec104, %wide.trip.count
  br i1 %cmp.n113, label %._crit_edge, label %scalar.ph100.preheader

._crit_edge:                                      ; preds = %scalar.ph100, %middle.block99, %.lr.ph48
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = icmp slt i64 %indvars.iv.next76, %65
  br i1 %66, label %.lr.ph48, label %._crit_edge49, !llvm.loop !20

scalar.ph100:                                     ; preds = %scalar.ph100.preheader, %scalar.ph100
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %scalar.ph100 ], [ %indvars.iv70.ph, %scalar.ph100.preheader ]
  %67 = getelementptr inbounds [1001 x i8], ptr @buf, i64 0, i64 %indvars.iv70
  %68 = load i8, ptr %67, align 1, !tbaa !16
  %69 = icmp eq i8 %68, 49
  %70 = zext i1 %69 to i64
  %71 = shl nuw i64 %70, %indvars.iv75
  %72 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %indvars.iv70
  %73 = load i64, ptr %72, align 8, !tbaa !17
  %74 = or i64 %71, %73
  store i64 %74, ptr %72, align 8, !tbaa !17
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %exitcond74.not = icmp eq i64 %indvars.iv.next71, %wide.trip.count
  br i1 %exitcond74.not, label %._crit_edge, label %scalar.ph100, !llvm.loop !21

.preheader:                                       ; preds = %.preheader.preheader, %.critedge
  %.052 = phi i32 [ %95, %.critedge ], [ 0, %.preheader.preheader ]
  %.03451 = phi i64 [ %102, %.critedge ], [ 1, %.preheader.preheader ]
  %75 = sext i32 %.052 to i64
  %76 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !17
  br label %81

._crit_edge53.loopexit:                           ; preds = %.critedge, %.critedge.thread
  %78 = phi i64 [ %94, %.critedge.thread ], [ %102, %.critedge ]
  %79 = trunc nsw i64 %78 to i32
  br label %._crit_edge53

._crit_edge53:                                    ; preds = %._crit_edge53.loopexit, %._crit_edge49
  %.034.lcssa = phi i32 [ 1, %._crit_edge49 ], [ %79, %._crit_edge53.loopexit ]
  %80 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.034.lcssa)
  ret i32 0

81:                                               ; preds = %.preheader, %85
  %indvars.iv79 = phi i64 [ %75, %.preheader ], [ %indvars.iv.next80, %85 ]
  %82 = getelementptr inbounds [1001 x i64], ptr @seq, i64 0, i64 %indvars.iv79
  %83 = load i64, ptr %82, align 8, !tbaa !17
  %84 = icmp eq i64 %77, %83
  br i1 %84, label %85, label %.critedge

85:                                               ; preds = %81
  %indvars.iv.next80 = add nsw i64 %indvars.iv79, 1
  %86 = icmp slt i64 %indvars.iv.next80, %47
  br i1 %86, label %81, label %.critedge.thread, !llvm.loop !22

.critedge.thread:                                 ; preds = %85
  %87 = add nsw i32 %.052, 1
  %smax.le = tail call i32 @llvm.smax.i32(i32 %45, i32 %87)
  %88 = sub nsw i32 %smax.le, %.052
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [1001 x i32], ptr @f, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = mul nsw i64 %.03451, %92
  %94 = srem i64 %93, 1000000007
  br label %._crit_edge53.loopexit

.critedge:                                        ; preds = %81
  %95 = trunc nsw i64 %indvars.iv79 to i32
  %96 = sub nsw i32 %95, %.052
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1001 x i32], ptr @f, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = mul nsw i64 %.03451, %100
  %102 = srem i64 %101, 1000000007
  %103 = icmp sgt i32 %45, %95
  br i1 %103, label %.preheader, label %._crit_edge53.loopexit, !llvm.loop !23
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint 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 #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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = distinct !{!19, !10, !11, !12}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10, !12, !11}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}


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