; LLVM IR from JayXon/Leanify :: 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: 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: 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) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(16) ptr @_ZN4pugi4impl12_GLOBAL__N_113get_allocatorINS_15xml_node_structEEERNS1_13xml_allocatorEPKT_(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_113xml_allocator7reserveEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 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) #3

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

; 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) #4 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
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %10, i64 8, i1 false), !tbaa.struct !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %11, i64 8, i1 false), !tbaa.struct !9
  %12 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8
  %14 = getelementptr inbounds %"class.pugi::xml_node", ptr %7, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8
  %16 = call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_110allow_moveENS_8xml_nodeES2_(ptr %13, ptr %15)
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %19 = getelementptr inbounds %"class.pugi::xml_node", ptr %10, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !10
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN4pugi4impl12_GLOBAL__N_113get_allocatorINS_15xml_node_structEEERNS1_13xml_allocatorEPKT_(ptr noundef %20)
  store ptr %21, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_113xml_allocator7reserveEv(ptr noundef nonnull align 8 dereferenceable(16) %22)
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
  store i32 1, ptr %9, align 4
  br label %41

25:                                               ; preds = %18
  %26 = getelementptr inbounds %"class.pugi::xml_node", ptr %10, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !10
  %28 = call noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef %27)
  %29 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %28, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !12
  %31 = or i64 %30, 64
  store i64 %31, ptr %29, align 8, !tbaa !12
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.pugi::xml_node", ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !10
  call void @_ZN4pugi4impl12_GLOBAL__N_111remove_nodeEPNS_15xml_node_structE(ptr noundef %34)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.pugi::xml_node", ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !10
  %38 = getelementptr inbounds %"class.pugi::xml_node", ptr %10, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !10
  call void @_ZN4pugi4impl12_GLOBAL__N_111append_nodeEPNS_15xml_node_structES3_(ptr noundef %37, ptr noundef %39)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 %40, i64 8, i1 false), !tbaa.struct !9
  store i32 1, ptr %9, align 4
  br label %41

41:                                               ; preds = %25, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %42

42:                                               ; preds = %41, %17
  %43 = getelementptr inbounds %"class.pugi::xml_node", ptr %3, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8
  ret ptr %44
}

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

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

declare void @_ZN4pugi8xml_nodeC1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{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 noundef nonnull align 8 dereferenceable(16) ptr @_ZN4pugi4impl12_GLOBAL__N_113get_allocatorINS_15xml_node_structEEERNS1_13xml_allocatorEPKT_(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_113xml_allocator7reserveEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; 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 #2 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)
  br label %20

6:                                                ; preds = %2
  %7 = load ptr, ptr %0, align 8, !tbaa !9
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN4pugi4impl12_GLOBAL__N_113get_allocatorINS_15xml_node_structEEERNS1_13xml_allocatorEPKT_(ptr noundef %7)
  %9 = tail call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_113xml_allocator7reserveEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %20

11:                                               ; preds = %6
  %12 = load ptr, ptr %0, align 8, !tbaa !9
  %13 = tail call noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef %12)
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = or i64 %14, 64
  store i64 %15, ptr %13, align 8, !tbaa !11
  %16 = load ptr, ptr %1, align 8, !tbaa !9
  tail call void @_ZN4pugi4impl12_GLOBAL__N_111remove_nodeEPNS_15xml_node_structE(ptr noundef %16)
  %17 = load ptr, ptr %1, align 8, !tbaa !9
  %18 = load ptr, ptr %0, align 8, !tbaa !9
  tail call void @_ZN4pugi4impl12_GLOBAL__N_111append_nodeEPNS_15xml_node_structES3_(ptr noundef %17, ptr noundef %18)
  %19 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %19, ptr %3, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %10, %11, %5
  %21 = load ptr, ptr %3, align 8
  ret ptr %21
}

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

; 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 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 = { 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: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass