; LLVM IR from merpheus-dev/LavaEngine :: src/Platforms/OpenGL (GLStandardRenderer)

; 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.Lava::OpenGL::GLStandardRenderer" = type { %"class.Lava::EntityRenderer", %"class.std::map", %"class.std::vector.3", ptr }
%"class.Lava::EntityRenderer" = type { %"class.Lava::BaseRenderer" }
%"class.Lava::BaseRenderer" = type { ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<Lava::MeshRenderer *, std::pair<Lava::MeshRenderer *const, std::vector<Lava::Entity *> *>, std::_Select1st<std::pair<Lava::MeshRenderer *const, std::vector<Lava::Entity *> *>>, std::less<Lava::MeshRenderer *>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<Lava::MeshRenderer *, std::pair<Lava::MeshRenderer *const, std::vector<Lava::Entity *> *>, std::_Select1st<std::pair<Lava::MeshRenderer *const, std::vector<Lava::Entity *> *>>, std::less<Lava::MeshRenderer *>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<Lava::Entity *, std::allocator<Lava::Entity *>>::_Vector_impl" }
%"struct.std::_Vector_base<Lava::Entity *, std::allocator<Lava::Entity *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Lava::Entity *, std::allocator<Lava::Entity *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Lava::Entity *, std::allocator<Lava::Entity *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.17 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Lava6OpenGL18GLStandardRenderer17LoadDefaultShaderERSt6vectorIPNS0_8GLShaderESaIS4_EE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %11 = getelementptr inbounds %"class.Lava::OpenGL::GLStandardRenderer", ptr %9, i32 0, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %10, ptr noundef @.str.17, i32 noundef 0, ptr noundef %12)
          to label %13 unwind label %20

13:                                               ; preds = %2
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %14 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %15 = getelementptr inbounds %"class.Lava::OpenGL::GLStandardRenderer", ptr %9, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %14, ptr noundef @.str.18, i32 noundef 1, ptr noundef %16)
          to label %17 unwind label %24

17:                                               ; preds = %13
  store ptr %14, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN4Lava6OpenGL8GLShaderESaIS3_EE9push_backERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN4Lava6OpenGL8GLShaderESaIS3_EE9push_backERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void

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 @_ZdlPvm(ptr noundef %10, i64 noundef 40) #7
  br label %28

24:                                               ; preds = %13
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %6, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %14, i64 noundef 40) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %28

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

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

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

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

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

declare void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef, i32 noundef, ptr noundef) unnamed_addr #4

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

attributes #0 = { 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 #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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { 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, !6, i64 88}
!10 = !{!"_ZTSN4Lava6OpenGL18GLStandardRendererE", !11, i64 0, !13, i64 16, !22, i64 64, !6, i64 88}
!11 = !{!"_ZTSN4Lava14EntityRendererE", !12, i64 0}
!12 = !{!"_ZTSN4Lava12BaseRendererE", !6, i64 8}
!13 = !{!"_ZTSSt3mapIPN4Lava12MeshRendererEPSt6vectorIPNS0_6EntityESaIS5_EESt4lessIS2_ESaISt4pairIKS2_S8_EEE", !14, i64 0}
!14 = !{!"_ZTSSt8_Rb_treeIPN4Lava12MeshRendererESt4pairIKS2_PSt6vectorIPNS0_6EntityESaIS7_EEESt10_Select1stISB_ESt4lessIS2_ESaISB_EE", !15, i64 0}
!15 = !{!"_ZTSNSt8_Rb_treeIPN4Lava12MeshRendererESt4pairIKS2_PSt6vectorIPNS0_6EntityESaIS7_EEESt10_Select1stISB_ESt4lessIS2_ESaISB_EE13_Rb_tree_implISF_Lb1EEE", !16, i64 0, !18, i64 8}
!16 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN4Lava12MeshRendererEEE", !17, i64 0}
!17 = !{!"_ZTSSt4lessIPN4Lava12MeshRendererEE"}
!18 = !{!"_ZTSSt15_Rb_tree_header", !19, i64 0, !21, i64 32}
!19 = !{!"_ZTSSt18_Rb_tree_node_base", !20, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSSt6vectorIPN4Lava6EntityESaIS2_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIPN4Lava6EntityESaIS2_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIPN4Lava6EntityESaIS2_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIPN4Lava6EntityESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


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

@.str.17 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Lava6OpenGL18GLStandardRenderer17LoadDefaultShaderERSt6vectorIPNS0_8GLShaderESaIS4_EE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %5 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #6
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %5, ptr noundef nonnull @.str.17, i32 noundef 0, ptr noundef %7)
          to label %8 unwind label %12

8:                                                ; preds = %2
  store ptr %5, ptr %3, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %9 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #6
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %9, ptr noundef nonnull @.str.18, i32 noundef 1, ptr noundef %10)
          to label %11 unwind label %14

11:                                               ; preds = %8
  store ptr %9, ptr %4, align 8, !tbaa !25
  call void @_ZNSt6vectorIPN4Lava6OpenGL8GLShaderESaIS3_EE9push_backERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @_ZNSt6vectorIPN4Lava6OpenGL8GLShaderESaIS3_EE9push_backERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret void

12:                                               ; preds = %2
  %13 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 40) #7
  br label %16

14:                                               ; preds = %8
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 40) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %16

16:                                               ; preds = %14, %12
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %13, %12 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  resume { ptr, i32 } %.pn
}

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

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

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

declare void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef, i32 noundef, ptr noundef) unnamed_addr #4

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

attributes #0 = { 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 #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { 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, !9, i64 88}
!6 = !{!"_ZTSN4Lava6OpenGL18GLStandardRendererE", !7, i64 0, !12, i64 16, !21, i64 64, !9, i64 88}
!7 = !{!"_ZTSN4Lava14EntityRendererE", !8, i64 0}
!8 = !{!"_ZTSN4Lava12BaseRendererE", !9, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSSt3mapIPN4Lava12MeshRendererEPSt6vectorIPNS0_6EntityESaIS5_EESt4lessIS2_ESaISt4pairIKS2_S8_EEE", !13, i64 0}
!13 = !{!"_ZTSSt8_Rb_treeIPN4Lava12MeshRendererESt4pairIKS2_PSt6vectorIPNS0_6EntityESaIS7_EEESt10_Select1stISB_ESt4lessIS2_ESaISB_EE", !14, i64 0}
!14 = !{!"_ZTSNSt8_Rb_treeIPN4Lava12MeshRendererESt4pairIKS2_PSt6vectorIPNS0_6EntityESaIS7_EEESt10_Select1stISB_ESt4lessIS2_ESaISB_EE13_Rb_tree_implISF_Lb1EEE", !15, i64 0, !17, i64 8}
!15 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN4Lava12MeshRendererEEE", !16, i64 0}
!16 = !{!"_ZTSSt4lessIPN4Lava12MeshRendererEE"}
!17 = !{!"_ZTSSt15_Rb_tree_header", !18, i64 0, !20, i64 32}
!18 = !{!"_ZTSSt18_Rb_tree_node_base", !19, i64 0, !9, i64 8, !9, i64 16, !9, i64 24}
!19 = !{!"_ZTSSt14_Rb_tree_color", !10, i64 0}
!20 = !{!"long", !10, i64 0}
!21 = !{!"_ZTSSt6vectorIPN4Lava6EntityESaIS2_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseIPN4Lava6EntityESaIS2_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIPN4Lava6EntityESaIS2_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIPN4Lava6EntityESaIS2_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!25 = !{!9, !9, i64 0}


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