; LLVM IR from NVIDIA/DALI :: dali/core/mm/malloc_resource.ll (ZN4dali2mm33cuda_malloc_async_memory_resourceC1Ei)

; 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.dali::CUDAStreamLease" = type { %"class.dali::CUDAStream", i32, ptr }
%"class.dali::CUDAStream" = type { %"class.dali::UniqueHandle" }
%"class.dali::UniqueHandle" = type { ptr }
%"class.dali::DeviceGuard" = type { ptr }
%"class.dali::mm::cuda_malloc_async_memory_resource" = type { %"class.dali::cuda_for_dali::stream_ordered_memory_resource.base", i32, %"class.dali::CUDAStreamLease", %"class.dali::cuda_for_dali::detail::stream_ordered_memory_resource_base" }
%"class.dali::cuda_for_dali::stream_ordered_memory_resource.base" = type { %"class.dali::cuda_for_dali::memory_resource" }
%"class.dali::cuda_for_dali::memory_resource" = type { %"class.dali::cuda_for_dali::detail::memory_resource_base" }
%"class.dali::cuda_for_dali::detail::memory_resource_base" = type { ptr }
%"class.dali::cuda_for_dali::detail::stream_ordered_memory_resource_base" = type { %"class.dali::cuda_for_dali::detail::memory_resource_base" }

@_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE = external dso_local unnamed_addr constant { [20 x ptr], [15 x ptr] }, align 8
@_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE = external dso_local unnamed_addr constant [12 x ptr], align 8

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(64) ptr @_ZN4dali2mm12_GLOBAL__N_120aligned_alloc_helper8instanceEv() #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef) #3

declare i32 @cudaGetDevice(ptr noundef) #4

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

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

declare noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv() #4

declare void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind writable sret(%"class.dali::CUDAStreamLease") align 8, ptr noundef nonnull align 8 dereferenceable(41), i32 noundef) #4

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

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

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

; Function Attrs: nounwind
declare void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali2mm33cuda_malloc_async_memory_resourceC1Ei(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.dali::DeviceGuard", align 8
  %8 = alloca %"class.dali::CUDAStreamLease", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @_ZN4dali13cuda_for_dali6detail20memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  call void @_ZN4dali13cuda_for_dali15memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef getelementptr inbounds ([12 x ptr], ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 0, i64 8)) #7
  %10 = getelementptr inbounds i8, ptr %9, i64 40
  call void @_ZN4dali13cuda_for_dali6detail35stream_ordered_memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef getelementptr inbounds ([12 x ptr], ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 0, i64 10)) #7
  call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef getelementptr inbounds ([12 x ptr], ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 0, i64 1)) #7
  store ptr getelementptr inbounds inrange(-88, 72) ({ [20 x ptr], [15 x ptr] }, ptr @_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE, i32 0, i32 0, i32 11), ptr %9, align 8, !tbaa !11
  store ptr getelementptr inbounds inrange(-88, 72) ({ [20 x ptr], [15 x ptr] }, ptr @_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE, i32 0, i32 0, i32 11), ptr %9, align 8, !tbaa !11
  store ptr getelementptr inbounds inrange(-88, 72) ({ [20 x ptr], [15 x ptr] }, ptr @_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE, i32 0, i32 0, i32 11), ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %9, i64 40
  store ptr getelementptr inbounds inrange(-72, 48) ({ [20 x ptr], [15 x ptr] }, ptr @_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE, i32 0, i32 1, i32 9), ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %9, i32 0, i32 2
  invoke void @_ZN4dali15CUDAStreamLeaseC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12)
          to label %13 unwind label %22

13:                                               ; preds = %2
  %14 = invoke noundef nonnull align 8 dereferenceable(64) ptr @_ZN4dali2mm12_GLOBAL__N_120aligned_alloc_helper8instanceEv()
          to label %15 unwind label %26

15:                                               ; preds = %13
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %18, label %30

18:                                               ; preds = %15
  %19 = invoke i32 @cudaGetDevice(ptr noundef %4)
          to label %20 unwind label %26

20:                                               ; preds = %18
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %19)
          to label %21 unwind label %26

21:                                               ; preds = %20
  br label %30

22:                                               ; preds = %2
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %5, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %6, align 4
  br label %59

26:                                               ; preds = %20, %18, %13
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %5, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %6, align 4
  br label %58

30:                                               ; preds = %21, %15
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %9, i32 0, i32 1
  store i32 %31, ptr %32, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %33 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %9, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !13
  invoke void @_ZN4dali11DeviceGuardC1Ei(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef %34)
          to label %35 unwind label %44

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #7
  %36 = invoke noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv()
          to label %37 unwind label %48

37:                                               ; preds = %35
  %38 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %9, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !13
  invoke void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind writable sret(%"class.dali::CUDAStreamLease") align 8 %8, ptr noundef nonnull align 8 dereferenceable(41) %36, i32 noundef %39)
          to label %40 unwind label %48

40:                                               ; preds = %37
  %41 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %9, i32 0, i32 2
  %42 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN4dali15CUDAStreamLeaseaSEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %41, ptr noundef nonnull align 8 dereferenceable(24) %8)
          to label %43 unwind label %52

43:                                               ; preds = %40
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #7
  call void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  ret void

44:                                               ; preds = %30
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %5, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %6, align 4
  br label %57

48:                                               ; preds = %37, %35
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %5, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %6, align 4
  br label %56

52:                                               ; preds = %40
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %5, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %6, align 4
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #7
  br label %56

56:                                               ; preds = %52, %48
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #7
  call void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #7
  br label %57

57:                                               ; preds = %56, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %58

58:                                               ; preds = %57, %26
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #7
  br label %59

59:                                               ; preds = %58, %22
  call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef getelementptr inbounds ([12 x ptr], ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 0, i64 1)) #7
  call void @_ZN4dali13cuda_for_dali15memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef getelementptr inbounds ([12 x ptr], ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 0, i64 8)) #7
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %5, align 8
  %62 = load i32, ptr %6, align 4
  %63 = insertvalue { ptr, i32 } poison, ptr %61, 0
  %64 = insertvalue { ptr, i32 } %63, i32 %62, 1
  resume { ptr, i32 } %64
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali6detail20memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali15memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali6detail35stream_ordered_memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

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

attributes #0 = { 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 #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 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN4dali2mm33cuda_malloc_async_memory_resourceE", !15, i64 0, !10, i64 8, !16, i64 16}
!15 = !{!"_ZTSN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEE"}
!16 = !{!"_ZTSN4dali15CUDAStreamLeaseE", !17, i64 0, !10, i64 8, !6, i64 16}
!17 = !{!"_ZTSN4dali10CUDAStreamE", !18, i64 0}
!18 = !{!"_ZTSN4dali12UniqueHandleIP11CUstream_stNS_10CUDAStreamEEE", !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"

%"class.dali::CUDAStreamLease" = type { %"class.dali::CUDAStream", i32, ptr }
%"class.dali::CUDAStream" = type { %"class.dali::UniqueHandle" }
%"class.dali::UniqueHandle" = type { ptr }
%"class.dali::DeviceGuard" = type { ptr }

@_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE = external dso_local unnamed_addr constant { [20 x ptr], [15 x ptr] }, align 8
@_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE = external dso_local unnamed_addr constant [12 x ptr], align 8

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(64) ptr @_ZN4dali2mm12_GLOBAL__N_120aligned_alloc_helper8instanceEv() local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef) local_unnamed_addr #3

declare i32 @cudaGetDevice(ptr noundef) local_unnamed_addr #4

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

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

declare noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv() local_unnamed_addr #4

declare void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind writable sret(%"class.dali::CUDAStreamLease") align 8, ptr noundef nonnull align 8 dereferenceable(41), i32 noundef) local_unnamed_addr #4

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

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

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

; Function Attrs: nounwind
declare void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali2mm33cuda_malloc_async_memory_resourceC1Ei(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca %"class.dali::DeviceGuard", align 8
  %5 = alloca %"class.dali::CUDAStreamLease", align 8
  store i32 %1, ptr %3, align 4, !tbaa !5
  tail call void @_ZN4dali13cuda_for_dali6detail20memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #7
  tail call void @_ZN4dali13cuda_for_dali15memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 64)) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZN4dali13cuda_for_dali6detail35stream_ordered_memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 80)) #7
  tail call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 8)) #7
  store ptr getelementptr inbounds inrange(-88, 72) (i8, ptr @_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE, i64 88), ptr %0, align 8, !tbaa !9
  store ptr getelementptr inbounds inrange(-72, 48) (i8, ptr @_ZTVN4dali2mm33cuda_malloc_async_memory_resourceE, i64 232), ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  invoke void @_ZN4dali15CUDAStreamLeaseC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7)
          to label %8 unwind label %14

8:                                                ; preds = %2
  %9 = tail call noundef nonnull align 8 dereferenceable(64) ptr @_ZN4dali2mm12_GLOBAL__N_120aligned_alloc_helper8instanceEv()
  %10 = icmp slt i32 %1, 0
  br i1 %10, label %11, label %18

11:                                               ; preds = %8
  %12 = invoke i32 @cudaGetDevice(ptr noundef nonnull %3)
          to label %13 unwind label %16

13:                                               ; preds = %11
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %12)
          to label %._crit_edge unwind label %16

._crit_edge:                                      ; preds = %13
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %18

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

16:                                               ; preds = %13, %11
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %36

18:                                               ; preds = %._crit_edge, %8
  %19 = phi i32 [ %.pre, %._crit_edge ], [ %1, %8 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %19, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  invoke void @_ZN4dali11DeviceGuardC1Ei(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %19)
          to label %21 unwind label %28

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #7
  %22 = invoke noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv()
          to label %23 unwind label %30

23:                                               ; preds = %21
  %24 = load i32, ptr %20, align 8, !tbaa !11
  invoke void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind nonnull writable sret(%"class.dali::CUDAStreamLease") align 8 %5, ptr noundef nonnull align 8 dereferenceable(41) %22, i32 noundef %24)
          to label %25 unwind label %30

25:                                               ; preds = %23
  %26 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN4dali15CUDAStreamLeaseaSEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %27 unwind label %32

27:                                               ; preds = %25
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #7
  call void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  ret void

28:                                               ; preds = %18
  %29 = landingpad { ptr, i32 }
          cleanup
  br label %35

30:                                               ; preds = %23, %21
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %34

32:                                               ; preds = %25
  %33 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  br label %34

34:                                               ; preds = %32, %30
  %.pn = phi { ptr, i32 } [ %33, %32 ], [ %31, %30 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #7
  call void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  br label %35

35:                                               ; preds = %34, %28
  %.pn.pn = phi { ptr, i32 } [ %.pn, %34 ], [ %29, %28 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %36

36:                                               ; preds = %35, %16
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %35 ], [ %17, %16 ]
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #7
  br label %37

37:                                               ; preds = %36, %14
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %36 ], [ %15, %14 ]
  call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 8)) #7
  call void @_ZN4dali13cuda_for_dali15memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZTTN4dali2mm33cuda_malloc_async_memory_resourceE, i64 64)) #7
  resume { ptr, i32 } %.pn.pn.pn.pn
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali6detail20memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali15memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4dali13cuda_for_dali6detail35stream_ordered_memory_resource_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #0 align 2

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

attributes #0 = { 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 #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 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN4dali2mm33cuda_malloc_async_memory_resourceE", !13, i64 0, !6, i64 8, !14, i64 16}
!13 = !{!"_ZTSN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEE"}
!14 = !{!"_ZTSN4dali15CUDAStreamLeaseE", !15, i64 0, !6, i64 8, !17, i64 16}
!15 = !{!"_ZTSN4dali10CUDAStreamE", !16, i64 0}
!16 = !{!"_ZTSN4dali12UniqueHandleIP11CUstream_stNS_10CUDAStreamEEE", !17, i64 0}
!17 = !{!"any pointer", !7, i64 0}


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