; LLVM IR from vczh/herodb :: Kernel/Source/Vlpp.ll (ZN2vl7parsing16ParsingTreeArray10RemoveItemEl)

; 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.vl::Ptr.46" = type { ptr, ptr, ptr, ptr }
%"class.vl::parsing::ParsingTreeArray" = type { %"class.vl::parsing::ParsingTreeNode.base", %"class.vl::reflection::Description.base.610", %"class.vl::ObjectString", %"class.vl::collections::List.598", %"class.vl::reflection::DescriptableObject" }
%"class.vl::parsing::ParsingTreeNode.base" = type { %"class.vl::Object", %"class.vl::reflection::Description.base.597", %"struct.vl::parsing::ParsingTextRange", ptr, %"class.vl::collections::List.598" }
%"class.vl::Object" = type { ptr }
%"class.vl::reflection::Description.base.597" = type { ptr }
%"struct.vl::parsing::ParsingTextRange" = type { %"struct.vl::parsing::ParsingTextPos", %"struct.vl::parsing::ParsingTextPos", i64 }
%"struct.vl::parsing::ParsingTextPos" = type { i64, i64, i64 }
%"class.vl::reflection::Description.base.610" = type { ptr }
%"class.vl::ObjectString" = type { %"class.vl::Object", ptr, ptr, i64, i64, i64 }
%"class.vl::collections::List.598" = type { %"class.vl::collections::ListBase.base.604", %"class.vl::collections::IEnumerable.602" }
%"class.vl::collections::ListBase.base.604" = type <{ %"class.vl::collections::ArrayBase.base.603", i64, i8 }>
%"class.vl::collections::ArrayBase.base.603" = type { %"class.vl::collections::ListStore.601", ptr, i64 }
%"class.vl::collections::ListStore.601" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.602" = type { %"class.vl::Interface" }
%"class.vl::Interface" = type { ptr }
%"class.vl::reflection::DescriptableObject" = type { ptr, i64, ptr, i64, ptr, %"class.vl::Ptr.12" }
%"class.vl::Ptr.12" = type { ptr, ptr, ptr, ptr }

; 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl7parsing15ParsingTreeNode17BeforeRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl7parsing15ParsingTreeNode16AfterRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl7parsing16ParsingTreeArray10RemoveItemEl(ptr noundef nonnull align 8 dereferenceable(232) %0, i64 noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca %"class.vl::Ptr.46", align 8
  %7 = alloca %"class.vl::Ptr.46", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.vl::Ptr.46", align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = icmp sle i64 0, %13
  br i1 %14, label %15, label %51

15:                                               ; preds = %2
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = getelementptr inbounds %"class.vl::parsing::ParsingTreeArray", ptr %12, i32 0, i32 3
  %18 = call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_3PtrINS_7parsing15ParsingTreeNodeEEEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %19 = icmp slt i64 %16, %18
  br i1 %19, label %20, label %51

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #3
  %21 = getelementptr inbounds %"class.vl::parsing::ParsingTreeArray", ptr %12, i32 0, i32 3
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33) %21, i64 noundef %22)
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %23)
  invoke void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %24 unwind label %34

24:                                               ; preds = %20
  %25 = invoke noundef zeroext i1 @_ZN2vl7parsing15ParsingTreeNode17BeforeRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128) %12, ptr noundef %7)
          to label %26 unwind label %38

26:                                               ; preds = %24
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #3
  br i1 %25, label %27, label %46

27:                                               ; preds = %26
  %28 = getelementptr inbounds %"class.vl::parsing::ParsingTreeArray", ptr %12, i32 0, i32 3
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = invoke noundef zeroext i1 @_ZN2vl11collections8ListBaseINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_E8RemoveAtEl(ptr noundef nonnull align 8 dereferenceable(33) %28, i64 noundef %29)
          to label %31 unwind label %34

31:                                               ; preds = %27
  invoke void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %32 unwind label %34

32:                                               ; preds = %31
  invoke void @_ZN2vl7parsing15ParsingTreeNode16AfterRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128) %12, ptr noundef %10)
          to label %33 unwind label %42

