; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1244)

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

@pw = external dso_local global [100001 x i32], align 16
@n = external dso_local global i32, align 4
@l = external dso_local global [100001 x i32], align 16
@r = external dso_local global [100001 x i32], align 16
@tot = external dso_local global i32, align 4
@que = external dso_local global [200002 x i32], align 16
@cnt = external dso_local global [200002 x i32], align 16
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 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
  store i32 0, ptr %1, align 4
  store i32 1, ptr @pw, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %32, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 100001
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %35

10:                                               ; preds = %6
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = sub nsw i32 %11, 1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = shl i32 %15, 1
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %18
  store i32 %16, ptr %19, align 4, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp sge i32 %23, 1000000007
  br i1 %24, label %25, label %31

25:                                               ; preds = %10
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sub nsw i32 %29, 1000000007
  store i32 %30, ptr %28, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %25, %10
  br label %32

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

35:                                               ; preds = %9
  br label %36

36:                                               ; preds = %197, %35
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %38 = icmp eq i32 %37, 1
  br i1 %38, label %39, label %200

39:                                               ; preds = %36
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @cnt, i8 0, i64 800008, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %69, %39
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %40
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr @l, i64 %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr @r, i64 %50
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %48, ptr noundef %51)
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @tot, align 4, !tbaa !5
  %59 = sext i32 %57 to i64
  %60 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %59
  store i32 %56, ptr %60, align 4, !tbaa !5
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr @tot, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr @tot, align 4, !tbaa !5
  %67 = sext i32 %65 to i64
  %68 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %45
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %3, align 4, !tbaa !5
  br label %40, !llvm.loop !11

72:                                               ; preds = %44
  %73 = load i32, ptr @tot, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i32, ptr @que, i64 %74
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %75)
  %76 = load i32, ptr @tot, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr @que, i64 %77
  %79 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %78)
  %80 = ptrtoint ptr %79 to i64
  %81 = sub i64 %80, ptrtoint (ptr @que to i64)
  %82 = sdiv exact i64 %81, 4
  %83 = trunc i64 %82 to i32
  store i32 %83, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %136, %72
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %139

89:                                               ; preds = %84
  %90 = load i32, ptr @tot, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr @que, i64 %91
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %94
  %96 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %92, ptr noundef nonnull align 4 dereferenceable(4) %95)
  %97 = ptrtoint ptr %96 to i64
  %98 = sub i64 %97, ptrtoint (ptr @que to i64)
  %99 = sdiv exact i64 %98, 4
  %100 = add nsw i64 %99, 1
  %101 = trunc i64 %100 to i32
  %102 = load i32, ptr %4, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %103
  store i32 %101, ptr %104, align 4, !tbaa !5
  %105 = load i32, ptr @tot, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds i32, ptr @que, i64 %106
  %108 = load i32, ptr %4, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %109
  %111 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %107, ptr noundef nonnull align 4 dereferenceable(4) %110)
  %112 = ptrtoint ptr %111 to i64
  %113 = sub i64 %112, ptrtoint (ptr @que to i64)
  %114 = sdiv exact i64 %113, 4
  %115 = add nsw i64 %114, 1
  %116 = trunc i64 %115 to i32
  %117 = load i32, ptr %4, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %118
  store i32 %116, ptr %119, align 4, !tbaa !5
  %120 = load i32, ptr %4, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %125, align 4, !tbaa !5
  %128 = load i32, ptr %4, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = add nsw i32 %134, -1
  store i32 %135, ptr %133, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %89
  %137 = load i32, ptr %4, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %4, align 4, !tbaa !5
  br label %84, !llvm.loop !12

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

140:                                              ; preds = %188, %139
  %141 = load i32, ptr %5, align 4, !tbaa !5
  %142 = load i32, ptr @tot, align 4, !tbaa !5
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %191

145:                                              ; preds = %140
  %146 = load i32, ptr %5, align 4, !tbaa !5
  %147 = sub nsw i32 %146, 1
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = load i32, ptr %5, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = add nsw i32 %154, %150
  store i32 %155, ptr %153, align 4, !tbaa !5
  %156 = load i32, ptr @ans, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = load i32, ptr %5, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = sub nsw i32 %162, 1
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = sub nsw i32 %161, %166
  %168 = sext i32 %167 to i64
  %169 = load i32, ptr @n, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %170
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = load i32, ptr @n, align 4, !tbaa !5
  %174 = load i32, ptr %5, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %175
  %177 = load i32, ptr %176, align 4, !tbaa !5
  %178 = sub nsw i32 %173, %177
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = sub nsw i32 %172, %181
  %183 = sext i32 %182 to i64
  %184 = mul nsw i64 %168, %183
  %185 = add nsw i64 %157, %184
  %186 = srem i64 %185, 1000000007
  %187 = trunc i64 %186 to i32
  store i32 %187, ptr @ans, align 4, !tbaa !5
  br label %188

