; LLVM IR from mackorone/mms :: old/v2/src/lib/pugixml/pugixml.ll (ZN4pugi8xml_node11append_moveERKS0_)

; 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.pugi::xml_node" = type { ptr }
%"struct.pugi::xml_node_struct" = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef) #0

; 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) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN4pugi4impl12_GLOBAL__N_111append_nodeEPNS_15xml_node_structES3_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local ptr @_ZN4pugi8xml_node11append_moveERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1) #2 align 2 {
  %3 = alloca %"class.pugi::xml_node", align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.pugi::xml_node", align 8
  %7 = alloca %"class.pugi::xml_node", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %9, i64 8, i1 false), !tbaa.struct !9
  %10 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8
  %12 = getelementptr inbounds %"class.pugi::xml_node", ptr %7, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8
  %14 = call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_110allow_moveENS_8xml_nodeES2_(ptr %11, ptr %13)
  br i1 %14, label %16, label %15

15:                                               ; preds = %2
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %32

16:                                               ; preds = %2
  %17 = getelementptr inbounds %"class.pugi::xml_node", ptr %8, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !10
  %19 = call noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef %18)
  %20 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !12
  %22 = or i64 %21, 32
  store i64 %22, ptr %20, align 8, !tbaa !12
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.pugi::xml_node", ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !10
  call void @_ZN4pugi4impl12_GLOBAL__N_111remove_nodeEPNS_15xml_node_structE(ptr noundef %25)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.pugi::xml_node", ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !10
  %29 = getelementptr inbounds %"class.pugi::xml_node", ptr %8, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !10
  call void @_ZN4pugi4impl12_GLOBAL__N_111append_nodeEPNS_15xml_node_structES3_(ptr noundef %28, ptr noundef %30)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 %31, i64 8, i1 false), !tbaa.struct !9
  br label %32

32:                                               ; preds = %16, %15
  %33 = getelementptr inbounds %"class.pugi::xml_node", ptr %3, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8
  ret ptr %34
}

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_110allow_moveENS_8xml_nodeES2_(ptr, ptr) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN4pugi4impl12_GLOBAL__N_111remove_nodeEPNS_15xml_node_structE(ptr noundef) #0

declare void @_ZN4pugi8xml_nodeC1Ev(ptr)

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

!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 = !{i64 0, i64 8, !5}
!10 = !{!11, !6, i64 0}
!11 = !{!"_ZTSN4pugi8xml_nodeE", !6, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSN4pugi15xml_node_structE", !14, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!14 = !{!"long", !7, 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"

%"class.pugi::xml_node" = type { ptr }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN4pugi4impl12_GLOBAL__N_111append_nodeEPNS_15xml_node_structES3_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local ptr @_ZN4pugi8xml_node11append_moveERKS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.pugi::xml_node", align 8
  %.sroa.01.0.copyload = load ptr, ptr %0, align 8, !tbaa !5
  %.sroa.0.0.copyload = load ptr, ptr %1, align 8, !tbaa !5
  %4 = tail call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_110allow_moveENS_8xml_nodeES2_(ptr %.sroa.01.0.copyload, ptr %.sroa.0.0.copyload)
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %.pre = load ptr, ptr %3, align 8
  br label %16

6:                                                ; preds = %2
  %7 = load ptr, ptr %0, align 8, !tbaa !9
  %8 = tail call noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef %7)
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = or i64 %9, 32
  store i64 %10, ptr %8, align 8, !tbaa !11
  %11 = load ptr, ptr %1, align 8, !tbaa !9
  tail call void @_ZN4pugi4impl12_GLOBAL__N_111remove_nodeEPNS_15xml_node_structE(ptr noundef %11)
  %12 = load ptr, ptr %1, align 8, !tbaa !9
  %13 = load ptr, ptr %0, align 8, !tbaa !9
  tail call void @_ZN4pugi4impl12_GLOBAL__N_111append_nodeEPNS_15xml_node_structES3_(ptr noundef %12, ptr noundef %13)
  %14 = load i64, ptr %1, align 8, !tbaa !5
  %15 = inttoptr i64 %14 to ptr
  br label %16

16:                                               ; preds = %6, %5
  %17 = phi ptr [ %15, %6 ], [ %.pre, %5 ]
  ret ptr %17
}

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_110allow_moveENS_8xml_nodeES2_(ptr, ptr) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN4pugi4impl12_GLOBAL__N_111remove_nodeEPNS_15xml_node_structE(ptr noundef) local_unnamed_addr #0

declare void @_ZN4pugi8xml_nodeC1Ev(ptr) local_unnamed_addr

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

!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 0}
!10 = !{!"_ZTSN4pugi8xml_nodeE", !6, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN4pugi15xml_node_structE", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"long", !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass