; LLVM IR from aagdev/mlimgsynth :: src (main_tstore_util)

; 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.TStoreUtil = type { %struct.TensorStore, %struct.Stream, %struct.Stream, %struct.StringStore, %struct.anon }
%struct.TensorStore = type { ptr, ptr, ptr, ptr, ptr }
%struct.Stream = type { ptr, ptr, ptr, ptr, ptr, %struct.StreamInt, i64, i32 }
%struct.StreamInt = type { [3 x ptr] }
%struct.StringStore = type { ptr, ptr, %struct.AllocatorArena }
%struct.AllocatorArena = type { i64, ptr, ptr }
%struct.anon = type { ptr, ptr, ptr, ptr, ptr, i32 }
%struct.TSTensorEntry = type { i32, i32, i32, [4 x i32], i64, i64, ptr, ptr }

@.str.17 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 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

declare double @timing_time(...) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @dynbuf_count(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 i32 @stream_seek(ptr noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @tsu_bench(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.StrSlice, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %18 = call double (...) @timing_time()
  store double %18, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  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 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TStoreUtil, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.TensorStore, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = call i32 @dynbuf_count(ptr noundef %22)
  store i32 %23, ptr %11, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %159, %1
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %12, align 4
  br label %162

29:                                               ; preds = %24
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.TStoreUtil, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.TensorStore, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds %struct.TSTensorEntry, ptr %33, i64 %35
  store ptr %36, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.TStoreUtil, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TSTensorEntry, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !23
  %42 = call { ptr, i64 } @strsto_get(ptr noundef %38, i32 noundef %41)
  %43 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 0
  %44 = extractvalue { ptr, i64 } %42, 0
  store ptr %44, ptr %43, align 8
  %45 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 1
  %46 = extractvalue { ptr, i64 } %42, 1
  store i64 %46, ptr %45, align 8
  %47 = getelementptr inbounds %struct.StrSlice, ptr %13, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !25
  store ptr %48, ptr %9, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %29
  %50 = call zeroext i1 @log_level_check(i32 noundef 60)
  br i1 %50, label %51, label %59

51:                                               ; preds = %49
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TSTensorEntry, ptr %53, i32 0, i32 4
  %55 = load i64, ptr %54, align 8, !tbaa !27
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TSTensorEntry, ptr %56, i32 0, i32 5
  %58 = load i64, ptr %57, align 8, !tbaa !28
  call void (i32, ptr, ...) @log_logf(i32 noundef 60, ptr noundef @.str.17, ptr noundef %52, i64 noundef %55, i64 noundef %58)
  br label %59

59:                                               ; preds = %51, %49
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.TSTensorEntry, ptr %63, i32 0, i32 6
  %65 = load ptr, ptr %64, align 8, !tbaa !29
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.TSTensorEntry, ptr %66, i32 0, i32 4
  %68 = load i64, ptr %67, align 8, !tbaa !27
  %69 = call i32 @stream_seek(ptr noundef %65, i64 noundef %68, i32 noundef 0)
  store i32 %69, ptr %14, align 4, !tbaa !9
  %70 = load i32, ptr %14, align 4, !tbaa !9
  %71 = icmp slt i32 %70, 0
  br i1 %71, label %72, label %89

72:                                               ; preds = %62
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  %75 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %75, label %76, label %80

76:                                               ; preds = %74
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.TSTensorEntry, ptr %77, i32 0, i32 4
  %79 = load i64, ptr %78, align 8, !tbaa !27
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.18, i64 noundef %79)
  br label %80

80:                                               ; preds = %76, %74
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %84, ptr %4, align 4, !tbaa !9
  store i32 15, ptr %12, align 4
  br label %90

85:                                               ; No predecessors!
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88, %62
  store i32 0, ptr %12, align 4
  br label %90

90:                                               ; preds = %89, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %91 = load i32, ptr %12, align 4
  switch i32 %91, label %162 [
    i32 0, label %92
  ]

92:                                               ; preds = %90
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.TSTensorEntry, ptr %95, i32 0, i32 6
  %97 = load ptr, ptr %96, align 8, !tbaa !29
  %98 = call zeroext i1 @stream_mmap_is(ptr noundef %97)
  br i1 %98, label %130, label %99

99:                                               ; preds = %94
  br label %100

100:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.TSTensorEntry, ptr %101, i32 0, i32 6
  %103 = load ptr, ptr %102, align 8, !tbaa !29
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.TSTensorEntry, ptr %104, i32 0, i32 5
  %106 = load i64, ptr %105, align 8, !tbaa !28
  %107 = call i32 @stream_read_prep(ptr noundef %103, i64 noundef %106)
  store i32 %107, ptr %15, align 4, !tbaa !9
  %108 = load i32, ptr %15, align 4, !tbaa !9
  %109 = icmp slt i32 %108, 0
  br i1 %109, label %110, label %124

110:                                              ; preds = %100
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111
  %113 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %113, label %114, label %115

114:                                              ; preds = %112
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.19)
  br label %115

115:                                              ; preds = %114, %112
  br label %116

116:                                              ; preds = %115
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %119, ptr %4, align 4, !tbaa !9
  store i32 15, ptr %12, align 4
  br label %125

120:                                              ; No predecessors!
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  br label %124

124:                                              ; preds = %123, %100
  store i32 0, ptr %12, align 4
  br label %125

125:                                              ; preds = %124, %118
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  %126 = load i32, ptr %12, align 4
  switch i32 %126, label %162 [
    i32 0, label %127
  ]

127:                                              ; preds = %125
  br label %128

128:                                              ; preds = %127
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129, %94
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.TSTensorEntry, ptr %131, i32 0, i32 6
  %133 = load ptr, ptr %132, align 8, !tbaa !29
  %134 = call ptr @stream_buffer_get_(ptr noundef %133, ptr noundef null)
  store ptr %134, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %135 = load ptr, ptr %16, align 8, !tbaa !5
  %136 = load ptr, ptr %8, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.TSTensorEntry, ptr %136, i32 0, i32 5
  %138 = load i64, ptr %137, align 8, !tbaa !28
  %139 = udiv i64 %138, 4
  %140 = getelementptr inbounds i32, ptr %135, i64 %139
  store ptr %140, ptr %17, align 8, !tbaa !5
  br label %141

141:                                              ; preds = %150, %130
  %142 = load ptr, ptr %16, align 8, !tbaa !5
  %143 = load ptr, ptr %17, align 8, !tbaa !5
  %144 = icmp ult ptr %142, %143
  br i1 %144, label %145, label %153

145:                                              ; preds = %141
  %146 = load ptr, ptr %16, align 8, !tbaa !5
  %147 = load i32, ptr %146, align 4, !tbaa !9
  %148 = load i32, ptr %7, align 4, !tbaa !9
  %149 = add i32 %148, %147
  store i32 %149, ptr %7, align 4, !tbaa !9
  br label %150

150:                                              ; preds = %145
  %151 = load ptr, ptr %16, align 8, !tbaa !5
  %152 = getelementptr inbounds i32, ptr %151, i32 1
  store ptr %152, ptr %16, align 8, !tbaa !5
  br label %141, !llvm.loop !30

153:                                              ; preds = %141
  %154 = load ptr, ptr %8, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.TSTensorEntry, ptr %154, i32 0, i32 5
  %156 = load i64, ptr %155, align 8, !tbaa !28
  %157 = load i64, ptr %6, align 8, !tbaa !13
  %158 = add i64 %157, %156
  store i64 %158, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %159

159:                                              ; preds = %153
  %160 = load i32, ptr %10, align 4, !tbaa !9
  %161 = add i32 %160, 1
  store i32 %161, ptr %10, align 4, !tbaa !9
  br label %24, !llvm.loop !32

162:                                              ; preds = %125, %90, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %163 = load i32, ptr %12, align 4
  switch i32 %163, label %211 [
    i32 2, label %164
    i32 15, label %189
  ]

164:                                              ; preds = %162
  %165 = call double (...) @timing_time()
  %166 = load double, ptr %5, align 8, !tbaa !11
  %167 = fsub double %165, %166
  store double %167, ptr %5, align 8, !tbaa !11
  br label %168

168:                                              ; preds = %164
  %169 = call zeroext i1 @log_level_check(i32 noundef 30)
  br i1 %169, label %170, label %186

170:                                              ; preds = %168
  %171 = load i32, ptr %7, align 4, !tbaa !9
  %172 = load ptr, ptr %3, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.TStoreUtil, ptr %172, i32 0, i32 0
  %174 = getelementptr inbounds %struct.TensorStore, ptr %173, i32 0, i32 0
  %175 = load ptr, ptr %174, align 8, !tbaa !15
  %176 = call i32 @dynbuf_count(ptr noundef %175)
  %177 = load double, ptr %5, align 8, !tbaa !11
  %178 = load i64, ptr %6, align 8, !tbaa !13
  %179 = uitofp i64 %178 to double
  %180 = fmul double %179, 0x3E10000000000000
  %181 = load i64, ptr %6, align 8, !tbaa !13
  %182 = uitofp i64 %181 to double
  %183 = fmul double %182, 0x3E10000000000000
  %184 = load double, ptr %5, align 8, !tbaa !11
  %185 = fdiv double %183, %184
  call void (i32, ptr, ...) @log_logf(i32 noundef 30, ptr noundef @.str.20, i32 noundef %171, i32 noundef %176, double noundef %177, double noundef %180, double noundef %185)
  br label %186

186:                                              ; preds = %170, %168
  br label %187

187:                                              ; preds = %186
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188, %162
  %190 = load i32, ptr %4, align 4, !tbaa !9
  %191 = icmp slt i32 %190, 0
  br i1 %191, label %192, label %209

192:                                              ; preds = %189
  %193 = load ptr, ptr %8, align 8, !tbaa !5
  %194 = icmp ne ptr %193, null
  br i1 %194, label %195, label %209

195:                                              ; preds = %192
  br label %196

196:                                              ; preds = %195
  %197 = call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %197, label %198, label %206

198:                                              ; preds = %196
  %199 = load ptr, ptr %9, align 8, !tbaa !5
  %200 = load ptr, ptr %8, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.TSTensorEntry, ptr %200, i32 0, i32 4
  %202 = load i64, ptr %201, align 8, !tbaa !27
  %203 = load ptr, ptr %8, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.TSTensorEntry, ptr %203, i32 0, i32 5
  %205 = load i64, ptr %204, align 8, !tbaa !28
  call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef @.str.21, ptr noundef %199, i64 noundef %202, i64 noundef %205)
  br label %206

206:                                              ; preds = %198, %196
  br label %207

207:                                              ; preds = %206
  br label %208

208:                                              ; preds = %207
  br label %209

209:                                              ; preds = %208, %192, %189
  %210 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %210, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %211

211:                                              ; preds = %209, %162
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %212 = load i32, ptr %2, align 4
  ret i32 %212
}

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

declare i32 @stream_read_prep(ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @stream_buffer_get_(ptr noundef, ptr 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 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"TStoreUtil", !17, i64 0, !18, i64 40, !18, i64 120, !20, i64 200, !22, i64 240}
!17 = !{!"TensorStore", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!18 = !{!"Stream", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !19, i64 40, !14, i64 64, !10, i64 72}
!19 = !{!"StreamInt", !7, i64 0}
!20 = !{!"StringStore", !6, i64 0, !6, i64 8, !21, i64 16}
!21 = !{!"AllocatorArena", !14, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40}
!23 = !{!24, !10, i64 0}
!24 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !14, i64 32, !14, i64 40, !6, i64 48, !6, i64 56}
!25 = !{!26, !6, i64 0}
!26 = !{!"StrSlice", !6, i64 0, !14, i64 8}
!27 = !{!24, !14, i64 32}
!28 = !{!24, !14, i64 40}
!29 = !{!24, !6, i64 48}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}


; 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.TSTensorEntry = type { i32, i32, i32, [4 x i32], i64, i64, ptr, ptr }

@.str.17 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1

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

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

declare double @timing_time(...) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -2147483648, 2) i32 @tsu_bench(ptr noundef %0) local_unnamed_addr #2 {
  %2 = tail call double (...) @timing_time() #4
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = tail call i32 @dynbuf_count(ptr noundef %3)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge103, label %.lr.ph102

.lr.ph102:                                        ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 200
  %wide.trip.count = zext i32 %4 to i64
  br label %6

6:                                                ; preds = %.lr.ph102, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph102 ], [ %indvars.iv.next, %._crit_edge ]
  %.051100 = phi i64 [ 0, %.lr.ph102 ], [ %68, %._crit_edge ]
  %.05299 = phi i32 [ 0, %.lr.ph102 ], [ %.153.lcssa, %._crit_edge ]
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.TSTensorEntry, ptr %7, i64 %indvars.iv
  %9 = load i32, ptr %8, align 8, !tbaa !18
  %10 = tail call { ptr, i64 } @strsto_get(ptr noundef nonnull %5, i32 noundef %9)
  %11 = extractvalue { ptr, i64 } %10, 0
  %12 = tail call zeroext i1 @log_level_check(i32 noundef 60)
  br i1 %12, label %13, label %18

13:                                               ; preds = %6
  %14 = getelementptr inbounds i8, ptr %8, i64 32
  %15 = load i64, ptr %14, align 8, !tbaa !20
  %16 = getelementptr inbounds i8, ptr %8, i64 40
  %17 = load i64, ptr %16, align 8, !tbaa !21
  tail call void (i32, ptr, ...) @log_logf(i32 noundef 60, ptr noundef nonnull @.str.17, ptr noundef %11, i64 noundef %15, i64 noundef %17) #4
  br label %18

18:                                               ; preds = %6, %13
  %19 = getelementptr inbounds i8, ptr %8, i64 48
  %20 = load ptr, ptr %19, align 8, !tbaa !22
  %21 = getelementptr inbounds i8, ptr %8, i64 32
  %22 = load i64, ptr %21, align 8, !tbaa !20
  %23 = tail call i32 @stream_seek(ptr noundef %20, i64 noundef %22, i32 noundef 0)
  %24 = icmp sgt i32 %23, -1
  br i1 %24, label %30, label %25

25:                                               ; preds = %18
  %26 = tail call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %26, label %27, label %.thread70

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %8, i64 32
  %29 = load i64, ptr %28, align 8, !tbaa !20
  tail call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.18, i64 noundef %29) #4
  br label %.thread70

30:                                               ; preds = %18
  %31 = load ptr, ptr %19, align 8, !tbaa !22
  %32 = tail call zeroext i1 @stream_mmap_is(ptr noundef %31)
  br i1 %32, label %42, label %33

33:                                               ; preds = %30
  %34 = load ptr, ptr %19, align 8, !tbaa !22
  %35 = getelementptr inbounds i8, ptr %8, i64 40
  %36 = load i64, ptr %35, align 8, !tbaa !21
  %37 = tail call i32 @stream_read_prep(ptr noundef %34, i64 noundef %36) #4
  %38 = icmp sgt i32 %37, -1
  br i1 %38, label %42, label %39

39:                                               ; preds = %33
  %40 = tail call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %40, label %41, label %.thread70

41:                                               ; preds = %39
  tail call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.19) #4
  br label %.thread70

42:                                               ; preds = %33, %30
  %43 = load ptr, ptr %19, align 8, !tbaa !22
  %44 = tail call ptr @stream_buffer_get_(ptr noundef %43, ptr noundef null)
  %45 = getelementptr inbounds i8, ptr %8, i64 40
  %46 = load i64, ptr %45, align 8, !tbaa !21
  %47 = lshr i64 %46, 2
  %48 = getelementptr inbounds i32, ptr %44, i64 %47
  %.idx = and i64 %46, -4
  %49 = icmp sgt i64 %.idx, 0
  br i1 %49, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %42
  %50 = ptrtoint ptr %44 to i64
  %51 = add i64 %.idx, %50
  %52 = add i64 %50, 4
  %umax = tail call i64 @llvm.umax.i64(i64 %51, i64 %52)
  %53 = xor i64 %50, -1
  %54 = add i64 %umax, %53
  %55 = lshr i64 %54, 2
  %56 = add nuw nsw i64 %55, 1
  %min.iters.check = icmp ult i64 %54, 28
  br i1 %min.iters.check, label %.lr.ph.preheader154, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %56, 9223372036854775800
  %57 = shl i64 %n.vec, 2
  %ind.end = getelementptr i8, ptr %44, i64 %57
  %58 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.05299, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %58, %vector.ph ], [ %60, %vector.body ]
  %vec.phi151 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %61, %vector.body ]
  %offset.idx = shl i64 %index, 2
  %next.gep = getelementptr i8, ptr %44, i64 %offset.idx
  %59 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <4 x i32>, ptr %next.gep, align 4, !tbaa !23
  %wide.load153 = load <4 x i32>, ptr %59, align 4, !tbaa !23
  %60 = add <4 x i32> %wide.load, %vec.phi
  %61 = add <4 x i32> %wide.load153, %vec.phi151
  %index.next = add nuw i64 %index, 8
  %62 = icmp eq i64 %index.next, %n.vec
  br i1 %62, label %middle.block, label %vector.body, !llvm.loop !24

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %61, %60
  %63 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %56, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader154

.lr.ph.preheader154:                              ; preds = %middle.block, %.lr.ph.preheader
  %.04996.ph = phi ptr [ %44, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.15395.ph = phi i32 [ %.05299, %.lr.ph.preheader ], [ %63, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader154, %.lr.ph
  %.04996 = phi ptr [ %66, %.lr.ph ], [ %.04996.ph, %.lr.ph.preheader154 ]
  %.15395 = phi i32 [ %65, %.lr.ph ], [ %.15395.ph, %.lr.ph.preheader154 ]
  %64 = load i32, ptr %.04996, align 4, !tbaa !23
  %65 = add i32 %64, %.15395
  %66 = getelementptr inbounds i8, ptr %.04996, i64 4
  %67 = icmp ult ptr %66, %48
  br i1 %67, label %.lr.ph, label %._crit_edge, !llvm.loop !28

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %42
  %.153.lcssa = phi i32 [ %.05299, %42 ], [ %63, %middle.block ], [ %65, %.lr.ph ]
  %68 = add i64 %46, %.051100
  %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_edge103.loopexit, label %6, !llvm.loop !29

._crit_edge103.loopexit:                          ; preds = %._crit_edge
  %69 = uitofp i64 %68 to double
  %70 = fmul double %69, 0x3E10000000000000
  br label %._crit_edge103

._crit_edge103:                                   ; preds = %._crit_edge103.loopexit, %1
  %.052.lcssa = phi i32 [ 0, %1 ], [ %.153.lcssa, %._crit_edge103.loopexit ]
  %.051.lcssa = phi double [ 0.000000e+00, %1 ], [ %70, %._crit_edge103.loopexit ]
  %71 = tail call double (...) @timing_time() #4
  %72 = tail call zeroext i1 @log_level_check(i32 noundef 30)
  br i1 %72, label %73, label %.thread70.thread

73:                                               ; preds = %._crit_edge103
  %74 = fsub double %71, %2
  %75 = load ptr, ptr %0, align 8, !tbaa !5
  %76 = tail call i32 @dynbuf_count(ptr noundef %75)
  %77 = fdiv double %.051.lcssa, %74
  tail call void (i32, ptr, ...) @log_logf(i32 noundef 30, ptr noundef nonnull @.str.20, i32 noundef %.052.lcssa, i32 noundef %76, double noundef %74, double noundef %.051.lcssa, double noundef %77) #4
  br label %.thread70.thread

.thread70:                                        ; preds = %27, %25, %41, %39
  %.477 = phi i32 [ %23, %27 ], [ %23, %25 ], [ %37, %41 ], [ %37, %39 ]
  %78 = tail call zeroext i1 @log_level_check(i32 noundef 10)
  br i1 %78, label %79, label %.thread70.thread

79:                                               ; preds = %.thread70
  %80 = getelementptr inbounds i8, ptr %8, i64 32
  %81 = load i64, ptr %80, align 8, !tbaa !20
  %82 = getelementptr inbounds i8, ptr %8, i64 40
  %83 = load i64, ptr %82, align 8, !tbaa !21
  tail call void (i32, ptr, ...) @log_logf(i32 noundef 10, ptr noundef nonnull @.str.21, ptr noundef %11, i64 noundef %81, i64 noundef %83) #4
  br label %.thread70.thread

.thread70.thread:                                 ; preds = %73, %._crit_edge103, %79, %.thread70
  %.477124 = phi i32 [ %.477, %79 ], [ %.477, %.thread70 ], [ 1, %._crit_edge103 ], [ 1, %73 ]
  ret i32 %.477124
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @stream_mmap_is(ptr noundef) local_unnamed_addr #0

declare i32 @stream_read_prep(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3

attributes #0 = { 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 #1 = { "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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !8, i64 0}
!6 = !{!"TStoreUtil", !7, i64 0, !11, i64 40, !11, i64 120, !15, i64 200, !17, i64 240}
!7 = !{!"TensorStore", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"Stream", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !12, i64 40, !13, i64 64, !14, i64 72}
!12 = !{!"StreamInt", !9, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!"int", !9, i64 0}
!15 = !{!"StringStore", !8, i64 0, !8, i64 8, !16, i64 16}
!16 = !{!"AllocatorArena", !13, i64 0, !8, i64 8, !8, i64 16}
!17 = !{!"", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !14, i64 40}
!18 = !{!19, !14, i64 0}
!19 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !9, i64 12, !13, i64 32, !13, i64 40, !8, i64 48, !8, i64 56}
!20 = !{!19, !13, i64 32}
!21 = !{!19, !13, i64 40}
!22 = !{!19, !8, i64 48}
!23 = !{!14, !14, i64 0}
!24 = distinct !{!24, !25, !26, !27}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!"llvm.loop.isvectorized", i32 1}
!27 = !{!"llvm.loop.unroll.runtime.disable"}
!28 = distinct !{!28, !25, !27, !26}
!29 = distinct !{!29, !25}


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