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

; 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.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl" }
%"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl" = type { %"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.dali::CUDAStreamLease" = type { %"class.dali::CUDAStream", i32, ptr }
%"class.dali::CUDAStream" = type { %"class.dali::UniqueHandle" }
%"class.dali::UniqueHandle" = type { ptr }
%class.anon = type { i8 }
%"class.std::allocator.7" = type { i8 }

@__dso_handle = external hidden global i8
@_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices = external hidden global i32, align 4
@_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices = external hidden global i64, align 8
@_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support = external hidden global %"class.std::vector.5", align 8
@_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support = external hidden global i64, align 8
@_ZTIN4dali9CUDAErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #0

declare i32 @__gxx_personality_v0(...)

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

declare i32 @cudaGetDevice(ptr noundef) #2

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEi(i32 noundef %0) #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %class.anon, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.std::allocator.7", align 1
  %7 = alloca %"class.dali::CUDAStreamLease", align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %10 = load atomic i8, ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices acquire, align 8
  %11 = icmp eq i8 %10, 0
  br i1 %11, label %12, label %19, !prof !9

12:                                               ; preds = %1
  %13 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices) #0
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %19

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #0
  %16 = invoke noundef i32 @"_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %17 unwind label %35

17:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #0
  store i32 %16, ptr @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices, align 4, !tbaa !5
  %18 = call ptr @llvm.invariant.start.p0(i64 4, ptr @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices)
  call void @__cxa_guard_release(ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices) #0
  br label %19

19:                                               ; preds = %17, %12, %1
  %20 = load atomic i8, ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support acquire, align 8
  %21 = icmp eq i8 %20, 0
  br i1 %21, label %22, label %30, !prof !9

22:                                               ; preds = %19
  %23 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support) #0
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %22
  %26 = load i32, ptr @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #0
  call void @_ZNSaIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #0
  invoke void @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEC2EmRKS4_(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %27, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %28 unwind label %39

28:                                               ; preds = %25
  call void @_ZNSt15__new_allocatorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #0
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #0
  %29 = call i32 @__cxa_atexit(ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EED2Ev, ptr @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, ptr @__dso_handle) #0
  call void @__cxa_guard_release(ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support) #0
  br label %30

30:                                               ; preds = %28, %22, %19
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = icmp slt i32 %31, 0
  br i1 %32, label %33, label %43

33:                                               ; preds = %30
  %34 = call i32 @cudaGetDevice(ptr noundef %2)
  call void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %34)
  br label %43

35:                                               ; preds = %15
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %4, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #0
  call void @__cxa_guard_abort(ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices) #0
  br label %103

39:                                               ; preds = %25
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %4, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %5, align 4
  call void @_ZNSt15__new_allocatorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #0
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #0
  call void @__cxa_guard_abort(ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support) #0
  br label %103

43:                                               ; preds = %33, %30
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %45) #0
  %47 = load i32, ptr %46, align 4, !tbaa !10
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %97, label %49

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #0
  %50 = call noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv()
  %51 = load i32, ptr %2, align 4, !tbaa !5
  call void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind writable sret(%"class.dali::CUDAStreamLease") align 8 %7, ptr noundef nonnull align 8 dereferenceable(41) %50, i32 noundef %51)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #0
  %52 = call noundef ptr @_ZNKR4dali15CUDAStreamLeasecvP11CUstream_stEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #0
  %53 = invoke i32 @cudaMallocAsync(ptr noundef %8, i64 noundef 16, ptr noundef %52)
          to label %54 unwind label %64

54:                                               ; preds = %49
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %53)
          to label %55 unwind label %64

55:                                               ; preds = %54
  %56 = load ptr, ptr %8, align 8, !tbaa !11
  %57 = call noundef ptr @_ZNKR4dali15CUDAStreamLeasecvP11CUstream_stEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #0
  %58 = invoke i32 @cudaFreeAsync(ptr noundef %56, ptr noundef %57)
          to label %59 unwind label %64

59:                                               ; preds = %55
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %58)
          to label %60 unwind label %64

60:                                               ; preds = %59
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %62) #0
  store i32 1, ptr %63, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #0
  br label %89

64:                                               ; preds = %59, %55, %54, %49
  %65 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTIN4dali9CUDAErrorE
  %66 = extractvalue { ptr, i32 } %65, 0
  store ptr %66, ptr %4, align 8
  %67 = extractvalue { ptr, i32 } %65, 1
  store i32 %67, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #0
  br label %68

68:                                               ; preds = %64
  %69 = load i32, ptr %5, align 4
  %70 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIN4dali9CUDAErrorE) #0
  %71 = icmp eq i32 %69, %70
  br i1 %71, label %72, label %96

72:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #0
  %73 = load ptr, ptr %4, align 8
  %74 = call ptr @__cxa_begin_catch(ptr %73) #0
  store ptr %74, ptr %9, align 8
  %75 = load ptr, ptr %9, align 8, !tbaa !11
  %76 = call noundef i32 @_ZNK4dali9CUDAError8rt_errorEv(ptr noundef nonnull align 8 dereferenceable(24) %75) #0
  %77 = icmp eq i32 %76, 801
  br i1 %77, label %78, label %82

78:                                               ; preds = %72
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %80) #0
  store i32 -1, ptr %81, align 4, !tbaa !10
  br label %87

82:                                               ; preds = %72
  invoke void @__cxa_rethrow() #8
          to label %111 unwind label %83

83:                                               ; preds = %82
  %84 = landingpad { ptr, i32 }
          cleanup
  %85 = extractvalue { ptr, i32 } %84, 0
  store ptr %85, ptr %4, align 8
  %86 = extractvalue { ptr, i32 } %84, 1
  store i32 %86, ptr %5, align 4
  invoke void @__cxa_end_catch()
          to label %94 unwind label %108

87:                                               ; preds = %78
  invoke void @__cxa_end_catch()
          to label %88 unwind label %90

88:                                               ; preds = %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #0
  br label %89

89:                                               ; preds = %88, %60
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #0
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #0
  br label %97

90:                                               ; preds = %87
  %91 = landingpad { ptr, i32 }
          cleanup
  %92 = extractvalue { ptr, i32 } %91, 0
  store ptr %92, ptr %4, align 8
  %93 = extractvalue { ptr, i32 } %91, 1
  store i32 %93, ptr %5, align 4
  br label %95

94:                                               ; preds = %83
  br label %95

95:                                               ; preds = %94, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #0
  br label %96

96:                                               ; preds = %95, %68
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #0
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #0
  br label %103

97:                                               ; preds = %89, %43
  %98 = load i32, ptr %2, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %99) #0
  %101 = load i32, ptr %100, align 4, !tbaa !10
  %102 = icmp eq i32 %101, 1
  ret i1 %102

103:                                              ; preds = %96, %39, %35
  %104 = load ptr, ptr %4, align 8
  %105 = load i32, ptr %5, align 4
  %106 = insertvalue { ptr, i32 } poison, ptr %104, 0
  %107 = insertvalue { ptr, i32 } %106, i32 %105, 1
  resume { ptr, i32 } %107

108:                                              ; preds = %83
  %109 = landingpad { ptr, i32 }
          catch ptr null
  %110 = extractvalue { ptr, i32 } %109, 0
  call void @__clang_call_terminate(ptr %110) #9
  unreachable

111:                                              ; preds = %82
  unreachable
}

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #0

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @"_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

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

; Function Attrs: nounwind
declare void @__cxa_guard_abort(ptr) #0

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZNSaIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEC2EmRKS4_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #4 align 2

declare i32 @cudaMallocAsync(ptr noundef, i64 noundef, ptr noundef) #2

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

declare i32 @cudaFreeAsync(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #6

declare ptr @__cxa_begin_catch(ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4dali9CUDAError8rt_errorEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

declare void @__cxa_rethrow()

declare void @__cxa_end_catch()

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #7

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZNSt15__new_allocatorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #4 align 2

attributes #0 = { nounwind }
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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { nounwind memory(none) }
attributes #7 = { noinline noreturn nounwind uwtable "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 #8 = { noreturn }
attributes #9 = { noreturn 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 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, 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.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl" }
%"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl" = type { %"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Support, std::allocator<Support>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.dali::CUDAStreamLease" = type { %"class.dali::CUDAStream", i32, ptr }
%"class.dali::CUDAStream" = type { %"class.dali::UniqueHandle" }
%"class.dali::UniqueHandle" = type { ptr }
%class.anon = type { i8 }
%"class.std::allocator.7" = type { i8 }

@__dso_handle = external hidden global i8
@_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices = external hidden global i32, align 4
@_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices = external hidden global i64, align 8
@_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support = external hidden global %"class.std::vector.5", align 8
@_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support = external hidden global i64, align 8
@_ZTIN4dali9CUDAErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

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

declare i32 @cudaGetDevice(ptr noundef) local_unnamed_addr #2

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

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

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 #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEi(i32 noundef %0) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %class.anon, align 1
  %4 = alloca %"class.std::allocator.7", align 1
  %5 = alloca %"class.dali::CUDAStreamLease", align 8
  %6 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %7 = load atomic i8, ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices acquire, align 8
  %8 = icmp eq i8 %7, 0
  br i1 %8, label %9, label %15, !prof !9

9:                                                ; preds = %1
  %10 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices) #8
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %15, label %11

11:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #8
  %12 = invoke noundef i32 @"_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %13 unwind label %30

13:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  store i32 %12, ptr @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices, align 4, !tbaa !5
  %14 = call ptr @llvm.invariant.start.p0(i64 4, ptr nonnull @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices)
  call void @__cxa_guard_release(ptr nonnull @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices) #8
  br label %15

15:                                               ; preds = %13, %9, %1
  %16 = load atomic i8, ptr @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support acquire, align 8
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %18, label %25, !prof !9

18:                                               ; preds = %15
  %19 = call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support) #8
  %.not8 = icmp eq i32 %19, 0
  br i1 %.not8, label %25, label %20

20:                                               ; preds = %18
  %21 = load i32, ptr @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #8
  call void @_ZNSaIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #8
  invoke void @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEC2EmRKS4_(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %22, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %23 unwind label %34

23:                                               ; preds = %20
  call void @_ZNSt15__new_allocatorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #8
  %24 = call i32 @__cxa_atexit(ptr nonnull @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EED2Ev, ptr nonnull @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, ptr nonnull @__dso_handle) #8
  call void @__cxa_guard_release(ptr nonnull @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support) #8
  br label %25

25:                                               ; preds = %23, %18, %15
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %28, label %38

28:                                               ; preds = %25
  %29 = call i32 @cudaGetDevice(ptr noundef nonnull %2)
  call void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %29)
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %38

30:                                               ; preds = %11
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  %33 = extractvalue { ptr, i32 } %31, 1
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  call void @__cxa_guard_abort(ptr nonnull @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE11num_devices) #8
  br label %86

34:                                               ; preds = %20
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  %37 = extractvalue { ptr, i32 } %35, 1
  call void @_ZNSt15__new_allocatorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #8
  call void @__cxa_guard_abort(ptr nonnull @_ZGVZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support) #8
  br label %86

38:                                               ; preds = %28, %25
  %39 = phi i32 [ %.pre, %28 ], [ %26, %25 ]
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %40) #8
  %42 = load i32, ptr %41, align 4, !tbaa !10
  %.not9 = icmp eq i32 %42, 0
  br i1 %.not9, label %43, label %80

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #8
  %44 = call noundef nonnull align 8 dereferenceable(41) ptr @_ZN4dali14CUDAStreamPool8instanceEv()
  %45 = load i32, ptr %2, align 4, !tbaa !5
  call void @_ZN4dali14CUDAStreamPool3GetEi(ptr dead_on_unwind nonnull writable sret(%"class.dali::CUDAStreamLease") align 8 %5, ptr noundef nonnull align 8 dereferenceable(41) %44, i32 noundef %45)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  %46 = call noundef ptr @_ZNKR4dali15CUDAStreamLeasecvP11CUstream_stEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %47 = invoke i32 @cudaMallocAsync(ptr noundef nonnull %6, i64 noundef 16, ptr noundef %46)
          to label %48 unwind label %58

48:                                               ; preds = %43
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %47)
          to label %49 unwind label %58

49:                                               ; preds = %48
  %50 = load ptr, ptr %6, align 8, !tbaa !11
  %51 = call noundef ptr @_ZNKR4dali15CUDAStreamLeasecvP11CUstream_stEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %52 = invoke i32 @cudaFreeAsync(ptr noundef %50, ptr noundef %51)
          to label %53 unwind label %58

53:                                               ; preds = %49
  invoke void @_Z9CUDA_CALLI9cudaErrorEvT_(i32 noundef %52)
          to label %54 unwind label %58

54:                                               ; preds = %53
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %56) #8
  store i32 1, ptr %57, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  br label %75

58:                                               ; preds = %53, %49, %48, %43
  %59 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTIN4dali9CUDAErrorE
  %60 = extractvalue { ptr, i32 } %59, 0
  %61 = extractvalue { ptr, i32 } %59, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  %62 = call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTIN4dali9CUDAErrorE) #8
  %63 = icmp eq i32 %61, %62
  br i1 %63, label %64, label %79

64:                                               ; preds = %58
  %65 = call ptr @__cxa_begin_catch(ptr %60) #8
  %66 = call noundef i32 @_ZNK4dali9CUDAError8rt_errorEv(ptr noundef nonnull align 8 dereferenceable(24) %65) #8
  %67 = icmp eq i32 %66, 801
  br i1 %67, label %68, label %72

68:                                               ; preds = %64
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %70) #8
  store i32 -1, ptr %71, align 4, !tbaa !10
  invoke void @__cxa_end_catch()
          to label %75 unwind label %76

72:                                               ; preds = %64
  invoke void @__cxa_rethrow() #9
          to label %92 unwind label %73

73:                                               ; preds = %72
  %74 = landingpad { ptr, i32 }
          cleanup
  invoke void @__cxa_end_catch()
          to label %78 unwind label %89

75:                                               ; preds = %68, %54
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  br label %80

76:                                               ; preds = %68
  %77 = landingpad { ptr, i32 }
          cleanup
  br label %78

78:                                               ; preds = %73, %76
  %.pn = phi { ptr, i32 } [ %77, %76 ], [ %74, %73 ]
  %.0 = extractvalue { ptr, i32 } %.pn, 0
  %.04 = extractvalue { ptr, i32 } %.pn, 1
  br label %79

79:                                               ; preds = %78, %58
  %.15 = phi i32 [ %.04, %78 ], [ %61, %58 ]
  %.1 = phi ptr [ %.0, %78 ], [ %60, %58 ]
  call void @_ZN4dali15CUDAStreamLeaseD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  br label %86

80:                                               ; preds = %75, %38
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7support, i64 noundef %82) #8
  %84 = load i32, ptr %83, align 4, !tbaa !10
  %85 = icmp eq i32 %84, 1
  ret i1 %85

86:                                               ; preds = %79, %34, %30
  %.26 = phi i32 [ %.15, %79 ], [ %37, %34 ], [ %33, %30 ]
  %.2 = phi ptr [ %.1, %79 ], [ %36, %34 ], [ %32, %30 ]
  %87 = insertvalue { ptr, i32 } poison, ptr %.2, 0
  %88 = insertvalue { ptr, i32 } %87, i32 %.26, 1
  resume { ptr, i32 } %88

89:                                               ; preds = %73
  %90 = landingpad { ptr, i32 }
          catch ptr null
  %91 = extractvalue { ptr, i32 } %90, 0
  call void @__clang_call_terminate(ptr %91) #10
  unreachable

92:                                               ; preds = %72
  unreachable
}

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @"_ZZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 align 2

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

; Function Attrs: nofree nounwind
declare void @__cxa_guard_abort(ptr) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZNSaIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEC2EmRKS4_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportSaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 align 2

declare i32 @cudaMallocAsync(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKR4dali15CUDAStreamLeasecvP11CUstream_stEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

declare i32 @cudaFreeAsync(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #6

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4dali9CUDAError8rt_errorEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

declare void @__cxa_rethrow() local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #7

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZNSt15__new_allocatorIZN4dali2mm33cuda_malloc_async_memory_resource12is_supportedEiE7SupportED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #4 align 2

attributes #0 = { nofree nounwind }
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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { nofree nosync nounwind memory(none) }
attributes #7 = { noinline noreturn nounwind uwtable "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 #8 = { nounwind }
attributes #9 = { noreturn }
attributes #10 = { noreturn 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 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


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