; LLVM IR from HiroIshida/tinyfk :: urdf_parser/tinyxml/tinyxml.ll (ZN9TiXmlNode11RemoveChildEPS_)

; 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.TiXmlNode = type { %class.TiXmlBase, ptr, i32, ptr, ptr, %"class.std::__cxx11::basic_string", ptr, ptr }
%class.TiXmlBase = type { ptr, %struct.TiXmlCursor, ptr }
%struct.TiXmlCursor = type { i32, i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str.2 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN9TiXmlNode11RemoveChildEPS_ = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN9TiXmlNode11RemoveChildEPS_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  store i1 false, ptr %3, align 1
  br label %60

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.TiXmlNode, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp ne ptr %13, %6
  br i1 %14, label %15, label %16

15:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 343, ptr noundef @__PRETTY_FUNCTION__._ZN9TiXmlNode11RemoveChildEPS_) #2
  unreachable

16:                                               ; preds = %10
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.TiXmlNode, ptr %17, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !18
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %29

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.TiXmlNode, ptr %22, i32 0, i32 6
  %24 = load ptr, ptr %23, align 8, !tbaa !19
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.TiXmlNode, ptr %25, i32 0, i32 7
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = getelementptr inbounds %class.TiXmlNode, ptr %27, i32 0, i32 6
  store ptr %24, ptr %28, align 8, !tbaa !19
  br label %34

29:                                               ; preds = %16
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.TiXmlNode, ptr %30, i32 0, i32 6
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = getelementptr inbounds %class.TiXmlNode, ptr %6, i32 0, i32 4
  store ptr %32, ptr %33, align 8, !tbaa !20
  br label %34

34:                                               ; preds = %29, %21
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.TiXmlNode, ptr %35, i32 0, i32 6
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %47

39:                                               ; preds = %34
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.TiXmlNode, ptr %40, i32 0, i32 7
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %class.TiXmlNode, ptr %43, i32 0, i32 6
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  %46 = getelementptr inbounds %class.TiXmlNode, ptr %45, i32 0, i32 7
  store ptr %42, ptr %46, align 8, !tbaa !18
  br label %52

47:                                               ; preds = %34
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.TiXmlNode, ptr %48, i32 0, i32 7
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  %51 = getelementptr inbounds %class.TiXmlNode, ptr %6, i32 0, i32 3
  store ptr %50, ptr %51, align 8, !tbaa !21
  br label %52

52:                                               ; preds = %47, %39
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %59, label %55

55:                                               ; preds = %52
  %56 = load ptr, ptr %53, align 8, !tbaa !22
  %57 = getelementptr inbounds ptr, ptr %56, i64 1
  %58 = load ptr, ptr %57, align 8
  call void %58(ptr noundef nonnull align 8 dereferenceable(104) %53) #3
  br label %59

59:                                               ; preds = %55, %52
  store i1 true, ptr %3, align 1
  br label %60

60:                                               ; preds = %59, %9
  %61 = load i1, ptr %3, align 1
  ret i1 %61
}

attributes #0 = { noreturn 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 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 #2 = { noreturn nounwind }
attributes #3 = { 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 24}
!10 = !{!"_ZTS9TiXmlNode", !11, i64 0, !6, i64 24, !14, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !6, i64 88, !6, i64 96}
!11 = !{!"_ZTS9TiXmlBase", !12, i64 8, !6, i64 16}
!12 = !{!"_ZTS11TiXmlCursor", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN9TiXmlNode8NodeTypeE", !7, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!10, !6, i64 96}
!19 = !{!10, !6, i64 88}
!20 = !{!10, !6, i64 48}
!21 = !{!10, !6, i64 40}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !8, i64 0}


; 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"

@.str.2 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN9TiXmlNode11RemoveChildEPS_ = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN9TiXmlNode11RemoveChildEPS_(ptr noundef nonnull writeonly align 8 dereferenceable(104) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %.not = icmp ne ptr %1, null
  br i1 %.not, label %3, label %19

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not17 = icmp eq ptr %5, %0
  br i1 %.not17, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 343, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN9TiXmlNode11RemoveChildEPS_) #2
  unreachable

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %1, i64 96
  %9 = load ptr, ptr %8, align 8, !tbaa !17
  %.not18 = icmp eq ptr %9, null
  %10 = getelementptr inbounds i8, ptr %1, i64 88
  %11 = load ptr, ptr %10, align 8, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = getelementptr inbounds i8, ptr %9, i64 88
  %.sink = select i1 %.not18, ptr %12, ptr %13
  store ptr %11, ptr %.sink, align 8, !tbaa !19
  %.not19 = icmp eq ptr %11, null
  %14 = getelementptr inbounds i8, ptr %11, i64 96
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %.sink20 = select i1 %.not19, ptr %15, ptr %14
  store ptr %9, ptr %.sink20, align 8, !tbaa !19
  %16 = load ptr, ptr %1, align 8, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load ptr, ptr %17, align 8
  tail call void %18(ptr noundef nonnull align 8 dereferenceable(104) %1) #3
  br label %19

19:                                               ; preds = %2, %7
  ret i1 %.not
}

attributes #0 = { noreturn 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 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 #2 = { noreturn nounwind }
attributes #3 = { 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, !12, i64 24}
!6 = !{!"_ZTS9TiXmlNode", !7, i64 0, !12, i64 24, !13, i64 32, !12, i64 40, !12, i64 48, !14, i64 56, !12, i64 88, !12, i64 96}
!7 = !{!"_ZTS9TiXmlBase", !8, i64 8, !12, i64 16}
!8 = !{!"_ZTS11TiXmlCursor", !9, i64 0, !9, i64 4}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!"_ZTSN9TiXmlNode8NodeTypeE", !10, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !10, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!16 = !{!"long", !10, i64 0}
!17 = !{!6, !12, i64 96}
!18 = !{!6, !12, i64 88}
!19 = !{!12, !12, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !11, i64 0}


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