; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构 (动态主席树)

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

@tree = external dso_local global %struct.Dynamic_ZXTree, align 4
@A = external dso_local global [100000 x i32], align 16
@B = external dso_local global [100000 x i32], align 16
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = 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 i8, align 1
  store i32 0, ptr %1, align 4
  %10 = load ptr, ptr @stdin, align 8, !tbaa !5
  %11 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %10)
  %12 = load ptr, ptr @stdout, align 8, !tbaa !5
  %13 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %12)
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @n, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %15

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

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %28

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [100000 x i32], ptr @A, i64 0, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %23)
  br label %25

25:                                               ; preds = %20
  %26 = load i32, ptr %2, align 4, !tbaa !9
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !9
  br label %15, !llvm.loop !11

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

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

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %42

34:                                               ; preds = %29
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100000 x i32], ptr @B, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %3, align 4, !tbaa !9
  br label %29, !llvm.loop !13

42:                                               ; preds = %33
  %43 = load i32, ptr @n, align 4, !tbaa !9
  %44 = load i32, ptr @n, align 4, !tbaa !9
  call void @_ZN14Dynamic_ZXTree4initEPiiS0_i(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, ptr noundef @A, i32 noundef %43, ptr noundef @B, i32 noundef %44)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %118, %42
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = load i32, ptr @q, align 4, !tbaa !9
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %121

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.6, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8)
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %60

54:                                               ; preds = %50
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = call noundef i32 @_ZN14Dynamic_ZXTree3preEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %55, i32 noundef %56, i32 noundef %57)
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %58)
  br label %117

60:                                               ; preds = %50
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %69

63:                                               ; preds = %60
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = call noundef i32 @_ZN14Dynamic_ZXTree4nextEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %64, i32 noundef %65, i32 noundef %66)
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %67)
  br label %116

69:                                               ; preds = %60
  %70 = load i32, ptr %5, align 4, !tbaa !9
  %71 = icmp eq i32 %70, 2
  br i1 %71, label %72, label %78

72:                                               ; preds = %69
  %73 = load i32, ptr %6, align 4, !tbaa !9
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = call noundef i32 @_ZN14Dynamic_ZXTree3kthEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %73, i32 noundef %74, i32 noundef %75)
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %76)
  br label %115

78:                                               ; preds = %69
  %79 = load i32, ptr %5, align 4, !tbaa !9
  %80 = icmp eq i32 %79, 3
  br i1 %80, label %81, label %87

81:                                               ; preds = %78
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = load i32, ptr %8, align 4, !tbaa !9
  %85 = call noundef i32 @_ZN14Dynamic_ZXTree3askEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %82, i32 noundef %83, i32 noundef %84)
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %85)
  br label %114

87:                                               ; preds = %78
  %88 = load i32, ptr %5, align 4, !tbaa !9
  %89 = icmp eq i32 %88, 4
  br i1 %89, label %90, label %96

90:                                               ; preds = %87
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = load i32, ptr %7, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = call noundef i32 @_ZN14Dynamic_ZXTree5countEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %91, i32 noundef %92, i32 noundef %93)
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %94)
  br label %113

96:                                               ; preds = %87
  %97 = load i32, ptr %5, align 4, !tbaa !9
  %98 = icmp eq i32 %97, 5
  br i1 %98, label %99, label %109

99:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %100 = load i32, ptr %6, align 4, !tbaa !9
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = load i32, ptr %8, align 4, !tbaa !9
  %103 = call noundef zeroext i1 @_ZN14Dynamic_ZXTree4findEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %100, i32 noundef %101, i32 noundef %102)
  %104 = zext i1 %103 to i8
  store i8 %104, ptr %9, align 1, !tbaa !14
  %105 = load i8, ptr %9, align 1, !tbaa !14, !range !16, !noundef !17
  %106 = trunc i8 %105 to i1
  %107 = zext i1 %106 to i32
  %108 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %107)
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %112

109:                                              ; preds = %96
  %110 = load i32, ptr %6, align 4, !tbaa !9
  %111 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN14Dynamic_ZXTree3setEii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %110, i32 noundef %111)
  br label %112

112:                                              ; preds = %109, %99
  br label %113

113:                                              ; preds = %112, %90
  br label %114

114:                                              ; preds = %113, %81
  br label %115

115:                                              ; preds = %114, %72
  br label %116

116:                                              ; preds = %115, %63
  br label %117

117:                                              ; preds = %116, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %4, align 4, !tbaa !9
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %4, align 4, !tbaa !9
  br label %45, !llvm.loop !18

121:                                              ; preds = %49
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14Dynamic_ZXTree4initEPiiS0_i(ptr noundef nonnull align 4 dereferenceable(62628020), ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree3preEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree4nextEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree3kthEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree3askEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree5countEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN14Dynamic_ZXTree4findEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14Dynamic_ZXTree3setEii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef) #3 align 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !12}


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

%struct.Dynamic_ZXTree = type { [5100000 x %"struct.Dynamic_ZXTree::node"], i32, i32, i32, i32, i32, [153000 x i32], [51000 x i32], [51000 x i32], [51000 x i32], [51000 x i32] }
%"struct.Dynamic_ZXTree::node" = type { i32, i32, i32 }

@tree = external dso_local global %struct.Dynamic_ZXTree, align 4
@A = external dso_local global [100000 x i32], align 16
@B = external dso_local global [100000 x i32], align 16
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = 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 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = load ptr, ptr @stdin, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %5)
  %7 = load ptr, ptr @stdout, align 8, !tbaa !5
  %8 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %7)
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @n, ptr noundef nonnull @q)
  %10 = load i32, ptr @n, align 4, !tbaa !9
  %.not15 = icmp slt i32 %10, 1
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  %.not1417 = icmp slt i32 %18, 1
  br i1 %.not1417, label %._crit_edge, label %.lr.ph19.preheader

.lr.ph19.preheader:                               ; preds = %.preheader
  %11 = add nuw i32 %18, 1
  %wide.trip.count = zext i32 %11 to i64
  %12 = zext nneg i32 %18 to i64
  %min.iters.check = icmp ult i32 %18, 8
  br i1 %min.iters.check, label %.lr.ph19.preheader33, label %vector.ph

.lr.ph19.preheader33:                             ; preds = %middle.block, %.lr.ph19.preheader
  %indvars.iv26.ph = phi i64 [ 1, %.lr.ph19.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph19

vector.ph:                                        ; preds = %.lr.ph19.preheader
  %n.vec = and i64 %12, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %offset.idx = or disjoint i64 %index, 1
  %13 = getelementptr inbounds [100000 x i32], ptr @B, i64 0, i64 %offset.idx
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  store <4 x i32> %vec.ind, ptr %13, align 4, !tbaa !9
  store <4 x i32> %step.add, ptr %14, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %15 = icmp eq i64 %index.next, %n.vec
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %12
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph19.preheader33

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %16 = getelementptr inbounds [100000 x i32], ptr @A, i64 0, i64 %indvars.iv
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %.not.not = icmp slt i64 %indvars.iv, %19
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph19, %middle.block, %0, %.preheader
  %.lcssa31 = phi i32 [ %18, %.preheader ], [ %10, %0 ], [ %18, %middle.block ], [ %18, %.lr.ph19 ]
  tail call void @_ZN14Dynamic_ZXTree4initEPiiS0_i(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, ptr noundef nonnull @A, i32 noundef %.lcssa31, ptr noundef nonnull @B, i32 noundef %.lcssa31)
  %20 = load i32, ptr @q, align 4, !tbaa !9
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph22, label %._crit_edge23

.lr.ph19:                                         ; preds = %.lr.ph19.preheader33, %.lr.ph19
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.lr.ph19 ], [ %indvars.iv26.ph, %.lr.ph19.preheader33 ]
  %22 = getelementptr inbounds [100000 x i32], ptr @B, i64 0, i64 %indvars.iv26
  %23 = trunc nuw nsw i64 %indvars.iv26 to i32
  store i32 %23, ptr %22, align 4, !tbaa !9
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next27, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph19, !llvm.loop !16

._crit_edge23:                                    ; preds = %60, %._crit_edge
  ret i32 0

.lr.ph22:                                         ; preds = %._crit_edge, %60
  %.01020 = phi i32 [ %61, %60 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.6, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %25 = load i32, ptr %1, align 4, !tbaa !9
  %26 = load i32, ptr %2, align 4, !tbaa !9
  switch i32 %25, label %58 [
    i32 0, label %27
    i32 1, label %32
    i32 2, label %37
    i32 3, label %42
    i32 4, label %47
    i32 5, label %52
  ]

27:                                               ; preds = %.lr.ph22
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = call noundef i32 @_ZN14Dynamic_ZXTree3preEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %28, i32 noundef %29)
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %30)
  br label %60

32:                                               ; preds = %.lr.ph22
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = call noundef i32 @_ZN14Dynamic_ZXTree4nextEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %33, i32 noundef %34)
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %35)
  br label %60

37:                                               ; preds = %.lr.ph22
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = call noundef i32 @_ZN14Dynamic_ZXTree3kthEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %38, i32 noundef %39)
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %40)
  br label %60

42:                                               ; preds = %.lr.ph22
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = load i32, ptr %4, align 4, !tbaa !9
  %45 = call noundef i32 @_ZN14Dynamic_ZXTree3askEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %43, i32 noundef %44)
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %45)
  br label %60

47:                                               ; preds = %.lr.ph22
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = call noundef i32 @_ZN14Dynamic_ZXTree5countEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %48, i32 noundef %49)
  %51 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %50)
  br label %60

52:                                               ; preds = %.lr.ph22
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = call noundef zeroext i1 @_ZN14Dynamic_ZXTree4findEiii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %53, i32 noundef %54)
  %56 = zext i1 %55 to i32
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %56)
  br label %60

58:                                               ; preds = %.lr.ph22
  %59 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN14Dynamic_ZXTree3setEii(ptr noundef nonnull align 4 dereferenceable(62628020) @tree, i32 noundef %26, i32 noundef %59)
  br label %60

60:                                               ; preds = %32, %42, %52, %58, %47, %37, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %61 = add nuw nsw i32 %.01020, 1
  %62 = load i32, ptr @q, align 4, !tbaa !9
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %.lr.ph22, label %._crit_edge23, !llvm.loop !17
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree3preEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree4nextEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree3kthEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree3askEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14Dynamic_ZXTree5countEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN14Dynamic_ZXTree4findEiii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14Dynamic_ZXTree3setEii(ptr noundef nonnull align 4 dereferenceable(62628020), i32 noundef, i32 noundef) local_unnamed_addr #4 align 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 = { "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 = { 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14, !13}
!17 = distinct !{!17, !12}


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