; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/tinyxml2.ll (ZN8tinyxml27XMLNode6UnlinkEPS0_)

; 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::XMLNode" = type { ptr, ptr, ptr, %"class.tinyxml2::StrPair", i32, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.tinyxml2::StrPair" = type { i32, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8tinyxml27XMLNode6UnlinkEPS0_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 5
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp eq ptr %6, %8
  br i1 %9, label %10, label %16

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 5
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %12, i32 0, i32 8
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 5
  store ptr %14, ptr %15, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %10, %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 6
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = icmp eq ptr %17, %19
  br i1 %20, label %21, label %27

21:                                               ; preds = %16
  %22 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %23, i32 0, i32 7
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 6
  store ptr %25, ptr %26, align 8, !tbaa !14
  br label %27

27:                                               ; preds = %21, %16
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %28, i32 0, i32 7
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %40

32:                                               ; preds = %27
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %33, i32 0, i32 8
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %36, i32 0, i32 7
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %38, i32 0, i32 8
  store ptr %35, ptr %39, align 8, !tbaa !13
  br label %40

40:                                               ; preds = %32, %27
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %41, i32 0, i32 8
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %53

45:                                               ; preds = %40
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %46, i32 0, i32 7
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %49, i32 0, i32 8
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %51, i32 0, i32 7
  store ptr %48, ptr %52, align 8, !tbaa !15
  br label %53

53:                                               ; preds = %45, %40
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %54, i32 0, i32 2
  store ptr null, ptr %55, align 8, !tbaa !16
  ret void
}

attributes #0 = { 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" }

!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 56}
!10 = !{!"_ZTSN8tinyxml27XMLNodeE", !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!11 = !{!"_ZTSN8tinyxml27StrPairE", !12, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 80}
!14 = !{!10, !6, i64 64}
!15 = !{!10, !6, i64 72}
!16 = !{!10, !6, i64 16}


; 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 nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN8tinyxml27XMLNode6UnlinkEPS0_(ptr nocapture noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, %1
  br i1 %5, label %6, label %9

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %4, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  store ptr %8, ptr %3, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %6, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = icmp eq ptr %11, %1
  br i1 %12, label %13, label %16

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %11, i64 72
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  store ptr %15, ptr %10, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %13, %9
  %17 = getelementptr inbounds i8, ptr %1, i64 72
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %.not = icmp eq ptr %18, null
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 80
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !12
  br i1 %.not, label %._crit_edge, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %18, i64 80
  store ptr %.pre, ptr %20, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %16, %19
  %.not13 = icmp eq ptr %.pre, null
  br i1 %.not13, label %23, label %21

21:                                               ; preds = %._crit_edge
  %22 = getelementptr inbounds i8, ptr %.pre, i64 72
  store ptr %18, ptr %22, align 8, !tbaa !14
  br label %23

23:                                               ; preds = %21, %._crit_edge
  %24 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr null, ptr %24, align 8, !tbaa !15
  ret void
}

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

!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, !7, i64 56}
!6 = !{!"_ZTSN8tinyxml27XMLNodeE", !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN8tinyxml27StrPairE", !11, i64 0, !7, i64 8, !7, i64 16}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 80}
!13 = !{!6, !7, i64 64}
!14 = !{!6, !7, i64 72}
!15 = !{!6, !7, i64 16}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass