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

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

%struct.Trie = type { [26 x i32] }

@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@lim = external dso_local global [100001 x i32], align 16
@seq = external dso_local global [100001 x i32], align 16
@tim = external dso_local global i32, align 4
@root = external dso_local global [100001 x i32], align 16
@mx = external dso_local global i32, align 4
@e = external dso_local global [100001 x %struct.Trie], align 16
@.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 [4 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateRiiii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %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
  store i32 0, ptr %1, align 4
  br label %9

9:                                                ; preds = %116, %0
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n)
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %12, label %117

12:                                               ; preds = %9
  store i32 0, ptr @mx, align 4, !tbaa !5
  store i32 0, ptr @tim, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  %13 = load i32, ptr @tot, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr @tot, align 4, !tbaa !5
  %15 = sext i32 %13 to i64
  %16 = getelementptr inbounds %struct.Trie, ptr @e, i64 %15
  call void @llvm.memset.p0.i64(ptr align 4 %16, i8 0, i64 104, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %24, %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z6inserti(i32 noundef %23)
  br label %24

24:                                               ; preds = %22
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !9

27:                                               ; preds = %21
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %62, %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %65

33:                                               ; preds = %28
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %40
  store i32 %38, ptr %41, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %58, %33
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x i32], ptr @lim, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = icmp sle i32 %43, %47
  br i1 %48, label %49, label %61

49:                                               ; preds = %42
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %51
  %53 = load i32, ptr @mx, align 4, !tbaa !5
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100001 x i32], ptr @seq, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  call void @_Z6updateRiiii(ptr noundef nonnull align 4 dereferenceable(4) %52, i32 noundef 0, i32 noundef %53, i32 noundef %57)
  br label %58

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

61:                                               ; preds = %42
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !12

65:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  %66 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %5)
  br label %67

67:                                               ; preds = %89, %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
  %70 = icmp ne i32 %68, 0
  br i1 %70, label %71, label %116

71:                                               ; preds = %67
  %72 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %6, ptr noundef %7)
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = add nsw i32 %73, %74
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = srem i32 %75, %76
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %6, align 4, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = add nsw i32 %79, %80
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = srem i32 %81, %82
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %7, align 4, !tbaa !5
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = icmp sgt i32 %85, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %71
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7) #6
  br label %89

89:                                               ; preds = %88, %71
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr @mx, align 4, !tbaa !5
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = sub nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100001 x i32], ptr @lim, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = call noundef i32 @_Z5queryiiii(i32 noundef %93, i32 noundef 0, i32 noundef %94, i32 noundef %99)
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = sub nsw i32 %101, 1
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = load i32, ptr @mx, align 4, !tbaa !5
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = sub nsw i32 %107, 1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x i32], ptr @lim, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = call noundef i32 @_Z5queryiiii(i32 noundef %105, i32 noundef 0, i32 noundef %106, i32 noundef %111)
  %113 = sub nsw i32 %100, %112
  store i32 %113, ptr %8, align 4, !tbaa !5
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %114)
  br label %67, !llvm.loop !13

116:                                              ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %9, !llvm.loop !14

117:                                              ; preds = %9
  ret i32 0
}

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #5 = { inlinehint mustprogress 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 #6 = { 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"

%struct.Trie = type { [26 x i32] }

@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@lim = external dso_local local_unnamed_addr global [100001 x i32], align 16
@seq = external dso_local local_unnamed_addr global [100001 x i32], align 16
@tim = external dso_local local_unnamed_addr global i32, align 4
@root = external dso_local global [100001 x i32], align 16
@mx = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local local_unnamed_addr global [100001 x %struct.Trie], align 16
@.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 [4 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateRiiii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %.lr.ph40, label %._crit_edge41

.lr.ph40:                                         ; preds = %0, %._crit_edge38
  store i32 0, ptr @mx, align 4, !tbaa !5
  store i32 0, ptr @tim, align 4, !tbaa !5
  store i32 1, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(104) @e, i8 0, i64 104, i1 false)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %.not21 = icmp slt i32 %6, 1
  br i1 %.not21, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %.lr.ph40
  store i32 0, ptr @tot, align 4, !tbaa !5
  br label %._crit_edge33

._crit_edge:                                      ; preds = %.lr.ph
  store i32 0, ptr @tot, align 4, !tbaa !5
  %.not1828 = icmp slt i32 %8, 1
  br i1 %.not1828, label %._crit_edge33, label %.lr.ph32

.lr.ph:                                           ; preds = %.lr.ph40, %.lr.ph
  %.01722 = phi i32 [ %7, %.lr.ph ], [ 1, %.lr.ph40 ]
  call void @_Z6inserti(i32 noundef %.01722)
  %7 = add nuw nsw i32 %.01722, 1
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.01722, %8
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge33:                                    ; preds = %._crit_edge27, %._crit_edge.thread, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr %1, align 4, !tbaa !5
  %.not1934 = icmp eq i32 %10, 0
  br i1 %.not1934, label %._crit_edge38, label %.lr.ph37

.lr.ph32:                                         ; preds = %._crit_edge, %._crit_edge27
  %12 = phi i32 [ %26, %._crit_edge27 ], [ %8, %._crit_edge ]
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %._crit_edge27 ], [ 1, %._crit_edge ]
  %.01530 = phi i32 [ %.1.lcssa, %._crit_edge27 ], [ 1, %._crit_edge ]
  %13 = add nsw i64 %indvars.iv43, -1
  %14 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %indvars.iv43
  store i32 %15, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds [100001 x i32], ptr @lim, i64 0, i64 %indvars.iv43
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not2023 = icmp sgt i32 %.01530, %18
  br i1 %.not2023, label %._crit_edge27, label %.lr.ph26.preheader

.lr.ph26.preheader:                               ; preds = %.lr.ph32
  %19 = sext i32 %.01530 to i64
  br label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph26.preheader, %.lr.ph26
  %indvars.iv = phi i64 [ %19, %.lr.ph26.preheader ], [ %indvars.iv.next, %.lr.ph26 ]
  %20 = load i32, ptr @mx, align 4, !tbaa !5
  %21 = getelementptr inbounds [100001 x i32], ptr @seq, i64 0, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !5
  call void @_Z6updateRiiii(ptr noundef nonnull align 4 dereferenceable(4) %16, i32 noundef 0, i32 noundef %20, i32 noundef %22)
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %17, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %.not20.not = icmp slt i64 %indvars.iv, %24
  br i1 %.not20.not, label %.lr.ph26, label %._crit_edge27.loopexit, !llvm.loop !11

._crit_edge27.loopexit:                           ; preds = %.lr.ph26
  %25 = trunc nsw i64 %indvars.iv.next to i32
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge27.loopexit, %.lr.ph32
  %26 = phi i32 [ %12, %.lr.ph32 ], [ %.pre, %._crit_edge27.loopexit ]
  %.1.lcssa = phi i32 [ %.01530, %.lr.ph32 ], [ %25, %._crit_edge27.loopexit ]
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %27 = sext i32 %26 to i64
  %.not18.not = icmp slt i64 %indvars.iv43, %27
  br i1 %.not18.not, label %.lr.ph32, label %._crit_edge33, !llvm.loop !12

.lr.ph37:                                         ; preds = %._crit_edge33, %40
  %.035 = phi i32 [ %61, %40 ], [ 0, %._crit_edge33 ]
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, %.035
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = srem i32 %30, %31
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, %.035
  %36 = srem i32 %35, %31
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %3, align 4, !tbaa !5
  %38 = icmp sgt i32 %32, %36
  br i1 %38, label %39, label %40

39:                                               ; preds = %.lr.ph37
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3) #6
  %.pre46 = load i32, ptr %3, align 4, !tbaa !5
  %.pre47 = load i32, ptr %2, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %39, %.lr.ph37
  %41 = phi i32 [ %.pre47, %39 ], [ %33, %.lr.ph37 ]
  %42 = phi i32 [ %.pre46, %39 ], [ %37, %.lr.ph37 ]
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr @mx, align 4, !tbaa !5
  %47 = add nsw i32 %41, -1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [100001 x i32], ptr @lim, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = call noundef i32 @_Z5queryiiii(i32 noundef %45, i32 noundef 0, i32 noundef %46, i32 noundef %50)
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100001 x i32], ptr @root, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr @mx, align 4, !tbaa !5
  %58 = getelementptr inbounds [100001 x i32], ptr @lim, i64 0, i64 %54
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = call noundef i32 @_Z5queryiiii(i32 noundef %56, i32 noundef 0, i32 noundef %57, i32 noundef %59)
  %61 = sub nsw i32 %51, %60
  %62 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %61)
  %63 = load i32, ptr %1, align 4, !tbaa !5
  %64 = add nsw i32 %63, -1
  store i32 %64, ptr %1, align 4, !tbaa !5
  %.not19 = icmp eq i32 %63, 0
  br i1 %.not19, label %._crit_edge38, label %.lr.ph37, !llvm.loop !13

._crit_edge38:                                    ; preds = %40, %._crit_edge33
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %65 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %66 = icmp eq i32 %65, 1
  br i1 %66, label %.lr.ph40, label %._crit_edge41, !llvm.loop !14

._crit_edge41:                                    ; preds = %._crit_edge38, %0
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { inlinehint mustprogress 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 #6 = { 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}


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