; LLVM IR from simbody/simbody :: SimTKcommon/src/tinyxml.ll (ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_)

; 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.SimTK::TiXmlNode" = type { %"class.SimTK::TiXmlBase", ptr, i32, ptr, ptr, %"class.SimTK::String", ptr, ptr }
%"class.SimTK::TiXmlBase" = type { ptr, %"struct.SimTK::TiXmlCursor", ptr }
%"struct.SimTK::TiXmlCursor" = type { i32, i32 }
%"class.SimTK::String" = type { %"class.std::__cxx11::basic_string" }
%"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.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_ = external hidden unnamed_addr constant [57 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104)) #2 align 2

declare void @_ZN5SimTK13TiXmlDocument8SetErrorEiPKcPNS_16TiXmlParsingDataENS_13TiXmlEncodingE(ptr noundef nonnull align 8 dereferenceable(192), i32 noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %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 %9, label %10

9:                                                ; preds = %2
  br label %12

10:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.19, i32 noundef 272, ptr noundef @__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_) #4
  unreachable

11:                                               ; No predecessors!
  br label %12

12:                                               ; preds = %11, %9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp eq ptr %15, null
  br i1 %16, label %22, label %17

17:                                               ; preds = %12
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = icmp eq ptr %20, %6
  br label %22

22:                                               ; preds = %17, %12
  %23 = phi i1 [ true, %12 ], [ %21, %17 ]
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  br label %27

25:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.19, i32 noundef 273, ptr noundef @__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_) #4
  unreachable

26:                                               ; No predecessors!
  br label %27

27:                                               ; preds = %26, %24
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %28)
  %30 = icmp eq ptr %29, null
  br i1 %30, label %36, label %31

31:                                               ; preds = %27
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %32)
  %34 = call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %6)
  %35 = icmp eq ptr %33, %34
  br label %36

36:                                               ; preds = %31, %27
  %37 = phi i1 [ true, %27 ], [ %35, %31 ]
  br i1 %37, label %38, label %39

38:                                               ; preds = %36
  br label %41

39:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.19, i32 noundef 274, ptr noundef @__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_) #4
  unreachable

40:                                               ; No predecessors!
  br label %41

41:                                               ; preds = %40, %38
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104) %42)
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %58

45:                                               ; preds = %41
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %52, label %48

48:                                               ; preds = %45
  %49 = load ptr, ptr %46, align 8, !tbaa !19
  %50 = getelementptr inbounds ptr, ptr %49, i64 1
  %51 = load ptr, ptr %50, align 8
  call void %51(ptr noundef nonnull align 8 dereferenceable(104) %46) #5
  br label %52

52:                                               ; preds = %48, %45
  %53 = call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %6)
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %57

55:                                               ; preds = %52
  %56 = call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %6)
  call void @_ZN5SimTK13TiXmlDocument8SetErrorEiPKcPNS_16TiXmlParsingDataENS_13TiXmlEncodingE(ptr noundef nonnull align 8 dereferenceable(192) %56, i32 noundef 16, ptr noundef null, ptr noundef null, i32 noundef 0)
  br label %57

57:                                               ; preds = %55, %52
  store ptr null, ptr %3, align 8
  br label %82

58:                                               ; preds = %41
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %59, i32 0, i32 1
  store ptr %6, ptr %60, align 8, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %61, i32 0, i32 6
  store ptr null, ptr %62, align 8, !tbaa !21
  %63 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %6, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !22
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %65, i32 0, i32 7
  store ptr %64, ptr %66, align 8, !tbaa !23
  %67 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %6, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %75

70:                                               ; preds = %58
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %6, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !22
  %74 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %73, i32 0, i32 6
  store ptr %71, ptr %74, align 8, !tbaa !21
  br label %78

75:                                               ; preds = %58
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %6, i32 0, i32 4
  store ptr %76, ptr %77, align 8, !tbaa !24
  br label %78

78:                                               ; preds = %75, %70
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %"class.SimTK::TiXmlNode", ptr %6, i32 0, i32 3
  store ptr %79, ptr %80, align 8, !tbaa !22
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %81, ptr %3, align 8
  br label %82

82:                                               ; preds = %78, %57
  %83 = load ptr, ptr %3, align 8
  ret ptr %83
}

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 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 = { 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 #3 = { "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 #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!"_ZTSN5SimTK9TiXmlNodeE", !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 = !{!"_ZTSN5SimTK9TiXmlBaseE", !12, i64 8, !6, i64 16}
!12 = !{!"_ZTSN5SimTK11TiXmlCursorE", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN5SimTK9TiXmlNode8NodeTypeE", !7, i64 0}
!15 = !{!"_ZTSN5SimTK6StringE", !16, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"vtable pointer", !8, i64 0}
!21 = !{!10, !6, i64 88}
!22 = !{!10, !6, i64 40}
!23 = !{!10, !6, i64 96}
!24 = !{!10, !6, i64 48}


; 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.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_ = external hidden unnamed_addr constant [57 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 uwtable
declare dso_local noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #2 align 2

declare void @_ZN5SimTK13TiXmlDocument8SetErrorEiPKcPNS_16TiXmlParsingDataENS_13TiXmlEncodingE(ptr noundef nonnull align 8 dereferenceable(192), i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.19, i32 noundef 272, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_) #4
  unreachable

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

9:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.19, i32 noundef 273, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_) #4
  unreachable

.critedge:                                        ; preds = %4
  %10 = tail call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %.critedge2, label %12

12:                                               ; preds = %.critedge
  %13 = tail call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %14 = tail call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %15 = icmp eq ptr %13, %14
  br i1 %15, label %.critedge2, label %16

16:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.19, i32 noundef 274, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5SimTK9TiXmlNode14LinkBeginChildEPS0_) #4
  unreachable

.critedge2:                                       ; preds = %.critedge, %12
  %17 = tail call noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %26

19:                                               ; preds = %.critedge2
  %20 = load ptr, ptr %1, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8
  tail call void %22(ptr noundef nonnull align 8 dereferenceable(104) %1) #5
  %23 = tail call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %.not22 = icmp eq ptr %23, null
  br i1 %.not22, label %33, label %24

24:                                               ; preds = %19
  %25 = tail call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  tail call void @_ZN5SimTK13TiXmlDocument8SetErrorEiPKcPNS_16TiXmlParsingDataENS_13TiXmlEncodingE(ptr noundef nonnull align 8 dereferenceable(192) %25, i32 noundef 16, ptr noundef null, ptr noundef null, i32 noundef 0)
  br label %33

26:                                               ; preds = %.critedge2
  store ptr %0, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 88
  store ptr null, ptr %27, align 8, !tbaa !20
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = getelementptr inbounds i8, ptr %1, i64 96
  store ptr %29, ptr %30, align 8, !tbaa !22
  %.not21 = icmp eq ptr %29, null
  %31 = getelementptr inbounds i8, ptr %0, i64 48
  %32 = getelementptr inbounds i8, ptr %29, i64 88
  %.sink = select i1 %.not21, ptr %31, ptr %32
  store ptr %1, ptr %.sink, align 8, !tbaa !23
  store ptr %1, ptr %28, align 8, !tbaa !21
  br label %33

33:                                               ; preds = %19, %24, %26
  %.0 = phi ptr [ %1, %26 ], [ null, %24 ], [ null, %19 ]
  ret ptr %.0
}

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 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 = { 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 #3 = { "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 #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!"_ZTSN5SimTK9TiXmlNodeE", !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 = !{!"_ZTSN5SimTK9TiXmlBaseE", !8, i64 8, !12, i64 16}
!8 = !{!"_ZTSN5SimTK11TiXmlCursorE", !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 = !{!"_ZTSN5SimTK9TiXmlNode8NodeTypeE", !10, i64 0}
!14 = !{!"_ZTSN5SimTK6StringE", !15, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !10, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!17 = !{!"long", !10, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !11, i64 0}
!20 = !{!6, !12, i64 88}
!21 = !{!6, !12, i64 40}
!22 = !{!6, !12, i64 96}
!23 = !{!12, !12, i64 0}


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