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

; 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.Allocator = type { ptr, ptr, ptr, ptr, i32 }
%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 }
%struct.TensorStore = type { ptr, ptr, ptr, ptr, ptr }
%struct.StringStore = type { ptr, ptr, %struct.AllocatorArena }
%struct.AllocatorArena = type { i64, ptr, ptr }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@g_allocator_dopt = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @tstore_read_gguf(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %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 i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %struct.Allocator, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca %struct.Any, align 8
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i64, align 8
  %26 = alloca i32, align 4
  %27 = alloca %struct.TSTensorEntry, align 8
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i64, align 8
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  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) #6
  store i32 1, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #6
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.TensorStore, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.StringStore, ptr %36, i32 0, i32 2
  call void @allocator_arena(ptr dead_on_unwind writable sret(%struct.Allocator) align 8 %11, ptr noundef %37)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call i32 @stream_read_chk(ptr noundef %38, i64 noundef 4, ptr noundef %12)
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %41, label %54

41:                                               ; preds = %3
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %44, label %45, label %46

45:                                               ; preds = %43
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str)
  br label %46

46:                                               ; preds = %45, %43
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  store i32 -12292, ptr %8, align 4, !tbaa !9
  br label %415

50:                                               ; No predecessors!
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53, %3
  %55 = call i32 @memcmp(ptr noundef %12, ptr noundef @.str.1, i64 noundef 4) #7
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %71

57:                                               ; preds = %54
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58
  %60 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %60, label %61, label %63

61:                                               ; preds = %59
  %62 = load i32, ptr %12, align 4, !tbaa !9
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.2, i32 noundef %62)
  br label %63

63:                                               ; preds = %61, %59
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  store i32 -12291, ptr %8, align 4, !tbaa !9
  br label %415

67:                                               ; No predecessors!
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70, %54
  br label %72

72:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = call i32 @stream_read_chk(ptr noundef %73, i64 noundef 4, ptr noundef %13)
  store i32 %74, ptr %14, align 4, !tbaa !9
  %75 = load i32, ptr %14, align 4, !tbaa !9
  %76 = icmp slt i32 %75, 0
  br i1 %76, label %77, label %82

77:                                               ; preds = %72
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %79, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %83

80:                                               ; No predecessors!
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81, %72
  store i32 0, ptr %15, align 4
  br label %83

83:                                               ; preds = %82, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  %84 = load i32, ptr %15, align 4
  switch i32 %84, label %429 [
    i32 0, label %85
    i32 8, label %415
  ]

85:                                               ; preds = %83
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %13, align 4, !tbaa !9
  %89 = icmp ne i32 %88, 2
  br i1 %89, label %90, label %107

90:                                               ; preds = %87
  %91 = load i32, ptr %13, align 4, !tbaa !9
  %92 = icmp ne i32 %91, 3
  br i1 %92, label %93, label %107

93:                                               ; preds = %90
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  %96 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %96, label %97, label %99

97:                                               ; preds = %95
  %98 = load i32, ptr %13, align 4, !tbaa !9
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.3, i32 noundef %98)
  br label %99

99:                                               ; preds = %97, %95
  br label %100

100:                                              ; preds = %99
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  store i32 -12291, ptr %8, align 4, !tbaa !9
  br label %415

103:                                              ; No predecessors!
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106, %90, %87
  br label %108

108:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  %110 = call i32 @stream_read_chk(ptr noundef %109, i64 noundef 8, ptr noundef %16)
  store i32 %110, ptr %18, align 4, !tbaa !9
  %111 = load i32, ptr %18, align 4, !tbaa !9
  %112 = icmp slt i32 %111, 0
  br i1 %112, label %113, label %118

113:                                              ; preds = %108
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %115, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %119

116:                                              ; No predecessors!
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117, %108
  store i32 0, ptr %15, align 4
  br label %119

119:                                              ; preds = %118, %114
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  %120 = load i32, ptr %15, align 4
  switch i32 %120, label %429 [
    i32 0, label %121
    i32 8, label %415
  ]

121:                                              ; preds = %119
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  br label %124

124:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = call i32 @stream_read_chk(ptr noundef %125, i64 noundef 8, ptr noundef %17)
  store i32 %126, ptr %19, align 4, !tbaa !9
  %127 = load i32, ptr %19, align 4, !tbaa !9
  %128 = icmp slt i32 %127, 0
  br i1 %128, label %129, label %134

129:                                              ; preds = %124
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %131, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %135

132:                                              ; No predecessors!
  br label %133

133:                                              ; preds = %132
  br label %134

134:                                              ; preds = %133, %124
  store i32 0, ptr %15, align 4
  br label %135

135:                                              ; preds = %134, %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  %136 = load i32, ptr %15, align 4
  switch i32 %136, label %429 [
    i32 0, label %137
    i32 8, label %415
  ]

137:                                              ; preds = %135
  br label %138

138:                                              ; preds = %137
  br label %139

139:                                              ; preds = %138
  br label %140

140:                                              ; preds = %139
  %141 = load i64, ptr %16, align 8, !tbaa !13
  %142 = icmp ule i64 %141, 65535
  br i1 %142, label %147, label %143

143:                                              ; preds = %140
  br label %144

144:                                              ; preds = %143
  store i32 -12290, ptr %8, align 4, !tbaa !9
  br label %415

145:                                              ; No predecessors!
  br label %146

146:                                              ; preds = %145
  br label %147

147:                                              ; preds = %146, %140
  br label %148

148:                                              ; preds = %147
  br label %149

149:                                              ; preds = %148
  br label %150

150:                                              ; preds = %149
  %151 = load i64, ptr %17, align 8, !tbaa !13
  %152 = icmp ule i64 %151, 65535
  br i1 %152, label %157, label %153

153:                                              ; preds = %150
  br label %154

154:                                              ; preds = %153
  store i32 -12290, ptr %8, align 4, !tbaa !9
  br label %415

155:                                              ; No predecessors!
  br label %156

156:                                              ; preds = %155
  br label %157

157:                                              ; preds = %156, %150
  br label %158

158:                                              ; preds = %157
  br label %159

159:                                              ; preds = %158
  br label %160

160:                                              ; preds = %159
  %161 = call zeroext i1 @log_level_check(i32 noundef 50)
  br i1 %161, label %162, label %167

162:                                              ; preds = %160
  %163 = load i64, ptr %17, align 8, !tbaa !13
  %164 = trunc i64 %163 to i32
  %165 = load i64, ptr %16, align 8, !tbaa !13
  %166 = trunc i64 %165 to i32
  call void (i32, ptr, ...) @log_logf(i32 noundef 50, ptr noundef @.str.4, i32 noundef %164, i32 noundef %166)
  br label %167

167:                                              ; preds = %162, %160
  br label %168

168:                                              ; preds = %167
  br label %169

169:                                              ; preds = %168
  %170 = load ptr, ptr %5, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.TensorStore, ptr %170, i32 0, i32 1
  %172 = load ptr, ptr %5, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.TensorStore, ptr %172, i32 0, i32 1
  %174 = load ptr, ptr %173, align 8, !tbaa !15
  %175 = call i32 @dynbuf_count(ptr noundef %174)
  %176 = zext i32 %175 to i64
  %177 = load i64, ptr %17, align 8, !tbaa !13
  %178 = add i64 %176, %177
  %179 = trunc i64 %178 to i32
  %180 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %181 = call ptr @dynbuf_realloc(ptr noundef %171, i32 noundef %179, i64 noundef 24, i32 noundef 0, ptr noundef %180)
  %182 = load ptr, ptr %5, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.TensorStore, ptr %182, i32 0, i32 3
  %184 = load ptr, ptr %5, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.TensorStore, ptr %184, i32 0, i32 3
  %186 = load ptr, ptr %185, align 8, !tbaa !16
  %187 = call i32 @dynbuf_count(ptr noundef %186)
  %188 = zext i32 %187 to i64
  %189 = load i64, ptr %17, align 8, !tbaa !13
  %190 = add i64 %188, %189
  %191 = trunc i64 %190 to i32
  %192 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %193 = call ptr @dynbuf_realloc(ptr noundef %183, i32 noundef %191, i64 noundef 4, i32 noundef 0, ptr noundef %192)
  %194 = load ptr, ptr %5, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.TensorStore, ptr %194, i32 0, i32 0
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.TensorStore, ptr %196, i32 0, i32 0
  %198 = load ptr, ptr %197, align 8, !tbaa !17
  %199 = call i32 @dynbuf_count(ptr noundef %198)
  %200 = zext i32 %199 to i64
  %201 = load i64, ptr %16, align 8, !tbaa !13
  %202 = add i64 %200, %201
  %203 = trunc i64 %202 to i32
  %204 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %205 = call ptr @dynbuf_realloc(ptr noundef %195, i32 noundef %203, i64 noundef 64, i32 noundef 0, ptr noundef %204)
  %206 = load ptr, ptr %5, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.TensorStore, ptr %206, i32 0, i32 2
  %208 = load ptr, ptr %5, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.TensorStore, ptr %208, i32 0, i32 2
  %210 = load ptr, ptr %209, align 8, !tbaa !18
  %211 = call i32 @dynbuf_count(ptr noundef %210)
  %212 = zext i32 %211 to i64
  %213 = load i64, ptr %16, align 8, !tbaa !13
  %214 = add i64 %212, %213
  %215 = trunc i64 %214 to i32
  %216 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %217 = call ptr @dynbuf_realloc(ptr noundef %207, i32 noundef %215, i64 noundef 4, i32 noundef 0, ptr noundef %216)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  store i64 0, ptr %20, align 8, !tbaa !13
  br label %218

218:                                              ; preds = %280, %169
  %219 = load i64, ptr %20, align 8, !tbaa !13
  %220 = load i64, ptr %17, align 8, !tbaa !13
  %221 = icmp ult i64 %219, %220
  br i1 %221, label %223, label %222

222:                                              ; preds = %218
  store i32 43, ptr %15, align 4
  br label %283

223:                                              ; preds = %218
  br label %224

224:                                              ; preds = %223
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %225 = load ptr, ptr %6, align 8, !tbaa !5
  %226 = load ptr, ptr %5, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.TensorStore, ptr %226, i32 0, i32 4
  %228 = load ptr, ptr %227, align 8, !tbaa !11
  %229 = call i32 @gguf_read_key(ptr noundef %225, ptr noundef %11, ptr noundef %228, ptr noundef %10)
  store i32 %229, ptr %21, align 4, !tbaa !9
  %230 = load i32, ptr %21, align 4, !tbaa !9
  %231 = icmp slt i32 %230, 0
  br i1 %231, label %232, label %237

232:                                              ; preds = %224
  br label %233

233:                                              ; preds = %232
  %234 = load i32, ptr %21, align 4, !tbaa !9
  store i32 %234, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %238

235:                                              ; No predecessors!
  br label %236

236:                                              ; preds = %235
  br label %237

237:                                              ; preds = %236, %224
  store i32 0, ptr %15, align 4
  br label %238

238:                                              ; preds = %237, %233
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  %239 = load i32, ptr %15, align 4
  switch i32 %239, label %283 [
    i32 0, label %240
  ]

240:                                              ; preds = %238
  br label %241

241:                                              ; preds = %240
  br label %242

242:                                              ; preds = %241
  call void @llvm.lifetime.start.p0(i64 16, ptr %22) #6
  call void @llvm.memset.p0.i64(ptr align 8 %22, i8 0, i64 16, i1 false)
  br label %243

243:                                              ; preds = %242
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %244 = load ptr, ptr %6, align 8, !tbaa !5
  %245 = load ptr, ptr %10, align 8, !tbaa !5
  %246 = call i32 @gguf_read_meta(ptr noundef %244, ptr noundef %11, ptr noundef %22, ptr noundef %245)
  store i32 %246, ptr %23, align 4, !tbaa !9
  %247 = load i32, ptr %23, align 4, !tbaa !9
  %248 = icmp slt i32 %247, 0
  br i1 %248, label %249, label %254

249:                                              ; preds = %243
  br label %250

250:                                              ; preds = %249
  %251 = load i32, ptr %23, align 4, !tbaa !9
  store i32 %251, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %255

252:                                              ; No predecessors!
  br label %253

253:                                              ; preds = %252
  br label %254

254:                                              ; preds = %253, %243
  store i32 0, ptr %15, align 4
  br label %255

255:                                              ; preds = %254, %250
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  %256 = load i32, ptr %15, align 4
  switch i32 %256, label %277 [
    i32 0, label %257
  ]

257:                                              ; preds = %255
  br label %258

258:                                              ; preds = %257
  br label %259

259:                                              ; preds = %258
  br label %260

260:                                              ; preds = %259
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  %261 = load ptr, ptr %5, align 8, !tbaa !5
  %262 = load ptr, ptr %10, align 8, !tbaa !5
  %263 = call i32 @tstore_meta_add(ptr noundef %261, ptr noundef %262, ptr noundef %22)
  store i32 %263, ptr %24, align 4, !tbaa !9
  %264 = load i32, ptr %24, align 4, !tbaa !9
  %265 = icmp slt i32 %264, 0
  br i1 %265, label %266, label %271

266:                                              ; preds = %260
  br label %267

267:                                              ; preds = %266
  %268 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %268, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %272

269:                                              ; No predecessors!
  br label %270

270:                                              ; preds = %269
  br label %271

271:                                              ; preds = %270, %260
  store i32 0, ptr %15, align 4
  br label %272

272:                                              ; preds = %271, %267
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  %273 = load i32, ptr %15, align 4
  switch i32 %273, label %277 [
    i32 0, label %274
  ]

274:                                              ; preds = %272
  br label %275

275:                                              ; preds = %274
  br label %276

276:                                              ; preds = %275
  store i32 0, ptr %15, align 4
  br label %277

277:                                              ; preds = %276, %272, %255
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #6
  %278 = load i32, ptr %15, align 4
  switch i32 %278, label %283 [
    i32 0, label %279
  ]

279:                                              ; preds = %277
  br label %280

280:                                              ; preds = %279
  %281 = load i64, ptr %20, align 8, !tbaa !13
  %282 = add i64 %281, 1
  store i64 %282, ptr %20, align 8, !tbaa !13
  br label %218, !llvm.loop !19

283:                                              ; preds = %277, %238, %222
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  %284 = load i32, ptr %15, align 4
  switch i32 %284, label %429 [
    i32 43, label %285
    i32 8, label %415
  ]

285:                                              ; preds = %283
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  store i64 0, ptr %25, align 8, !tbaa !13
  br label %286

286:                                              ; preds = %369, %285
  %287 = load i64, ptr %25, align 8, !tbaa !13
  %288 = load i64, ptr %16, align 8, !tbaa !13
  %289 = icmp ult i64 %287, %288
  br i1 %289, label %291, label %290

290:                                              ; preds = %286
  store i32 58, ptr %15, align 4
  br label %372

291:                                              ; preds = %286
  br label %292

292:                                              ; preds = %291
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %293 = load ptr, ptr %6, align 8, !tbaa !5
  %294 = load ptr, ptr %5, align 8, !tbaa !5
  %295 = getelementptr inbounds %struct.TensorStore, ptr %294, i32 0, i32 4
  %296 = load ptr, ptr %295, align 8, !tbaa !11
  %297 = call i32 @gguf_read_key(ptr noundef %293, ptr noundef %11, ptr noundef %296, ptr noundef %10)
  store i32 %297, ptr %26, align 4, !tbaa !9
  %298 = load i32, ptr %26, align 4, !tbaa !9
  %299 = icmp slt i32 %298, 0
  br i1 %299, label %300, label %305

300:                                              ; preds = %292
  br label %301

301:                                              ; preds = %300
  %302 = load i32, ptr %26, align 4, !tbaa !9
  store i32 %302, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %306

303:                                              ; No predecessors!
  br label %304

304:                                              ; preds = %303
  br label %305

305:                                              ; preds = %304, %292
  store i32 0, ptr %15, align 4
  br label %306

306:                                              ; preds = %305, %301
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  %307 = load i32, ptr %15, align 4
  switch i32 %307, label %372 [
    i32 0, label %308
  ]

308:                                              ; preds = %306
  br label %309

309:                                              ; preds = %308
  br label %310

310:                                              ; preds = %309
  call void @llvm.lifetime.start.p0(i64 64, ptr %27) #6
  call void @llvm.memset.p0.i64(ptr align 8 %27, i8 0, i64 64, i1 false)
  br label %311

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

317:                                              ; preds = %311
  br label %318

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

320:                                              ; No predecessors!
  br label %321

321:                                              ; preds = %320
  br label %322

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

323:                                              ; preds = %322, %318
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  %324 = load i32, ptr %15, align 4
  switch i32 %324, label %366 [
    i32 0, label %325
  ]

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 %29) #6
  %329 = load ptr, ptr %7, align 8, !tbaa !5
  %330 = load ptr, ptr %5, align 8, !tbaa !5
  %331 = call i32 @tstore_cb_call(ptr noundef %329, ptr noundef %330, ptr noundef %27, ptr noundef %10)
  store i32 %331, ptr %9, align 4, !tbaa !9
  store i32 %331, ptr %29, align 4, !tbaa !9
  %332 = load i32, ptr %29, 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 %29, align 4, !tbaa !9
  store i32 %336, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, 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 %15, align 4
  br label %340

340:                                              ; preds = %339, %335
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  %341 = load i32, ptr %15, align 4
  switch i32 %341, label %366 [
    i32 0, label %342
  ]

342:                                              ; preds = %340
  br label %343

343:                                              ; preds = %342
  br label %344

344:                                              ; preds = %343
  %345 = load i32, ptr %9, align 4, !tbaa !9
  %346 = icmp sgt i32 %345, 0
  br i1 %346, label %347, label %365

347:                                              ; preds = %344
  br label %348

348:                                              ; preds = %347
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #6
  %349 = load ptr, ptr %5, align 8, !tbaa !5
  %350 = load ptr, ptr %10, align 8, !tbaa !5
  %351 = call i32 @tstore_tensor_add(ptr noundef %349, ptr noundef %350, ptr noundef %27)
  store i32 %351, ptr %30, align 4, !tbaa !9
  %352 = load i32, ptr %30, align 4, !tbaa !9
  %353 = icmp slt i32 %352, 0
  br i1 %353, label %354, label %359

354:                                              ; preds = %348
  br label %355

355:                                              ; preds = %354
  %356 = load i32, ptr %30, align 4, !tbaa !9
  store i32 %356, ptr %8, align 4, !tbaa !9
  store i32 8, ptr %15, align 4
  br label %360

357:                                              ; No predecessors!
  br label %358

358:                                              ; preds = %357
  br label %359

359:                                              ; preds = %358, %348
  store i32 0, ptr %15, align 4
  br label %360

360:                                              ; preds = %359, %355
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #6
  %361 = load i32, ptr %15, align 4
  switch i32 %361, label %366 [
    i32 0, label %362
  ]

362:                                              ; preds = %360
  br label %363

363:                                              ; preds = %362
  br label %364

364:                                              ; preds = %363
  br label %365

365:                                              ; preds = %364, %344
  store i32 0, ptr %15, align 4
  br label %366

366:                                              ; preds = %365, %360, %340, %323
  call void @llvm.lifetime.end.p0(i64 64, ptr %27) #6
  %367 = load i32, ptr %15, align 4
  switch i32 %367, label %372 [
    i32 0, label %368
  ]

368:                                              ; preds = %366
  br label %369

369:                                              ; preds = %368
  %370 = load i64, ptr %25, align 8, !tbaa !13
  %371 = add i64 %370, 1
  store i64 %371, ptr %25, align 8, !tbaa !13
  br label %286, !llvm.loop !21

372:                                              ; preds = %366, %306, %290
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  %373 = load i32, ptr %15, align 4
  switch i32 %373, label %429 [
    i32 58, label %374
    i32 8, label %415
  ]

374:                                              ; preds = %372
  %375 = load ptr, ptr %6, align 8, !tbaa !5
  %376 = call i64 @stream_pos_get(ptr noundef %375)
  store i64 %376, ptr %31, align 8, !tbaa !13
  %377 = load i64, ptr %31, align 8, !tbaa !13
  %378 = call i64 @gguf_align(i64 noundef %377)
  store i64 %378, ptr %31, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #6
  store i32 0, ptr %32, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #6
  %379 = load ptr, ptr %5, align 8, !tbaa !5
  %380 = getelementptr inbounds %struct.TensorStore, ptr %379, i32 0, i32 0
  %381 = load ptr, ptr %380, align 8, !tbaa !17
  %382 = call i32 @dynbuf_count(ptr noundef %381)
  store i32 %382, ptr %33, align 4, !tbaa !9
  br label %383

383:                                              ; preds = %411, %374
  %384 = load i32, ptr %32, align 4, !tbaa !9
  %385 = load i32, ptr %33, align 4, !tbaa !9
  %386 = icmp ult i32 %384, %385
  br i1 %386, label %388, label %387

387:                                              ; preds = %383
  store i32 77, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #6
  br label %414

388:                                              ; preds = %383
  %389 = load ptr, ptr %5, align 8, !tbaa !5
  %390 = getelementptr inbounds %struct.TensorStore, ptr %389, i32 0, i32 0
  %391 = load ptr, ptr %390, align 8, !tbaa !17
  %392 = load i32, ptr %32, align 4, !tbaa !9
  %393 = zext i32 %392 to i64
  %394 = getelementptr inbounds %struct.TSTensorEntry, ptr %391, i64 %393
  %395 = getelementptr inbounds %struct.TSTensorEntry, ptr %394, i32 0, i32 6
  %396 = load ptr, ptr %395, align 8, !tbaa !22
  %397 = load ptr, ptr %6, align 8, !tbaa !5
  %398 = icmp ne ptr %396, %397
  br i1 %398, label %399, label %400

399:                                              ; preds = %388
  br label %411

400:                                              ; preds = %388
  %401 = load i64, ptr %31, align 8, !tbaa !13
  %402 = load ptr, ptr %5, align 8, !tbaa !5
  %403 = getelementptr inbounds %struct.TensorStore, ptr %402, i32 0, i32 0
  %404 = load ptr, ptr %403, align 8, !tbaa !17
  %405 = load i32, ptr %32, align 4, !tbaa !9
  %406 = zext i32 %405 to i64
  %407 = getelementptr inbounds %struct.TSTensorEntry, ptr %404, i64 %406
  %408 = getelementptr inbounds %struct.TSTensorEntry, ptr %407, i32 0, i32 4
  %409 = load i64, ptr %408, align 8, !tbaa !24
  %410 = add i64 %409, %401
  store i64 %410, ptr %408, align 8, !tbaa !24
  br label %411

411:                                              ; preds = %400, %399
  %412 = load i32, ptr %32, align 4, !tbaa !9
  %413 = add i32 %412, 1
  store i32 %413, ptr %32, align 4, !tbaa !9
  br label %383, !llvm.loop !25

414:                                              ; preds = %387
  br label %415

415:                                              ; preds = %414, %372, %283, %154, %144, %135, %119, %102, %83, %66, %49
  %416 = load i32, ptr %8, align 4, !tbaa !9
  %417 = icmp slt i32 %416, 0
  br i1 %417, label %418, label %427

418:                                              ; preds = %415
  br label %419

419:                                              ; preds = %418
  %420 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %420, label %421, label %424

421:                                              ; preds = %419
  %422 = load i32, ptr %8, align 4, !tbaa !9
  %423 = sub nsw i32 0, %422
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.5, i32 noundef %423)
  br label %424

424:                                              ; preds = %421, %419
  br label %425

425:                                              ; preds = %424
  br label %426

426:                                              ; preds = %425
  br label %427

427:                                              ; preds = %426, %415
  %428 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %428, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %429

429:                                              ; preds = %427, %372, %283, %135, %119, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %430 = load i32, ptr %4, align 4
  ret i32 %430
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @allocator_arena(ptr dead_on_unwind noalias writable sret(%struct.Allocator) align 8, ptr noundef) #2

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

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @gguf_read_key(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @gguf_read_meta(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @gguf_read_tensor(ptr noundef, ptr noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @gguf_align(i64 noundef) #0

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

!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, !6, i64 32}
!12 = !{!"TensorStore", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !6, i64 24}
!17 = !{!12, !6, i64 0}
!18 = !{!12, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!23, !6, i64 48}
!23 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !14, i64 32, !14, i64 40, !6, i64 48, !6, i64 56}
!24 = !{!23, !14, i64 32}
!25 = distinct !{!25, !20}


; 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.Allocator = type { ptr, ptr, ptr, ptr, i32 }
%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 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@g_allocator_dopt = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @tstore_read_gguf(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = alloca %struct.Allocator, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca %struct.Any, align 8
  %11 = alloca %struct.TSTensorEntry, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #6
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  call void @allocator_arena(ptr dead_on_unwind nonnull writable sret(%struct.Allocator) align 8 %5, ptr noundef nonnull %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  %15 = call i32 @stream_read_chk(ptr noundef %1, i64 noundef 4, ptr noundef nonnull %6)
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %18, label %19, label %.thread150

19:                                               ; preds = %17
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str) #6
  br label %.thread150

20:                                               ; preds = %3
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %6, ptr noundef nonnull dereferenceable(4) @.str.1, i64 4)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %25, label %21

21:                                               ; preds = %20
  %22 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %22, label %23, label %.thread150

23:                                               ; preds = %21
  %24 = load i32, ptr %6, align 4, !tbaa !11
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.2, i32 noundef %24) #6
  br label %.thread150

25:                                               ; preds = %20
  %26 = call i32 @stream_read_chk(ptr noundef %1, i64 noundef 4, ptr noundef nonnull %7)
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %.thread150, label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %7, align 4
  %30 = add i32 %29, -4
  %or.cond = icmp ult i32 %30, -2
  br i1 %or.cond, label %31, label %35

31:                                               ; preds = %28
  %32 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %32, label %33, label %.thread150

33:                                               ; preds = %31
  %34 = load i32, ptr %7, align 4, !tbaa !11
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.3, i32 noundef %34) #6
  br label %.thread150

35:                                               ; preds = %28
  %36 = call i32 @stream_read_chk(ptr noundef %1, i64 noundef 8, ptr noundef nonnull %8)
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %.thread150, label %38

38:                                               ; preds = %35
  %39 = call i32 @stream_read_chk(ptr noundef %1, i64 noundef 8, ptr noundef nonnull %9)
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %.thread150, label %41

41:                                               ; preds = %38
  %42 = load i64, ptr %8, align 8, !tbaa !13
  %43 = icmp ult i64 %42, 65536
  %44 = load i64, ptr %9, align 8
  %45 = icmp ult i64 %44, 65536
  %or.cond127 = select i1 %43, i1 %45, i1 false
  br i1 %or.cond127, label %46, label %.thread150

46:                                               ; preds = %41
  %47 = call zeroext i1 @log_level_check(i32 noundef 50)
  br i1 %47, label %48, label %53

48:                                               ; preds = %46
  %49 = load i64, ptr %9, align 8, !tbaa !13
  %50 = trunc i64 %49 to i32
  %51 = load i64, ptr %8, align 8, !tbaa !13
  %52 = trunc i64 %51 to i32
  call void (i32, ptr, ...) @log_logf(i32 noundef 50, ptr noundef nonnull @.str.4, i32 noundef %50, i32 noundef %52) #6
  br label %53

53:                                               ; preds = %48, %46
  %54 = getelementptr inbounds i8, ptr %0, i64 8
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = call i32 @dynbuf_count(ptr noundef %55)
  %57 = load i64, ptr %9, align 8, !tbaa !13
  %58 = trunc i64 %57 to i32
  %59 = add i32 %56, %58
  %60 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %61 = call ptr @dynbuf_realloc(ptr noundef nonnull %54, i32 noundef %59, i64 noundef 24, i32 noundef 0, ptr noundef %60)
  %62 = getelementptr inbounds i8, ptr %0, i64 24
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = call i32 @dynbuf_count(ptr noundef %63)
  %65 = load i64, ptr %9, align 8, !tbaa !13
  %66 = trunc i64 %65 to i32
  %67 = add i32 %64, %66
  %68 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %69 = call ptr @dynbuf_realloc(ptr noundef nonnull %62, i32 noundef %67, i64 noundef 4, i32 noundef 0, ptr noundef %68)
  %70 = load ptr, ptr %0, align 8, !tbaa !17
  %71 = call i32 @dynbuf_count(ptr noundef %70)
  %72 = load i64, ptr %8, align 8, !tbaa !13
  %73 = trunc i64 %72 to i32
  %74 = add i32 %71, %73
  %75 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %76 = call ptr @dynbuf_realloc(ptr noundef nonnull %0, i32 noundef %74, i64 noundef 64, i32 noundef 0, ptr noundef %75)
  %77 = getelementptr inbounds i8, ptr %0, i64 16
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  %79 = call i32 @dynbuf_count(ptr noundef %78)
  %80 = load i64, ptr %8, align 8, !tbaa !13
  %81 = trunc i64 %80 to i32
  %82 = add i32 %79, %81
  %83 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %84 = call ptr @dynbuf_realloc(ptr noundef nonnull %77, i32 noundef %82, i64 noundef 4, i32 noundef 0, ptr noundef %83)
  %85 = load i64, ptr %9, align 8, !tbaa !13
  %.not168 = icmp eq i64 %85, 0
  br i1 %.not168, label %.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %53, %.thread
  %.0102159 = phi i64 [ %97, %.thread ], [ 0, %53 ]
  %86 = load ptr, ptr %12, align 8, !tbaa !9
  %87 = call i32 @gguf_read_key(ptr noundef %1, ptr noundef nonnull %5, ptr noundef %86, ptr noundef nonnull %4)
  %88 = icmp sgt i32 %87, -1
  br i1 %88, label %89, label %.thread150

89:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = call i32 @gguf_read_meta(ptr noundef %1, ptr noundef nonnull %5, ptr noundef nonnull %10, ptr noundef %90)
  %92 = icmp sgt i32 %91, -1
  br i1 %92, label %93, label %100

93:                                               ; preds = %89
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = call i32 @tstore_meta_add(ptr noundef nonnull %0, ptr noundef %94, ptr noundef nonnull %10)
  %96 = icmp slt i32 %95, 0
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #6
  br i1 %96, label %.thread150, label %.thread

.thread:                                          ; preds = %93
  %97 = add nuw i64 %.0102159, 1
  %98 = load i64, ptr %9, align 8, !tbaa !13
  %99 = icmp ult i64 %97, %98
  br i1 %99, label %.lr.ph, label %.preheader, !llvm.loop !19

100:                                              ; preds = %89
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #6
  br label %.thread150

.preheader:                                       ; preds = %.thread, %53
  %101 = load i64, ptr %8, align 8, !tbaa !13
  %.not169 = icmp eq i64 %101, 0
  br i1 %.not169, label %.thread145, label %.lr.ph165

.lr.ph165:                                        ; preds = %.preheader, %.thread140
  %.0103164 = phi i64 [ %117, %.thread140 ], [ 0, %.preheader ]
  %102 = load ptr, ptr %12, align 8, !tbaa !9
  %103 = call i32 @gguf_read_key(ptr noundef %1, ptr noundef nonnull %5, ptr noundef %102, ptr noundef nonnull %4)
  %104 = icmp sgt i32 %103, -1
  br i1 %104, label %105, label %.thread150

105:                                              ; preds = %.lr.ph165
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %11) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %11, i8 0, i64 64, i1 false)
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = call i32 @gguf_read_tensor(ptr noundef %1, ptr noundef nonnull %11, ptr noundef %106)
  %108 = icmp sgt i32 %107, -1
  br i1 %108, label %109, label %120

109:                                              ; preds = %105
  %110 = call i32 @tstore_cb_call(ptr noundef %2, ptr noundef nonnull %0, ptr noundef nonnull %11, ptr noundef nonnull %4)
  %111 = icmp sgt i32 %110, -1
  br i1 %111, label %112, label %120

112:                                              ; preds = %109
  %.not114 = icmp eq i32 %110, 0
  br i1 %.not114, label %.thread140, label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = call i32 @tstore_tensor_add(ptr noundef nonnull %0, ptr noundef %114, ptr noundef nonnull %11)
  %116 = icmp sgt i32 %115, -1
  br i1 %116, label %.thread140, label %120

.thread140:                                       ; preds = %112, %113
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %11) #6
  %117 = add nuw i64 %.0103164, 1
  %118 = load i64, ptr %8, align 8, !tbaa !13
  %119 = icmp ult i64 %117, %118
  br i1 %119, label %.lr.ph165, label %.thread145, !llvm.loop !21

120:                                              ; preds = %113, %109, %105
  %.15 = phi i32 [ %110, %109 ], [ %107, %105 ], [ %115, %113 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %11) #6
  br label %.thread150

