; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/QTREE3 (qtree3)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@WHITE = external dso_local global i32, align 4
@adj_list = external dso_local global [101000 x %"class.std::vector"], align 16
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@chain_no = external dso_local global i32, align 4
@chain_ind = external dso_local global [101000 x i32], align 16
@chain_head = external dso_local global [101000 x i32], align 16
@pos_in_base = external dso_local global [101000 x i32], align 16
@chain_count = external dso_local global [101000 x i32], align 16
@color = external dso_local global [101000 x i32], align 16
@ptr = external dso_local global i32, align 4
@.str = 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 uwtable
declare dso_local void @_Z4initiii(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 @_Z11update_treeiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

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

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

7:                                                ; preds = %23, %0
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %26

12:                                               ; preds = %7
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [101000 x i32], ptr @chain_head, i64 0, i64 %14
  store i32 -1, ptr %15, align 4, !tbaa !5
  %16 = load i32, ptr @WHITE, align 4, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [101000 x i32], ptr @color, 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 [101000 x i32], ptr @chain_count, i64 0, i64 %21
  store i32 0, ptr %22, align 4, !tbaa !5
  br label %23

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

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

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

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %47

32:                                               ; preds = %27
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a, ptr noundef @b)
  %34 = load i32, ptr @a, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr @a, align 4, !tbaa !5
  %36 = load i32, ptr @b, align 4, !tbaa !5
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr @b, align 4, !tbaa !5
  %38 = load i32, ptr @a, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [101000 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %39
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %40, ptr noundef nonnull align 4 dereferenceable(4) @b)
  %41 = load i32, ptr @b, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [101000 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %42
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %43, ptr noundef nonnull align 4 dereferenceable(4) @a)
  br label %44

44:                                               ; preds = %32
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %3, align 4, !tbaa !5
  br label %27, !llvm.loop !11

47:                                               ; preds = %31
  store i32 0, ptr @chain_no, align 4, !tbaa !5
  store i32 0, ptr @ptr, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef 0, i32 noundef -1, i32 noundef 0)
  call void @_Z3hldii(i32 noundef 0, i32 noundef -1)
  %48 = load i32, ptr @ptr, align 4, !tbaa !5
  call void @_Z4initiii(i32 noundef 1, i32 noundef 0, i32 noundef %48)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %105, %47
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = load i32, ptr @q, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %49
  %55 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a, ptr noundef @b)
  %56 = load i32, ptr @a, align 4, !tbaa !5
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %99

58:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %59 = load i32, ptr @b, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  store i32 %60, ptr %5, align 4, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [101000 x i32], ptr @color, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sub nsw i32 1, %64
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [101000 x i32], ptr @color, i64 0, i64 %67
  store i32 %65, ptr %68, align 4, !tbaa !5
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [101000 x i32], ptr @color, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = load i32, ptr @WHITE, align 4, !tbaa !5
  %74 = icmp eq i32 %72, %73
  br i1 %74, label %75, label %84

75:                                               ; preds = %58
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [101000 x i32], ptr @chain_ind, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [101000 x i32], ptr @chain_count, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = add nsw i32 %82, -1
  store i32 %83, ptr %81, align 4, !tbaa !5
  br label %93

84:                                               ; preds = %58
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [101000 x i32], ptr @chain_ind, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [101000 x i32], ptr @chain_count, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %90, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %84, %75
  %94 = load i32, ptr @ptr, align 4, !tbaa !5
  %95 = load i32, ptr %5, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [101000 x i32], ptr @pos_in_base, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  call void @_Z11update_treeiiii(i32 noundef 1, i32 noundef 0, i32 noundef %94, i32 noundef %98)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %104

99:                                               ; preds = %54
  %100 = load i32, ptr @b, align 4, !tbaa !5
  %101 = sub nsw i32 %100, 1
  %102 = call noundef i32 @_Z8query_upii(i32 noundef %101, i32 noundef 0)
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %102)
  br label %104

104:                                              ; preds = %99, %93
  br label %105

105:                                              ; preds = %104
  %106 = load i32, ptr %4, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %4, align 4, !tbaa !5
  br label %49, !llvm.loop !12

108:                                              ; preds = %53
  ret i32 0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

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

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 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

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

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


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@WHITE = external dso_local local_unnamed_addr global i32, align 4
@adj_list = external dso_local global [101000 x %"class.std::vector"], align 16
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@chain_no = external dso_local local_unnamed_addr global i32, align 4
@chain_ind = external dso_local local_unnamed_addr global [101000 x i32], align 16
@chain_head = external dso_local local_unnamed_addr global [101000 x i32], align 16
@pos_in_base = external dso_local local_unnamed_addr global [101000 x i32], align 16
@chain_count = external dso_local local_unnamed_addr global [101000 x i32], align 16
@color = external dso_local local_unnamed_addr global [101000 x i32], align 16
@ptr = external dso_local local_unnamed_addr global i32, align 4
@.str = 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 uwtable
declare dso_local void @_Z4initiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @q)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %4 = load i32, ptr @WHITE, align 4, !tbaa !5
  %5 = zext nneg i32 %2 to i64
  %6 = shl nuw nsw i64 %5, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @chain_head, i8 -1, i64 %6, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @chain_count, i8 0, i64 %6, i1 false), !tbaa !5
  %min.iters.check = icmp ult i32 %2, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %5, 2147483640
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %4, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %7 = getelementptr inbounds [101000 x i32], ptr @color, i64 0, i64 %index
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  store <4 x i32> %broadcast.splat, ptr %7, align 16, !tbaa !5
  store <4 x i32> %broadcast.splat, ptr %8, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %9 = icmp eq i64 %index.next, %n.vec
  br i1 %9, label %middle.block, label %vector.body, !llvm.loop !9

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

.preheader:                                       ; preds = %scalar.ph, %middle.block
  %.not = icmp eq i32 %2, 1
  br i1 %.not, label %._crit_edge, label %.lr.ph19

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %10 = getelementptr inbounds [101000 x i32], ptr @color, i64 0, i64 %indvars.iv
  store i32 %4, ptr %10, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %5
  br i1 %exitcond.not, label %.preheader, label %scalar.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph19, %0, %.preheader
  store i32 0, ptr @chain_no, align 4, !tbaa !5
  store i32 0, ptr @ptr, align 4, !tbaa !5
  tail call void @_Z3dfsiii(i32 noundef 0, i32 noundef -1, i32 noundef 0)
  tail call void @_Z3hldii(i32 noundef 0, i32 noundef -1)
  %11 = load i32, ptr @ptr, align 4, !tbaa !5
  tail call void @_Z4initiii(i32 noundef 1, i32 noundef 0, i32 noundef %11)
  %12 = load i32, ptr @q, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph22, label %._crit_edge23

.lr.ph19:                                         ; preds = %.preheader, %.lr.ph19
  %.01618 = phi i32 [ %24, %.lr.ph19 ], [ 1, %.preheader ]
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b)
  %15 = load i32, ptr @a, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr @a, align 4, !tbaa !5
  %17 = load i32, ptr @b, align 4, !tbaa !5
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr @b, align 4, !tbaa !5
  %19 = sext i32 %16 to i64
  %20 = getelementptr inbounds [101000 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %19
  tail call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 4 dereferenceable(4) @b)
  %21 = load i32, ptr @b, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [101000 x %"class.std::vector"], ptr @adj_list, i64 0, i64 %22
  tail call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 4 dereferenceable(4) @a)
  %24 = add nuw nsw i32 %.01618, 1
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %.lr.ph19, label %._crit_edge, !llvm.loop !14

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

.lr.ph22:                                         ; preds = %._crit_edge, %51
  %.01520 = phi i32 [ %52, %51 ], [ 0, %._crit_edge ]
  %27 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b)
  %28 = load i32, ptr @a, align 4, !tbaa !5
  %29 = icmp eq i32 %28, 0
  %30 = load i32, ptr @b, align 4, !tbaa !5
  %31 = add nsw i32 %30, -1
  br i1 %29, label %32, label %48

32:                                               ; preds = %.lr.ph22
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds [101000 x i32], ptr @color, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sub nsw i32 1, %35
  store i32 %36, ptr %34, align 4, !tbaa !5
  %37 = load i32, ptr @WHITE, align 4, !tbaa !5
  %38 = icmp eq i32 %36, %37
  %39 = getelementptr inbounds [101000 x i32], ptr @chain_ind, i64 0, i64 %33
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [101000 x i32], ptr @chain_count, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %. = select i1 %38, i32 -1, i32 1
  %44 = add nsw i32 %43, %.
  store i32 %44, ptr %42, align 4, !tbaa !5
  %45 = load i32, ptr @ptr, align 4, !tbaa !5
  %46 = getelementptr inbounds [101000 x i32], ptr @pos_in_base, i64 0, i64 %33
  %47 = load i32, ptr %46, align 4, !tbaa !5
  tail call void @_Z11update_treeiiii(i32 noundef 1, i32 noundef 0, i32 noundef %45, i32 noundef %47)
  br label %51

48:                                               ; preds = %.lr.ph22
  %49 = tail call noundef i32 @_Z8query_upii(i32 noundef %31, i32 noundef 0)
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %49)
  br label %51

51:                                               ; preds = %32, %48
  %52 = add nuw nsw i32 %.01520, 1
  %53 = load i32, ptr @q, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %.lr.ph22, label %._crit_edge23, !llvm.loop !15
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

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

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

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

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass