; 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::internal::atomic_backoff" = type { i32 }
%"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: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext, i8 noundef zeroext) #1 align 2

; 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
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 uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE2EEEhhh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext, i8 noundef zeroext) #1 align 2

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

23:                                               ; preds = %1
  store i1 true, ptr %2, align 1
  br label %170

24:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store ptr %18, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 3
  %26 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %25, i8 noundef zeroext 16)
  br label %27

27:                                               ; preds = %91, %24
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %18)
  %28 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %"class.tbb::queuing_rw_mutex", ptr %29, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %31 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %6, i64 noundef 1)
  %32 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef %31, ptr noundef %18)
  %33 = icmp ne ptr %18, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br i1 %33, label %34, label %94

34:                                               ; preds = %27
  %35 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 2
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockEPvEEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %36 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 2
  %37 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef %36, i64 noundef 1)
  store ptr %37, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %38, i32 0, i32 3
  %40 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %39)
  %41 = zext i8 %40 to i16
  store i16 %41, ptr %8, align 2, !tbaa !15
  %42 = load i16, ptr %8, align 2, !tbaa !15
  %43 = zext i16 %42 to i32
  %44 = and i32 %43, 6
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %49

46:                                               ; preds = %34
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %47, i32 0, i32 4
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %48, i32 noundef 1)
  br label %49

49:                                               ; preds = %46, %34
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %50, i32 0, i32 1
  %52 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef %51, ptr noundef %18)
  store ptr %52, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = call noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef %53)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27) %18, i64 noundef %54)
  %55 = load i16, ptr %8, align 2, !tbaa !15
  %56 = zext i16 %55 to i32
  %57 = and i32 %56, 30
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %87

59:                                               ; preds = %49
  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)
  %60 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %9, i64 noundef 1)
  store ptr %60, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @_ZN3tbb8internal14atomic_backoffC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %10)
  br label %61

61:                                               ; preds = %83, %59
  %62 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 2
  %63 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %62)
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = icmp eq ptr %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %61
  store i32 3, ptr %11, align 4
  br label %84

67:                                               ; preds = %61
  %68 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 3
  %69 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %68)
  %70 = zext i8 %69 to i32
  %71 = and i32 %70, 96
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %82

73:                                               ; preds = %67
  %74 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 2
  %75 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %74)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = icmp eq ptr %75, %76
  br i1 %77, label %78, label %81

78:                                               ; preds = %73
  %79 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 2
  %80 = 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) %79, ptr noundef %80)
  br label %81

81:                                               ; preds = %78, %73
  store i32 6, ptr %11, align 4
  br label %84

82:                                               ; preds = %67
  br label %83

83:                                               ; preds = %82
  call void @_ZN3tbb8internal14atomic_backoff5pauseEv(ptr noundef nonnull align 4 dereferenceable(4) %10)
  br label %61, !llvm.loop !17

84:                                               ; preds = %81, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %85 = load i32, ptr %11, align 4
  switch i32 %85, label %91 [
    i32 3, label %86
  ]

86:                                               ; preds = %84
  store i32 2, ptr %11, align 4
  br label %91

87:                                               ; preds = %49
  %88 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 2
  %89 = 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) %88, ptr noundef %89)
  br label %90

90:                                               ; preds = %87
  store i32 0, ptr %11, align 4
  br label %91

91:                                               ; preds = %90, %86, %84
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %92 = load i32, ptr %11, align 4
  switch i32 %92, label %169 [
    i32 0, label %93
    i32 2, label %27
    i32 6, label %98
  ]

93:                                               ; preds = %91
  br label %95

94:                                               ; preds = %27
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %18)
  br label %95

95:                                               ; preds = %94, %93
  %96 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 3
  %97 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %96, i8 noundef zeroext 32, i8 noundef zeroext 16)
  br label %98

98:                                               ; preds = %167, %95, %91
  %99 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !9
  %101 = getelementptr inbounds %"class.tbb::queuing_rw_mutex", ptr %100, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %102 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %12, i64 noundef 1)
  %103 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %101, ptr noundef %18, ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %104 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %105 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef %104, i64 noundef 1)
  store ptr %105, ptr %13, align 8, !tbaa !5
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  %107 = icmp ne ptr %106, null
  br i1 %107, label %108, label %152

108:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  %109 = load ptr, ptr %13, align 8, !tbaa !5
  %110 = call noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock25try_acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %109)
  %111 = zext i1 %110 to i8
  store i8 %111, ptr %14, align 1, !tbaa !19
  %112 = load ptr, ptr %13, align 8, !tbaa !5
  %113 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %112, i32 0, i32 3
  %114 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE2EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %113, i8 noundef zeroext 32, i8 noundef zeroext 16)
  %115 = load i8, ptr %14, align 1, !tbaa !19, !range !21, !noundef !22
  %116 = trunc i8 %115 to i1
  br i1 %116, label %136, label %117

117:                                              ; preds = %108
  %118 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %119 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %120 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %15, i64 noundef 1)
  %121 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEEPS2_PVS6_S6_S6_(ptr noundef %118, ptr noundef %119, ptr noundef %120)
  store ptr %121, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  %122 = load ptr, ptr %4, align 8, !tbaa !5
  %123 = ptrtoint ptr %122 to i64
  %124 = and i64 %123, 1
  %125 = icmp ne i64 %124, 0
  br i1 %125, label %126, label %131

126:                                              ; preds = %117
  %127 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %128 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %127, ptr noundef %128)
  %129 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %130 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %129)
  store ptr %130, ptr %13, align 8, !tbaa !5
  br label %135

131:                                              ; preds = %117
  %132 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %133 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %16, i64 noundef 1)
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %132, ptr noundef %133)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %134 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %134)
  br label %135

135:                                              ; preds = %131, %126
  br label %144

136:                                              ; preds = %108
  %137 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %138 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %137, ptr noundef %138)
  %139 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %139)
  %140 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %141 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %140, ptr noundef %141)
  %142 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %143 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %142)
  store ptr %143, ptr %13, align 8, !tbaa !5
  br label %144

144:                                              ; preds = %136, %135
  %145 = load ptr, ptr %13, align 8, !tbaa !5
  %146 = icmp ne ptr %145, null
  br i1 %146, label %147, label %148

147:                                              ; preds = %144
  store i32 6, ptr %11, align 4
  br label %149

148:                                              ; preds = %144
  store i32 0, ptr %11, align 4
  br label %149

149:                                              ; preds = %148, %147
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  %150 = load i32, ptr %11, align 4
  switch i32 %150, label %167 [
    i32 0, label %151
  ]

151:                                              ; preds = %149
  br label %155

152:                                              ; preds = %98
  %153 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 1
  %154 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %153, ptr noundef %154)
  br label %155

155:                                              ; preds = %152, %151
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock33wait_for_release_of_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %18)
  %156 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 4
  call void @_ZN3tbb8internal18spin_wait_while_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %156, i32 noundef 2)
  call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !23
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #5
  %157 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 3
  %158 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %157)
  %159 = zext i8 %158 to i32
  %160 = icmp ne i32 %159, 64
  %161 = zext i1 %160 to i8
  store i8 %161, ptr %17, align 1, !tbaa !19
  %162 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 3
  %163 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %162, i8 noundef zeroext 1)
  %164 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %18, i32 0, i32 4
  call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %164, i32 noundef 1)
  %165 = load i8, ptr %17, align 1, !tbaa !19, !range !21, !noundef !22
  %166 = trunc i8 %165 to i1
  store i1 %166, ptr %2, align 1
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #5
  br label %167

167:                                              ; preds = %155, %149
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  %168 = load i32, ptr %11, align 4
  switch i32 %168, label %169 [
    i32 6, label %98
  ]

169:                                              ; preds = %167, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %170

170:                                              ; preds = %169, %23
  %171 = load i1, ptr %2, align 1
  ret i1 %171
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock33wait_for_release_of_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27)) #0 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 = !{!16, !16, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !20, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{i64 2149595038}


; 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 }
%"class.tbb::internal::atomic_backoff" = type { i32 }

; 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: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1 align 2

; 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
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 uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE2EEEhhh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock17upgrade_to_writerEv(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 ptr, align 8
  %5 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %6 = alloca %"class.tbb::internal::atomic_backoff", align 4
  %7 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %10 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = tail call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %11)
  %13 = icmp eq i8 %12, 1
  br i1 %13, label %88, label %14

14:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  store ptr %0, ptr %2, align 8, !tbaa !5
  %15 = tail call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %11, i8 noundef zeroext 16)
  tail call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  %16 = load ptr, ptr %0, align 8, !tbaa !9
  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)
  %17 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef 1)
  %18 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef %17, ptr noundef nonnull %0)
  %.not41 = icmp eq ptr %18, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br i1 %.not41, label %._crit_edge, label %.lr.ph42

.lr.ph42:                                         ; preds = %14
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  br label %23

.critedge:                                        ; preds = %48, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  %20 = load ptr, ptr %0, align 8, !tbaa !9
  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)
  %21 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef 1)
  %22 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef %21, ptr noundef nonnull %0)
  %.not = icmp eq ptr %22, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br i1 %.not, label %._crit_edge, label %23

23:                                               ; preds = %.lr.ph42, %.critedge
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockEPvEEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %24 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef nonnull %19, i64 noundef 1)
  store ptr %24, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 24
  %26 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %25)
  %27 = zext i8 %26 to i32
  %28 = and i32 %27, 6
  %.not24 = icmp eq i32 %28, 0
  br i1 %.not24, label %32, label %29

29:                                               ; preds = %23
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 25
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %31, i32 noundef 1)
  br label %32

32:                                               ; preds = %29, %23
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEEPS2_PVS6_S6_(ptr noundef nonnull %34, ptr noundef nonnull %0)
  %36 = call noundef i64 @_ZN3tbb8get_flagEPNS_16queuing_rw_mutex11scoped_lockE(ptr noundef %35)
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock32unblock_or_wait_on_internal_lockEm(ptr noundef nonnull align 8 dereferenceable(27) %0, i64 noundef %36)
  %37 = and i32 %27, 30
  %.not25 = icmp eq i32 %37, 0
  br i1 %.not25, label %.thread, label %38

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %39 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @_ZN3tbb8internal14atomic_backoffC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %40 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %19)
  %.not2740 = icmp eq ptr %40, %39
  br i1 %.not2740, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %38, %48
  %41 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %11)
  %42 = and i8 %41, 96
  %.not26 = icmp eq i8 %42, 0
  br i1 %.not26, label %48, label %43

43:                                               ; preds = %.lr.ph
  %44 = call noundef ptr @_ZN3tbb8internal23__TBB_load_with_acquireIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %19)
  %45 = icmp eq ptr %44, %39
  br i1 %45, label %46, label %.preheader.loopexit

46:                                               ; preds = %43
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef %47)
  br label %.preheader.loopexit

48:                                               ; preds = %.lr.ph
  call void @_ZN3tbb8internal14atomic_backoff5pauseEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %49 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %19)
  %.not27 = icmp eq ptr %49, %39
  br i1 %.not27, label %.lr.ph, label %.critedge, !llvm.loop !15

.thread:                                          ; preds = %32
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %51

.preheader.loopexit:                              ; preds = %46, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %.preheader

._crit_edge:                                      ; preds = %.critedge, %14
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  br label %51

51:                                               ; preds = %.thread, %._crit_edge
  %52 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %11, i8 noundef zeroext 32, i8 noundef zeroext 16)
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %51
  %53 = getelementptr inbounds i8, ptr %0, i64 8
  br label %54

54:                                               ; preds = %.preheader, %87
  %55 = load ptr, ptr %0, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %56 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %7, i64 noundef 1)
  %57 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEES4_S4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %55, ptr noundef nonnull %0, ptr noundef %56)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %58 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE13fetch_and_addILNS_16memory_semanticsE1EEEPS2_PVS6_l(ptr noundef nonnull %53, i64 noundef 1)
  store ptr %58, ptr %8, align 8, !tbaa !5
  %.not28 = icmp eq ptr %58, null
  br i1 %.not28, label %82, label %59

59:                                               ; preds = %54
  %60 = call noundef zeroext i1 @_ZN3tbb16queuing_rw_mutex11scoped_lock25try_acquire_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %58)
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %61, i64 24
  %63 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE2EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %62, i8 noundef zeroext 32, i8 noundef zeroext 16)
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  br i1 %60, label %76, label %65

65:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %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) %8)
  %66 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %9, i64 noundef 1)
  %67 = call noundef ptr @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEE16compare_and_swapILNS_16memory_semanticsE2EEEPS2_PVS6_S6_S6_(ptr noundef nonnull %53, ptr noundef %64, ptr noundef %66)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  %68 = ptrtoint ptr %67 to i64
  %69 = and i64 %68, 1
  %.not29 = icmp eq i64 %69, 0
  br i1 %.not29, label %73, label %70

70:                                               ; preds = %65
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef %71)
  %72 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %53)
  store ptr %72, ptr %8, align 8, !tbaa !5
  br label %80

73:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  call void @_ZN3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEC2ERPS2_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %74 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEorEl(ptr noundef nonnull align 8 dereferenceable(8) %10, i64 noundef 1)
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef %74)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %75)
  %.pr = load ptr, ptr %8, align 8, !tbaa !5
  br label %80

76:                                               ; preds = %59
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef %64)
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock21release_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %77)
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef %78)
  %79 = call noundef ptr @_ZN3tbb8internal18__TBB_load_relaxedIPNS_16queuing_rw_mutex11scoped_lockEEET_RVKS5_(ptr noundef nonnull align 8 dereferenceable(8) %53)
  store ptr %79, ptr %8, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %70, %73, %76
  %81 = phi ptr [ %72, %70 ], [ %.pr, %73 ], [ %79, %76 ]
  %.not30 = icmp eq ptr %81, null
  br i1 %.not30, label %.thread32, label %87

82:                                               ; preds = %54
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef null)
  br label %.thread32

.thread32:                                        ; preds = %80, %82
  call void @_ZN3tbb16queuing_rw_mutex11scoped_lock33wait_for_release_of_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27) %0)
  %83 = getelementptr inbounds i8, ptr %0, i64 25
  call void @_ZN3tbb8internal18spin_wait_while_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %83, i32 noundef 2)
  call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !17
  %84 = call noundef zeroext i8 @_ZNVK3tbb8internal11atomic_implIhEcvhEv(ptr noundef nonnull align 1 dereferenceable(1) %11)
  %85 = icmp ne i8 %84, 64
  %86 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %11, i8 noundef zeroext 1)
  call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %83, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  br label %88

87:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  br label %54

88:                                               ; preds = %1, %.thread32
  %.3 = phi i1 [ %85, %.thread32 ], [ true, %1 ]
  ret i1 %.3
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock33wait_for_release_of_internal_lockEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #0 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 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i64 2149595038}


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