.thread145:                                       ; preds = %.thread140, %.preheader
  %121 = call i64 @stream_pos_get(ptr noundef %1)
  %122 = call i64 @gguf_align(i64 noundef %121)
  %123 = load ptr, ptr %0, align 8, !tbaa !17
  %124 = call i32 @dynbuf_count(ptr noundef %123)
  %.not170 = icmp eq i32 %124, 0
  br i1 %.not170, label %.loopexit, label %.lr.ph167

.lr.ph167:                                        ; preds = %.thread145
  %125 = load ptr, ptr %0, align 8, !tbaa !17
  %wide.trip.count = zext i32 %124 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %126 = icmp eq i32 %124, 1
  br i1 %126, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph167.new

.lr.ph167.new:                                    ; preds = %.lr.ph167
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  br label %127

127:                                              ; preds = %143, %.lr.ph167.new
  %indvars.iv = phi i64 [ 0, %.lr.ph167.new ], [ %indvars.iv.next.1, %143 ]
  %niter = phi i64 [ 0, %.lr.ph167.new ], [ %niter.next.1, %143 ]
  %128 = getelementptr inbounds %struct.TSTensorEntry, ptr %125, i64 %indvars.iv
  %129 = getelementptr inbounds i8, ptr %128, i64 48
  %130 = load ptr, ptr %129, align 8, !tbaa !22
  %.not115 = icmp eq ptr %130, %1
  br i1 %.not115, label %131, label %135

131:                                              ; preds = %127
  %132 = getelementptr inbounds i8, ptr %128, i64 32
  %133 = load i64, ptr %132, align 8, !tbaa !24
  %134 = add i64 %133, %122
  store i64 %134, ptr %132, align 8, !tbaa !24
  br label %135

135:                                              ; preds = %127, %131
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %136 = getelementptr inbounds %struct.TSTensorEntry, ptr %125, i64 %indvars.iv.next
  %137 = getelementptr inbounds i8, ptr %136, i64 48
  %138 = load ptr, ptr %137, align 8, !tbaa !22
  %.not115.1 = icmp eq ptr %138, %1
  br i1 %.not115.1, label %139, label %143

139:                                              ; preds = %135
  %140 = getelementptr inbounds i8, ptr %136, i64 32
  %141 = load i64, ptr %140, align 8, !tbaa !24
  %142 = add i64 %141, %122
  store i64 %142, ptr %140, align 8, !tbaa !24
  br label %143

143:                                              ; preds = %139, %135
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %127, !llvm.loop !25

.thread150:                                       ; preds = %.lr.ph, %93, %.lr.ph165, %100, %120, %38, %35, %25, %41, %33, %31, %23, %21, %19, %17
  %.17152 = phi i32 [ -12290, %41 ], [ -12291, %33 ], [ -12291, %31 ], [ -12291, %23 ], [ -12291, %21 ], [ -12292, %19 ], [ -12292, %17 ], [ %91, %100 ], [ %.15, %120 ], [ %39, %38 ], [ %36, %35 ], [ %26, %25 ], [ %103, %.lr.ph165 ], [ %87, %.lr.ph ], [ %95, %93 ]
  %144 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %144, label %145, label %.loopexit

145:                                              ; preds = %.thread150
  %146 = sub nsw i32 0, %.17152
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.5, i32 noundef %146) #6
  br label %.loopexit

.loopexit.loopexit.unr-lcssa:                     ; preds = %143, %.lr.ph167
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph167 ], [ %indvars.iv.next.1, %143 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa
  %147 = getelementptr inbounds %struct.TSTensorEntry, ptr %125, i64 %indvars.iv.unr
  %148 = getelementptr inbounds i8, ptr %147, i64 48
  %149 = load ptr, ptr %148, align 8, !tbaa !22
  %.not115.epil = icmp eq ptr %149, %1
  br i1 %.not115.epil, label %150, label %.loopexit

150:                                              ; preds = %.epil.preheader
  %151 = getelementptr inbounds i8, ptr %147, i64 32
  %152 = load i64, ptr %151, align 8, !tbaa !24
  %153 = add i64 %152, %122
  store i64 %153, ptr %151, align 8, !tbaa !24
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %150, %.epil.preheader, %.thread145, %145, %.thread150
  %.0 = phi i32 [ %.17152, %.thread150 ], [ %.17152, %145 ], [ 1, %.thread145 ], [ 1, %.epil.preheader ], [ 1, %150 ], [ 1, %.loopexit.loopexit.unr-lcssa ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  ret i32 %.0
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @allocator_arena(ptr dead_on_unwind noalias writable sret(%struct.Allocator) align 8, ptr noundef) local_unnamed_addr #2

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @gguf_read_key(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @gguf_read_meta(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @gguf_read_tensor(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @gguf_align(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"TensorStore", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 0}
!18 = !{!10, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!23, !6, i64 48}
!23 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !7, i64 12, !14, i64 32, !14, i64 40, !6, i64 48, !6, i64 56}
!24 = !{!23, !14, i64 32}
!25 = distinct !{!25, !20}


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