; LLVM IR from facebookresearch/habitat-sim :: src/deps/tinyxml2/tinyxml2.ll (ZN8tinyxml211XMLDocument5ClearEv)

; 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.tinyxml2::XMLDocument" = type { %"class.tinyxml2::XMLNode", i8, i8, i32, i32, %"class.tinyxml2::StrPair", i32, ptr, i32, i32, %"class.tinyxml2::DynArray", %"class.tinyxml2::MemPoolT", %"class.tinyxml2::MemPoolT.1", %"class.tinyxml2::MemPoolT.3", %"class.tinyxml2::MemPoolT.5" }
%"class.tinyxml2::XMLNode" = type { ptr, ptr, ptr, %"class.tinyxml2::StrPair", i32, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.tinyxml2::StrPair" = type { i32, ptr, ptr }
%"class.tinyxml2::DynArray" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.0", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::MemPool" = type { ptr }
%"class.tinyxml2::DynArray.0" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT.1" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.2", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::DynArray.2" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT.3" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.4", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::DynArray.4" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT.5" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.6", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::DynArray.6" = type { ptr, [10 x ptr], i32, i32 }

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml27XMLNode14DeleteChildrenEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8tinyxml211XMLDocument5ClearEv(ptr noundef nonnull align 8 dereferenceable(776) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  call void @_ZN8tinyxml27XMLNode14DeleteChildrenEv(ptr noundef nonnull align 8 dereferenceable(104) %3)
  br label %4

4:                                                ; preds = %8, %1
  %5 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 10
  %6 = call noundef i32 @_ZNK8tinyxml28DynArrayIPNS_7XMLNodeELi10EE4SizeEv(ptr noundef nonnull align 8 dereferenceable(96) %5)
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %12

8:                                                ; preds = %4
  %9 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 10
  %10 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8tinyxml28DynArrayIPNS_7XMLNodeELi10EEixEi(ptr noundef nonnull align 8 dereferenceable(96) %9, i32 noundef 0)
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN8tinyxml211XMLDocument10DeleteNodeEPNS_7XMLNodeE(ptr noundef nonnull align 8 dereferenceable(776) %3, ptr noundef %11)
  br label %4, !llvm.loop !9

12:                                               ; preds = %4
  call void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(776) %3)
  %13 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 7
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = icmp eq ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @_ZdaPv(ptr noundef %14) #3
  br label %17

17:                                               ; preds = %16, %12
  %18 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 7
  store ptr null, ptr %18, align 8, !tbaa !11
  %19 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 9
  store i32 0, ptr %19, align 4, !tbaa !29
  ret void
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(776)) #1 align 2

attributes #0 = { nobuiltin 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 #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 = { builtin 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 152}
!12 = !{!"_ZTSN8tinyxml211XMLDocumentE", !13, i64 0, !16, i64 104, !16, i64 105, !17, i64 108, !18, i64 112, !14, i64 120, !15, i64 144, !6, i64 152, !15, i64 160, !15, i64 164, !19, i64 168, !20, i64 264, !23, i64 392, !25, i64 520, !27, i64 648}
!13 = !{!"_ZTSN8tinyxml27XMLNodeE", !6, i64 8, !6, i64 16, !14, i64 24, !15, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!14 = !{!"_ZTSN8tinyxml27StrPairE", !15, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSN8tinyxml28XMLErrorE", !7, i64 0}
!18 = !{!"_ZTSN8tinyxml210WhitespaceE", !7, i64 0}
!19 = !{!"_ZTSN8tinyxml28DynArrayIPNS_7XMLNodeELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!20 = !{!"_ZTSN8tinyxml28MemPoolTILi120EEE", !21, i64 0, !22, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!21 = !{!"_ZTSN8tinyxml27MemPoolE"}
!22 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi120EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!23 = !{!"_ZTSN8tinyxml28MemPoolTILi80EEE", !21, i64 0, !24, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!24 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi80EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!25 = !{!"_ZTSN8tinyxml28MemPoolTILi112EEE", !21, i64 0, !26, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!26 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi112EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!27 = !{!"_ZTSN8tinyxml28MemPoolTILi104EEE", !21, i64 0, !28, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!28 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi104EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!29 = !{!12, !15, i64 164}


; 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml27XMLNode14DeleteChildrenEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8tinyxml211XMLDocument5ClearEv(ptr noundef nonnull align 8 dereferenceable(776) %0) local_unnamed_addr #1 align 2 {
  tail call void @_ZN8tinyxml27XMLNode14DeleteChildrenEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 168
  %3 = tail call noundef i32 @_ZNK8tinyxml28DynArrayIPNS_7XMLNodeELi10EE4SizeEv(ptr noundef nonnull align 8 dereferenceable(96) %2)
  %.not1 = icmp eq i32 %3, 0
  br i1 %.not1, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8tinyxml28DynArrayIPNS_7XMLNodeELi10EEixEi(ptr noundef nonnull align 8 dereferenceable(96) %2, i32 noundef 0)
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @_ZN8tinyxml211XMLDocument10DeleteNodeEPNS_7XMLNodeE(ptr noundef nonnull align 8 dereferenceable(776) %0, ptr noundef %5)
  %6 = tail call noundef i32 @_ZNK8tinyxml28DynArrayIPNS_7XMLNodeELi10EE4SizeEv(ptr noundef nonnull align 8 dereferenceable(96) %2)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %1
  tail call void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(776) %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 152
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = icmp eq ptr %8, null
  br i1 %9, label %11, label %10

10:                                               ; preds = %._crit_edge
  tail call void @_ZdaPv(ptr noundef nonnull %8) #3
  br label %11

11:                                               ; preds = %10, %._crit_edge
  store ptr null, ptr %7, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %0, i64 164
  store i32 0, ptr %12, align 4, !tbaa !29
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8tinyxml28DynArrayIPNS_7XMLNodeELi10EE4SizeEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(776)) local_unnamed_addr #1 align 2

attributes #0 = { nobuiltin 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 #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 = { builtin 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 152}
!12 = !{!"_ZTSN8tinyxml211XMLDocumentE", !13, i64 0, !16, i64 104, !16, i64 105, !17, i64 108, !18, i64 112, !14, i64 120, !15, i64 144, !6, i64 152, !15, i64 160, !15, i64 164, !19, i64 168, !20, i64 264, !23, i64 392, !25, i64 520, !27, i64 648}
!13 = !{!"_ZTSN8tinyxml27XMLNodeE", !6, i64 8, !6, i64 16, !14, i64 24, !15, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!14 = !{!"_ZTSN8tinyxml27StrPairE", !15, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSN8tinyxml28XMLErrorE", !7, i64 0}
!18 = !{!"_ZTSN8tinyxml210WhitespaceE", !7, i64 0}
!19 = !{!"_ZTSN8tinyxml28DynArrayIPNS_7XMLNodeELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!20 = !{!"_ZTSN8tinyxml28MemPoolTILi120EEE", !21, i64 0, !22, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!21 = !{!"_ZTSN8tinyxml27MemPoolE"}
!22 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi120EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!23 = !{!"_ZTSN8tinyxml28MemPoolTILi80EEE", !21, i64 0, !24, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!24 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi80EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!25 = !{!"_ZTSN8tinyxml28MemPoolTILi112EEE", !21, i64 0, !26, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!26 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi112EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!27 = !{!"_ZTSN8tinyxml28MemPoolTILi104EEE", !21, i64 0, !28, i64 8, !6, i64 104, !15, i64 112, !15, i64 116, !15, i64 120, !15, i64 124}
!28 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi104EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!29 = !{!12, !15, i64 164}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass