; LLVM IR from Razakhel/RaZ :: src/RaZ/Render/SubmeshRenderer.ll (ZNK3Raz15SubmeshRenderer5cloneEv)

; 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.Raz::SubmeshRenderer" = type { %"class.Raz::VertexArray", %"class.Raz::VertexBuffer", %"class.Raz::IndexBuffer", i32, %"class.std::function.3", i64 }
%"class.Raz::VertexArray" = type { %"class.Raz::OwnerValue" }
%"class.Raz::OwnerValue" = type { i32 }
%"class.Raz::VertexBuffer" = type { i32, %"class.Raz::OwnerValue" }
%"class.Raz::IndexBuffer" = type { i32, i32, %"class.Raz::OwnerValue" }
%"class.std::function.3" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Raz15SubmeshRenderer5cloneEv(ptr dead_on_unwind noalias writable sret(%"class.Raz::SubmeshRenderer") align 8 %0, ptr noundef nonnull align 8 dereferenceable(72) %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZN3Raz15SubmeshRendererC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %9 = getelementptr inbounds %"class.Raz::SubmeshRenderer", ptr %8, i32 0, i32 3
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.Raz::SubmeshRenderer", ptr %0, i32 0, i32 3
  store i32 %10, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.Raz::SubmeshRenderer", ptr %8, i32 0, i32 4
  %13 = getelementptr inbounds %"class.Raz::SubmeshRenderer", ptr %0, i32 0, i32 4
  %14 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt8functionIFvRKN3Raz12VertexBufferERKNS0_11IndexBufferEEEaSERKS8_(ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef nonnull align 8 dereferenceable(32) %12)
          to label %15 unwind label %20

15:                                               ; preds = %2
  %16 = getelementptr inbounds %"class.Raz::SubmeshRenderer", ptr %8, i32 0, i32 5
  %17 = load i64, ptr %16, align 8, !tbaa !20
  %18 = getelementptr inbounds %"class.Raz::SubmeshRenderer", ptr %0, i32 0, i32 5
  store i64 %17, ptr %18, align 8, !tbaa !20
  store i1 true, ptr %5, align 1
  %19 = load i1, ptr %5, align 1
  br i1 %19, label %25, label %24

20:                                               ; preds = %2
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %6, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %7, align 4
  call void @_ZN3Raz15SubmeshRendererD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0) #2
  br label %26

24:                                               ; preds = %15
  call void @_ZN3Raz15SubmeshRendererD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0) #2
  br label %25

25:                                               ; preds = %24, %15
  ret void

26:                                               ; preds = %20
  %27 = load ptr, ptr %6, align 8
  %28 = load i32, ptr %7, align 4
  %29 = insertvalue { ptr, i32 } poison, ptr %27, 0
  %30 = insertvalue { ptr, i32 } %29, i32 %28, 1
  resume { ptr, i32 } %30
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3Raz15SubmeshRendererC2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3Raz15SubmeshRendererD2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #1 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 = { 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 = { 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, !16, i64 24}
!10 = !{!"_ZTSN3Raz15SubmeshRendererE", !11, i64 0, !14, i64 4, !15, i64 12, !16, i64 24, !17, i64 32, !19, i64 64}
!11 = !{!"_ZTSN3Raz11VertexArrayE", !12, i64 0}
!12 = !{!"_ZTSN3Raz10OwnerValueIjLj0EEE", !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3Raz12VertexBufferE", !13, i64 0, !12, i64 4}
!15 = !{!"_ZTSN3Raz11IndexBufferE", !13, i64 0, !13, i64 4, !12, i64 8}
!16 = !{!"_ZTSN3Raz10RenderModeE", !7, i64 0}
!17 = !{!"_ZTSSt8functionIFvRKN3Raz12VertexBufferERKNS0_11IndexBufferEEE", !18, i64 0, !6, i64 24}
!18 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!10, !19, i64 64}


; 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.Raz::SubmeshRenderer" = type { %"class.Raz::VertexArray", %"class.Raz::VertexBuffer", %"class.Raz::IndexBuffer", i32, %"class.std::function.3", i64 }
%"class.Raz::VertexArray" = type { %"class.Raz::OwnerValue" }
%"class.Raz::OwnerValue" = type { i32 }
%"class.Raz::VertexBuffer" = type { i32, %"class.Raz::OwnerValue" }
%"class.Raz::IndexBuffer" = type { i32, i32, %"class.Raz::OwnerValue" }
%"class.std::function.3" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Raz15SubmeshRenderer5cloneEv(ptr dead_on_unwind noalias nonnull writable sret(%"class.Raz::SubmeshRenderer") align 8 %0, ptr noundef nonnull align 8 dereferenceable(72) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN3Raz15SubmeshRendererC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %4, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt8functionIFvRKN3Raz12VertexBufferERKNS0_11IndexBufferEEEaSERKS8_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %9 unwind label %13

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %1, i64 64
  %11 = load i64, ptr %10, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %11, ptr %12, align 8, !tbaa !19
  ret void

13:                                               ; preds = %2
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3Raz15SubmeshRendererD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0) #2
  resume { ptr, i32 } %14
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3Raz15SubmeshRendererC2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3Raz15SubmeshRendererD2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #1 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 = { 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 = { 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, !14, i64 24}
!6 = !{!"_ZTSN3Raz15SubmeshRendererE", !7, i64 0, !12, i64 4, !13, i64 12, !14, i64 24, !15, i64 32, !18, i64 64}
!7 = !{!"_ZTSN3Raz11VertexArrayE", !8, i64 0}
!8 = !{!"_ZTSN3Raz10OwnerValueIjLj0EEE", !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN3Raz12VertexBufferE", !9, i64 0, !8, i64 4}
!13 = !{!"_ZTSN3Raz11IndexBufferE", !9, i64 0, !9, i64 4, !8, i64 8}
!14 = !{!"_ZTSN3Raz10RenderModeE", !10, i64 0}
!15 = !{!"_ZTSSt8functionIFvRKN3Raz12VertexBufferERKNS0_11IndexBufferEEE", !16, i64 0, !17, i64 24}
!16 = !{!"_ZTSSt14_Function_base", !10, i64 0, !17, i64 16}
!17 = !{!"any pointer", !10, i64 0}
!18 = !{!"long", !10, i64 0}
!19 = !{!6, !18, i64 64}


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