188:                                              ; preds = %145
  %189 = load i32, ptr %5, align 4, !tbaa !5
  %190 = add nsw i32 %189, 1
  store i32 %190, ptr %5, align 4, !tbaa !5
  br label %140, !llvm.loop !13

191:                                              ; preds = %144
  %192 = load i32, ptr @ans, align 4, !tbaa !5
  %193 = icmp slt i32 %192, 0
  br i1 %193, label %194, label %197

194:                                              ; preds = %191
  %195 = load i32, ptr @ans, align 4, !tbaa !5
  %196 = add nsw i32 %195, 1000000007
  store i32 %196, ptr @ans, align 4, !tbaa !5
  br label %197

197:                                              ; preds = %194, %191
  %198 = load i32, ptr @ans, align 4, !tbaa !5
  %199 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %198)
  br label %36, !llvm.loop !14

200:                                              ; preds = %36
  ret i32 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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nounwind }

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

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


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

@pw = external dso_local local_unnamed_addr global [100001 x i32], align 16
@n = external dso_local global i32, align 4
@l = external dso_local global [100001 x i32], align 16
@r = external dso_local global [100001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [200002 x i32], align 16
@cnt = external dso_local local_unnamed_addr global [200002 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 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 @pw, align 16, !tbaa !5
  br label %3

.preheader32:                                     ; preds = %3
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph42, label %._crit_edge43

3:                                                ; preds = %3, %0
  %4 = phi i32 [ 1, %0 ], [ %spec.select.1, %3 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %3 ]
  %5 = shl i32 %4, 1
  %6 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv
  %7 = icmp sgt i32 %5, 1000000006
  %8 = add nsw i32 %5, -1000000007
  %spec.select = select i1 %7, i32 %8, i32 %5
  store i32 %spec.select, ptr %6, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = shl i32 %spec.select, 1
  %10 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv.next
  %11 = icmp sgt i32 %9, 1000000006
  %12 = add nsw i32 %9, -1000000007
  %spec.select.1 = select i1 %11, i32 %12, i32 %9
  store i32 %spec.select.1, ptr %10, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 100001
  br i1 %exitcond.not.1, label %.preheader32, label %3, !llvm.loop !9

.lr.ph42:                                         ; preds = %.preheader32, %106
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800008) @cnt, i8 0, i64 800008, i1 false)
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph42
  %15 = phi i32 [ 0, %.lr.ph42 ], [ %37, %.lr.ph ]
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i32, ptr @que, i64 %16
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %17)
  %18 = load i32, ptr @tot, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @que, i64 %19
  %21 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %20)
  %22 = ptrtoint ptr %21 to i64
  %23 = sub i64 %22, ptrtoint (ptr @que to i64)
  %24 = lshr exact i64 %23, 2
  %25 = trunc i64 %24 to i32
  store i32 %25, ptr @tot, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph37, label %.preheader

.lr.ph:                                           ; preds = %.lr.ph42, %.lr.ph
  %indvars.iv47 = phi i64 [ %indvars.iv.next48, %.lr.ph ], [ 0, %.lr.ph42 ]
  %28 = getelementptr inbounds i32, ptr @l, i64 %indvars.iv47
  %29 = getelementptr inbounds i32, ptr @r, i64 %indvars.iv47
  %30 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %28, ptr noundef nonnull %29)
  %31 = load i32, ptr %28, align 4, !tbaa !5
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %34
  store i32 %31, ptr %35, align 4, !tbaa !5
  %36 = load i32, ptr %29, align 4, !tbaa !5
  %37 = add nsw i32 %32, 2
  store i32 %37, ptr @tot, align 4, !tbaa !5
  %38 = sext i32 %33 to i64
  %39 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  %indvars.iv.next48 = add nuw nsw i64 %indvars.iv47, 1
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = icmp slt i64 %indvars.iv.next48, %41
  br i1 %42, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader.loopexit:                              ; preds = %.lr.ph37
  %.pre = load i32, ptr @tot, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %._crit_edge
  %43 = phi i32 [ %25, %._crit_edge ], [ %.pre, %.preheader.loopexit ]
  %.lcssa = phi i32 [ %26, %._crit_edge ], [ %77, %.preheader.loopexit ]
  %44 = icmp sgt i32 %43, 1
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !5
  br i1 %44, label %.lr.ph39, label %.preheader._crit_edge

.lr.ph39:                                         ; preds = %.preheader
  %45 = sext i32 %.lcssa to i64
  %46 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %wide.trip.count = zext nneg i32 %43 to i64
  %.pre57 = load i32, ptr @cnt, align 16, !tbaa !5
  %.pre58 = load i32, ptr @que, align 16, !tbaa !5
  br label %82

.lr.ph37:                                         ; preds = %._crit_edge, %.lr.ph37
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %.lr.ph37 ], [ 0, %._crit_edge ]
  %48 = load i32, ptr @tot, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr @que, i64 %49
  %51 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %indvars.iv50
  %52 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %50, ptr noundef nonnull align 4 dereferenceable(4) %51)
  %53 = ptrtoint ptr %52 to i64
  %54 = sub i64 %53, ptrtoint (ptr @que to i64)
  %55 = lshr exact i64 %54, 2
  %56 = trunc i64 %55 to i32
  %57 = add i32 %56, 1
  store i32 %57, ptr %51, align 4, !tbaa !5
  %58 = load i32, ptr @tot, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr @que, i64 %59
  %61 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %indvars.iv50
  %62 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %60, ptr noundef nonnull align 4 dereferenceable(4) %61)
  %63 = ptrtoint ptr %62 to i64
  %64 = sub i64 %63, ptrtoint (ptr @que to i64)
  %65 = lshr exact i64 %64, 2
  %66 = trunc i64 %65 to i32
  %67 = add i32 %66, 1
  store i32 %67, ptr %61, align 4, !tbaa !5
  %68 = load i32, ptr %51, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %70, align 4, !tbaa !5
  %73 = sext i32 %67 to i64
  %74 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %74, align 4, !tbaa !5
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = icmp slt i64 %indvars.iv.next51, %78
  br i1 %79, label %.lr.ph37, label %.preheader.loopexit, !llvm.loop !12

._crit_edge40:                                    ; preds = %82
  store i32 %103, ptr @ans, align 4, !tbaa !5
  br label %.preheader._crit_edge

.preheader._crit_edge:                            ; preds = %.preheader, %._crit_edge40
  %80 = phi i32 [ %103, %._crit_edge40 ], [ %ans.promoted, %.preheader ]
  %81 = icmp slt i32 %80, 0
  br i1 %81, label %104, label %106

82:                                               ; preds = %.lr.ph39, %82
  %83 = phi i32 [ %.pre58, %.lr.ph39 ], [ %91, %82 ]
  %84 = phi i32 [ %.pre57, %.lr.ph39 ], [ %88, %82 ]
  %indvars.iv53 = phi i64 [ 1, %.lr.ph39 ], [ %indvars.iv.next54, %82 ]
  %85 = phi i32 [ %ans.promoted, %.lr.ph39 ], [ %103, %82 ]
  %86 = getelementptr inbounds [200002 x i32], ptr @cnt, i64 0, i64 %indvars.iv53
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = add nsw i32 %87, %84
  store i32 %88, ptr %86, align 4, !tbaa !5
  %89 = sext i32 %85 to i64
  %90 = getelementptr inbounds [200002 x i32], ptr @que, i64 0, i64 %indvars.iv53
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sub nsw i32 %91, %83
  %93 = sext i32 %92 to i64
  %94 = sub nsw i32 %.lcssa, %88
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sub nsw i32 %47, %97
  %99 = sext i32 %98 to i64
  %100 = mul nsw i64 %99, %93
  %101 = add nsw i64 %100, %89
  %102 = srem i64 %101, 1000000007
  %103 = trunc nsw i64 %102 to i32
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next54, %wide.trip.count
  br i1 %exitcond56.not, label %._crit_edge40, label %82, !llvm.loop !13

104:                                              ; preds = %.preheader._crit_edge
  %105 = add nsw i32 %80, 1000000007
  store i32 %105, ptr @ans, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %104, %.preheader._crit_edge
  %107 = phi i32 [ %105, %104 ], [ %80, %.preheader._crit_edge ]
  %108 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %107)
  %109 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %110 = icmp eq i32 %109, 1
  br i1 %110, label %.lr.ph42, label %._crit_edge43, !llvm.loop !14

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 nounwind willreturn memory(argmem: write) }
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" }

!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}


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