; 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: mustprogress uwtable
define dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock7acquireERS0_b(ptr noundef nonnull align 8 dereferenceable(27) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %9 = alloca i16, align 2
  %10 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %11 = alloca i16, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = zext i1 %2 to i8
  store i8 %12, ptr %6, align 1, !tbaa !9
  %13 = load ptr, ptr %4, align 8
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 0
  store ptr %14, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 1
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef null)
  %17 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 2
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef null)
  %18 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 4
  call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %18, i32 noundef 0)
  %19 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %20 = trunc i8 %19 to i1
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 1, i32 2
  %23 = trunc i32 %22 to i8
  %24 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 3
  %25 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %24, i8 noundef zeroext %23)
  %26 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 5
  store i8 0, ptr %26, align 2, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.tbb::queuing_rw_mutex", ptr %27, i32 0, i32 0
  %29 = call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEES4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef %13)
  store ptr %29, ptr %7, align 8, !tbaa !5
  %30 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %41

32:                                               ; preds = %3
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %40

35:                                               ; preds = %32
  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)
  %36 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEanEl(ptr noundef nonnull align 8 dereferenceable(8) %8, i64 noundef -2)
  store ptr %36, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %37, i32 0, i32 2
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef %13)
  %39 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 4
  call void @_ZN3tbb8internal18spin_wait_until_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %39, i32 noundef 1)
  br label %40

40:                                               ; preds = %35, %32
  br label %82

41:                                               ; preds = %3
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %67

44:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = ptrtoint ptr %45 to i64
  %47 = and i64 %46, 1
  %48 = icmp ne i64 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %44
  store i16 32, ptr %9, align 2, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %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) %7)
  %50 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEanEl(ptr noundef nonnull align 8 dereferenceable(8) %10, i64 noundef -2)
  store ptr %50, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %56

51:                                               ; preds = %44
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %52, i32 0, i32 3
  %54 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %53, i8 noundef zeroext 4, i8 noundef zeroext 2)
  %55 = zext i8 %54 to i16
  store i16 %55, ptr %9, align 2, !tbaa !20
  br label %56

56:                                               ; preds = %51, %49
  %57 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 1
  %58 = 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) %57, ptr noundef %58)
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %59, i32 0, i32 2
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %60, ptr noundef %13)
  %61 = load i16, ptr %9, align 2, !tbaa !20
  %62 = zext i16 %61 to i32
  %63 = icmp ne i32 %62, 8
  br i1 %63, label %64, label %66

64:                                               ; preds = %56
  %65 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 4
  call void @_ZN3tbb8internal18spin_wait_until_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %65, i32 noundef 1)
  br label %66

66:                                               ; preds = %64, %56
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #5
  br label %67

67:                                               ; preds = %66, %41
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #5
  %68 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 3
  %69 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %68, i8 noundef zeroext 8, i8 noundef zeroext 2)
  %70 = zext i8 %69 to i16
  store i16 %70, ptr %11, align 2, !tbaa !20
  %71 = load i16, ptr %11, align 2, !tbaa !20
  %72 = zext i16 %71 to i32
  %73 = icmp ne i32 %72, 2
  br i1 %73, label %74, label %81

74:                                               ; preds = %67
  %75 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 2
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef null)
  %76 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 3
  %77 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %76, i8 noundef zeroext 8)
  %78 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 2
  %79 = load ptr, ptr %78, align 8, !tbaa !22
  %80 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %79, i32 0, i32 4
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %80, i32 noundef 1)
  br label %81

81:                                               ; preds = %74, %67
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #5
  br label %82

82:                                               ; preds = %81, %40
  %83 = getelementptr inbounds %"class.tbb::queuing_rw_mutex::scoped_lock", ptr %13, i32 0, i32 4
  %84 = call noundef zeroext i8 @_ZN3tbb8internal23__TBB_load_with_acquireIhEET_RVKS2_(ptr noundef nonnull align 1 dereferenceable(1) %83)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

; 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) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) #0 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 uwtable
declare dso_local noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEES4_S4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 align 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEanEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #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) #1

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

; 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) #0 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) #0

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint mustprogress 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN3tbb16queuing_rw_mutex11scoped_lockE", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !7, i64 25, !7, i64 26}
!13 = !{!"_ZTSN3tbb6atomicIhEE", !14, i64 0}
!14 = !{!"_ZTSN3tbb8internal27atomic_impl_with_arithmeticIhhcEE", !15, i64 0}
!15 = !{!"_ZTSN3tbb8internal11atomic_implIhEE", !16, i64 0}
!16 = !{!"_ZTSN3tbb8internal15aligned_storageIhLm1EEE", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !7, i64 26}
!20 = !{!21, !21, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = !{!12, !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: mustprogress uwtable
define dso_local void @_ZN3tbb16queuing_rw_mutex11scoped_lock7acquireERS0_b(ptr noundef nonnull align 8 dereferenceable(27) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  %6 = alloca %"class.tbb::tricky_atomic_pointer", align 8
  store ptr %1, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef null)
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef null)
  %9 = getelementptr inbounds i8, ptr %0, i64 25
  tail call void @_ZN3tbb8internal19__TBB_store_relaxedIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %9, i32 noundef 0)
  %10 = select i1 %2, i8 1, i8 2
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = tail call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %11, i8 noundef zeroext %10)
  %13 = getelementptr inbounds i8, ptr %0, i64 26
  store i8 0, ptr %13, align 2, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %14 = tail call noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEES4_S4_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %0)
  store ptr %14, ptr %4, align 8, !tbaa !15
  %.not10 = icmp eq ptr %14, null
  br i1 %2, label %15, label %19

15:                                               ; preds = %3
  br i1 %.not10, label %38, label %16

16:                                               ; preds = %15
  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)
  %17 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEanEl(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef -2)
  store ptr %17, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull %0)
  call void @_ZN3tbb8internal18spin_wait_until_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %9, i32 noundef 1)
  br label %38

19:                                               ; preds = %3
  br i1 %.not10, label %32, label %20

20:                                               ; preds = %19
  %21 = ptrtoint ptr %14 to i64
  %22 = and i64 %21, 1
  %.not7 = icmp eq i64 %22, 0
  br i1 %.not7, label %26, label %.critedge

.critedge:                                        ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %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) %4)
  %23 = call noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEanEl(ptr noundef nonnull align 8 dereferenceable(8) %6, i64 noundef -2)
  store ptr %23, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef %23)
  %24 = load ptr, ptr %4, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull %0)
  br label %31

26:                                               ; preds = %20
  %27 = getelementptr inbounds i8, ptr %14, i64 24
  %28 = tail call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %27, i8 noundef zeroext 4, i8 noundef zeroext 2)
  %29 = icmp eq i8 %28, 8
  tail call void @_ZN3tbb8internal19__TBB_store_relaxedIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull %14)
  %30 = getelementptr inbounds i8, ptr %14, i64 16
  tail call void @_ZN3tbb8internal24__TBB_store_with_releaseIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef nonnull %0)
  br i1 %29, label %32, label %31

31:                                               ; preds = %.critedge, %26
  call void @_ZN3tbb8internal18spin_wait_until_eqIhiEEvRVKT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %9, i32 noundef 1)
  br label %32

32:                                               ; preds = %26, %31, %19
  %33 = call noundef zeroext i8 @_ZN3tbb8internal11atomic_implIhE16compare_and_swapILNS_16memory_semanticsE1EEEhhh(ptr noundef nonnull align 1 dereferenceable(1) %11, i8 noundef zeroext 8, i8 noundef zeroext 2)
  %.not9 = icmp eq i8 %33, 2
  br i1 %.not9, label %38, label %34

34:                                               ; preds = %32
  call void @_ZN3tbb8internal18spin_wait_while_eqIPNS_16queuing_rw_mutex11scoped_lockES4_EEvRVKT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef null)
  %35 = call noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1) %11, i8 noundef zeroext 8)
  %36 = load ptr, ptr %8, align 8, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %36, i64 25
  call void @_ZN3tbb8internal24__TBB_store_with_releaseIhiEEvRVT_T0_(ptr noundef nonnull align 1 dereferenceable(1) %37, i32 noundef 1)
  br label %38

38:                                               ; preds = %32, %34, %15, %16
  %39 = call noundef zeroext i8 @_ZN3tbb8internal23__TBB_load_with_acquireIhEET_RVKS2_(ptr noundef nonnull align 1 dereferenceable(1) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret void
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN3tbb6atomicIhEaSEh(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) local_unnamed_addr #0 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 uwtable
declare dso_local noundef ptr @_ZN3tbb8internal11atomic_implIPNS_16queuing_rw_mutex11scoped_lockEE15fetch_and_storeILNS_16memory_semanticsE2EEES4_S4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK3tbb21tricky_atomic_pointerINS_16queuing_rw_mutex11scoped_lockEEanEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_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 #1

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

; 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 #0 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 #0

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint mustprogress 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, !7, i64 0}
!6 = !{!"_ZTSN3tbb16queuing_rw_mutex11scoped_lockE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !8, i64 25, !8, i64 26}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN3tbb6atomicIhEE", !11, i64 0}
!11 = !{!"_ZTSN3tbb8internal27atomic_impl_with_arithmeticIhhcEE", !12, i64 0}
!12 = !{!"_ZTSN3tbb8internal11atomic_implIhEE", !13, i64 0}
!13 = !{!"_ZTSN3tbb8internal15aligned_storageIhLm1EEE", !8, i64 0}
!14 = !{!6, !8, i64 26}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 16}


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