33:                                               ; preds = %32
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #3
  store i1 true, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %47

34:                                               ; preds = %31, %27, %20
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %8, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %9, align 4
  br label %50

38:                                               ; preds = %24
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %8, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %9, align 4
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #3
  br label %50

42:                                               ; preds = %32
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %8, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %9, align 4
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #3
  br label %50

46:                                               ; preds = %26
  store i32 0, ptr %11, align 4
  br label %47

47:                                               ; preds = %46, %33
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #3
  %48 = load i32, ptr %11, align 4
  switch i32 %48, label %59 [
    i32 0, label %49
    i32 1, label %52
  ]

49:                                               ; preds = %47
  br label %51

50:                                               ; preds = %42, %38, %34
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #3
  br label %54

51:                                               ; preds = %49, %15, %2
  store i1 false, ptr %3, align 1
  br label %52

52:                                               ; preds = %51, %47
  %53 = load i1, ptr %3, align 1
  ret i1 %53

54:                                               ; preds = %50
  %55 = load ptr, ptr %8, align 8
  %56 = load i32, ptr %9, align 4
  %57 = insertvalue { ptr, i32 } poison, ptr %55, 0
  %58 = insertvalue { ptr, i32 } %57, i32 %56, 1
  resume { ptr, i32 } %58

59:                                               ; preds = %47
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl11collections8ListBaseINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_E8RemoveAtEl(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}


; 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.vl::Ptr.46" = type { ptr, ptr, ptr, ptr }

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl7parsing15ParsingTreeNode17BeforeRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl7parsing15ParsingTreeNode16AfterRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl7parsing16ParsingTreeArray10RemoveItemEl(ptr noundef nonnull align 8 dereferenceable(232) %0, i64 noundef %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.vl::Ptr.46", align 8
  %4 = alloca %"class.vl::Ptr.46", align 8
  %5 = alloca %"class.vl::Ptr.46", align 8
  %6 = icmp sgt i64 %1, -1
  br i1 %6, label %7, label %26

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 184
  %9 = tail call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_3PtrINS_7parsing15ParsingTreeNodeEEEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = icmp sgt i64 %9, %1
  br i1 %10, label %11, label %26

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #3
  %12 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33) %8, i64 noundef %1)
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %12)
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 8 dereferenceable(32) %3)
  %13 = invoke noundef zeroext i1 @_ZN2vl7parsing15ParsingTreeNode17BeforeRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull %4)
          to label %14 unwind label %20

14:                                               ; preds = %11
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #3
  br i1 %13, label %15, label %.thread

.thread:                                          ; preds = %14
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #3
  br label %26

15:                                               ; preds = %14
  %16 = invoke noundef zeroext i1 @_ZN2vl11collections8ListBaseINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_E8RemoveAtEl(ptr noundef nonnull align 8 dereferenceable(33) %8, i64 noundef %1)
          to label %17 unwind label %18

17:                                               ; preds = %15
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %3)
  invoke void @_ZN2vl7parsing15ParsingTreeNode16AfterRemoveChildENS_3PtrIS1_EE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull %5)
          to label %24 unwind label %22

18:                                               ; preds = %15
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %25

20:                                               ; preds = %11
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #3
  br label %25

22:                                               ; preds = %17
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  br label %25

24:                                               ; preds = %17
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #3
  br label %26

25:                                               ; preds = %22, %20, %18
  %.pn = phi { ptr, i32 } [ %23, %22 ], [ %19, %18 ], [ %21, %20 ]
  call void @_ZN2vl3PtrINS_7parsing15ParsingTreeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #3
  resume { ptr, i32 } %.pn

26:                                               ; preds = %2, %7, %.thread, %24
  %.1 = phi i1 [ true, %24 ], [ false, %.thread ], [ false, %7 ], [ false, %2 ]
  ret i1 %.1
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl11collections8ListBaseINS_3PtrINS_7parsing15ParsingTreeNodeEEEPS4_E8RemoveAtEl(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass