; LLVM IR from jrouwe/JoltPhysics :: TestFramework/UI/UIElement.ll (ZNK9UIElement6CopyToEPS_)

; 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.UIElement = type { %class.UIEventListener, i32, ptr, %"class.JPH::Array", %"class.UIElement::Position", %"class.UIElement::Position", %"class.UIElement::Size", %"class.UIElement::Size", %"class.UIElement::Size", %"class.UIElement::Size", i8, i8, i8, i8, i8, i8, i8, %"class.JPH::Array.2", ptr }
%class.UIEventListener = type { ptr }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.UIElement::Position" = type { i32, %"class.UIElement::Size" }
%"class.UIElement::Size" = type { i32, i32 }
%"class.JPH::Array.2" = type { i64, i64, 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: mustprogress uwtable
declare dso_local void @_ZN9UIElement3AddEPS_(ptr noundef nonnull align 8 dereferenceable(144), ptr noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9UIElement6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.UIElement, ptr %12, i32 0, i32 1
  store i32 %11, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.UIElement, ptr %15, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %14, i64 12, i1 false), !tbaa.struct !21
  %17 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.UIElement, ptr %18, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %17, i64 12, i1 false), !tbaa.struct !21
  %20 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 6
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.UIElement, ptr %21, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %22, ptr align 8 %20, i64 8, i1 false), !tbaa.struct !25
  %23 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 7
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.UIElement, ptr %24, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %23, i64 8, i1 false), !tbaa.struct !25
  %26 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 10
  %27 = load i8, ptr %26, align 8, !tbaa !26, !range !27, !noundef !28
  %28 = trunc i8 %27 to i1
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.UIElement, ptr %29, i32 0, i32 10
  %31 = zext i1 %28 to i8
  store i8 %31, ptr %30, align 8, !tbaa !26
  %32 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 11
  %33 = load i8, ptr %32, align 1, !tbaa !29, !range !27, !noundef !28
  %34 = trunc i8 %33 to i1
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.UIElement, ptr %35, i32 0, i32 11
  %37 = zext i1 %34 to i8
  store i8 %37, ptr %36, align 1, !tbaa !29
  %38 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 15
  %39 = load i8, ptr %38, align 1, !tbaa !30, !range !27, !noundef !28
  %40 = trunc i8 %39 to i1
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.UIElement, ptr %41, i32 0, i32 15
  %43 = zext i1 %40 to i8
  store i8 %43, ptr %42, align 1, !tbaa !30
  %44 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 16
  %45 = load i8, ptr %44, align 2, !tbaa !31, !range !27, !noundef !28
  %46 = trunc i8 %45 to i1
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %class.UIElement, ptr %47, i32 0, i32 16
  %49 = zext i1 %46 to i8
  store i8 %49, ptr %48, align 2, !tbaa !31
  %50 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 18
  %51 = load ptr, ptr %50, align 8, !tbaa !32
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %class.UIElement, ptr %52, i32 0, i32 18
  store ptr %51, ptr %53, align 8, !tbaa !32
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %54 = getelementptr inbounds %class.UIElement, ptr %9, i32 0, i32 3
  store ptr %54, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %55)
  store ptr %56, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %57)
  store ptr %58, ptr %7, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %70, %2
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = icmp ne ptr %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %73

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  store ptr %66, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = call noundef ptr @_ZNK9UIElement5CloneEv(ptr noundef nonnull align 8 dereferenceable(144) %68)
  call void @_ZN9UIElement3AddEPS_(ptr noundef nonnull align 8 dereferenceable(144) %67, ptr noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %70

70:                                               ; preds = %64
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds ptr, ptr %71, i32 1
  store ptr %72, ptr %6, align 8, !tbaa !5
  br label %59

73:                                               ; preds = %63
  ret void
}

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

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

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 = { 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 #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, !12, i64 8}
!10 = !{!"_ZTS9UIElement", !11, i64 0, !12, i64 8, !6, i64 16, !13, i64 24, !15, i64 48, !15, i64 60, !17, i64 72, !17, i64 80, !17, i64 88, !17, i64 96, !19, i64 104, !19, i64 105, !19, i64 106, !19, i64 107, !19, i64 108, !19, i64 109, !19, i64 110, !20, i64 112, !6, i64 136}
!11 = !{!"_ZTS15UIEventListener"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN9UIElement8PositionE", !16, i64 0, !17, i64 4}
!16 = !{!"_ZTSN9UIElement10EAlignmentE", !7, i64 0}
!17 = !{!"_ZTSN9UIElement4SizeE", !12, i64 0, !18, i64 4}
!18 = !{!"_ZTSN9UIElement6EUnitsE", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSN3JPH5ArrayIP11UIAnimationNS_12STLAllocatorIS2_EEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!21 = !{i64 0, i64 4, !22, i64 4, i64 4, !23, i64 8, i64 4, !24}
!22 = !{!16, !16, i64 0}
!23 = !{!12, !12, i64 0}
!24 = !{!18, !18, i64 0}
!25 = !{i64 0, i64 4, !23, i64 4, i64 4, !24}
!26 = !{!10, !19, i64 104}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!10, !19, i64 105}
!30 = !{!10, !19, i64 109}
!31 = !{!10, !19, i64 110}
!32 = !{!10, !6, i64 136}


; 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 @_ZN9UIElement3AddEPS_(ptr noundef nonnull align 8 dereferenceable(144), ptr noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9UIElement6CopyToEPS_(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %4, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = getelementptr inbounds i8, ptr %1, i64 48
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %7, ptr noundef nonnull align 8 dereferenceable(12) %6, i64 12, i1 false), !tbaa.struct !20
  %8 = getelementptr inbounds i8, ptr %0, i64 60
  %9 = getelementptr inbounds i8, ptr %1, i64 60
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %8, i64 12, i1 false), !tbaa.struct !20
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  %11 = getelementptr inbounds i8, ptr %1, i64 72
  %12 = load i64, ptr %10, align 8
  store i64 %12, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = getelementptr inbounds i8, ptr %1, i64 80
  %15 = load i64, ptr %13, align 8
  store i64 %15, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 104
  %17 = load i8, ptr %16, align 8, !tbaa !24, !range !25, !noundef !26
  %18 = getelementptr inbounds i8, ptr %1, i64 104
  store i8 %17, ptr %18, align 8, !tbaa !24
  %19 = getelementptr inbounds i8, ptr %0, i64 105
  %20 = load i8, ptr %19, align 1, !tbaa !27, !range !25, !noundef !26
  %21 = getelementptr inbounds i8, ptr %1, i64 105
  store i8 %20, ptr %21, align 1, !tbaa !27
  %22 = getelementptr inbounds i8, ptr %0, i64 109
  %23 = load i8, ptr %22, align 1, !tbaa !28, !range !25, !noundef !26
  %24 = getelementptr inbounds i8, ptr %1, i64 109
  store i8 %23, ptr %24, align 1, !tbaa !28
  %25 = getelementptr inbounds i8, ptr %0, i64 110
  %26 = load i8, ptr %25, align 2, !tbaa !29, !range !25, !noundef !26
  %27 = getelementptr inbounds i8, ptr %1, i64 110
  store i8 %26, ptr %27, align 2, !tbaa !29
  %28 = getelementptr inbounds i8, ptr %0, i64 136
  %29 = load ptr, ptr %28, align 8, !tbaa !30
  %30 = getelementptr inbounds i8, ptr %1, i64 136
  store ptr %29, ptr %30, align 8, !tbaa !30
  %31 = getelementptr inbounds i8, ptr %0, i64 24
  %32 = tail call noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %31)
  %33 = tail call noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %31)
  %.not19 = icmp eq ptr %32, %33
  br i1 %.not19, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.020 = phi ptr [ %36, %.lr.ph ], [ %32, %2 ]
  %34 = load ptr, ptr %.020, align 8, !tbaa !31
  %35 = tail call noundef ptr @_ZNK9UIElement5CloneEv(ptr noundef nonnull align 8 dereferenceable(144) %34)
  tail call void @_ZN9UIElement3AddEPS_(ptr noundef nonnull align 8 dereferenceable(144) %1, ptr noundef %35)
  %36 = getelementptr inbounds i8, ptr %.020, i64 8
  %.not = icmp eq ptr %36, %33
  br i1 %.not, label %._crit_edge, label %.lr.ph
}

; Function Attrs: mustprogress 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 dso_local noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

!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, !8, i64 8}
!6 = !{!"_ZTS9UIElement", !7, i64 0, !8, i64 8, !11, i64 16, !12, i64 24, !14, i64 48, !14, i64 60, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !18, i64 104, !18, i64 105, !18, i64 106, !18, i64 107, !18, i64 108, !18, i64 109, !18, i64 110, !19, i64 112, !11, i64 136}
!7 = !{!"_ZTS15UIEventListener"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEEE", !13, i64 0, !13, i64 8, !11, i64 16}
!13 = !{!"long", !9, i64 0}
!14 = !{!"_ZTSN9UIElement8PositionE", !15, i64 0, !16, i64 4}
!15 = !{!"_ZTSN9UIElement10EAlignmentE", !9, i64 0}
!16 = !{!"_ZTSN9UIElement4SizeE", !8, i64 0, !17, i64 4}
!17 = !{!"_ZTSN9UIElement6EUnitsE", !9, i64 0}
!18 = !{!"bool", !9, i64 0}
!19 = !{!"_ZTSN3JPH5ArrayIP11UIAnimationNS_12STLAllocatorIS2_EEEE", !13, i64 0, !13, i64 8, !11, i64 16}
!20 = !{i64 0, i64 4, !21, i64 4, i64 4, !22, i64 8, i64 4, !23}
!21 = !{!15, !15, i64 0}
!22 = !{!8, !8, i64 0}
!23 = !{!17, !17, i64 0}
!24 = !{!6, !18, i64 104}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!6, !18, i64 105}
!28 = !{!6, !18, i64 109}
!29 = !{!6, !18, i64 110}
!30 = !{!6, !11, i64 136}
!31 = !{!11, !11, i64 0}


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