; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/tbb (queuing_rw_mutex)

; 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.tbb::tricky_atomic_pointer" = type { ptr }
%"class.tbb::queuing_rw_mutex::scoped_lock" = type <{ ptr, ptr, ptr, %"struct.tbb::atomic.0", i8, i8, [5 x i8] }>
%"struct.tbb::atomic.0" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic.1" }
%"struct.tbb::internal::atomic_impl_with_arithmetic.1" = type { %"struct.tbb::internal::atomic_impl.2" }
%"struct.tbb::internal::atomic_impl.2" = type { %"struct.tbb::internal::aligned_storage.3" }
%"struct.tbb::internal::aligned_storage.3" = type { i8 }
%"class.tbb::queuing_rw_mutex" = type { %"struct.tbb::atomic" }
%"struct.tbb::atomic" = type { %"struct.tbb::internal::atomic_impl_with_arithmetic" }
%"struct.tbb::internal::atomic_impl_with_arithmetic" = type { %"struct.tbb::internal::atomic_impl" }
%"struct.tbb::internal::atomic_impl" = type { %"struct.tbb::internal::aligned_storage" }
%"struct.tbb::internal::aligned_storage" = type { ptr }

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) #1 align 2

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock7releaseEv(ptr noundef nonnull align 8 dereferenceable(27) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %9 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %12 = load ptr, ptr %2, align 8
  %13 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 3
  %14 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %13)
  %15 = zext i8 %14 to i32
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %61

17:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %18 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %19 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %18)
  store ptr %19, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %33, label %22

22:                                               ; preds = %17
  %23 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.tbb::queuing_rw_mutex", ptr %24, i32 0, i32 0
  %26 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef null, ptr noundef %12)
  %27 = icmp eq ptr %12, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  store i32 2, ptr %5, align 4
  br label %58

29:                                               ; preds = %22
  %30 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef null)
  %31 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %32 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %31)
  store ptr %32, ptr %3, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %29, %17
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %34, i32 0, i32 4
  call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %35, i32 noundef 2)
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %36, i32 0, i32 3
  %38 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %37)
  %39 = zext i8 %38 to i32
  %40 = icmp eq i32 %39, 32
  br i1 %40, label %41, label %52

41:                                               ; preds = %33
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %42, i32 0, i32 1
  %44 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef %43, ptr noundef null)
  store ptr %44, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %45, i32 0, i32 3
  %47 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %46, i8 noundef zeroext 64)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %48, i32 0, i32 4
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %49, i32 noundef 1)
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef %50)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27) %12, i64 noundef %51)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %57

52:                                               ; preds = %33
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %53, i32 0, i32 1
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %54, ptr noundef null)
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %55, i32 0, i32 4
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %56, i32 noundef 1)
  br label %57

57:                                               ; preds = %52, %41
  store i32 0, ptr %5, align 4
  br label %58

58:                                               ; preds = %57, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %59 = load i32, ptr %5, align 4
  switch i32 %59, label %157 [
    i32 0, label %60
    i32 2, label %155
  ]

60:                                               ; preds = %58
  br label %154

61:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %149, %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %63 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 1
  %64 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef %63, i64 noundef 1)
  store ptr %64, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %117

67:                                               ; preds = %62
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = call noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock25try_acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %68)
  br i1 %69, label %84, label %70

70:                                               ; preds = %67
  %71 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 1
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %73 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %8, i64 noundef 1)
  %74 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEEPS2_PVS6_S6_S6_(ptr noundef %71, ptr noundef %72, ptr noundef %73)
  store ptr %74, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = ptrtoint ptr %75 to i64
  %77 = and i64 %76, 1
  %78 = icmp ne i64 %77, 0
  br i1 %78, label %83, label %79

79:                                               ; preds = %70
  %80 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %81 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %9, i64 noundef 1)
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %80, ptr noundef %81)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %82)
  br label %83

83:                                               ; preds = %79, %70
  store ptr null, ptr %6, align 8, !tbaa !5
  store i32 3, ptr %5, align 4
  br label %149

84:                                               ; preds = %67
  %85 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 1
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %85, ptr noundef %86)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %12)
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %87, i32 0, i32 2
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %88, ptr noundef null)
  %89 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %90 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %89)
  %91 = icmp ne ptr %90, null
  br i1 %91, label %101, label %92

92:                                               ; preds = %84
  %93 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !9
  %95 = getelementptr inbounds %"class.tbb::queuing_rw_mutex", ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %95, ptr noundef %96, ptr noundef %12)
  %98 = icmp ne ptr %12, %97
  br i1 %98, label %99, label %101

99:                                               ; preds = %92
  %100 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockEPvEEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %100, ptr noundef null)
  br label %101

101:                                              ; preds = %99, %92, %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %102 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %103 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %102)
  store ptr %103, ptr %10, align 8, !tbaa !5
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = icmp ne ptr %104, null
  br i1 %105, label %106, label %115

106:                                              ; preds = %101
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %107, i32 0, i32 1
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef %108, ptr noundef %109)
  store ptr %110, ptr %6, align 8, !tbaa !5
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %111, i32 0, i32 2
  %113 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %114 = load ptr, ptr %113, align 8, !tbaa !15
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %112, ptr noundef %114)
  br label %115

115:                                              ; preds = %106, %101
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %116)
  br label %145

117:                                              ; preds = %62
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %118 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %119 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %118)
  store ptr %119, ptr %11, align 8, !tbaa !5
  %120 = load ptr, ptr %11, align 8, !tbaa !5
  %121 = icmp ne ptr %120, null
  br i1 %121, label %134, label %122

122:                                              ; preds = %117
  %123 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !9
  %125 = getelementptr inbounds %"class.tbb::queuing_rw_mutex", ptr %124, i32 0, i32 0
  %126 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %125, ptr noundef null, ptr noundef %12)
  %127 = icmp ne ptr %12, %126
  br i1 %127, label %128, label %132

128:                                              ; preds = %122
  %129 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %129, ptr noundef null)
  %130 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 2
  %131 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %130)
  store ptr %131, ptr %11, align 8, !tbaa !5
  br label %133

132:                                              ; preds = %122
  store i32 4, ptr %5, align 4
  br label %142

133:                                              ; preds = %128
  br label %134

134:                                              ; preds = %133, %117
  %135 = load ptr, ptr %11, align 8, !tbaa !5
  %136 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %135, i32 0, i32 4
  call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %136, i32 noundef 2)
  %137 = load ptr, ptr %11, align 8, !tbaa !5
  %138 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %137, i32 0, i32 1
  %139 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef %138, ptr noundef null)
  store ptr %139, ptr %6, align 8, !tbaa !5
  %140 = load ptr, ptr %11, align 8, !tbaa !5
  %141 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %140, i32 0, i32 4
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %141, i32 noundef 1)
  store i32 0, ptr %5, align 4
  br label %142

142:                                              ; preds = %134, %132
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %143 = load i32, ptr %5, align 4
  switch i32 %143, label %149 [
    i32 0, label %144
    i32 4, label %146
  ]

144:                                              ; preds = %142
  br label %145

145:                                              ; preds = %144, %115
  br label %146

146:                                              ; preds = %145, %142
  %147 = load ptr, ptr %6, align 8, !tbaa !5
  %148 = call noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef %147)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27) %12, i64 noundef %148)
  store i32 0, ptr %5, align 4
  br label %149

149:                                              ; preds = %146, %142, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %150 = load i32, ptr %5, align 4
  switch i32 %150, label %151 [
    i32 3, label %62
  ]

151:                                              ; preds = %149
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %152 = load i32, ptr %5, align 4
  switch i32 %152, label %157 [
    i32 0, label %153
  ]

153:                                              ; preds = %151
  br label %154

154:                                              ; preds = %153, %60
  br label %155

155:                                              ; preds = %154, %58
  %156 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %12, i32 0, i32 4
  call void @_ZN3tbb8internal18spin_wait_while_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %156, i32 noundef 2)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock10initializeEv(ptr noundef nonnull align 8 dereferenceable(27) %12)
  ret void

157:                                              ; preds = %151, %58
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8)) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef, ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27), i64 noundef) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef, i64 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock25try_acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEEPS2_PVS6_S6_S6_(ptr noundef, ptr noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8)) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb8internal18spin_wait_while_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock10initializeEv(ptr noundef nonnull align 8 dereferenceable(27)) #3 align 2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN3tbb16queuing_rw_mutex11scoped_lockE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !7, i64 25, !7, i64 26}
!11 = !{!"_ZTSN3tbb6atomicIhEE", !12, i64 0}
!12 = !{!"_ZTSN3tbb8internal27atomic_impl_with_arithmeticIhhcEE", !13, i64 0}
!13 = !{!"_ZTSN3tbb8internal11atomic_implIhEE", !14, i64 0}
!14 = !{!"_ZTSN3tbb8internal15aligned_storageIhLm1EEE", !7, i64 0}
!15 = !{!10, !6, i64 16}


; 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.tbb::tricky_atomic_pointer" = type { ptr }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock7releaseEv(ptr noundef nonnull align 8 dereferenceable(27) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %4 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = tail call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %5)
  %7 = icmp eq i8 %6, 1
  br i1 %7, label %10, label %.preheader

.preheader:                                       ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %9 = tail call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef nonnull %8, i64 noundef 1)
  store ptr %9, ptr %2, align 8, !tbaa !5
  %.not37 = icmp eq ptr %9, null
  br i1 %.not37, label %._crit_edge, label %.lr.ph

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = tail call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %11)
  %.not33 = icmp eq ptr %12, null
  br i1 %.not33, label %13, label %19

13:                                               ; preds = %10
  %14 = load ptr, ptr %0, align 8, !tbaa !9
  %15 = tail call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef null, ptr noundef nonnull %0)
  %16 = icmp eq ptr %15, %0
  br i1 %16, label %77, label %17

17:                                               ; preds = %13
  tail call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef null)
  %18 = tail call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %11)
  br label %19

19:                                               ; preds = %17, %10
  %.019 = phi ptr [ %12, %10 ], [ %18, %17 ]
  %20 = getelementptr inbounds i8, ptr %.019, i64 25
  tail call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %20, i32 noundef 2)
  %21 = getelementptr inbounds i8, ptr %.019, i64 24
  %22 = tail call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %21)
  %23 = icmp eq i8 %22, 32
  br i1 %23, label %24, label %29

24:                                               ; preds = %19
  tail call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  %25 = getelementptr inbounds i8, ptr %.019, i64 8
  %26 = tail call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef nonnull %25, ptr noundef null)
  %27 = tail call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %21, i8 noundef zeroext 64)
  tail call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %20, i32 noundef 1)
  %28 = tail call noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef %26)
  tail call void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27) %0, i64 noundef %28)
  br label %77

29:                                               ; preds = %19
  %30 = getelementptr inbounds i8, ptr %.019, i64 8
  tail call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef null)
  tail call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %20, i32 noundef 1)
  br label %77

.lr.ph:                                           ; preds = %.preheader, %75
  %31 = phi ptr [ %76, %75 ], [ %9, %.preheader ]
  %32 = call noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock25try_acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %31)
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  br i1 %32, label %42, label %34

34:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %35 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef 1)
  %36 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEEPS2_PVS6_S6_S6_(ptr noundef nonnull %8, ptr noundef %33, ptr noundef %35)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %37 = ptrtoint ptr %36 to i64
  %38 = and i64 %37, 1
  %.not29 = icmp eq i64 %38, 0
  br i1 %.not29, label %39, label %75

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %40 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %4, i64 noundef 1)
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef %40)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %41)
  br label %75

42:                                               ; preds = %.lr.ph
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef %33)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 16
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef null)
  %45 = getelementptr inbounds i8, ptr %0, i64 16
  %46 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %45)
  %.not30 = icmp eq ptr %46, null
  br i1 %.not30, label %47, label %52

47:                                               ; preds = %42
  %48 = load ptr, ptr %0, align 8, !tbaa !9
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %48, ptr noundef %49, ptr noundef nonnull %0)
  %.not31 = icmp eq ptr %50, %0
  br i1 %.not31, label %52, label %51

51:                                               ; preds = %47
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockEPvEEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef null)
  br label %52

52:                                               ; preds = %51, %47, %42
  %53 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %45)
  %.not32 = icmp eq ptr %53, null
  br i1 %.not32, label %61, label %54

54:                                               ; preds = %52
  %55 = getelementptr inbounds i8, ptr %53, i64 8
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef nonnull %55, ptr noundef %56)
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i64 16
  %60 = load ptr, ptr %45, align 8, !tbaa !15
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %59, ptr noundef %60)
  br label %61

61:                                               ; preds = %54, %52
  %.1 = phi ptr [ %57, %54 ], [ null, %52 ]
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %62)
  br label %.thread

._crit_edge:                                      ; preds = %75, %.preheader
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  %63 = getelementptr inbounds i8, ptr %0, i64 16
  %64 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %63)
  %.not27 = icmp eq ptr %64, null
  br i1 %.not27, label %65, label %70

65:                                               ; preds = %._crit_edge
  %66 = load ptr, ptr %0, align 8, !tbaa !9
  %67 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %66, ptr noundef null, ptr noundef nonnull %0)
  %.not28 = icmp eq ptr %67, %0
  br i1 %.not28, label %.thread, label %68

68:                                               ; preds = %65
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %63, ptr noundef null)
  %69 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %63)
  br label %70

70:                                               ; preds = %68, %._crit_edge
  %.0 = phi ptr [ %64, %._crit_edge ], [ %69, %68 ]
  %71 = getelementptr inbounds i8, ptr %.0, i64 25
  call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %71, i32 noundef 2)
  %72 = getelementptr inbounds i8, ptr %.0, i64 8
  %73 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef nonnull %72, ptr noundef null)
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %71, i32 noundef 1)
  br label %.thread

.thread:                                          ; preds = %61, %65, %70
  %.3 = phi ptr [ %.1, %61 ], [ %73, %70 ], [ null, %65 ]
  %74 = call noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef %.3)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27) %0, i64 noundef %74)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  br label %77

75:                                               ; preds = %34, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %76 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef nonnull %8, i64 noundef 1)
  store ptr %76, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %76, null
  br i1 %.not, label %._crit_edge, label %.lr.ph

77:                                               ; preds = %.thread, %13, %29, %24
  %78 = getelementptr inbounds i8, ptr %0, i64 25
  call void @_ZN3tbb8internal18spin_wait_while_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %78, i32 noundef 2)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock10initializeEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef, i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock25try_acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEEPS2_PVS6_S6_S6_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tbb8internal18spin_wait_while_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock10initializeEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #3 align 2

attributes #0 = { 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 #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN3tbb16queuing_rw_mutex11scoped_lockE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !7, i64 25, !7, i64 26}
!11 = !{!"_ZTSN3tbb6atomicIhEE", !12, i64 0}
!12 = !{!"_ZTSN3tbb8internal27atomic_impl_with_arithmeticIhhcEE", !13, i64 0}
!13 = !{!"_ZTSN3tbb8internal11atomic_implIhEE", !14, i64 0}
!14 = !{!"_ZTSN3tbb8internal15aligned_storageIhLm1EEE", !7, i64 0}
!15 = !{!10, !6, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass