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

; 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::GLParticleRenderer" = type { %"class.Lava::ParticleRenderer", %"class.std::vector", ptr, ptr, ptr, %"class.std::shared_ptr" }
%"class.Lava::ParticleRenderer" = type { %"class.Lava::BaseRenderer", ptr }
%"class.Lava::BaseRenderer" = type { ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Lava::ParticleSystem *, std::allocator<Lava::ParticleSystem *>>::_Vector_impl" }
%"struct.std::_Vector_base<Lava::ParticleSystem *, std::allocator<Lava::ParticleSystem *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Lava::ParticleSystem *, std::allocator<Lava::ParticleSystem *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Lava::ParticleSystem *, std::allocator<Lava::ParticleSystem *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Lava6OpenGL18GLParticleRenderer11LoadShadersEv(ptr noundef nonnull align 8 dereferenceable(88) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %8 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %9 = getelementptr inbounds %"class.Lava::OpenGL::GLParticleRenderer", ptr %7, i32 0, i32 2
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %8, ptr noundef @.str.2, i32 noundef 0, ptr noundef %10)
          to label %11 unwind label %22

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

15:                                               ; preds = %11
  store ptr %12, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.Lava::OpenGL::GLParticleRenderer", ptr %7, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN4Lava6OpenGL12GLShaderBank9AddShaderEPNS0_8GLShaderE(ptr noundef nonnull align 8 dereferenceable(40) %17, ptr noundef %18)
  %19 = getelementptr inbounds %"class.Lava::OpenGL::GLParticleRenderer", ptr %7, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN4Lava6OpenGL12GLShaderBank9AddShaderEPNS0_8GLShaderE(ptr noundef nonnull align 8 dereferenceable(40) %20, ptr noundef %21)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void

22:                                               ; preds = %1
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %4, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %8, i64 noundef 40) #7
  br label %30

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

30:                                               ; preds = %26, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %4, align 8
  %33 = load i32, ptr %5, align 4
  %34 = insertvalue { ptr, i32 } poison, ptr %32, 0
  %35 = insertvalue { ptr, i32 } %34, i32 %33, 1
  resume { ptr, i32 } %35
}

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

declare void @_ZN4Lava6OpenGL12GLShaderBank9AddShaderEPNS0_8GLShaderE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #4

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 48}
!10 = !{!"_ZTSN4Lava6OpenGL18GLParticleRendererE", !11, i64 0, !13, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !17, i64 72}
!11 = !{!"_ZTSN4Lava16ParticleRendererE", !12, i64 0, !6, i64 16}
!12 = !{!"_ZTSN4Lava12BaseRendererE", !6, i64 8}
!13 = !{!"_ZTSSt6vectorIPN4Lava14ParticleSystemESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIPN4Lava14ParticleSystemESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN4Lava14ParticleSystemESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN4Lava14ParticleSystemESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTSSt10shared_ptrIN4Lava6OpenGL14GLVertexBufferEE", !18, i64 0}
!18 = !{!"_ZTSSt12__shared_ptrIN4Lava6OpenGL14GLVertexBufferELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !19, i64 8}
!19 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, 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"

@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 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: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Lava6OpenGL18GLParticleRenderer11LoadShadersEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(88) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %2, ptr noundef nonnull @.str.2, i32 noundef 0, ptr noundef %4)
          to label %5 unwind label %11

5:                                                ; preds = %1
  %6 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN4Lava6OpenGL8GLShaderC1EPKc10ShaderTypePNS0_12GLShaderBankE(ptr noundef nonnull align 8 dereferenceable(36) %6, ptr noundef nonnull @.str.3, i32 noundef 1, ptr noundef %7)
          to label %8 unwind label %13

8:                                                ; preds = %5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @_ZN4Lava6OpenGL12GLShaderBank9AddShaderEPNS0_8GLShaderE(ptr noundef nonnull align 8 dereferenceable(40) %9, ptr noundef nonnull %2)
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @_ZN4Lava6OpenGL12GLShaderBank9AddShaderEPNS0_8GLShaderE(ptr noundef nonnull align 8 dereferenceable(40) %10, ptr noundef nonnull %6)
  ret void

11:                                               ; preds = %1
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %15

13:                                               ; preds = %5
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %15

15:                                               ; preds = %13, %11
  %.sink = phi ptr [ %6, %13 ], [ %2, %11 ]
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %12, %11 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %.sink, i64 noundef 40) #5
  resume { ptr, i32 } %.pn
}

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

declare void @_ZN4Lava6OpenGL12GLShaderBank9AddShaderEPNS0_8GLShaderE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #3

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 = { 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 #2 = { 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 #3 = { "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 = { builtin allocsize(0) }
attributes #5 = { 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 48}
!6 = !{!"_ZTSN4Lava6OpenGL18GLParticleRendererE", !7, i64 0, !12, i64 24, !9, i64 48, !9, i64 56, !9, i64 64, !16, i64 72}
!7 = !{!"_ZTSN4Lava16ParticleRendererE", !8, i64 0, !9, i64 16}
!8 = !{!"_ZTSN4Lava12BaseRendererE", !9, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSSt6vectorIPN4Lava14ParticleSystemESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIPN4Lava14ParticleSystemESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIPN4Lava14ParticleSystemESaIS2_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN4Lava14ParticleSystemESaIS2_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!16 = !{!"_ZTSSt10shared_ptrIN4Lava6OpenGL14GLVertexBufferEE", !17, i64 0}
!17 = !{!"_ZTSSt12__shared_ptrIN4Lava6OpenGL14GLVertexBufferELN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0, !18, i64 8}
!18 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0}


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