; LLVM IR from ThePhysicsGuys/Physics3D :: graphics/buffers/vertexBuffer.ll (ZN3P3D8Graphics12VertexBufferC2EOS1_)

; 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.P3D::Graphics::Bindable" = type <{ ptr, i32, [4 x i8] }>
%"class.P3D::Graphics::VertexBuffer" = type { %"class.P3D::Graphics::Bindable.base", i64, i64, %"struct.P3D::Graphics::BufferLayout" }
%"class.P3D::Graphics::Bindable.base" = type <{ ptr, i32 }>
%"struct.P3D::Graphics::BufferLayout" = type <{ %"class.std::vector", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<P3D::Graphics::BufferElement, std::allocator<P3D::Graphics::BufferElement>>::_Vector_impl" }
%"struct.std::_Vector_base<P3D::Graphics::BufferElement, std::allocator<P3D::Graphics::BufferElement>>::_Vector_impl" = type { %"struct.std::_Vector_base<P3D::Graphics::BufferElement, std::allocator<P3D::Graphics::BufferElement>>::_Vector_impl_data" }
%"struct.std::_Vector_base<P3D::Graphics::BufferElement, std::allocator<P3D::Graphics::BufferElement>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTVN3P3D8Graphics12VertexBufferE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12VertexBufferC2EOS1_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %"class.P3D::Graphics::Bindable", ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 8, !tbaa !9
  call void @_ZN3P3D8Graphics8BindableC2Ej(ptr noundef nonnull align 8 dereferenceable(12) %5, i32 noundef %8)
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN3P3D8Graphics12VertexBufferE, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !12
  %9 = getelementptr inbounds %"class.P3D::Graphics::VertexBuffer", ptr %5, i32 0, i32 1
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.P3D::Graphics::VertexBuffer", ptr %10, i32 0, i32 1
  %12 = load i64, ptr %11, align 8, !tbaa !14
  store i64 %12, ptr %9, align 8, !tbaa !14
  %13 = getelementptr inbounds %"class.P3D::Graphics::VertexBuffer", ptr %5, i32 0, i32 2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.P3D::Graphics::VertexBuffer", ptr %14, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !22
  store i64 %16, ptr %13, align 8, !tbaa !22
  %17 = getelementptr inbounds %"class.P3D::Graphics::VertexBuffer", ptr %5, i32 0, i32 3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.P3D::Graphics::VertexBuffer", ptr %18, i32 0, i32 3
  call void @_ZN3P3D8Graphics12BufferLayoutC2EOS1_(ptr noundef nonnull align 8 dereferenceable(28) %17, ptr noundef nonnull align 8 dereferenceable(28) %19) #3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.P3D::Graphics::Bindable", ptr %20, i32 0, i32 1
  store i32 0, ptr %21, align 8, !tbaa !9
  ret void
}

declare void @_ZN3P3D8Graphics8BindableC2Ej(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D8Graphics12BufferLayoutC2EOS1_(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(28)) 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 = { "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 = { 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 #3 = { 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, !11, i64 8}
!10 = !{!"_ZTSN3P3D8Graphics8BindableE", !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !8, i64 0}
!14 = !{!15, !16, i64 16}
!15 = !{!"_ZTSN3P3D8Graphics12VertexBufferE", !10, i64 0, !16, i64 16, !16, i64 24, !17, i64 32}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3P3D8Graphics12BufferLayoutE", !18, i64 0, !11, i64 24}
!18 = !{!"_ZTSSt6vectorIN3P3D8Graphics13BufferElementESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIN3P3D8Graphics13BufferElementESaIS2_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN3P3D8Graphics13BufferElementESaIS2_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN3P3D8Graphics13BufferElementESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!15, !16, i64 24}


; 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"

@_ZTVN3P3D8Graphics12VertexBufferE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12VertexBufferC2EOS1_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  tail call void @_ZN3P3D8Graphics8BindableC2Ej(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %4)
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN3P3D8Graphics12VertexBufferE, i64 16), ptr %0, align 8, !tbaa !10
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load <2 x i64>, ptr %6, align 8, !tbaa !12
  store <2 x i64> %7, ptr %5, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = getelementptr inbounds i8, ptr %1, i64 32
  tail call void @_ZN3P3D8Graphics12BufferLayoutC2EOS1_(ptr noundef nonnull align 8 dereferenceable(28) %8, ptr noundef nonnull align 8 dereferenceable(28) %9) #3
  store i32 0, ptr %3, align 8, !tbaa !5
  ret void
}

declare void @_ZN3P3D8Graphics8BindableC2Ej(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D8Graphics12BufferLayoutC2EOS1_(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(28)) 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 = { "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 = { 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 #3 = { 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, !7, i64 8}
!6 = !{!"_ZTSN3P3D8Graphics8BindableE", !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"vtable pointer", !9, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass