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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK13TiXmlDocument6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(157) %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 %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK9TiXmlNode6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(104) %6, ptr noundef %7)
  %8 = getelementptr inbounds %class.TiXmlDocument, ptr %6, i32 0, i32 1
  %9 = load i8, ptr %8, align 8, !tbaa !9, !range !20, !noundef !21
  %10 = trunc i8 %9 to i1
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 1
  %13 = zext i1 %10 to i8
  store i8 %13, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %class.TiXmlDocument, ptr %6, i32 0, i32 3
  %15 = load i32, ptr %14, align 4, !tbaa !22
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.TiXmlDocument, ptr %16, i32 0, i32 3
  store i32 %15, ptr %17, align 4, !tbaa !22
  %18 = getelementptr inbounds %class.TiXmlDocument, ptr %6, i32 0, i32 4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.TiXmlDocument, ptr %19, i32 0, i32 4
  %21 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef nonnull align 8 dereferenceable(32) %18)
  %22 = getelementptr inbounds %class.TiXmlDocument, ptr %6, i32 0, i32 5
  %23 = load i32, ptr %22, align 8, !tbaa !23
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.TiXmlDocument, ptr %24, i32 0, i32 5
  store i32 %23, ptr %25, align 8, !tbaa !23
  %26 = getelementptr inbounds %class.TiXmlDocument, ptr %6, i32 0, i32 6
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.TiXmlDocument, ptr %27, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %26, i64 8, i1 false), !tbaa.struct !24
  %29 = getelementptr inbounds %class.TiXmlDocument, ptr %6, i32 0, i32 7
  %30 = load i8, ptr %29, align 4, !tbaa !26, !range !20, !noundef !21
  %31 = trunc i8 %30 to i1
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.TiXmlDocument, ptr %32, i32 0, i32 7
  %34 = zext i1 %31 to i8
  store i8 %34, ptr %33, align 4, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.TiXmlNode, ptr %6, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !27
  store ptr %36, ptr %5, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %48, %2
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %51

40:                                               ; preds = %37
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !28
  %44 = getelementptr inbounds ptr, ptr %43, i64 16
  %45 = load ptr, ptr %44, align 8
  %46 = call noundef ptr %45(ptr noundef nonnull align 8 dereferenceable(104) %42)
  %47 = call noundef ptr @_ZN9TiXmlNode12LinkEndChildEPS_(ptr noundef nonnull align 8 dereferenceable(104) %41, ptr noundef %46)
  br label %48

48:                                               ; preds = %40
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call noundef ptr @_ZN9TiXmlNode11NextSiblingEv(ptr noundef nonnull align 8 dereferenceable(104) %49)
  store ptr %50, ptr %5, align 8, !tbaa !5
  br label %37, !llvm.loop !30

51:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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, !19, i64 104}
!10 = !{!"_ZTS13TiXmlDocument", !11, i64 0, !19, i64 104, !14, i64 108, !16, i64 112, !14, i64 144, !13, i64 148, !19, i64 156}
!11 = !{!"_ZTS9TiXmlNode", !12, i64 0, !6, i64 24, !15, i64 32, !6, i64 40, !6, i64 48, !16, i64 56, !6, i64 88, !6, i64 96}
!12 = !{!"_ZTS9TiXmlBase", !13, i64 8, !6, i64 16}
!13 = !{!"_ZTS11TiXmlCursor", !14, i64 0, !14, i64 4}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSN9TiXmlNode8NodeTypeE", !7, 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 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!10, !14, i64 108}
!23 = !{!10, !14, i64 144}
!24 = !{i64 0, i64 4, !25, i64 4, i64 4, !25}
!25 = !{!14, !14, i64 0}
!26 = !{!10, !19, i64 156}
!27 = !{!11, !6, i64 40}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !8, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; 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 uwtable
declare dso_local void @_ZNK9TiXmlNode6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9TiXmlNode12LinkEndChildEPS_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK13TiXmlDocument6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(157) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  tail call void @_ZNK9TiXmlNode6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !19, !noundef !20
  %5 = getelementptr inbounds i8, ptr %1, i64 104
  store i8 %4, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 108
  %7 = load i32, ptr %6, align 4, !tbaa !21
  %8 = getelementptr inbounds i8, ptr %1, i64 108
  store i32 %7, ptr %8, align 4, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %0, i64 112
  %10 = getelementptr inbounds i8, ptr %1, i64 112
  %11 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull align 8 dereferenceable(32) %9)
  %12 = getelementptr inbounds i8, ptr %0, i64 144
  %13 = load i32, ptr %12, align 8, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %1, i64 144
  store i32 %13, ptr %14, align 8, !tbaa !22
  %15 = getelementptr inbounds i8, ptr %0, i64 148
  %16 = getelementptr inbounds i8, ptr %1, i64 148
  %17 = load i64, ptr %15, align 4
  store i64 %17, ptr %16, align 4
  %18 = getelementptr inbounds i8, ptr %0, i64 156
  %19 = load i8, ptr %18, align 4, !tbaa !23, !range !19, !noundef !20
  %20 = getelementptr inbounds i8, ptr %1, i64 156
  store i8 %19, ptr %20, align 4, !tbaa !23
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  %22 = load ptr, ptr %21, align 8, !tbaa !24
  %.not12 = icmp eq ptr %22, null
  br i1 %.not12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.013 = phi ptr [ %28, %.lr.ph ], [ %22, %2 ]
  %23 = load ptr, ptr %.013, align 8, !tbaa !25
  %24 = getelementptr inbounds i8, ptr %23, i64 128
  %25 = load ptr, ptr %24, align 8
  %26 = tail call noundef ptr %25(ptr noundef nonnull align 8 dereferenceable(104) %.013)
  %27 = tail call noundef ptr @_ZN9TiXmlNode12LinkEndChildEPS_(ptr noundef nonnull align 8 dereferenceable(104) %1, ptr noundef %26)
  %28 = tail call noundef ptr @_ZN9TiXmlNode11NextSiblingEv(ptr noundef nonnull align 8 dereferenceable(104) %.013)
  %.not = icmp eq ptr %28, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !27

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void
}

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

!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, !18, i64 104}
!6 = !{!"_ZTS13TiXmlDocument", !7, i64 0, !18, i64 104, !10, i64 108, !15, i64 112, !10, i64 144, !9, i64 148, !18, i64 156}
!7 = !{!"_ZTS9TiXmlNode", !8, i64 0, !13, i64 24, !14, i64 32, !13, i64 40, !13, i64 48, !15, i64 56, !13, i64 88, !13, i64 96}
!8 = !{!"_ZTS9TiXmlBase", !9, i64 8, !13, i64 16}
!9 = !{!"_ZTS11TiXmlCursor", !10, i64 0, !10, i64 4}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"any pointer", !11, i64 0}
!14 = !{!"_ZTSN9TiXmlNode8NodeTypeE", !11, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !11, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!17 = !{!"long", !11, i64 0}
!18 = !{!"bool", !11, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!6, !10, i64 108}
!22 = !{!6, !10, i64 144}
!23 = !{!6, !18, i64 156}
!24 = !{!7, !13, i64 40}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !12, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass