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

; 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::DeviceGuard" = type { ptr }
%"class.dali::CUDAStreamLease" = type { %"class.dali::CUDAStream", i32, ptr }
%"class.dali::CUDAStream" = type { %"class.dali::UniqueHandle" }
%"class.dali::UniqueHandle" = 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" }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali2mm33cuda_malloc_async_memory_resourceC2Ei(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.dali::DeviceGuard", align 8
  %10 = alloca %"class.dali::CUDAStreamLease", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  %12 = load ptr, ptr %5, align 8
  %13 = getelementptr inbounds ptr, ptr %12, i64 1
  call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef %13) #7
  %14 = load ptr, ptr %12, align 8
  store ptr %14, ptr %11, align 8, !tbaa !11
  %15 = getelementptr inbounds ptr, ptr %12, i64 5
  %16 = load ptr, ptr %15, align 8
  %17 = load ptr, ptr %11, align 8, !tbaa !11
  %18 = getelementptr i8, ptr %17, i64 -80
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds i8, ptr %11, i64 %19
  store ptr %16, ptr %20, align 8, !tbaa !11
  %21 = getelementptr inbounds ptr, ptr %12, i64 6
  %22 = load ptr, ptr %21, align 8
  %23 = load ptr, ptr %11, align 8, !tbaa !11
  %24 = getelementptr i8, ptr %23, i64 -56
  %25 = load i64, ptr %24, align 8
  %26 = getelementptr inbounds i8, ptr %11, i64 %25
  store ptr %22, ptr %26, align 8, !tbaa !11
  %27 = getelementptr inbounds ptr, ptr %12, i64 7
  %28 = load ptr, ptr %27, align 8
  %29 = load ptr, ptr %11, align 8, !tbaa !11
  %30 = getelementptr i8, ptr %29, i64 -88
  %31 = load i64, ptr %30, align 8
  %32 = getelementptr inbounds i8, ptr %11, i64 %31
  store ptr %28, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %11, i32 0, i32 2
  invoke void @_ZN4dali15CUDAStreamLeaseC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %33)
          to label %34 unwind label %43

34:                                               ; preds = %3
  %35 = invoke noundef nonnull align 8 dereferenceable(64) ptr @_ZN4dali2mm12_GLOBAL__N_120aligned_alloc_helper8instanceEv()
          to label %36 unwind label %47

36:                                               ; preds = %34
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %51

39:                                               ; preds = %36
  %40 = invoke i32 @cudaGetDevice(ptr noundef %6)
          to label %41 unwind label %47

41:                                               ; preds = %39
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %40)
          to label %42 unwind label %47

42:                                               ; preds = %41
  br label %51

43:                                               ; preds = %3
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %7, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %8, align 4
  br label %80

47:                                               ; preds = %41, %39, %34
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %7, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %8, align 4
  br label %79

51:                                               ; preds = %42, %36
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %11, i32 0, i32 1
  store i32 %52, ptr %53, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %54 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %11, i32 0, i32 1
  %55 = load i32, ptr %54, align 8, !tbaa !13
  invoke void @_ZN4dali11DeviceGuardC1Ei(ptr noundef nonnull align 8 dereferenceable(8) %9, i32 noundef %55)
          to label %56 unwind label %65

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #7
  %57 = invoke noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv()
          to label %58 unwind label %69

58:                                               ; preds = %56
  %59 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %11, i32 0, i32 1
  %60 = load i32, ptr %59, align 8, !tbaa !13
  invoke void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind writable sret(%"class.dali::CUDAStreamLease") align 8 %10, ptr noundef nonnull align 8 dereferenceable(41) %57, i32 noundef %60)
          to label %61 unwind label %69

61:                                               ; preds = %58
  %62 = getelementptr inbounds %"class.dali::mm::cuda_malloc_async_memory_resource", ptr %11, i32 0, i32 2
  %63 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN4dali15CUDAStreamLeaseaSEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %62, ptr noundef nonnull align 8 dereferenceable(24) %10)
          to label %64 unwind label %73

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

65:                                               ; preds = %51
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %7, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %8, align 4
  br label %78

69:                                               ; preds = %58, %56
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %7, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %8, align 4
  br label %77

73:                                               ; preds = %61
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %7, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %8, align 4
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #7
  br label %77

77:                                               ; preds = %73, %69
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #7
  call void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  br label %78

78:                                               ; preds = %77, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %79

79:                                               ; preds = %78, %47
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %33) #7
  br label %80

80:                                               ; preds = %79, %43
  %81 = getelementptr inbounds ptr, ptr %12, i64 1
  call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef %81) #7
  br label %82

82:                                               ; preds = %80
  %83 = load ptr, ptr %7, align 8
  %84 = load i32, ptr %8, align 4
  %85 = insertvalue { ptr, i32 } poison, ptr %83, 0
  %86 = insertvalue { ptr, i32 } %85, i32 %84, 1
  resume { ptr, i32 } %86
}

; 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 #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali15CUDAStreamLeaseC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 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)) #0 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 #1 align 2

attributes #0 = { 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 #1 = { 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 #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::DeviceGuard" = type { ptr }
%"class.dali::CUDAStreamLease" = type { %"class.dali::CUDAStream", i32, ptr }
%"class.dali::CUDAStream" = type { %"class.dali::UniqueHandle" }
%"class.dali::UniqueHandle" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali2mm33cuda_malloc_async_memory_resourceC2Ei(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca %"class.dali::DeviceGuard", align 8
  %6 = alloca %"class.dali::CUDAStreamLease", align 8
  store i32 %2, ptr %4, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  tail call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %7) #7
  %8 = load ptr, ptr %1, align 8
  store ptr %8, ptr %0, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %1, i64 40
  %10 = load ptr, ptr %9, align 8
  %11 = getelementptr i8, ptr %8, i64 -80
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr %0, i64 %12
  store ptr %10, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %1, i64 48
  %15 = load ptr, ptr %14, align 8
  %16 = load ptr, ptr %0, align 8, !tbaa !9
  %17 = getelementptr i8, ptr %16, i64 -56
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr %0, i64 %18
  store ptr %15, ptr %19, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %1, i64 56
  %21 = load ptr, ptr %20, align 8
  %22 = load ptr, ptr %0, align 8, !tbaa !9
  %23 = getelementptr i8, ptr %22, i64 -88
  %24 = load i64, ptr %23, align 8
  %25 = getelementptr inbounds i8, ptr %0, i64 %24
  store ptr %21, ptr %25, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  invoke void @_ZN4dali15CUDAStreamLeaseC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %26)
          to label %27 unwind label %33

27:                                               ; preds = %3
  %28 = tail call noundef nonnull align 8 dereferenceable(64) ptr @_ZN4dali2mm12_GLOBAL__N_120aligned_alloc_helper8instanceEv()
  %29 = icmp slt i32 %2, 0
  br i1 %29, label %30, label %37

30:                                               ; preds = %27
  %31 = invoke i32 @cudaGetDevice(ptr noundef nonnull %4)
          to label %32 unwind label %35

32:                                               ; preds = %30
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %31)
          to label %._crit_edge unwind label %35

._crit_edge:                                      ; preds = %32
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %37

33:                                               ; preds = %3
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %56

35:                                               ; preds = %32, %30
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %55

37:                                               ; preds = %._crit_edge, %27
  %38 = phi i32 [ %.pre, %._crit_edge ], [ %2, %27 ]
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %38, ptr %39, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  invoke void @_ZN4dali11DeviceGuardC1Ei(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %38)
          to label %40 unwind label %47

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

42:                                               ; preds = %40
  %43 = load i32, ptr %39, align 8, !tbaa !11
  invoke void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind nonnull writable sret(%"class.dali::CUDAStreamLease") align 8 %6, ptr noundef nonnull align 8 dereferenceable(41) %41, i32 noundef %43)
          to label %44 unwind label %49

44:                                               ; preds = %42
  %45 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN4dali15CUDAStreamLeaseaSEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 8 dereferenceable(24) %6)
          to label %46 unwind label %51

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

47:                                               ; preds = %37
  %48 = landingpad { ptr, i32 }
          cleanup
  br label %54

49:                                               ; preds = %42, %40
  %50 = landingpad { ptr, i32 }
          cleanup
  br label %53

51:                                               ; preds = %44
  %52 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  br label %53

53:                                               ; preds = %51, %49
  %.pn = phi { ptr, i32 } [ %52, %51 ], [ %50, %49 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #7
  call void @_ZN4dali11DeviceGuardD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #7
  br label %54

54:                                               ; preds = %53, %47
  %.pn.pn = phi { ptr, i32 } [ %.pn, %53 ], [ %48, %47 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %55

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

56:                                               ; preds = %55, %33
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %55 ], [ %34, %33 ]
  call void @_ZN4dali13cuda_for_dali30stream_ordered_memory_resourceINS0_11memory_kind6deviceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %7) #7
  resume { ptr, i32 } %.pn.pn.pn.pn
}

; 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 #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali15CUDAStreamLeaseC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 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 #0 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 #1 align 2

attributes #0 = { 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 #1 = { 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 #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