; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/树算法 (快速求树中与结点x距离不超过k的点权和)

; 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.TreeSet = type { [16500000 x %"struct.TreeSet::node"], i32, i32, i32 }
%"struct.TreeSet::node" = type { i32, i32, i32 }

@value = external dso_local global [110000 x i32], align 16
@root = external dso_local global [110000 x i32], align 16
@root2 = external dso_local global [110000 x i32], align 16
@tree = external dso_local global %struct.TreeSet, align 4
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6insertii(i32 noundef, i32 noundef) #2

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @_Z4initv()
  call void @_ZN7TreeSet4initEii(ptr noundef nonnull align 4 dereferenceable(198000012) @tree, i32 noundef 0, i32 noundef 110000)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %26, %0
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %29

21:                                               ; preds = %16
  %22 = call noundef i32 @_ZN7TreeSet7newnodeEv(ptr noundef nonnull align 4 dereferenceable(198000012) @tree)
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [110000 x i32], ptr @root, i64 0, i64 %24
  store i32 %22, ptr %25, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %21
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !9

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

30:                                               ; preds = %40, %29
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %43

35:                                               ; preds = %30
  %36 = call noundef i32 @_ZN7TreeSet7newnodeEv(ptr noundef nonnull align 4 dereferenceable(198000012) @tree)
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [110000 x i32], ptr @root2, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %35
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %5, align 4, !tbaa !5
  br label %30, !llvm.loop !11

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

44:                                               ; preds = %54, %43
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %44
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [110000 x i32], ptr @value, i64 0, i64 %51
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %52)
  br label %54

54:                                               ; preds = %49
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !5
  br label %44, !llvm.loop !12

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

58:                                               ; preds = %69, %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

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

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %64 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %8, ptr noundef %9)
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = load i32, ptr %9, align 4, !tbaa !5
  call void @_Z6insertii(i32 noundef %65, i32 noundef %66)
  %67 = load i32, ptr %9, align 4, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z6insertii(i32 noundef %67, i32 noundef %68)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %69

69:                                               ; preds = %63
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !5
  br label %58, !llvm.loop !13

72:                                               ; preds = %62
  call void @_Z4DFS1iii(i32 noundef 1, i32 noundef 0, i32 noundef 1)
  call void @_Z4DFS2ii(i32 noundef 1, i32 noundef 1)
  %73 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z5buildiii(i32 noundef 1, i32 noundef %73, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !14
  br label %74

74:                                               ; preds = %111, %72
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %3, align 4, !tbaa !5
  %77 = icmp ne i32 %75, 0
  br i1 %77, label %78, label %112

78:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %79 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %11, ptr noundef %12, ptr noundef %13)
  %80 = load i64, ptr %10, align 8, !tbaa !14
  %81 = load i64, ptr %12, align 8, !tbaa !14
  %82 = xor i64 %81, %80
  store i64 %82, ptr %12, align 8, !tbaa !14
  %83 = load i64, ptr %10, align 8, !tbaa !14
  %84 = load i64, ptr %13, align 8, !tbaa !14
  %85 = xor i64 %84, %83
  store i64 %85, ptr %13, align 8, !tbaa !14
  %86 = load i64, ptr %11, align 8, !tbaa !14
  %87 = icmp eq i64 %86, 0
  br i1 %87, label %88, label %96

88:                                               ; preds = %78
  %89 = load i64, ptr %12, align 8, !tbaa !14
  %90 = trunc i64 %89 to i32
  %91 = load i64, ptr %13, align 8, !tbaa !14
  %92 = trunc i64 %91 to i32
  %93 = call noundef i64 @_Z5queryii(i32 noundef %90, i32 noundef %92)
  store i64 %93, ptr %10, align 8, !tbaa !14
  %94 = load i64, ptr %10, align 8, !tbaa !14
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %94)
  br label %111

96:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %97 = load i64, ptr %13, align 8, !tbaa !14
  %98 = load i64, ptr %12, align 8, !tbaa !14
  %99 = getelementptr inbounds [110000 x i32], ptr @value, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = sub nsw i64 %97, %101
  %103 = trunc i64 %102 to i32
  store i32 %103, ptr %14, align 4, !tbaa !5
  %104 = load i64, ptr %13, align 8, !tbaa !14
  %105 = trunc i64 %104 to i32
  %106 = load i64, ptr %12, align 8, !tbaa !14
  %107 = getelementptr inbounds [110000 x i32], ptr @value, i64 0, i64 %106
  store i32 %105, ptr %107, align 4, !tbaa !5
  %108 = load i64, ptr %12, align 8, !tbaa !14
  %109 = trunc i64 %108 to i32
  %110 = load i32, ptr %14, align 4, !tbaa !5
  call void @_Z6updateii(i32 noundef %109, i32 noundef %110)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %111

111:                                              ; preds = %96, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %74, !llvm.loop !16

112:                                              ; preds = %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7TreeSet4initEii(ptr noundef nonnull align 4 dereferenceable(198000012), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7TreeSet7newnodeEv(ptr noundef nonnull align 4 dereferenceable(198000012)) #2 align 2

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #3 = { 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 #4 = { "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 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = distinct !{!16, !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.TreeSet = type { [16500000 x %"struct.TreeSet::node"], i32, i32, i32 }
%"struct.TreeSet::node" = type { i32, i32, i32 }

@value = external dso_local global [110000 x i32], align 16
@root = external dso_local local_unnamed_addr global [110000 x i32], align 16
@root2 = external dso_local local_unnamed_addr global [110000 x i32], align 16
@tree = external dso_local global %struct.TreeSet, align 4
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4DFS1iii(i32 noundef, i32 noundef, 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: 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 @_Z4DFS2ii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6insertii(i32 noundef, i32 noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @_Z4initv()
  call void @_ZN7TreeSet4initEii(ptr noundef nonnull align 4 dereferenceable(198000012) @tree, i32 noundef 0, i32 noundef 110000)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %.not24 = icmp slt i32 %9, 1
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.preheader23:                                     ; preds = %.lr.ph
  %10 = icmp slt i32 %13, 1
  br i1 %10, label %._crit_edge, label %.lr.ph28

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %11 = call noundef i32 @_ZN7TreeSet7newnodeEv(ptr noundef nonnull align 4 dereferenceable(198000012) @tree)
  %12 = getelementptr inbounds [110000 x i32], ptr @root, i64 0, i64 %indvars.iv
  store i32 %11, ptr %12, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %.not.not = icmp slt i64 %indvars.iv, %14
  br i1 %.not.not, label %.lr.ph, label %.preheader23, !llvm.loop !9

.preheader22:                                     ; preds = %.lr.ph28
  %15 = icmp slt i32 %18, 1
  br i1 %15, label %._crit_edge, label %.lr.ph31

.lr.ph28:                                         ; preds = %.preheader23, %.lr.ph28
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %.lr.ph28 ], [ 1, %.preheader23 ]
  %16 = call noundef i32 @_ZN7TreeSet7newnodeEv(ptr noundef nonnull align 4 dereferenceable(198000012) @tree)
  %17 = getelementptr inbounds [110000 x i32], ptr @root2, i64 0, i64 %indvars.iv40
  store i32 %16, ptr %17, align 4, !tbaa !5
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %.not19.not = icmp slt i64 %indvars.iv40, %19
  br i1 %.not19.not, label %.lr.ph28, label %.preheader22, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph31
  %20 = icmp sgt i32 %23, 1
  br i1 %20, label %.lr.ph33, label %._crit_edge

.lr.ph31:                                         ; preds = %.preheader22, %.lr.ph31
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %.lr.ph31 ], [ 1, %.preheader22 ]
  %21 = getelementptr inbounds [110000 x i32], ptr @value, i64 0, i64 %indvars.iv43
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %21)
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %.not20.not = icmp slt i64 %indvars.iv43, %24
  br i1 %.not20.not, label %.lr.ph31, label %.preheader, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph33, %0, %.preheader23, %.preheader22, %.preheader
  call void @_Z4DFS1iii(i32 noundef 1, i32 noundef 0, i32 noundef 1)
  call void @_Z4DFS2ii(i32 noundef 1, i32 noundef 1)
  %25 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z5buildiii(i32 noundef 1, i32 noundef %25, i32 noundef 0)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %2, align 4, !tbaa !5
  %.not2134 = icmp eq i32 %26, 0
  br i1 %.not2134, label %._crit_edge38, label %.lr.ph37

.lr.ph33:                                         ; preds = %.preheader, %.lr.ph33
  %.01632 = phi i32 [ %33, %.lr.ph33 ], [ 1, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z6insertii(i32 noundef %29, i32 noundef %30)
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z6insertii(i32 noundef %31, i32 noundef %32)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %33 = add nuw nsw i32 %.01632, 1
  %34 = load i32, ptr %1, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph33, label %._crit_edge, !llvm.loop !13

.lr.ph37:                                         ; preds = %._crit_edge, %54
  %.01535 = phi i64 [ %.1, %54 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %37 = load i64, ptr %6, align 8, !tbaa !14
  %38 = xor i64 %37, %.01535
  store i64 %38, ptr %6, align 8, !tbaa !14
  %39 = load i64, ptr %7, align 8, !tbaa !14
  %40 = xor i64 %39, %.01535
  store i64 %40, ptr %7, align 8, !tbaa !14
  %41 = load i64, ptr %5, align 8, !tbaa !14
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %.lr.ph37
  %44 = trunc i64 %38 to i32
  %45 = trunc i64 %40 to i32
  %46 = call noundef i64 @_Z5queryii(i32 noundef %44, i32 noundef %45)
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %46)
  br label %54

48:                                               ; preds = %.lr.ph37
  %49 = getelementptr inbounds [110000 x i32], ptr @value, i64 0, i64 %38
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = trunc i64 %40 to i32
  %52 = sub i32 %51, %50
  store i32 %51, ptr %49, align 4, !tbaa !5
  %53 = trunc i64 %38 to i32
  call void @_Z6updateii(i32 noundef %53, i32 noundef %52)
  br label %54

54:                                               ; preds = %48, %43
  %.1 = phi i64 [ %46, %43 ], [ %.01535, %48 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %2, align 4, !tbaa !5
  %.not21 = icmp eq i32 %55, 0
  br i1 %.not21, label %._crit_edge38, label %.lr.ph37, !llvm.loop !16

._crit_edge38:                                    ; preds = %54, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7TreeSet4initEii(ptr noundef nonnull align 4 dereferenceable(198000012), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7TreeSet7newnodeEv(ptr noundef nonnull align 4 dereferenceable(198000012)) local_unnamed_addr #2 align 2

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

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 = { 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 #3 = { 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 #4 = { 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 #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 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = distinct !{!16, !10}


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