; LLVM IR from Xiangyu-Hu/SPHinXsys :: src/shared/tools/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
  br label %6

6:                                                ; preds = %2
  br label %7

7:                                                ; preds = %6
  br label %8

8:                                                ; preds = %7
  br label %9

9:                                                ; preds = %8
  br label %10

10:                                               ; preds = %9
  br label %11

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

16:                                               ; preds = %11
  %17 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 5
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %18, i32 0, i32 8
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 5
  store ptr %20, ptr %21, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %16, %11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 6
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = icmp eq ptr %23, %25
  br i1 %26, label %27, label %33

27:                                               ; preds = %22
  %28 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %29, i32 0, i32 7
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %5, i32 0, i32 6
  store ptr %31, ptr %32, align 8, !tbaa !14
  br label %33

33:                                               ; preds = %27, %22
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %34, i32 0, i32 7
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %46

38:                                               ; preds = %33
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %39, i32 0, i32 8
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %42, i32 0, i32 7
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %44, i32 0, i32 8
  store ptr %41, ptr %45, align 8, !tbaa !13
  br label %46

46:                                               ; preds = %38, %33
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %47, i32 0, i32 8
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %59

51:                                               ; preds = %46
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %52, i32 0, i32 7
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %55, i32 0, i32 8
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %57, i32 0, i32 7
  store ptr %54, ptr %58, align 8, !tbaa !15
  br label %59

59:                                               ; preds = %51, %46
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %60, i32 0, i32 8
  store ptr null, ptr %61, align 8, !tbaa !13
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %62, i32 0, i32 7
  store ptr null, ptr %63, align 8, !tbaa !15
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %64, i32 0, i32 2
  store ptr null, ptr %65, 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
  %.not15 = icmp eq ptr %.pre, null
  br i1 %.not15, 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
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass