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

; 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::internal::concurrent_vector_base_v3::segment_value_t" = type { ptr }
%"struct.tbb::internal::concurrent_vector_base_v3::segment_not_used" = type { i8 }
%"struct.tbb::internal::concurrent_vector_base_v3::segment_allocated" = type { i8 }
%"struct.tbb::internal::concurrent_vector_base_v3::segment_allocation_failed" = type { i8 }
%"class.tbb::internal::concurrent_vector_base_v3::helper" = type { ptr, i64, i64, i64, i64, i64, i64 }
%"class.tbb::internal::concurrent_vector_base_v3::segment_t" = type { %"struct.tbb::atomic.4" }
%"struct.tbb::atomic.4" = type { %"struct.tbb::internal::atomic_impl.5" }
%"struct.tbb::internal::atomic_impl.5" = type { %"struct.tbb::internal::aligned_storage.6" }
%"struct.tbb::internal::aligned_storage.6" = type { ptr }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v312segment_baseEm(i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_16segment_not_usedE(ptr noundef nonnull align 8 dereferenceable(8)) #1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3tbb8internal25concurrent_vector_base_v36helper7cleanupEv(ptr noundef nonnull align 8 dereferenceable(56) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %6 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %7 = alloca %"struct.tbb::internal::concurrent_vector_base_v3::segment_not_used", align 1
  %8 = alloca %"struct.tbb::internal::concurrent_vector_base_v3::segment_allocated", align 1
  %9 = alloca %"struct.tbb::internal::concurrent_vector_base_v3::segment_allocation_failed", align 1
  %10 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %11 = alloca %"struct.tbb::internal::concurrent_vector_base_v3::segment_not_used", align 1
  %12 = alloca %"struct.tbb::internal::concurrent_vector_base_v3::segment_allocation_failed", align 1
  %13 = alloca i32, align 4
  %14 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %15 = alloca %"struct.tbb::internal::concurrent_vector_base_v3::segment_allocated", align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %16 = load ptr, ptr %2, align 8
  %17 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %131, label %20

20:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %21 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 2
  %22 = load i64, ptr %21, align 8, !tbaa !12
  store i64 %22, ptr %3, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %23 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 5
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = sub i64 %24, 1
  %26 = call noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v316segment_index_ofEm(i64 noundef %25)
  store i64 %26, ptr %4, align 8, !tbaa !13
  %27 = load i64, ptr %3, align 8, !tbaa !13
  %28 = call noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v312segment_baseEm(i64 noundef %27)
  %29 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 4
  %30 = load i64, ptr %29, align 8, !tbaa !15
  %31 = icmp ult i64 %28, %30
  br i1 %31, label %32, label %37

32:                                               ; preds = %20
  %33 = load i64, ptr %3, align 8, !tbaa !13
  %34 = add i64 %33, 1
  store i64 %34, ptr %3, align 8, !tbaa !13
  %35 = call ptr @_ZN3tbb8internal25concurrent_vector_base_v36helper17get_segment_valueEmb(ptr noundef nonnull align 8 dereferenceable(56) %16, i64 noundef %33, i1 noundef zeroext true)
  %36 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", ptr %5, i32 0, i32 0
  store ptr %35, ptr %36, align 8
  br label %37

37:                                               ; preds = %32, %20
  %38 = load i64, ptr %3, align 8, !tbaa !13
  %39 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !16
  %41 = icmp ult i64 %38, %40
  br i1 %41, label %42, label %107

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %43 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 4
  %44 = load i64, ptr %43, align 8, !tbaa !15
  %45 = icmp ugt i64 %44, 0
  %46 = call ptr @_ZN3tbb8internal25concurrent_vector_base_v36helper17get_segment_valueEmb(ptr noundef nonnull align 8 dereferenceable(56) %16, i64 noundef 0, i1 noundef zeroext %45)
  %47 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", ptr %6, i32 0, i32 0
  store ptr %46, ptr %47, align 8
  %48 = call noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v316segment_not_usedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %48, label %49, label %55

49:                                               ; preds = %42
  %50 = load i64, ptr %3, align 8, !tbaa !13
  %51 = icmp ne i64 %50, 0
  br i1 %51, label %55, label %52

52:                                               ; preds = %49
  %53 = load i64, ptr %3, align 8, !tbaa !13
  %54 = add i64 %53, 1
  store i64 %54, ptr %3, align 8, !tbaa !13
  br label %55

55:                                               ; preds = %52, %49, %42
  %56 = call noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v317segment_allocatedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %56, label %57, label %78

57:                                               ; preds = %55
  br label %58

58:                                               ; preds = %74, %57
  %59 = load i64, ptr %3, align 8, !tbaa !13
  %60 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !16
  %62 = icmp ult i64 %59, %61
  br i1 %62, label %63, label %67

63:                                               ; preds = %58
  %64 = load i64, ptr %3, align 8, !tbaa !13
  %65 = load i64, ptr %4, align 8, !tbaa !13
  %66 = icmp ule i64 %64, %65
  br label %67

67:                                               ; preds = %63, %58
  %68 = phi i1 [ false, %58 ], [ %66, %63 ]
  br i1 %68, label %69, label %77

69:                                               ; preds = %67
  %70 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !17
  %72 = load i64, ptr %3, align 8, !tbaa !13
  %73 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %71, i64 %72
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper15publish_segmentINS1_25segment_allocation_failedEEEvRNS1_9segment_tET_(ptr noundef nonnull align 8 dereferenceable(8) %73)
  br label %74

74:                                               ; preds = %69
  %75 = load i64, ptr %3, align 8, !tbaa !13
  %76 = add i64 %75, 1
  store i64 %76, ptr %3, align 8, !tbaa !13
  br label %58, !llvm.loop !18

77:                                               ; preds = %67
  br label %106

78:                                               ; preds = %55
  br label %79

79:                                               ; preds = %102, %78
  %80 = load i64, ptr %3, align 8, !tbaa !13
  %81 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 1
  %82 = load i64, ptr %81, align 8, !tbaa !16
  %83 = icmp ult i64 %80, %82
  br i1 %83, label %84, label %88

84:                                               ; preds = %79
  %85 = load i64, ptr %3, align 8, !tbaa !13
  %86 = load i64, ptr %4, align 8, !tbaa !13
  %87 = icmp ule i64 %85, %86
  br label %88

88:                                               ; preds = %84, %79
  %89 = phi i1 [ false, %79 ], [ %87, %84 ]
  br i1 %89, label %90, label %105

90:                                               ; preds = %88
  %91 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !17
  %93 = load i64, ptr %3, align 8, !tbaa !13
  %94 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %92, i64 %93
  %95 = call noundef ptr @_ZNK3tbb8internal25concurrent_vector_base_v315segment_value_t7pointerIcEEPT_v(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %96 = load i64, ptr %3, align 8, !tbaa !13
  %97 = call noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v312segment_baseEm(i64 noundef %96)
  %98 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 6
  %99 = load i64, ptr %98, align 8, !tbaa !20
  %100 = mul i64 %97, %99
  %101 = getelementptr inbounds i8, ptr %95, i64 %100
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper15publish_segmentIPvEEvRNS1_9segment_tET_(ptr noundef nonnull align 8 dereferenceable(8) %94, ptr noundef %101)
  br label %102

102:                                              ; preds = %90
  %103 = load i64, ptr %3, align 8, !tbaa !13
  %104 = add i64 %103, 1
  store i64 %104, ptr %3, align 8, !tbaa !13
  br label %79, !llvm.loop !21

105:                                              ; preds = %88
  br label %106

106:                                              ; preds = %105, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %107

107:                                              ; preds = %106, %37
  br label %108

108:                                              ; preds = %126, %107
  %109 = load i64, ptr %3, align 8, !tbaa !13
  %110 = load i64, ptr %4, align 8, !tbaa !13
  %111 = icmp ule i64 %109, %110
  br i1 %111, label %112, label %129

112:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %113 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !17
  %115 = load i64, ptr %3, align 8, !tbaa !13
  %116 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %114, i64 %115
  %117 = call ptr @_ZNK3tbb8internal25concurrent_vector_base_v39segment_t4loadILNS_16memory_semanticsE1EEENS1_15segment_value_tEv(ptr noundef nonnull align 8 dereferenceable(8) %116)
  %118 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", ptr %10, i32 0, i32 0
  store ptr %117, ptr %118, align 8
  %119 = call noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_16segment_not_usedE(ptr noundef nonnull align 8 dereferenceable(8) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br i1 %119, label %120, label %125

120:                                              ; preds = %112
  %121 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !17
  %123 = load i64, ptr %3, align 8, !tbaa !13
  %124 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %122, i64 %123
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper15publish_segmentINS1_25segment_allocation_failedEEEvRNS1_9segment_tET_(ptr noundef nonnull align 8 dereferenceable(8) %124)
  br label %125

125:                                              ; preds = %120, %112
  br label %126

126:                                              ; preds = %125
  %127 = load i64, ptr %3, align 8, !tbaa !13
  %128 = add i64 %127, 1
  store i64 %128, ptr %3, align 8, !tbaa !13
  br label %108, !llvm.loop !22

129:                                              ; preds = %108
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper13first_segmentEv(ptr noundef nonnull align 8 dereferenceable(56) %16) #6
  store i32 11, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  %130 = load i32, ptr %13, align 4
  switch i32 %130, label %178 [
    i32 11, label %139
  ]

131:                                              ; preds = %1
  br label %132

132:                                              ; preds = %176, %131
  %133 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 3
  %134 = load i64, ptr %133, align 8, !tbaa !9
  %135 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 5
  %136 = load i64, ptr %135, align 8, !tbaa !14
  %137 = icmp ule i64 %134, %136
  br i1 %137, label %138, label %177

138:                                              ; preds = %132
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper12next_segmentEv(ptr noundef nonnull align 8 dereferenceable(56) %16) #6
  br label %139

139:                                              ; preds = %138, %129
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %140 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8, !tbaa !17
  %142 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 2
  %143 = load i64, ptr %142, align 8, !tbaa !12
  %144 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %141, i64 %143
  %145 = call ptr @_ZNK3tbb8internal25concurrent_vector_base_v39segment_t4loadILNS_16memory_semanticsE3EEENS1_15segment_value_tEv(ptr noundef nonnull align 8 dereferenceable(8) %144)
  %146 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", ptr %14, i32 0, i32 0
  store ptr %145, ptr %146, align 8
  %147 = call noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_17segment_allocatedE(ptr noundef nonnull align 8 dereferenceable(8) %14)
  br i1 %147, label %148, label %175

148:                                              ; preds = %139
  %149 = call noundef ptr @_ZNK3tbb8internal25concurrent_vector_base_v315segment_value_t7pointerIcEEPT_v(ptr noundef nonnull align 8 dereferenceable(8) %14)
  %150 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 6
  %151 = load i64, ptr %150, align 8, !tbaa !20
  %152 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 4
  %153 = load i64, ptr %152, align 8, !tbaa !15
  %154 = mul i64 %151, %153
  %155 = getelementptr inbounds i8, ptr %149, i64 %154
  %156 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 3
  %157 = load i64, ptr %156, align 8, !tbaa !9
  %158 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 5
  %159 = load i64, ptr %158, align 8, !tbaa !14
  %160 = icmp ult i64 %157, %159
  br i1 %160, label %161, label %164

161:                                              ; preds = %148
  %162 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 3
  %163 = load i64, ptr %162, align 8, !tbaa !9
  br label %167

164:                                              ; preds = %148
  %165 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 5
  %166 = load i64, ptr %165, align 8, !tbaa !14
  br label %167

167:                                              ; preds = %164, %161
  %168 = phi i64 [ %163, %161 ], [ %166, %164 ]
  %169 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 4
  %170 = load i64, ptr %169, align 8, !tbaa !15
  %171 = sub i64 %168, %170
  %172 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::helper", ptr %16, i32 0, i32 6
  %173 = load i64, ptr %172, align 8, !tbaa !20
  %174 = mul i64 %171, %173
  call void @llvm.memset.p0.i64(ptr align 1 %155, i8 0, i64 %174, i1 false)
  br label %176

175:                                              ; preds = %139
  br label %176

176:                                              ; preds = %175, %167
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %132, !llvm.loop !23

177:                                              ; preds = %132
  ret void

178:                                              ; preds = %129
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v316segment_index_ofEm(i64 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZN3tbb8internal25concurrent_vector_base_v36helper17get_segment_valueEmb(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i1 noundef zeroext) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v316segment_not_usedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v317segment_allocatedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8)) #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_17segment_allocatedE(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress 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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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, !11, i64 24}
!10 = !{!"_ZTSN3tbb8internal25concurrent_vector_base_v36helperE", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 40}
!15 = !{!10, !11, i64 32}
!16 = !{!10, !11, i64 8}
!17 = !{!10, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !11, i64 48}
!21 = distinct !{!21, !19}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}


; 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::internal::concurrent_vector_base_v3::segment_value_t" = type { ptr }
%"class.tbb::internal::concurrent_vector_base_v3::segment_t" = type { %"struct.tbb::atomic.4" }
%"struct.tbb::atomic.4" = type { %"struct.tbb::internal::atomic_impl.5" }
%"struct.tbb::internal::atomic_impl.5" = type { %"struct.tbb::internal::aligned_storage.6" }
%"struct.tbb::internal::aligned_storage.6" = type { ptr }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v312segment_baseEm(i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_16segment_not_usedE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3tbb8internal25concurrent_vector_base_v36helper7cleanupEv(ptr noundef nonnull align 8 dereferenceable(56) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %3 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %4 = alloca %"class.tbb::internal::concurrent_vector_base_v3::segment_value_t", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not24 = icmp eq i64 %6, 0
  br i1 %.not24, label %7, label %67

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load i64, ptr %10, align 8, !tbaa !12
  %12 = add i64 %11, -1
  %13 = tail call noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v316segment_index_ofEm(i64 noundef %12)
  %14 = tail call noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v312segment_baseEm(i64 noundef %9)
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load i64, ptr %15, align 8, !tbaa !13
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %7
  %19 = add i64 %9, 1
  %20 = tail call ptr @_ZN3tbb8internal25concurrent_vector_base_v36helper17get_segment_valueEmb(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %9, i1 noundef zeroext true)
  br label %21

21:                                               ; preds = %18, %7
  %.0 = phi i64 [ %19, %18 ], [ %9, %7 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !14
  %24 = icmp ult i64 %.0, %23
  br i1 %24, label %25, label %57

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %26 = load i64, ptr %15, align 8, !tbaa !13
  %27 = icmp ne i64 %26, 0
  %28 = tail call ptr @_ZN3tbb8internal25concurrent_vector_base_v36helper17get_segment_valueEmb(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef 0, i1 noundef zeroext %27)
  store ptr %28, ptr %2, align 8
  %29 = call noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v316segment_not_usedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %30 = icmp eq i64 %.0, 0
  %or.cond.not = and i1 %30, %29
  %spec.select = select i1 %or.cond.not, i64 1, i64 %.0
  %31 = call noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v317segment_allocatedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %32 = load i64, ptr %22, align 8, !tbaa !14
  %33 = icmp ult i64 %spec.select, %32
  %34 = icmp ule i64 %spec.select, %13
  %35 = and i1 %34, %33
  br i1 %31, label %.preheader, label %.preheader27

.preheader27:                                     ; preds = %25
  br i1 %35, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader27
  %36 = getelementptr inbounds i8, ptr %0, i64 48
  br label %44

.preheader:                                       ; preds = %25
  br i1 %35, label %.lr.ph31, label %.loopexit

.lr.ph31:                                         ; preds = %.preheader, %.lr.ph31
  %.230 = phi i64 [ %39, %.lr.ph31 ], [ %spec.select, %.preheader ]
  %37 = load ptr, ptr %0, align 8, !tbaa !15
  %38 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %37, i64 %.230
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper15publish_segmentINS1_25segment_allocation_failedEEEvRNS1_9segment_tET_(ptr noundef nonnull align 8 dereferenceable(8) %38)
  %39 = add nuw i64 %.230, 1
  %40 = load i64, ptr %22, align 8, !tbaa !14
  %41 = icmp ult i64 %39, %40
  %42 = icmp ult i64 %.230, %13
  %43 = and i1 %42, %41
  br i1 %43, label %.lr.ph31, label %.loopexit, !llvm.loop !16

44:                                               ; preds = %.lr.ph, %44
  %.329 = phi i64 [ %spec.select, %.lr.ph ], [ %52, %44 ]
  %45 = load ptr, ptr %0, align 8, !tbaa !15
  %46 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %45, i64 %.329
  %47 = call noundef ptr @_ZNK3tbb8internal25concurrent_vector_base_v315segment_value_t7pointerIcEEPT_v(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %48 = call noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v312segment_baseEm(i64 noundef %.329)
  %49 = load i64, ptr %36, align 8, !tbaa !18
  %50 = mul i64 %49, %48
  %51 = getelementptr inbounds i8, ptr %47, i64 %50
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper15publish_segmentIPvEEvRNS1_9segment_tET_(ptr noundef nonnull align 8 dereferenceable(8) %46, ptr noundef %51)
  %52 = add nuw i64 %.329, 1
  %53 = load i64, ptr %22, align 8, !tbaa !14
  %54 = icmp ult i64 %52, %53
  %55 = icmp ult i64 %.329, %13
  %56 = and i1 %55, %54
  br i1 %56, label %44, label %.loopexit, !llvm.loop !19

.loopexit:                                        ; preds = %44, %.lr.ph31, %.preheader27, %.preheader
  %.4 = phi i64 [ %spec.select, %.preheader ], [ %spec.select, %.preheader27 ], [ %39, %.lr.ph31 ], [ %52, %44 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %57

57:                                               ; preds = %.loopexit, %21
  %.5 = phi i64 [ %.4, %.loopexit ], [ %.0, %21 ]
  %.not33 = icmp ugt i64 %.5, %13
  br i1 %.not33, label %._crit_edge, label %.lr.ph35

.lr.ph35:                                         ; preds = %57, %65
  %.634 = phi i64 [ %66, %65 ], [ %.5, %57 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %58 = load ptr, ptr %0, align 8, !tbaa !15
  %59 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %58, i64 %.634
  %60 = call ptr @_ZNK3tbb8internal25concurrent_vector_base_v39segment_t4loadILNS_16memory_semanticsE1EEENS1_15segment_value_tEv(ptr noundef nonnull align 8 dereferenceable(8) %59)
  store ptr %60, ptr %3, align 8
  %61 = call noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_16segment_not_usedE(ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br i1 %61, label %62, label %65

62:                                               ; preds = %.lr.ph35
  %63 = load ptr, ptr %0, align 8, !tbaa !15
  %64 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %63, i64 %.634
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper15publish_segmentINS1_25segment_allocation_failedEEEvRNS1_9segment_tET_(ptr noundef nonnull align 8 dereferenceable(8) %64)
  br label %65

65:                                               ; preds = %.lr.ph35, %62
  %66 = add i64 %.634, 1
  %.not = icmp ugt i64 %66, %13
  br i1 %.not, label %._crit_edge, label %.lr.ph35, !llvm.loop !20

._crit_edge:                                      ; preds = %65, %57
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper13first_segmentEv(ptr noundef nonnull align 8 dereferenceable(56) %0) #7
  br label %72

67:                                               ; preds = %1, %92
  %68 = phi i64 [ %6, %1 ], [ %.pre, %92 ]
  %69 = getelementptr inbounds i8, ptr %0, i64 40
  %70 = load i64, ptr %69, align 8, !tbaa !12
  %.not26 = icmp ugt i64 %68, %70
  br i1 %.not26, label %93, label %71

71:                                               ; preds = %67
  call void @_ZN3tbb8internal25concurrent_vector_base_v36helper12next_segmentEv(ptr noundef nonnull align 8 dereferenceable(56) %0) #7
  br label %72

72:                                               ; preds = %._crit_edge, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %73 = load ptr, ptr %0, align 8, !tbaa !15
  %74 = getelementptr inbounds i8, ptr %0, i64 16
  %75 = load i64, ptr %74, align 8, !tbaa !11
  %76 = getelementptr inbounds %"class.tbb::internal::concurrent_vector_base_v3::segment_t", ptr %73, i64 %75
  %77 = call ptr @_ZNK3tbb8internal25concurrent_vector_base_v39segment_t4loadILNS_16memory_semanticsE3EEENS1_15segment_value_tEv(ptr noundef nonnull align 8 dereferenceable(8) %76)
  store ptr %77, ptr %4, align 8
  %78 = call noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_17segment_allocatedE(ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %78, label %79, label %92

79:                                               ; preds = %72
  %80 = call noundef ptr @_ZNK3tbb8internal25concurrent_vector_base_v315segment_value_t7pointerIcEEPT_v(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %81 = getelementptr inbounds i8, ptr %0, i64 48
  %82 = load i64, ptr %81, align 8, !tbaa !18
  %83 = getelementptr inbounds i8, ptr %0, i64 32
  %84 = load i64, ptr %83, align 8, !tbaa !13
  %85 = mul i64 %84, %82
  %86 = getelementptr inbounds i8, ptr %80, i64 %85
  %87 = load i64, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %0, i64 40
  %89 = load i64, ptr %88, align 8, !tbaa !12
  %. = call i64 @llvm.umin.i64(i64 %87, i64 %89)
  %90 = sub i64 %., %84
  %91 = mul i64 %90, %82
  call void @llvm.memset.p0.i64(ptr align 1 %86, i8 0, i64 %91, i1 false)
  br label %92

92:                                               ; preds = %72, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %.pre = load i64, ptr %5, align 8, !tbaa !5
  br label %67, !llvm.loop !21

93:                                               ; preds = %67
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3tbb8internal25concurrent_vector_base_v316segment_index_ofEm(i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZN3tbb8internal25concurrent_vector_base_v36helper17get_segment_valueEmb(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i1 noundef zeroext) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v316segment_not_usedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internalneINS0_25concurrent_vector_base_v317segment_allocatedEEEbRKNS2_15segment_value_tET_(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3tbb8internaleqERKNS0_25concurrent_vector_base_v315segment_value_tENS1_17segment_allocatedE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress 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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !10, i64 24}
!6 = !{!"_ZTSN3tbb8internal25concurrent_vector_base_v36helperE", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!6, !10, i64 40}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 48}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !17}


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