; LLVM IR from duc0/ContestNeko :: CPPProjects (SubtreeSize)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z7queryUpiiRKSt6vectorIiSaIiEERK12WeightedTreeIiERK23HeavyLightDecompositionIiER11SegmentTreeIiiE(i32 noundef %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(92) %4, ptr noundef nonnull align 8 dereferenceable(168) %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 2000000000, ptr %14, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %83, %6
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %10, align 8, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %20, i64 noundef %22) #3
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %28

26:                                               ; preds = %19
  %27 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %27, ptr %14, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %26, %19
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = icmp eq i32 %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  br label %84

33:                                               ; preds = %28
  %34 = load ptr, ptr %12, align 8, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = call noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE7isLightEi(ptr noundef nonnull align 8 dereferenceable(92) %34, i32 noundef %35)
  br i1 %36, label %37, label %41

37:                                               ; preds = %33
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = call noundef i32 @_ZNK12WeightedTreeIiE9getParentEi(ptr noundef nonnull align 8 dereferenceable(80) %38, i32 noundef %39)
  store i32 %40, ptr %8, align 4, !tbaa !5
  br label %83

41:                                               ; preds = %33
  %42 = load ptr, ptr %12, align 8, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = call noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE15inSameHeavyPathEii(ptr noundef nonnull align 8 dereferenceable(92) %42, i32 noundef %43, i32 noundef %44)
  br i1 %45, label %46, label %63

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %47 = load ptr, ptr %13, align 8, !tbaa !9
  %48 = load ptr, ptr %12, align 8, !tbaa !9
  %49 = load i32, ptr %9, align 4, !tbaa !5
  %50 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %48, i32 noundef %49)
  %51 = load ptr, ptr %12, align 8, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %51, i32 noundef %52)
  %54 = call noundef i32 @_ZN11SegmentTreeIiiE5queryEii(ptr noundef nonnull align 8 dereferenceable(168) %47, i32 noundef %50, i32 noundef %53)
  store i32 %54, ptr %15, align 4, !tbaa !5
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = icmp ne i32 %55, 2000000000
  br i1 %56, label %57, label %61

57:                                               ; preds = %46
  %58 = load ptr, ptr %12, align 8, !tbaa !9
  %59 = load i32, ptr %15, align 4, !tbaa !5
  %60 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE13getNodeAtTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %58, i32 noundef %59)
  store i32 %60, ptr %14, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %57, %46
  %62 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %62, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %86

63:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %64 = load ptr, ptr %13, align 8, !tbaa !9
  %65 = load ptr, ptr %12, align 8, !tbaa !9
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE11getHeadTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %65, i32 noundef %66)
  %68 = load ptr, ptr %12, align 8, !tbaa !9
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %68, i32 noundef %69)
  %71 = call noundef i32 @_ZN11SegmentTreeIiiE5queryEii(ptr noundef nonnull align 8 dereferenceable(168) %64, i32 noundef %67, i32 noundef %70)
  store i32 %71, ptr %17, align 4, !tbaa !5
  %72 = load i32, ptr %17, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 2000000000
  br i1 %73, label %74, label %78

74:                                               ; preds = %63
  %75 = load ptr, ptr %12, align 8, !tbaa !9
  %76 = load i32, ptr %17, align 4, !tbaa !5
  %77 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE13getNodeAtTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %75, i32 noundef %76)
  store i32 %77, ptr %14, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %74, %63
  %79 = load ptr, ptr %12, align 8, !tbaa !9
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = call noundef i32 @_ZNK23HeavyLightDecompositionIiE7getHeadEi(ptr noundef nonnull align 8 dereferenceable(92) %79, i32 noundef %80)
  store i32 %81, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %82

82:                                               ; preds = %78
  br label %83

83:                                               ; preds = %82, %37
  br label %18, !llvm.loop !11

84:                                               ; preds = %32
  %85 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %85, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %86

86:                                               ; preds = %84, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %87 = load i32, ptr %7, align 4
  ret i32 %87
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE7isLightEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12WeightedTreeIiE9getParentEi(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE15inSameHeavyPathEii(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN11SegmentTreeIiiE5queryEii(ptr noundef nonnull align 8 dereferenceable(168), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE13getNodeAtTimeEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE11getHeadTimeEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE7getHeadEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z7queryUpiiRKSt6vectorIiSaIiEERK12WeightedTreeIiERK23HeavyLightDecompositionIiER11SegmentTreeIiiE(i32 noundef %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(92) %4, ptr noundef nonnull align 8 dereferenceable(168) %5) local_unnamed_addr #0 {
  %7 = sext i32 %0 to i64
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %7) #2
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 1
  %spec.select41 = select i1 %10, i32 %0, i32 2000000000
  %11 = icmp eq i32 %0, %1
  br i1 %11, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %6, %31
  %spec.select43 = phi i32 [ %spec.select, %31 ], [ %spec.select41, %6 ]
  %.03242 = phi i32 [ %.1, %31 ], [ %0, %6 ]
  %12 = tail call noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE7isLightEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %.03242)
  br i1 %12, label %13, label %15

13:                                               ; preds = %.lr.ph
  %14 = tail call noundef i32 @_ZNK12WeightedTreeIiE9getParentEi(ptr noundef nonnull align 8 dereferenceable(80) %3, i32 noundef %.03242)
  br label %31

15:                                               ; preds = %.lr.ph
  %16 = tail call noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE15inSameHeavyPathEii(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %.03242, i32 noundef %1)
  br i1 %16, label %17, label %23

17:                                               ; preds = %15
  %18 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %1)
  %19 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %.03242)
  %20 = tail call noundef i32 @_ZN11SegmentTreeIiiE5queryEii(ptr noundef nonnull align 8 dereferenceable(168) %5, i32 noundef %18, i32 noundef %19)
  %.not38 = icmp eq i32 %20, 2000000000
  br i1 %.not38, label %.loopexit, label %21

21:                                               ; preds = %17
  %22 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE13getNodeAtTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %20)
  br label %.loopexit

23:                                               ; preds = %15
  %24 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE11getHeadTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %.03242)
  %25 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %.03242)
  %26 = tail call noundef i32 @_ZN11SegmentTreeIiiE5queryEii(ptr noundef nonnull align 8 dereferenceable(168) %5, i32 noundef %24, i32 noundef %25)
  %.not = icmp eq i32 %26, 2000000000
  br i1 %.not, label %29, label %27

27:                                               ; preds = %23
  %28 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE13getNodeAtTimeEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %26)
  br label %29

29:                                               ; preds = %27, %23
  %.3 = phi i32 [ %28, %27 ], [ %spec.select43, %23 ]
  %30 = tail call noundef i32 @_ZNK23HeavyLightDecompositionIiE7getHeadEi(ptr noundef nonnull align 8 dereferenceable(92) %4, i32 noundef %.03242)
  br label %31

31:                                               ; preds = %29, %13
  %.4 = phi i32 [ %spec.select43, %13 ], [ %.3, %29 ]
  %.1 = phi i32 [ %14, %13 ], [ %30, %29 ]
  %32 = sext i32 %.1 to i64
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %32) #2
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp eq i32 %34, 1
  %spec.select = select i1 %35, i32 %.1, i32 %.4
  %36 = icmp eq i32 %.1, %1
  br i1 %36, label %.loopexit, label %.lr.ph, !llvm.loop !9

.loopexit:                                        ; preds = %31, %6, %17, %21
  %.0 = phi i32 [ %22, %21 ], [ %spec.select43, %17 ], [ %spec.select41, %6 ], [ %spec.select, %31 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE7isLightEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12WeightedTreeIiE9getParentEi(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK23HeavyLightDecompositionIiE15inSameHeavyPathEii(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN11SegmentTreeIiiE5queryEii(ptr noundef nonnull align 8 dereferenceable(168), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE12getStartTimeEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE13getNodeAtTimeEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE11getHeadTimeEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK23HeavyLightDecompositionIiE7getHeadEi(ptr noundef nonnull align 8 dereferenceable(92), i32 noundef) local_unnamed_addr #1 align 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 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 #2 = { 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"}


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