; LLVM IR from jrouwe/JoltPhysics :: TestFramework/Renderer/VK/RendererVK.ll (ZN10RendererVK10FreeBufferER8BufferVK)

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

%"struct.JPH::AssertLastParam" = type { i8 }
%"struct.RendererVK::Key" = type { i64, i32, i32 }
%class.BufferVK = type { ptr, ptr, i64, i64, i32, i32, i64 }
%class.Renderer = type { ptr, ptr, float, i8, [11 x i8], %struct.CameraState, %"class.JPH::Vec3", %class.Frustum, %class.Frustum, i32, %"struct.Renderer::VertexShaderConstantBuffer", %"struct.Renderer::VertexShaderConstantBuffer", %"struct.Renderer::PixelShaderConstantBuffer" }
%struct.CameraState = type <{ %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", float, [12 x i8] }>
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%class.Frustum = type { [5 x %"class.JPH::Plane"] }
%"class.JPH::Plane" = type { %"class.JPH::Vec4" }
%"class.JPH::Vec4" = type { %union.anon.0 }
%union.anon.0 = type { <4 x float> }
%"struct.Renderer::VertexShaderConstantBuffer" = type { %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Mat44", %"class.JPH::Mat44" }
%"class.JPH::Mat44" = type { [4 x %"class.JPH::Vec4"] }
%"struct.Renderer::PixelShaderConstantBuffer" = type { %"class.JPH::Vec4", %"class.JPH::Vec4" }
%class.RendererVK = type { %class.Renderer, ptr, ptr, ptr, %struct.VkPhysicalDeviceMemoryProperties, ptr, i32, i32, ptr, ptr, ptr, ptr, i8, %"class.JPH::Array", i32, %struct.VkExtent2D, %"class.JPH::Array.1", ptr, ptr, ptr, ptr, ptr, ptr, [2 x ptr], [2 x ptr], ptr, ptr, ptr, ptr, ptr, ptr, %"class.JPH::Array.4", i32, ptr, [2 x ptr], [2 x ptr], [2 x ptr], [2 x ptr], %"class.JPH::Ref", [2 x %"class.std::unique_ptr"], [2 x %"class.std::unique_ptr"], [2 x %"class.std::unique_ptr"], [2 x %"class.JPH::UnorderedMap"], %"class.JPH::UnorderedMap", %"class.JPH::UnorderedMap.9", i32, i32, i64, i64 }
%struct.VkPhysicalDeviceMemoryProperties = type { i32, [32 x %struct.VkMemoryType], i32, [16 x %struct.VkMemoryHeap] }
%struct.VkMemoryType = type { i32, i32 }
%struct.VkMemoryHeap = type { i64, i32 }
%"class.JPH::Array" = type { i64, i64, ptr }
%struct.VkExtent2D = type { i32, i32 }
%"class.JPH::Array.1" = type { i64, i64, ptr }
%"class.JPH::Array.4" = type { i64, i64, ptr }
%"class.JPH::Ref" = type { ptr }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.8" }
%"struct.std::_Head_base.8" = type { ptr }
%"class.JPH::UnorderedMap" = type { %"class.JPH::HashTable.base", [4 x i8] }
%"class.JPH::HashTable.base" = type <{ ptr, ptr, i32, i32, i32 }>
%"class.JPH::UnorderedMap.9" = type { %"class.JPH::HashTable.base.11", [4 x i8] }
%"class.JPH::HashTable.base.11" = type <{ ptr, ptr, i32, i32, i32 }>

@.str.13 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [26 x i8], align 1

; 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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10RendererVK10FreeBufferER8BufferVK(ptr noundef nonnull align 16 dereferenceable(1936) %0, ptr noundef nonnull align 8 dereferenceable(48) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.JPH::AssertLastParam", align 1
  %6 = alloca %"struct.RendererVK::Key", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %class.BufferVK, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %41

12:                                               ; preds = %2
  br label %13

13:                                               ; preds = %12
  %14 = getelementptr inbounds %class.Renderer, ptr %7, i32 0, i32 9
  %15 = load i32, ptr %14, align 16, !tbaa !13
  %16 = icmp ult i32 %15, 2
  br i1 %16, label %20, label %17

17:                                               ; preds = %13
  %18 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.19, ptr noundef @.str.13, i32 noundef 1177)
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !24
  br label %20

20:                                               ; preds = %19, %17, %13
  br label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds %class.RendererVK, ptr %7, i32 0, i32 42
  %23 = getelementptr inbounds %class.Renderer, ptr %7, i32 0, i32 9
  %24 = load i32, ptr %23, align 16, !tbaa !13
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [2 x %"class.JPH::UnorderedMap"], ptr %22, i64 0, i64 %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  %27 = getelementptr inbounds %"struct.RendererVK::Key", ptr %6, i32 0, i32 0
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.BufferVK, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !25
  store i64 %30, ptr %27, align 8, !tbaa !26
  %31 = getelementptr inbounds %"struct.RendererVK::Key", ptr %6, i32 0, i32 1
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.BufferVK, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !28
  store i32 %34, ptr %31, align 8, !tbaa !29
  %35 = getelementptr inbounds %"struct.RendererVK::Key", ptr %6, i32 0, i32 2
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.BufferVK, ptr %36, i32 0, i32 5
  %38 = load i32, ptr %37, align 4, !tbaa !30
  store i32 %38, ptr %35, align 4, !tbaa !31
  %39 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH12UnorderedMapIN10RendererVK3KeyENS_5ArrayI8BufferVKNS_12STLAllocatorIS4_EEEENS1_9KeyHasherESt8equal_toIS2_EEixERKS2_(ptr noundef nonnull align 8 dereferenceable(28) %26, ptr noundef nonnull align 8 dereferenceable(16) %6)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3JPH5ArrayI8BufferVKNS_12STLAllocatorIS1_EEE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %39, ptr noundef nonnull align 8 dereferenceable(48) %40)
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  br label %41

41:                                               ; preds = %21, %2
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH12UnorderedMapIN10RendererVK3KeyENS_5ArrayI8BufferVKNS_12STLAllocatorIS4_EEEENS1_9KeyHasherESt8equal_toIS2_EEixERKS2_(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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, !6, i64 0}
!10 = !{!"_ZTS8BufferVK", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !12, i64 36, !11, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 272}
!14 = !{!"_ZTS8Renderer", !6, i64 8, !15, i64 16, !16, i64 20, !17, i64 32, !18, i64 96, !19, i64 112, !19, i64 192, !12, i64 272, !20, i64 288, !20, i64 544, !22, i64 800}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS11CameraState", !18, i64 0, !18, i64 16, !18, i64 32, !15, i64 48}
!18 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!19 = !{!"_ZTS7Frustum", !7, i64 0}
!20 = !{!"_ZTSN8Renderer26VertexShaderConstantBufferE", !21, i64 0, !21, i64 64, !21, i64 128, !21, i64 192}
!21 = !{!"_ZTSN3JPH5Mat44E", !7, i64 0}
!22 = !{!"_ZTSN8Renderer25PixelShaderConstantBufferE", !23, i64 0, !23, i64 16}
!23 = !{!"_ZTSN3JPH4Vec4E", !7, i64 0}
!24 = !{i64 2158964613}
!25 = !{!10, !11, i64 24}
!26 = !{!27, !11, i64 0}
!27 = !{!"_ZTSN10RendererVK3KeyE", !11, i64 0, !12, i64 8, !12, i64 12}
!28 = !{!10, !12, i64 32}
!29 = !{!27, !12, i64 8}
!30 = !{!10, !12, i64 36}
!31 = !{!27, !12, i64 12}


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

%"struct.RendererVK::Key" = type { i64, i32, i32 }
%"class.JPH::UnorderedMap" = type { %"class.JPH::HashTable.base", [4 x i8] }
%"class.JPH::HashTable.base" = type <{ ptr, ptr, i32, i32, i32 }>

@.str.13 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [26 x i8], align 1

; 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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10RendererVK10FreeBufferER8BufferVK(ptr noundef nonnull align 16 dereferenceable(1936) %0, ptr noundef nonnull align 8 dereferenceable(48) %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %"struct.RendererVK::Key", align 8
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %23, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 272
  %7 = load i32, ptr %6, align 16, !tbaa !12
  %8 = icmp ult i32 %7, 2
  br i1 %8, label %12, label %9

9:                                                ; preds = %5
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.13, i32 noundef 1177)
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !23
  br label %12

12:                                               ; preds = %5, %9, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 1784
  %14 = load i32, ptr %6, align 16, !tbaa !12
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [2 x %"class.JPH::UnorderedMap"], ptr %13, i64 0, i64 %15
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  %17 = getelementptr inbounds i8, ptr %1, i64 24
  %18 = load i64, ptr %17, align 8, !tbaa !24
  store i64 %18, ptr %3, align 8, !tbaa !25
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  %20 = getelementptr inbounds i8, ptr %1, i64 32
  %21 = load <2 x i32>, ptr %20, align 8, !tbaa !27
  store <2 x i32> %21, ptr %19, align 8, !tbaa !27
  %22 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH12UnorderedMapIN10RendererVK3KeyENS_5ArrayI8BufferVKNS_12STLAllocatorIS4_EEEENS1_9KeyHasherESt8equal_toIS2_EEixERKS2_(ptr noundef nonnull align 8 dereferenceable(28) %16, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @_ZN3JPH5ArrayI8BufferVKNS_12STLAllocatorIS1_EEE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %22, ptr noundef nonnull align 8 dereferenceable(48) %1)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  br label %23

23:                                               ; preds = %12, %2
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3JPH12UnorderedMapIN10RendererVK3KeyENS_5ArrayI8BufferVKNS_12STLAllocatorIS4_EEEENS1_9KeyHasherESt8equal_toIS2_EEixERKS2_(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 0}
!6 = !{!"_ZTS8BufferVK", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !11, i64 36, !10, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 272}
!13 = !{!"_ZTS8Renderer", !7, i64 8, !14, i64 16, !15, i64 20, !16, i64 32, !17, i64 96, !18, i64 112, !18, i64 192, !11, i64 272, !19, i64 288, !19, i64 544, !21, i64 800}
!14 = !{!"float", !8, i64 0}
!15 = !{!"bool", !8, i64 0}
!16 = !{!"_ZTS11CameraState", !17, i64 0, !17, i64 16, !17, i64 32, !14, i64 48}
!17 = !{!"_ZTSN3JPH4Vec3E", !8, i64 0}
!18 = !{!"_ZTS7Frustum", !8, i64 0}
!19 = !{!"_ZTSN8Renderer26VertexShaderConstantBufferE", !20, i64 0, !20, i64 64, !20, i64 128, !20, i64 192}
!20 = !{!"_ZTSN3JPH5Mat44E", !8, i64 0}
!21 = !{!"_ZTSN8Renderer25PixelShaderConstantBufferE", !22, i64 0, !22, i64 16}
!22 = !{!"_ZTSN3JPH4Vec4E", !8, i64 0}
!23 = !{i64 2158964613}
!24 = !{!6, !10, i64 24}
!25 = !{!26, !10, i64 0}
!26 = !{!"_ZTSN10RendererVK3KeyE", !10, i64 0, !11, i64 8, !11, i64 12}
!27 = !{!11, !11, i64 0}


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