; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/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", %"class.tinyxml2::StrPair", i32, ptr, i32, %"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", i32, ptr, 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(104)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(704)) #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 = { 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, !6, i64 176}
!10 = !{!"_ZTSN8tinyxml211XMLDocumentE", !11, i64 0, !14, i64 104, !14, i64 105, !15, i64 108, !16, i64 112, !12, i64 120, !12, i64 144, !13, i64 168, !6, i64 176, !13, i64 184, !17, i64 192, !20, i64 320, !22, i64 448, !24, i64 576}
!11 = !{!"_ZTSN8tinyxml27XMLNodeE", !6, i64 8, !6, i64 16, !12, i64 24, !13, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!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 = !{!"_ZTSN8tinyxml28MemPoolTILi120EEE", !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_8MemPoolTILi120EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!20 = !{!"_ZTSN8tinyxml28MemPoolTILi80EEE", !18, i64 0, !21, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!21 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi80EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!22 = !{!"_ZTSN8tinyxml28MemPoolTILi112EEE", !18, i64 0, !23, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!23 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi112EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}
!24 = !{!"_ZTSN8tinyxml28MemPoolTILi104EEE", !18, i64 0, !25, i64 8, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!25 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi104EE5BlockELi10EEE", !6, i64 0, !7, i64 8, !13, i64 88, !13, i64 92}


; 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(704) %0) local_unnamed_addr #1 align 2 {
  tail call void @_ZN8tinyxml27XMLNode14DeleteChildrenEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  tail call void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(704) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 176
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %6, label %5

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

6:                                                ; preds = %5, %1
  store ptr null, ptr %2, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml211XMLDocument10ClearErrorEv(ptr noundef nonnull align 8 dereferenceable(704)) 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 = { 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, !8, i64 176}
!6 = !{!"_ZTSN8tinyxml211XMLDocumentE", !7, i64 0, !13, i64 104, !13, i64 105, !14, i64 108, !15, i64 112, !11, i64 120, !11, i64 144, !12, i64 168, !8, i64 176, !12, i64 184, !16, i64 192, !19, i64 320, !21, i64 448, !23, i64 576}
!7 = !{!"_ZTSN8tinyxml27XMLNodeE", !8, i64 8, !8, i64 16, !11, i64 24, !12, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96}
!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 = !{!"_ZTSN8tinyxml28MemPoolTILi120EEE", !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_8MemPoolTILi120EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!19 = !{!"_ZTSN8tinyxml28MemPoolTILi80EEE", !17, i64 0, !20, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!20 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi80EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!21 = !{!"_ZTSN8tinyxml28MemPoolTILi112EEE", !17, i64 0, !22, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!22 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi112EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}
!23 = !{!"_ZTSN8tinyxml28MemPoolTILi104EEE", !17, i64 0, !24, i64 8, !8, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!24 = !{!"_ZTSN8tinyxml28DynArrayIPNS_8MemPoolTILi104EE5BlockELi10EEE", !8, i64 0, !9, i64 8, !12, i64 88, !12, i64 92}


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