; LLVM IR from ETH3D/dataset-pipeline :: thirdparty/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, ptr, ptr, ptr, %"class.tinyxml2::MemPoolT", %"class.tinyxml2::MemPoolT.0", %"class.tinyxml2::MemPoolT.2", %"class.tinyxml2::MemPoolT.4" }
%"class.tinyxml2::XMLNode" = type { ptr, ptr, ptr, %"class.tinyxml2::StrPair", ptr, ptr, ptr, ptr, ptr }
%"class.tinyxml2::StrPair" = type { i32, ptr, ptr }
%"class.tinyxml2::MemPoolT" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::MemPool" = type { ptr }
%"class.tinyxml2::DynArray" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT.0" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.1", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::DynArray.1" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT.2" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.3", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::DynArray.3" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::MemPoolT.4" = type { %"class.tinyxml2::MemPool", %"class.tinyxml2::DynArray.5", ptr, i32, i32, i32, i32 }
%"class.tinyxml2::DynArray.5" = 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(88)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8tinyxml211XMLDocument5ClearEv(ptr noundef nonnull align 8 dereferenceable(640) %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(88) %3)
  %4 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 3
  store i32 0, ptr %4, align 4, !tbaa !9
  %5 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 5
  store ptr null, ptr %5, align 8, !tbaa !26
  %6 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 6
  store ptr null, ptr %6, align 8, !tbaa !27
  %7 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 7
  %8 = load ptr, ptr %7, align 8, !tbaa !28
  %9 = icmp eq ptr %8, null
  br i1 %9, label %11, label %10

10:                                               ; preds = %1
  call void @_ZdaPv(ptr noundef %8) #2
  br label %11

11:                                               ; preds = %10, %1
  %12 = getelementptr inbounds %"class.tinyxml2::XMLDocument", ptr %3, i32 0, i32 7
  store ptr null, ptr %12, align 8, !tbaa !28
  ret void
}

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 = { 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 = !{!10, !15, i64 92}
!10 = !{!"_ZTSN8tinyxml211XMLDocumentE", !11, i64 0, !14, i64 88, !14, i64 89, !15, i64 92, !16, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !17, i64 128, !20, i64 256, !22, i64 384, !24, i64 512}
!11 = !{!"_ZTSN8tinyxml27XMLNodeE", !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!12 = !{!"_ZTSN8tinyxml27StrPairE", !13, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN8tinyxml28XMLErrorE", !7, i64 0}
!16 = !{!"_ZTSN8tinyxml210WhitespaceE", !7, i64 0}
!17 = !{!"_ZTSN8tinyxml28MemPoolTILi104EEE", !18, i64 0, !19, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!18 = !{!"_ZTSN8tinyxml27MemPoolE"}
!19 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi104EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!20 = !{!"_ZTSN8tinyxml28MemPoolTILi72EEE", !18, i64 0, !21, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!21 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi72EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!22 = !{!"_ZTSN8tinyxml28MemPoolTILi96EEE", !18, i64 0, !23, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!23 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi96EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!24 = !{!"_ZTSN8tinyxml28MemPoolTILi88EEE", !18, i64 0, !25, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!25 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi88EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!26 = !{!10, !6, i64 104}
!27 = !{!10, !6, i64 112}
!28 = !{!10, !6, i64 120}


; 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(88)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8tinyxml211XMLDocument5ClearEv(ptr noundef nonnull align 8 dereferenceable(640) %0) local_unnamed_addr #1 align 2 {
  tail call void @_ZN8tinyxml27XMLNode14DeleteChildrenEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = getelementptr inbounds i8, ptr %0, i64 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  %5 = load ptr, ptr %4, align 8, !tbaa !25
  %6 = icmp eq ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %1
  tail call void @_ZdaPv(ptr noundef nonnull %5) #3
  br label %8

8:                                                ; preds = %7, %1
  store ptr null, ptr %4, align 8, !tbaa !25
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !14, i64 92}
!6 = !{!"_ZTSN8tinyxml211XMLDocumentE", !7, i64 0, !13, i64 88, !13, i64 89, !14, i64 92, !15, i64 96, !8, i64 104, !8, i64 112, !8, i64 120, !16, i64 128, !19, i64 256, !21, i64 384, !23, i64 512}
!7 = !{!"_ZTSN8tinyxml27XMLNodeE", !8, i64 8, !8, i64 16, !11, i64 24, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN8tinyxml27StrPairE", !12, i64 0, !8, i64 8, !8, i64 16}
!12 = !{!"int", !9, i64 0}
!13 = !{!"bool", !9, i64 0}
!14 = !{!"_ZTSN8tinyxml28XMLErrorE", !9, i64 0}
!15 = !{!"_ZTSN8tinyxml210WhitespaceE", !9, i64 0}
!16 = !{!"_ZTSN8tinyxml28MemPoolTILi104EEE", !17, i64 0, !18, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!17 = !{!"_ZTSN8tinyxml27MemPoolE"}
!18 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi104EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!19 = !{!"_ZTSN8tinyxml28MemPoolTILi72EEE", !17, i64 0, !20, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!20 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi72EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!21 = !{!"_ZTSN8tinyxml28MemPoolTILi96EEE", !17, i64 0, !22, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!22 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi96EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!23 = !{!"_ZTSN8tinyxml28MemPoolTILi88EEE", !17, i64 0, !24, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!24 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi88EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!25 = !{!6, !8, i64 120}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass