; LLVM IR from aagdev/mlimgsynth :: src/ccompute (tensorstore_safet)

; 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"

%struct.StrSlice = type { ptr, i64 }
%struct.TensorStore = type { ptr, ptr, ptr, ptr, ptr }
%struct.TSMetaEntry = type { i32, %struct.Any }
%struct.Any = type { i16, i16, i32, %union.AnyPayload }
%union.AnyPayload = type { i64 }
%struct.TSTensorEntry = type { i32, i32, i32, [4 x i32], i64, i64, ptr, ptr }

@g_allocator_dopt = external global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @log_level_check(i32 noundef) #1

declare void @log_logf(i32 noundef, ptr noundef, ...) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tstore_cb_call(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @stream_pos_get(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @dynbuf_free(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @tstore_write_safet(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct.StrSlice, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca %struct.StrSlice, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !11
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i32 @stream_write_chk(ptr noundef %29, i64 noundef 8, ptr noundef %10)
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %32, label %45

32:                                               ; preds = %3
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.6)
  br label %37

37:                                               ; preds = %36, %34
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  store i32 -12295, ptr %8, align 4, !tbaa !9
  br label %382

41:                                               ; No predecessors!
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44, %3
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = call i32 @stream_char_put(ptr noundef %46, i32 noundef 123)
  store i8 1, ptr %13, align 1, !tbaa !13
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TensorStore, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = call i32 @dynbuf_count(ptr noundef %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %142

53:                                               ; preds = %45
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = call i32 @stream_str_put(ptr noundef %54, ptr noundef @.str.7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TensorStore, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = call i32 @dynbuf_count(ptr noundef %58)
  store i32 %59, ptr %15, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %134, %53
  %61 = load i32, ptr %14, align 4, !tbaa !9
  %62 = load i32, ptr %15, align 4, !tbaa !9
  %63 = icmp ult i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 9, ptr %16, align 4
  br label %137

65:                                               ; preds = %60
  %66 = load i32, ptr %14, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %71

68:                                               ; preds = %65
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = call i32 @stream_char_put(ptr noundef %69, i32 noundef 44)
  br label %71

71:                                               ; preds = %68, %65
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call i32 @stream_char_put(ptr noundef %72, i32 noundef 34)
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.TensorStore, ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !17
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.TensorStore, ptr %78, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = load i32, ptr %14, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds %struct.TSMetaEntry, ptr %80, i64 %82
  %84 = getelementptr inbounds %struct.TSMetaEntry, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !18
  %86 = call { ptr, i64 } @strsto_get(ptr noundef %77, i32 noundef %85)
  %87 = getelementptr inbounds { ptr, i64 }, ptr %17, i32 0, i32 0
  %88 = extractvalue { ptr, i64 } %86, 0
  store ptr %88, ptr %87, align 8
  %89 = getelementptr inbounds { ptr, i64 }, ptr %17, i32 0, i32 1
  %90 = extractvalue { ptr, i64 } %86, 1
  store i64 %90, ptr %89, align 8
  %91 = getelementptr inbounds %struct.StrSlice, ptr %17, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !22
  %93 = call i32 @stream_str_put_escape(ptr noundef %74, ptr noundef %92)
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = call i32 @stream_str_put(ptr noundef %94, ptr noundef @.str.8)
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.TensorStore, ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !15
  %99 = load i32, ptr %14, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds %struct.TSMetaEntry, ptr %98, i64 %100
  %102 = getelementptr inbounds %struct.TSMetaEntry, ptr %101, i32 0, i32 1
  %103 = getelementptr inbounds %struct.Any, ptr %102, i32 0, i32 0
  %104 = load i16, ptr %103, align 8, !tbaa !24
  %105 = zext i16 %104 to i32
  %106 = icmp ne i32 %105, 15
  br i1 %106, label %107, label %120

107:                                              ; preds = %71
  br label %108

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108
  %110 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %110, label %111, label %112

111:                                              ; preds = %109
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.9)
  br label %112

112:                                              ; preds = %111, %109
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113
  br label %115

115:                                              ; preds = %114
  store i32 -12293, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %16, align 4
  br label %137

116:                                              ; No predecessors!
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  br label %120

120:                                              ; preds = %119, %71
  %121 = load ptr, ptr %6, align 8, !tbaa !5
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.TensorStore, ptr %122, i32 0, i32 1
  %124 = load ptr, ptr %123, align 8, !tbaa !15
  %125 = load i32, ptr %14, align 4, !tbaa !9
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds %struct.TSMetaEntry, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.TSMetaEntry, ptr %127, i32 0, i32 1
  %129 = getelementptr inbounds %struct.Any, ptr %128, i32 0, i32 3
  %130 = load ptr, ptr %129, align 8, !tbaa !25
  %131 = call i32 @stream_str_put_escape(ptr noundef %121, ptr noundef %130)
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = call i32 @stream_char_put(ptr noundef %132, i32 noundef 34)
  br label %134

134:                                              ; preds = %120
  %135 = load i32, ptr %14, align 4, !tbaa !9
  %136 = add i32 %135, 1
  store i32 %136, ptr %14, align 4, !tbaa !9
  br label %60, !llvm.loop !26

137:                                              ; preds = %115, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %138 = load i32, ptr %16, align 4
  switch i32 %138, label %397 [
    i32 9, label %139
    i32 8, label %382
  ]

139:                                              ; preds = %137
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = call i32 @stream_char_put(ptr noundef %140, i32 noundef 125)
  store i8 0, ptr %13, align 1, !tbaa !13
  br label %142

142:                                              ; preds = %139, %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %143 = load ptr, ptr %5, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.TensorStore, ptr %143, i32 0, i32 0
  %145 = load ptr, ptr %144, align 8, !tbaa !28
  %146 = getelementptr inbounds %struct.TSTensorEntry, ptr %145, i64 0
  store ptr %146, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %147 = load ptr, ptr %18, align 8, !tbaa !5
  %148 = load ptr, ptr %5, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.TensorStore, ptr %148, i32 0, i32 0
  %150 = load ptr, ptr %149, align 8, !tbaa !28
  %151 = call i32 @dynbuf_count(ptr noundef %150)
  %152 = zext i32 %151 to i64
  %153 = getelementptr inbounds %struct.TSTensorEntry, ptr %147, i64 %152
  store ptr %153, ptr %19, align 8, !tbaa !5
  br label %154

154:                                              ; preds = %283, %142
  %155 = load ptr, ptr %18, align 8, !tbaa !5
  %156 = load ptr, ptr %19, align 8, !tbaa !5
  %157 = icmp ult ptr %155, %156
  br i1 %157, label %159, label %158

158:                                              ; preds = %154
  store i32 18, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  br label %286

159:                                              ; preds = %154
  %160 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %161 = call ptr @dynbuf_resize(ptr noundef %9, i32 noundef 0, i64 noundef 1, i32 noundef 1, ptr noundef %160)
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  %163 = load ptr, ptr %5, align 8, !tbaa !5
  %164 = load ptr, ptr %18, align 8, !tbaa !5
  %165 = call i32 @tstore_cb_call(ptr noundef %162, ptr noundef %163, ptr noundef %164, ptr noundef %9)
  %166 = icmp slt i32 %165, 0
  br i1 %166, label %167, label %168

167:                                              ; preds = %159
  br label %283

168:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %169 = load ptr, ptr %9, align 8, !tbaa !5
  %170 = icmp ne ptr %169, null
  br i1 %170, label %171, label %177

171:                                              ; preds = %168
  %172 = load ptr, ptr %9, align 8, !tbaa !5
  %173 = getelementptr inbounds i8, ptr %172, i64 0
  %174 = load i8, ptr %173, align 1, !tbaa !25
  %175 = sext i8 %174 to i32
  %176 = icmp ne i32 %175, 0
  br i1 %176, label %191, label %177

177:                                              ; preds = %171, %168
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.TensorStore, ptr %178, i32 0, i32 4
  %180 = load ptr, ptr %179, align 8, !tbaa !17
  %181 = load ptr, ptr %18, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.TSTensorEntry, ptr %181, i32 0, i32 0
  %183 = load i32, ptr %182, align 8, !tbaa !29
  %184 = call { ptr, i64 } @strsto_get(ptr noundef %180, i32 noundef %183)
  %185 = getelementptr inbounds { ptr, i64 }, ptr %21, i32 0, i32 0
  %186 = extractvalue { ptr, i64 } %184, 0
  store ptr %186, ptr %185, align 8
  %187 = getelementptr inbounds { ptr, i64 }, ptr %21, i32 0, i32 1
  %188 = extractvalue { ptr, i64 } %184, 1
  store i64 %188, ptr %187, align 8
  %189 = getelementptr inbounds %struct.StrSlice, ptr %21, i32 0, i32 0
  %190 = load ptr, ptr %189, align 8, !tbaa !22
  br label %193

191:                                              ; preds = %171
  %192 = load ptr, ptr %9, align 8, !tbaa !5
  br label %193

193:                                              ; preds = %191, %177
  %194 = phi ptr [ %190, %177 ], [ %192, %191 ]
  store ptr %194, ptr %20, align 8, !tbaa !5
  %195 = load ptr, ptr %6, align 8, !tbaa !5
  %196 = load ptr, ptr %18, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.TSTensorEntry, ptr %196, i32 0, i32 6
  store ptr %195, ptr %197, align 8, !tbaa !31
  %198 = load i64, ptr %10, align 8, !tbaa !11
  %199 = load ptr, ptr %18, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.TSTensorEntry, ptr %199, i32 0, i32 4
  store i64 %198, ptr %200, align 8, !tbaa !32
  %201 = load ptr, ptr %18, align 8, !tbaa !5
  %202 = call i64 @tstore_tensor_size(ptr noundef %201)
  %203 = load ptr, ptr %18, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.TSTensorEntry, ptr %203, i32 0, i32 5
  store i64 %202, ptr %204, align 8, !tbaa !33
  %205 = load ptr, ptr %18, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.TSTensorEntry, ptr %205, i32 0, i32 5
  %207 = load i64, ptr %206, align 8, !tbaa !33
  %208 = call i64 @safet_align(i64 noundef %207)
  %209 = load i64, ptr %10, align 8, !tbaa !11
  %210 = add i64 %209, %208
  store i64 %210, ptr %10, align 8, !tbaa !11
  %211 = load i8, ptr %13, align 1, !tbaa !13, !range !34, !noundef !35
  %212 = trunc i8 %211 to i1
  br i1 %212, label %213, label %214

213:                                              ; preds = %193
  store i8 0, ptr %13, align 1, !tbaa !13
  br label %217

214:                                              ; preds = %193
  %215 = load ptr, ptr %6, align 8, !tbaa !5
  %216 = call i32 @stream_char_put(ptr noundef %215, i32 noundef 44)
  br label %217

217:                                              ; preds = %214, %213
  %218 = load ptr, ptr %6, align 8, !tbaa !5
  %219 = call i32 @stream_char_put(ptr noundef %218, i32 noundef 34)
  %220 = load ptr, ptr %6, align 8, !tbaa !5
  %221 = load ptr, ptr %20, align 8, !tbaa !5
  %222 = call i32 @stream_str_put_escape(ptr noundef %220, ptr noundef %221)
  %223 = load ptr, ptr %6, align 8, !tbaa !5
  %224 = call i32 @stream_str_put(ptr noundef %223, ptr noundef @.str.10)
  %225 = load ptr, ptr %6, align 8, !tbaa !5
  %226 = load ptr, ptr %18, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.TSTensorEntry, ptr %226, i32 0, i32 1
  %228 = load i32, ptr %227, align 4, !tbaa !36
  %229 = call ptr @tstore_dtype_str(i32 noundef %228)
  %230 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %225, ptr noundef @.str.11, ptr noundef %229)
  %231 = load ptr, ptr %18, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.TSTensorEntry, ptr %231, i32 0, i32 2
  %233 = load i32, ptr %232, align 8, !tbaa !37
  %234 = icmp ne i32 %233, 0
  br i1 %234, label %235, label %268

235:                                              ; preds = %217
  %236 = load ptr, ptr %6, align 8, !tbaa !5
  %237 = call i32 @stream_str_put(ptr noundef %236, ptr noundef @.str.12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %238 = load ptr, ptr %18, align 8, !tbaa !5
  %239 = getelementptr inbounds %struct.TSTensorEntry, ptr %238, i32 0, i32 2
  %240 = load i32, ptr %239, align 8, !tbaa !37
  %241 = sub nsw i32 %240, 1
  store i32 %241, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  store i32 1, ptr %23, align 4, !tbaa !9
  br label %242

242:                                              ; preds = %262, %235
  %243 = load i32, ptr %22, align 4, !tbaa !9
  %244 = icmp sge i32 %243, 0
  br i1 %244, label %246, label %245

245:                                              ; preds = %242
  store i32 21, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br label %265

246:                                              ; preds = %242
  %247 = load i32, ptr %23, align 4, !tbaa !9
  %248 = icmp ne i32 %247, 0
  br i1 %248, label %249, label %250

249:                                              ; preds = %246
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %253

250:                                              ; preds = %246
  %251 = load ptr, ptr %6, align 8, !tbaa !5
  %252 = call i32 @stream_char_put(ptr noundef %251, i32 noundef 44)
  br label %253

253:                                              ; preds = %250, %249
  %254 = load ptr, ptr %6, align 8, !tbaa !5
  %255 = load ptr, ptr %18, align 8, !tbaa !5
  %256 = getelementptr inbounds %struct.TSTensorEntry, ptr %255, i32 0, i32 3
  %257 = load i32, ptr %22, align 4, !tbaa !9
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [4 x i32], ptr %256, i64 0, i64 %258
  %260 = load i32, ptr %259, align 4, !tbaa !9
  %261 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %254, ptr noundef @.str.13, i32 noundef %260)
  br label %262

262:                                              ; preds = %253
  %263 = load i32, ptr %22, align 4, !tbaa !9
  %264 = add nsw i32 %263, -1
  store i32 %264, ptr %22, align 4, !tbaa !9
  br label %242, !llvm.loop !38

265:                                              ; preds = %245
  %266 = load ptr, ptr %6, align 8, !tbaa !5
  %267 = call i32 @stream_char_put(ptr noundef %266, i32 noundef 93)
  br label %268

268:                                              ; preds = %265, %217
  %269 = load ptr, ptr %6, align 8, !tbaa !5
  %270 = load ptr, ptr %18, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.TSTensorEntry, ptr %270, i32 0, i32 4
  %272 = load i64, ptr %271, align 8, !tbaa !32
  %273 = load ptr, ptr %18, align 8, !tbaa !5
  %274 = getelementptr inbounds %struct.TSTensorEntry, ptr %273, i32 0, i32 4
  %275 = load i64, ptr %274, align 8, !tbaa !32
  %276 = load ptr, ptr %18, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.TSTensorEntry, ptr %276, i32 0, i32 5
  %278 = load i64, ptr %277, align 8, !tbaa !33
  %279 = add i64 %275, %278
  %280 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %269, ptr noundef @.str.14, i64 noundef %272, i64 noundef %279)
  %281 = load ptr, ptr %6, align 8, !tbaa !5
  %282 = call i32 @stream_char_put(ptr noundef %281, i32 noundef 125)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  br label %283

283:                                              ; preds = %268, %167
  %284 = load ptr, ptr %18, align 8, !tbaa !5
  %285 = getelementptr inbounds %struct.TSTensorEntry, ptr %284, i32 1
  store ptr %285, ptr %18, align 8, !tbaa !5
  br label %154, !llvm.loop !39

286:                                              ; preds = %158
  %287 = load i64, ptr %10, align 8, !tbaa !11
  store i64 %287, ptr %12, align 8, !tbaa !11
  %288 = load ptr, ptr %6, align 8, !tbaa !5
  %289 = call i32 @stream_char_put(ptr noundef %288, i32 noundef 125)
  %290 = load ptr, ptr %6, align 8, !tbaa !5
  %291 = call i64 @stream_pos_get(ptr noundef %290)
  store i64 %291, ptr %11, align 8, !tbaa !11
  br label %292

292:                                              ; preds = %286
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %293 = load ptr, ptr %6, align 8, !tbaa !5
  %294 = call i32 @stream_seek(ptr noundef %293, i64 noundef 0, i32 noundef 0)
  store i32 %294, ptr %24, align 4, !tbaa !9
  %295 = load i32, ptr %24, align 4, !tbaa !9
  %296 = icmp slt i32 %295, 0
  br i1 %296, label %297, label %302

297:                                              ; preds = %292
  br label %298

298:                                              ; preds = %297
  %299 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %299, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %16, align 4
  br label %303

300:                                              ; No predecessors!
  br label %301

301:                                              ; preds = %300
  br label %302

302:                                              ; preds = %301, %292
  store i32 0, ptr %16, align 4
  br label %303

303:                                              ; preds = %302, %298
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  %304 = load i32, ptr %16, align 4
  switch i32 %304, label %397 [
    i32 0, label %305
    i32 8, label %382
  ]

305:                                              ; preds = %303
  br label %306

306:                                              ; preds = %305
  br label %307

307:                                              ; preds = %306
  %308 = load i64, ptr %11, align 8, !tbaa !11
  %309 = call i64 @safet_align(i64 noundef %308)
  store i64 %309, ptr %11, align 8, !tbaa !11
  %310 = load i64, ptr %11, align 8, !tbaa !11
  %311 = sub i64 %310, 8
  store i64 %311, ptr %10, align 8, !tbaa !11
  br label %312

312:                                              ; preds = %307
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  %313 = load ptr, ptr %6, align 8, !tbaa !5
  %314 = call i32 @stream_write_chk(ptr noundef %313, i64 noundef 8, ptr noundef %10)
  store i32 %314, ptr %25, align 4, !tbaa !9
  %315 = load i32, ptr %25, align 4, !tbaa !9
  %316 = icmp slt i32 %315, 0
  br i1 %316, label %317, label %322

317:                                              ; preds = %312
  br label %318

318:                                              ; preds = %317
  %319 = load i32, ptr %25, align 4, !tbaa !9
  store i32 %319, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %16, align 4
  br label %323

320:                                              ; No predecessors!
  br label %321

321:                                              ; preds = %320
  br label %322

322:                                              ; preds = %321, %312
  store i32 0, ptr %16, align 4
  br label %323

323:                                              ; preds = %322, %318
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  %324 = load i32, ptr %16, align 4
  switch i32 %324, label %397 [
    i32 0, label %325
    i32 8, label %382
  ]

325:                                              ; preds = %323
  br label %326

326:                                              ; preds = %325
  br label %327

327:                                              ; preds = %326
  br label %328

328:                                              ; preds = %327
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #4
  %329 = load ptr, ptr %6, align 8, !tbaa !5
  %330 = load i64, ptr %11, align 8, !tbaa !11
  %331 = call i32 @stream_seek(ptr noundef %329, i64 noundef %330, i32 noundef 0)
  store i32 %331, ptr %26, align 4, !tbaa !9
  %332 = load i32, ptr %26, align 4, !tbaa !9
  %333 = icmp slt i32 %332, 0
  br i1 %333, label %334, label %339

334:                                              ; preds = %328
  br label %335

335:                                              ; preds = %334
  %336 = load i32, ptr %26, align 4, !tbaa !9
  store i32 %336, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %16, align 4
  br label %340

337:                                              ; No predecessors!
  br label %338

338:                                              ; preds = %337
  br label %339

339:                                              ; preds = %338, %328
  store i32 0, ptr %16, align 4
  br label %340

340:                                              ; preds = %339, %335
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #4
  %341 = load i32, ptr %16, align 4
  switch i32 %341, label %397 [
    i32 0, label %342
    i32 8, label %382
  ]

342:                                              ; preds = %340
  br label %343

343:                                              ; preds = %342
  br label %344

344:                                              ; preds = %343
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #4
  %345 = load ptr, ptr %5, align 8, !tbaa !5
  %346 = getelementptr inbounds %struct.TensorStore, ptr %345, i32 0, i32 0
  %347 = load ptr, ptr %346, align 8, !tbaa !28
  %348 = getelementptr inbounds %struct.TSTensorEntry, ptr %347, i64 0
  store ptr %348, ptr %27, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  %349 = load ptr, ptr %27, align 8, !tbaa !5
  %350 = load ptr, ptr %5, align 8, !tbaa !5
  %351 = getelementptr inbounds %struct.TensorStore, ptr %350, i32 0, i32 0
  %352 = load ptr, ptr %351, align 8, !tbaa !28
  %353 = call i32 @dynbuf_count(ptr noundef %352)
  %354 = zext i32 %353 to i64
  %355 = getelementptr inbounds %struct.TSTensorEntry, ptr %349, i64 %354
  store ptr %355, ptr %28, align 8, !tbaa !5
  br label %356

356:                                              ; preds = %367, %344
  %357 = load ptr, ptr %27, align 8, !tbaa !5
  %358 = load ptr, ptr %28, align 8, !tbaa !5
  %359 = icmp ult ptr %357, %358
  br i1 %359, label %361, label %360

360:                                              ; preds = %356
  store i32 36, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  br label %370

361:                                              ; preds = %356
  %362 = load i64, ptr %11, align 8, !tbaa !11
  %363 = load ptr, ptr %27, align 8, !tbaa !5
  %364 = getelementptr inbounds %struct.TSTensorEntry, ptr %363, i32 0, i32 4
  %365 = load i64, ptr %364, align 8, !tbaa !32
  %366 = add i64 %365, %362
  store i64 %366, ptr %364, align 8, !tbaa !32
  br label %367

367:                                              ; preds = %361
  %368 = load ptr, ptr %27, align 8, !tbaa !5
  %369 = getelementptr inbounds %struct.TSTensorEntry, ptr %368, i32 1
  store ptr %369, ptr %27, align 8, !tbaa !5
  br label %356, !llvm.loop !40

370:                                              ; preds = %360
  %371 = load i64, ptr %11, align 8, !tbaa !11
  %372 = load i64, ptr %12, align 8, !tbaa !11
  %373 = add i64 %372, %371
  store i64 %373, ptr %12, align 8, !tbaa !11
  br label %374

374:                                              ; preds = %370
  %375 = call zeroext i1 @log_level_check(i32 noundef 50)
  br i1 %375, label %376, label %379

376:                                              ; preds = %374
  %377 = load i64, ptr %11, align 8, !tbaa !11
  %378 = load i64, ptr %12, align 8, !tbaa !11
  call void (i32, ptr, ...) @log_logf(i32 noundef 50, ptr noundef @.str.15, i64 noundef %377, i64 noundef %378)
  br label %379

379:                                              ; preds = %376, %374
  br label %380

380:                                              ; preds = %379
  br label %381

381:                                              ; preds = %380
  br label %382

382:                                              ; preds = %381, %340, %323, %303, %137, %40
  %383 = load i32, ptr %8, align 4, !tbaa !9
  %384 = icmp slt i32 %383, 0
  br i1 %384, label %385, label %394

385:                                              ; preds = %382
  br label %386

386:                                              ; preds = %385
  %387 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %387, label %388, label %391

388:                                              ; preds = %386
  %389 = load i32, ptr %8, align 4, !tbaa !9
  %390 = sub nsw i32 0, %389
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.16, i32 noundef %390)
  br label %391

391:                                              ; preds = %388, %386
  br label %392

392:                                              ; preds = %391
  br label %393

393:                                              ; preds = %392
  br label %394

394:                                              ; preds = %393, %382
  %395 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  call void @dynbuf_free(ptr noundef %9, ptr noundef %395)
  %396 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %396, ptr %4, align 4
  store i32 1, ptr %16, align 4
  br label %397

397:                                              ; preds = %394, %340, %323, %303, %137
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %398 = load i32, ptr %4, align 4
  ret i32 %398
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_write_chk(ptr noalias noundef, i64 noundef, ptr noalias noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_char_put(ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @dynbuf_count(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_str_put(ptr noalias noundef, ptr noalias noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_str_put_escape(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden { ptr, i64 } @strsto_get(ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @dynbuf_resize(ptr noundef, i32 noundef, i64 noundef, i32 noundef, ptr noundef) #1

declare i64 @tstore_tensor_size(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @safet_align(i64 noundef) #3

declare i32 @stream_printf(ptr noundef, ptr noundef, ...) #2

declare ptr @tstore_dtype_str(i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_seek(ptr noundef, i64 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { "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 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"TensorStore", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!17 = !{!16, !6, i64 32}
!18 = !{!19, !10, i64 0}
!19 = !{!"", !10, i64 0, !20, i64 8}
!20 = !{!"Any", !21, i64 0, !21, i64 2, !10, i64 4, !7, i64 8}
!21 = !{!"short", !7, i64 0}
!22 = !{!23, !6, i64 0}
!23 = !{!"StrSlice", !6, i64 0, !12, i64 8}
!24 = !{!19, !21, i64 8}
!25 = !{!7, !7, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!16, !6, i64 0}
!29 = !{!30, !10, i64 0}
!30 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !12, i64 32, !12, i64 40, !6, i64 48, !6, i64 56}
!31 = !{!30, !6, i64 48}
!32 = !{!30, !12, i64 32}
!33 = !{!30, !12, i64 40}
!34 = !{i8 0, i8 2}
!35 = !{}
!36 = !{!30, !10, i64 4}
!37 = !{!30, !10, i64 8}
!38 = distinct !{!38, !27}
!39 = distinct !{!39, !27}
!40 = distinct !{!40, !27}


; 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"

%struct.TSMetaEntry = type { i32, %struct.Any }
%struct.Any = type { i16, i16, i32, %union.AnyPayload }
%union.AnyPayload = type { i64 }
%struct.TSTensorEntry = type { i32, i32, i32, [4 x i32], i64, i64, ptr, ptr }

@g_allocator_dopt = external local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @log_level_check(i32 noundef) local_unnamed_addr #1

declare void @log_logf(i32 noundef, ptr noundef, ...) local_unnamed_addr #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: inlinehint nounwind uwtable
declare hidden i32 @tstore_cb_call(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @stream_pos_get(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @dynbuf_free(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @tstore_write_safet(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  %6 = call i32 @stream_write_chk(ptr noundef %1, i64 noundef 8, ptr noundef nonnull %5)
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %3
  %9 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %9, label %.thread131.sink.split, label %.thread131

10:                                               ; preds = %3
  %11 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 123)
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = call i32 @dynbuf_count(ptr noundef %13)
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %57, label %15

15:                                               ; preds = %10
  %16 = call i32 @stream_str_put(ptr noundef %1, ptr noundef nonnull @.str.7)
  %17 = load ptr, ptr %12, align 8, !tbaa !11
  %18 = call i32 @dynbuf_count(ptr noundef %17)
  %.not151 = icmp eq i32 %18, 0
  br i1 %.not151, label %._crit_edge, label %19

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  %wide.trip.count = zext i32 %18 to i64
  %21 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 34)
  %22 = load ptr, ptr %20, align 8, !tbaa !13
  %23 = load ptr, ptr %12, align 8, !tbaa !11
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = call { ptr, i64 } @strsto_get(ptr noundef %22, i32 noundef %24)
  %26 = extractvalue { ptr, i64 } %25, 0
  %27 = call i32 @stream_str_put_escape(ptr noundef %1, ptr noundef %26)
  %28 = call i32 @stream_str_put(ptr noundef %1, ptr noundef nonnull @.str.8)
  %29 = load ptr, ptr %12, align 8, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = load i16, ptr %30, align 8, !tbaa !19
  %.not119.peel = icmp eq i16 %31, 15
  br i1 %.not119.peel, label %32, label %.loopexit

32:                                               ; preds = %19
  %33 = getelementptr inbounds i8, ptr %29, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  %35 = call i32 @stream_str_put_escape(ptr noundef %1, ptr noundef %34)
  %36 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 34)
  %exitcond.peel.not = icmp eq i32 %18, 1
  br i1 %exitcond.peel.not, label %._crit_edge, label %.peel.next

.peel.next:                                       ; preds = %32, %51
  %indvars.iv = phi i64 [ %indvars.iv.next, %51 ], [ 1, %32 ]
  %37 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 44)
  %38 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 34)
  %39 = load ptr, ptr %20, align 8, !tbaa !13
  %40 = load ptr, ptr %12, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.TSMetaEntry, ptr %40, i64 %indvars.iv
  %42 = load i32, ptr %41, align 8, !tbaa !14
  %43 = call { ptr, i64 } @strsto_get(ptr noundef %39, i32 noundef %42)
  %44 = extractvalue { ptr, i64 } %43, 0
  %45 = call i32 @stream_str_put_escape(ptr noundef %1, ptr noundef %44)
  %46 = call i32 @stream_str_put(ptr noundef %1, ptr noundef nonnull @.str.8)
  %47 = load ptr, ptr %12, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct.TSMetaEntry, ptr %47, i64 %indvars.iv, i32 1
  %49 = load i16, ptr %48, align 8, !tbaa !19
  %.not119 = icmp eq i16 %49, 15
  br i1 %.not119, label %51, label %.loopexit

.loopexit:                                        ; preds = %.peel.next, %19
  %50 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %50, label %.thread131.sink.split, label %.thread131

51:                                               ; preds = %.peel.next
  %52 = getelementptr inbounds i8, ptr %48, i64 8
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = call i32 @stream_str_put_escape(ptr noundef %1, ptr noundef %53)
  %55 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 34)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.peel.next, !llvm.loop !21

._crit_edge:                                      ; preds = %51, %32, %15
  %56 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 125)
  br label %57

57:                                               ; preds = %._crit_edge, %10
  %58 = load ptr, ptr %0, align 8, !tbaa !24
  %59 = call i32 @dynbuf_count(ptr noundef %58)
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds %struct.TSTensorEntry, ptr %58, i64 %60
  %.not152 = icmp eq i32 %59, 0
  br i1 %.not152, label %._crit_edge146, label %.lr.ph145

.lr.ph145:                                        ; preds = %57
  %62 = getelementptr inbounds i8, ptr %0, i64 32
  br label %68

._crit_edge146:                                   ; preds = %124, %57
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 125)
  %65 = call i64 @stream_pos_get(ptr noundef %1)
  %66 = call i32 @stream_seek(ptr noundef %1, i64 noundef 0, i32 noundef 0)
  %67 = icmp slt i32 %66, 0
  br i1 %67, label %.thread131, label %127

68:                                               ; preds = %.lr.ph145, %124
  %.1105143 = phi i1 [ %.not, %.lr.ph145 ], [ %.3107, %124 ]
  %.0113142 = phi ptr [ %58, %.lr.ph145 ], [ %125, %124 ]
  %69 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %70 = call ptr @dynbuf_resize(ptr noundef nonnull %4, i32 noundef 0, i64 noundef 1, i32 noundef 1, ptr noundef %69)
  %71 = call i32 @tstore_cb_call(ptr noundef %2, ptr noundef nonnull %0, ptr noundef %.0113142, ptr noundef nonnull %4)
  %72 = icmp slt i32 %71, 0
  br i1 %72, label %124, label %73

73:                                               ; preds = %68
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %.not120 = icmp eq ptr %74, null
  br i1 %.not120, label %77, label %75

75:                                               ; preds = %73
  %76 = load i8, ptr %74, align 1, !tbaa !20
  %.not121 = icmp eq i8 %76, 0
  br i1 %.not121, label %77, label %82

77:                                               ; preds = %75, %73
  %78 = load ptr, ptr %62, align 8, !tbaa !13
  %79 = load i32, ptr %.0113142, align 8, !tbaa !25
  %80 = call { ptr, i64 } @strsto_get(ptr noundef %78, i32 noundef %79)
  %81 = extractvalue { ptr, i64 } %80, 0
  br label %82

82:                                               ; preds = %75, %77
  %83 = phi ptr [ %81, %77 ], [ %74, %75 ]
  %84 = getelementptr inbounds i8, ptr %.0113142, i64 48
  store ptr %1, ptr %84, align 8, !tbaa !27
  %85 = load i64, ptr %5, align 8, !tbaa !9
  %86 = getelementptr inbounds i8, ptr %.0113142, i64 32
  store i64 %85, ptr %86, align 8, !tbaa !28
  %87 = call i64 @tstore_tensor_size(ptr noundef %.0113142) #5
  %88 = getelementptr inbounds i8, ptr %.0113142, i64 40
  store i64 %87, ptr %88, align 8, !tbaa !29
  %89 = call i64 @safet_align(i64 noundef %87)
  %90 = load i64, ptr %5, align 8, !tbaa !9
  %91 = add i64 %90, %89
  store i64 %91, ptr %5, align 8, !tbaa !9
  br i1 %.1105143, label %94, label %92

92:                                               ; preds = %82
  %93 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 44)
  br label %94

94:                                               ; preds = %82, %92
  %95 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 34)
  %96 = call i32 @stream_str_put_escape(ptr noundef %1, ptr noundef %83)
  %97 = call i32 @stream_str_put(ptr noundef %1, ptr noundef nonnull @.str.10)
  %98 = getelementptr inbounds i8, ptr %.0113142, i64 4
  %99 = load i32, ptr %98, align 4, !tbaa !30
  %100 = call ptr @tstore_dtype_str(i32 noundef %99) #5
  %101 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %1, ptr noundef nonnull @.str.11, ptr noundef %100) #5
  %102 = getelementptr inbounds i8, ptr %.0113142, i64 8
  %103 = load i32, ptr %102, align 8, !tbaa !31
  %.not122 = icmp eq i32 %103, 0
  br i1 %.not122, label %118, label %104

104:                                              ; preds = %94
  %105 = call i32 @stream_str_put(ptr noundef %1, ptr noundef nonnull @.str.12)
  %106 = load i32, ptr %102, align 8, !tbaa !31
  %107 = icmp sgt i32 %106, 0
  br i1 %107, label %108, label %._crit_edge141

108:                                              ; preds = %104
  %109 = getelementptr inbounds i8, ptr %.0113142, i64 12
  %110 = zext nneg i32 %106 to i64
  %indvars.iv.next157.peel = add nsw i64 %110, -1
  %.phi.trans.insert = getelementptr inbounds [4 x i32], ptr %109, i64 0, i64 %indvars.iv.next157.peel
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !32
  %111 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %1, ptr noundef nonnull @.str.13, i32 noundef %.pre) #5
  %.not163 = icmp eq i32 %106, 1
  br i1 %.not163, label %._crit_edge141, label %.peel.next159

._crit_edge141:                                   ; preds = %.peel.next159, %108, %104
  %112 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 93)
  br label %118

.peel.next159:                                    ; preds = %108, %.peel.next159
  %indvars.iv156 = phi i64 [ %indvars.iv.next157, %.peel.next159 ], [ %indvars.iv.next157.peel, %108 ]
  %indvars.iv.next157 = add nsw i64 %indvars.iv156, -1
  %113 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 44)
  %114 = getelementptr inbounds [4 x i32], ptr %109, i64 0, i64 %indvars.iv.next157
  %115 = load i32, ptr %114, align 4, !tbaa !32
  %116 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %1, ptr noundef nonnull @.str.13, i32 noundef %115) #5
  %117 = icmp ugt i64 %indvars.iv156, 1
  br i1 %117, label %.peel.next159, label %._crit_edge141, !llvm.loop !33

118:                                              ; preds = %._crit_edge141, %94
  %119 = load i64, ptr %86, align 8, !tbaa !28
  %120 = load i64, ptr %88, align 8, !tbaa !29
  %121 = add i64 %120, %119
  %122 = call i32 (ptr, ptr, ...) @stream_printf(ptr noundef %1, ptr noundef nonnull @.str.14, i64 noundef %119, i64 noundef %121) #5
  %123 = call i32 @stream_char_put(ptr noundef %1, i32 noundef 125)
  br label %124

124:                                              ; preds = %68, %118
  %.3107 = phi i1 [ %.1105143, %68 ], [ false, %118 ]
  %125 = getelementptr inbounds i8, ptr %.0113142, i64 64
  %126 = icmp ult ptr %125, %61
  br i1 %126, label %68, label %._crit_edge146, !llvm.loop !34

127:                                              ; preds = %._crit_edge146
  %128 = call i64 @safet_align(i64 noundef %65)
  %129 = add i64 %128, -8
  store i64 %129, ptr %5, align 8, !tbaa !9
  %130 = call i32 @stream_write_chk(ptr noundef %1, i64 noundef 8, ptr noundef nonnull %5)
  %131 = icmp slt i32 %130, 0
  br i1 %131, label %.thread131, label %132

132:                                              ; preds = %127
  %133 = call i32 @stream_seek(ptr noundef %1, i64 noundef %128, i32 noundef 0)
  %134 = icmp slt i32 %133, 0
  %....1 = call i32 @llvm.smin.i32(i32 %133, i32 0)
  br i1 %134, label %.thread131, label %135

135:                                              ; preds = %132
  %136 = load ptr, ptr %0, align 8, !tbaa !24
  %137 = call i32 @dynbuf_count(ptr noundef %136)
  %138 = zext i32 %137 to i64
  %139 = getelementptr inbounds %struct.TSTensorEntry, ptr %136, i64 %138
  %.not153 = icmp eq i32 %137, 0
  br i1 %.not153, label %._crit_edge150, label %.lr.ph149

._crit_edge150:                                   ; preds = %.lr.ph149, %135
  %140 = call zeroext i1 @log_level_check(i32 noundef 50)
  br i1 %140, label %146, label %151

.lr.ph149:                                        ; preds = %135, %.lr.ph149
  %.099147 = phi ptr [ %144, %.lr.ph149 ], [ %136, %135 ]
  %141 = getelementptr inbounds i8, ptr %.099147, i64 32
  %142 = load i64, ptr %141, align 8, !tbaa !28
  %143 = add i64 %142, %128
  store i64 %143, ptr %141, align 8, !tbaa !28
  %144 = getelementptr inbounds i8, ptr %.099147, i64 64
  %145 = icmp ult ptr %144, %139
  br i1 %145, label %.lr.ph149, label %._crit_edge150, !llvm.loop !35

146:                                              ; preds = %._crit_edge150
  %147 = add i64 %128, %63
  call void (i32, ptr, ...) @log_logf(i32 noundef 50, ptr noundef nonnull @.str.15, i64 noundef %128, i64 noundef %147) #5
  br label %151

.thread131.sink.split:                            ; preds = %.loopexit, %8
  %.str.9.sink = phi ptr [ @.str.6, %8 ], [ @.str.9, %.loopexit ]
  %.5133.ph = phi i32 [ -12295, %8 ], [ -12293, %.loopexit ]
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull %.str.9.sink) #5
  br label %.thread131

.thread131:                                       ; preds = %.thread131.sink.split, %132, %127, %._crit_edge146, %.loopexit, %8
  %.5133 = phi i32 [ -12295, %8 ], [ -12293, %.loopexit ], [ %133, %132 ], [ %130, %127 ], [ %66, %._crit_edge146 ], [ %.5133.ph, %.thread131.sink.split ]
  %148 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %148, label %149, label %151

149:                                              ; preds = %.thread131
  %150 = sub nsw i32 0, %.5133
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.16, i32 noundef %150) #5
  br label %151

151:                                              ; preds = %146, %._crit_edge150, %.thread131, %149
  %.5134 = phi i32 [ %.5133, %.thread131 ], [ %.5133, %149 ], [ %....1, %._crit_edge150 ], [ %....1, %146 ]
  %152 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  call void @dynbuf_free(ptr noundef nonnull %4, ptr noundef %152)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret i32 %.5134
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_write_chk(ptr noalias noundef, i64 noundef, ptr noalias noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_char_put(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @dynbuf_count(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_str_put(ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_str_put_escape(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden { ptr, i64 } @strsto_get(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @dynbuf_resize(ptr noundef, i32 noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i64 @tstore_tensor_size(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i64 @safet_align(i64 noundef) local_unnamed_addr #3

declare i32 @stream_printf(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

declare ptr @tstore_dtype_str(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_seek(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { "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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"TensorStore", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!12, !6, i64 32}
!14 = !{!15, !16, i64 0}
!15 = !{!"", !16, i64 0, !17, i64 8}
!16 = !{!"int", !7, i64 0}
!17 = !{!"Any", !18, i64 0, !18, i64 2, !16, i64 4, !7, i64 8}
!18 = !{!"short", !7, i64 0}
!19 = !{!15, !18, i64 8}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22, !23}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.peeled.count", i32 1}
!24 = !{!12, !6, i64 0}
!25 = !{!26, !16, i64 0}
!26 = !{!"", !16, i64 0, !16, i64 4, !16, i64 8, !7, i64 12, !10, i64 32, !10, i64 40, !6, i64 48, !6, i64 56}
!27 = !{!26, !6, i64 48}
!28 = !{!26, !10, i64 32}
!29 = !{!26, !10, i64 40}
!30 = !{!26, !16, i64 4}
!31 = !{!26, !16, i64 8}
!32 = !{!16, !16, i64 0}
!33 = distinct !{!33, !22, !23}
!34 = distinct !{!34, !22}
!35 = distinct !{!35, !22}


; Effective O3 passes: AggressiveInstCombinePass,BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass