; LLVM IR from ThePhysicsGuys/Physics3D :: graphics (meshRegistry)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl" }
%"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl" = type { %"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.P3D::Graphics::Comp::Mesh" = type <{ %"struct.P3D::RC", i64, i32, i8, [3 x i8] }>
%"struct.P3D::RC" = type { ptr, i64 }

@_ZN3P3D8Graphics12MeshRegistry6meshesE = external dso_local global %"class.std::vector", align 8

; 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12MeshRegistry13registerShapeERKNS0_20ExtendedTriangleMeshE(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Graphics::Comp::Mesh") align 8 %0, ptr noundef nonnull align 8 dereferenceable(88) %1) #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %9 = call noundef i64 @_ZNKSt6vectorIPN3P3D8Graphics11IndexedMeshESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN3P3D8Graphics12MeshRegistry6meshesE) #6
  store i64 %9, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 96) #7
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN3P3D8Graphics11IndexedMeshC1ERKNS0_20ExtendedTriangleMeshE(ptr noundef nonnull align 8 dereferenceable(96) %10, ptr noundef nonnull align 8 dereferenceable(88) %11)
          to label %12 unwind label %16

12:                                               ; preds = %2
  store ptr %10, ptr %6, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN3P3D8Graphics11IndexedMeshESaIS3_EE9push_backEOS3_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN3P3D8Graphics12MeshRegistry6meshesE, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call noundef i32 @_ZNK3P3D8Graphics20ExtendedTriangleMesh8getFlagsEv(ptr noundef nonnull align 8 dereferenceable(88) %14)
  call void @_ZN3P3D8Graphics4Comp4MeshC2Emi(ptr noundef nonnull align 8 dereferenceable(29) %0, i64 noundef %13, i32 noundef %15)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret void

16:                                               ; preds = %2
  %17 = landingpad { ptr, i32 }
          cleanup
  %18 = extractvalue { ptr, i32 } %17, 0
  store ptr %18, ptr %7, align 8
  %19 = extractvalue { ptr, i32 } %17, 1
  store i32 %19, ptr %8, align 4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 96) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %7, align 8
  %22 = load i32, ptr %8, align 4
  %23 = insertvalue { ptr, i32 } poison, ptr %21, 0
  %24 = insertvalue { ptr, i32 } %23, i32 %22, 1
  resume { ptr, i32 } %24
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D8Graphics4Comp4MeshC2Emi(ptr noundef nonnull align 8 dereferenceable(29), i64 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN3P3D8Graphics11IndexedMeshESaIS3_EE9push_backEOS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

declare void @_ZN3P3D8Graphics11IndexedMeshC1ERKNS0_20ExtendedTriangleMeshE(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3P3D8Graphics20ExtendedTriangleMesh8getFlagsEv(ptr noundef nonnull align 8 dereferenceable(88)) #2 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 = { 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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin nounwind "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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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, !10, i64 0}
!10 = !{!"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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl" }
%"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl" = type { %"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<P3D::Graphics::IndexedMesh *, std::allocator<P3D::Graphics::IndexedMesh *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.P3D::Graphics::Comp::Mesh" = type <{ %"struct.P3D::RC", i64, i32, i8, [3 x i8] }>
%"struct.P3D::RC" = type { ptr, i64 }

@_ZN3P3D8Graphics12MeshRegistry6meshesE = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12MeshRegistry13registerShapeERKNS0_20ExtendedTriangleMeshE(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Graphics::Comp::Mesh") align 8 %0, ptr noundef nonnull align 8 dereferenceable(88) %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = tail call noundef i64 @_ZNKSt6vectorIPN3P3D8Graphics11IndexedMeshESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN3P3D8Graphics12MeshRegistry6meshesE) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %5 = tail call noalias noundef nonnull dereferenceable(96) ptr @_Znwm(i64 noundef 96) #7
  invoke void @_ZN3P3D8Graphics11IndexedMeshC1ERKNS0_20ExtendedTriangleMeshE(ptr noundef nonnull align 8 dereferenceable(96) %5, ptr noundef nonnull align 8 dereferenceable(88) %1)
          to label %6 unwind label %8

6:                                                ; preds = %2
  store ptr %5, ptr %3, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN3P3D8Graphics11IndexedMeshESaIS3_EE9push_backEOS3_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN3P3D8Graphics12MeshRegistry6meshesE, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %7 = call noundef i32 @_ZNK3P3D8Graphics20ExtendedTriangleMesh8getFlagsEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  call void @_ZN3P3D8Graphics4Comp4MeshC2Emi(ptr noundef nonnull align 8 dereferenceable(29) %0, i64 noundef %4, i32 noundef %7)
  ret void

8:                                                ; preds = %2
  %9 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 96) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  resume { ptr, i32 } %9
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D8Graphics4Comp4MeshC2Emi(ptr noundef nonnull align 8 dereferenceable(29), i64 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN3P3D8Graphics11IndexedMeshESaIS3_EE9push_backEOS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

declare void @_ZN3P3D8Graphics11IndexedMeshC1ERKNS0_20ExtendedTriangleMeshE(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3P3D8Graphics20ExtendedTriangleMesh8getFlagsEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin nounwind "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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass