; LLVM IR from aagdev/mlimgsynth :: src/ccommon (structio)

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

%union.AnyPayload = type { i64 }
%struct.Any = type { i16, i16, i32, %union.AnyPayload }
%struct.StioStream = type { ptr, ptr, ptr, ptr, ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__.stio_read_chunk_vector = external hidden unnamed_addr constant [78 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @stream_commit(ptr noalias noundef, ptr noalias noundef) #2

declare zeroext i1 @anyp_cast(i32 noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @stio_read_chunk_vector(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) #5 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca %union.AnyPayload, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  %28 = zext i1 %4 to i8
  store i8 %28, ptr %11, align 1, !tbaa !11
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = call zeroext i1 @anyb_pointer_is(i32 noundef %29)
  br i1 %30, label %31, label %32

31:                                               ; preds = %5
  br label %33

32:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 217, ptr noundef @__PRETTY_FUNCTION__.stio_read_chunk_vector) #6
  unreachable

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = call i32 @anyb_pointer_deref(i32 noundef %34)
  store i32 %35, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = call i64 @anyb_size(i32 noundef %36)
  store i64 %37, ptr %13, align 8, !tbaa !13
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.Any, ptr %38, i32 0, i32 0
  %40 = load i16, ptr %39, align 8, !tbaa !15
  %41 = zext i16 %40 to i32
  %42 = icmp eq i32 %41, 13
  br i1 %42, label %43, label %55

43:                                               ; preds = %33
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = trunc i32 %44 to i16
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Any, ptr %46, i32 0, i32 0
  store i16 %45, ptr %47, align 8, !tbaa !15
  %48 = load i64, ptr %13, align 8, !tbaa !13
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Any, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !18
  %52 = zext i32 %51 to i64
  %53 = udiv i64 %52, %48
  %54 = trunc i64 %53 to i32
  store i32 %54, ptr %50, align 4, !tbaa !18
  br label %55

55:                                               ; preds = %43, %33
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Any, ptr %56, i32 0, i32 0
  %58 = load i16, ptr %57, align 8, !tbaa !15
  %59 = zext i16 %58 to i32
  %60 = call zeroext i1 @anyb_pointer_is(i32 noundef %59)
  br i1 %60, label %62, label %61

61:                                               ; preds = %55
  store i32 -521, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %274

62:                                               ; preds = %55
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Any, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !18
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = icmp ugt i32 %65, %66
  br i1 %67, label %68, label %72

68:                                               ; preds = %62
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Any, ptr %70, i32 0, i32 2
  store i32 %69, ptr %71, align 4, !tbaa !18
  br label %72

72:                                               ; preds = %68, %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Any, ptr %73, i32 0, i32 0
  %75 = load i16, ptr %74, align 8, !tbaa !15
  %76 = zext i16 %75 to i32
  %77 = call i32 @anyb_pointer_deref(i32 noundef %76)
  store i32 %77, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %78 = load i32, ptr %15, align 4, !tbaa !9
  %79 = call i64 @anyb_size(i32 noundef %78)
  store i64 %79, ptr %16, align 8, !tbaa !13
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.Any, ptr %80, i32 0, i32 3
  %82 = load ptr, ptr %81, align 8, !tbaa !19
  %83 = icmp ne ptr %82, null
  br i1 %83, label %98, label %84

84:                                               ; preds = %72
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.StioStream, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !20
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.Any, ptr %88, i32 0, i32 2
  %90 = load i32, ptr %89, align 4, !tbaa !18
  %91 = zext i32 %90 to i64
  %92 = load i64, ptr %13, align 8, !tbaa !13
  %93 = mul i64 %91, %92
  %94 = call i32 @stream_seek(ptr noundef %87, i64 noundef %93, i32 noundef 1)
  %95 = icmp slt i32 %94, 0
  br i1 %95, label %96, label %97

96:                                               ; preds = %84
  store i32 -517, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %273

97:                                               ; preds = %84
  br label %272

98:                                               ; preds = %72
  %99 = load i32, ptr %15, align 4, !tbaa !9
  %100 = load i32, ptr %12, align 4, !tbaa !9
  %101 = icmp eq i32 %99, %100
  br i1 %101, label %102, label %235

102:                                              ; preds = %98
  %103 = load i64, ptr %16, align 8, !tbaa !13
  %104 = icmp eq i64 %103, 1
  br i1 %104, label %105, label %128

105:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.StioStream, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !20
  %109 = load ptr, ptr %8, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.Any, ptr %109, i32 0, i32 2
  %111 = load i32, ptr %110, align 4, !tbaa !18
  %112 = zext i32 %111 to i64
  %113 = load ptr, ptr %8, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.Any, ptr %113, i32 0, i32 3
  %115 = load ptr, ptr %114, align 8, !tbaa !19
  %116 = call i64 @stream_read(ptr noundef %108, i64 noundef %112, ptr noundef %115)
  store i64 %116, ptr %17, align 8, !tbaa !13
  %117 = load i64, ptr %17, align 8, !tbaa !13
  %118 = load ptr, ptr %8, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.Any, ptr %118, i32 0, i32 2
  %120 = load i32, ptr %119, align 4, !tbaa !18
  %121 = zext i32 %120 to i64
  %122 = icmp ne i64 %117, %121
  br i1 %122, label %123, label %124

123:                                              ; preds = %105
  store i32 -515, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %125

124:                                              ; preds = %105
  store i32 0, ptr %14, align 4
  br label %125

125:                                              ; preds = %124, %123
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  %126 = load i32, ptr %14, align 4
  switch i32 %126, label %273 [
    i32 0, label %127
  ]

127:                                              ; preds = %125
  br label %234

128:                                              ; preds = %102
  %129 = load i8, ptr %11, align 1, !tbaa !11, !range !22, !noundef !23
  %130 = trunc i8 %129 to i1
  br i1 %130, label %158, label %131

131:                                              ; preds = %128
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.StioStream, ptr %132, i32 0, i32 1
  %134 = load ptr, ptr %133, align 8, !tbaa !20
  %135 = load ptr, ptr %8, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.Any, ptr %135, i32 0, i32 2
  %137 = load i32, ptr %136, align 4, !tbaa !18
  %138 = zext i32 %137 to i64
  %139 = load i64, ptr %16, align 8, !tbaa !13
  %140 = mul i64 %138, %139
  %141 = load ptr, ptr %8, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.Any, ptr %141, i32 0, i32 3
  %143 = load ptr, ptr %142, align 8, !tbaa !19
  %144 = call i64 @stream_read(ptr noundef %134, i64 noundef %140, ptr noundef %143)
  store i64 %144, ptr %18, align 8, !tbaa !13
  %145 = load i64, ptr %18, align 8, !tbaa !13
  %146 = load ptr, ptr %8, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.Any, ptr %146, i32 0, i32 2
  %148 = load i32, ptr %147, align 4, !tbaa !18
  %149 = zext i32 %148 to i64
  %150 = load i64, ptr %16, align 8, !tbaa !13
  %151 = mul i64 %149, %150
  %152 = icmp ne i64 %145, %151
  br i1 %152, label %153, label %154

153:                                              ; preds = %131
  store i32 -516, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %155

154:                                              ; preds = %131
  store i32 0, ptr %14, align 4
  br label %155

155:                                              ; preds = %154, %153
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  %156 = load i32, ptr %14, align 4
  switch i32 %156, label %273 [
    i32 0, label %157
  ]

157:                                              ; preds = %155
  br label %233

158:                                              ; preds = %128
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %159 = load ptr, ptr %8, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.Any, ptr %159, i32 0, i32 3
  %161 = load ptr, ptr %160, align 8, !tbaa !19
  store ptr %161, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %162 = load ptr, ptr %19, align 8, !tbaa !5
  %163 = load ptr, ptr %8, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.Any, ptr %163, i32 0, i32 2
  %165 = load i32, ptr %164, align 4, !tbaa !18
  %166 = zext i32 %165 to i64
  %167 = load i64, ptr %13, align 8, !tbaa !13
  %168 = mul i64 %166, %167
  %169 = getelementptr inbounds i8, ptr %162, i64 %168
  store ptr %169, ptr %20, align 8, !tbaa !5
  br label %170

170:                                              ; preds = %228, %158
  %171 = load ptr, ptr %19, align 8, !tbaa !5
  %172 = load ptr, ptr %20, align 8, !tbaa !5
  %173 = icmp ult ptr %171, %172
  br i1 %173, label %174, label %229

174:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %175 = load ptr, ptr %7, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.StioStream, ptr %175, i32 0, i32 1
  %177 = load ptr, ptr %176, align 8, !tbaa !20
  %178 = load ptr, ptr %20, align 8, !tbaa !5
  %179 = load ptr, ptr %19, align 8, !tbaa !5
  %180 = ptrtoint ptr %178 to i64
  %181 = ptrtoint ptr %179 to i64
  %182 = sub i64 %180, %181
  %183 = load i64, ptr %13, align 8, !tbaa !13
  %184 = mul i64 %182, %183
  %185 = call i32 @stream_read_prep(ptr noundef %177, i64 noundef %184)
  %186 = sext i32 %185 to i64
  store i64 %186, ptr %21, align 8, !tbaa !13
  %187 = load i64, ptr %21, align 8, !tbaa !13
  %188 = load i64, ptr %13, align 8, !tbaa !13
  %189 = icmp ult i64 %187, %188
  br i1 %189, label %190, label %191

190:                                              ; preds = %174
  store i32 -516, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %226

191:                                              ; preds = %174
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %192 = load ptr, ptr %7, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.StioStream, ptr %192, i32 0, i32 1
  %194 = load ptr, ptr %193, align 8, !tbaa !20
  %195 = call ptr @stream_buffer_get_(ptr noundef %194, ptr noundef %22)
  store ptr %195, ptr %23, align 8, !tbaa !5
  br label %196

196:                                              ; preds = %208, %191
  %197 = load ptr, ptr %23, align 8, !tbaa !5
  %198 = load i64, ptr %13, align 8, !tbaa !13
  %199 = getelementptr inbounds i8, ptr %197, i64 %198
  %200 = load ptr, ptr %22, align 8, !tbaa !5
  %201 = icmp ult ptr %199, %200
  br i1 %201, label %202, label %206

202:                                              ; preds = %196
  %203 = load ptr, ptr %19, align 8, !tbaa !5
  %204 = load ptr, ptr %20, align 8, !tbaa !5
  %205 = icmp ult ptr %203, %204
  br label %206

206:                                              ; preds = %202, %196
  %207 = phi i1 [ false, %196 ], [ %205, %202 ]
  br i1 %207, label %208, label %221

208:                                              ; preds = %206
  %209 = load ptr, ptr %19, align 8, !tbaa !5
  %210 = load ptr, ptr %23, align 8, !tbaa !5
  %211 = load i64, ptr %13, align 8, !tbaa !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %209, ptr align 1 %210, i64 %211, i1 false)
  %212 = load i64, ptr %13, align 8, !tbaa !13
  %213 = trunc i64 %212 to i32
  %214 = load ptr, ptr %19, align 8, !tbaa !5
  call void @byteswap(i32 noundef %213, ptr noundef %214)
  %215 = load i64, ptr %13, align 8, !tbaa !13
  %216 = load ptr, ptr %23, align 8, !tbaa !5
  %217 = getelementptr inbounds i8, ptr %216, i64 %215
  store ptr %217, ptr %23, align 8, !tbaa !5
  %218 = load i64, ptr %13, align 8, !tbaa !13
  %219 = load ptr, ptr %19, align 8, !tbaa !5
  %220 = getelementptr inbounds i8, ptr %219, i64 %218
  store ptr %220, ptr %19, align 8, !tbaa !5
  br label %196, !llvm.loop !24

221:                                              ; preds = %206
  %222 = load ptr, ptr %7, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.StioStream, ptr %222, i32 0, i32 1
  %224 = load ptr, ptr %223, align 8, !tbaa !20
  %225 = load ptr, ptr %23, align 8, !tbaa !5
  call void @stream_commit(ptr noundef %224, ptr noundef %225)
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  store i32 0, ptr %14, align 4
  br label %226

226:                                              ; preds = %221, %190
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  %227 = load i32, ptr %14, align 4
  switch i32 %227, label %230 [
    i32 0, label %228
  ]

228:                                              ; preds = %226
  br label %170, !llvm.loop !26

229:                                              ; preds = %170
  store i32 0, ptr %14, align 4
  br label %230

230:                                              ; preds = %229, %226
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  %231 = load i32, ptr %14, align 4
  switch i32 %231, label %273 [
    i32 0, label %232
  ]

232:                                              ; preds = %230
  br label %233

233:                                              ; preds = %232, %157
  br label %234

234:                                              ; preds = %233, %127
  br label %271

235:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  %236 = load ptr, ptr %8, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.Any, ptr %236, i32 0, i32 3
  %238 = load ptr, ptr %237, align 8, !tbaa !19
  store ptr %238, ptr %25, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  store i32 0, ptr %26, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #7
  %239 = load ptr, ptr %8, align 8, !tbaa !5
  %240 = getelementptr inbounds %struct.Any, ptr %239, i32 0, i32 2
  %241 = load i32, ptr %240, align 4, !tbaa !18
  store i32 %241, ptr %27, align 4, !tbaa !9
  br label %242

242:                                              ; preds = %267, %235
  %243 = load i32, ptr %26, align 4, !tbaa !9
  %244 = load i32, ptr %27, align 4, !tbaa !9
  %245 = icmp ult i32 %243, %244
  br i1 %245, label %247, label %246

246:                                              ; preds = %242
  store i32 6, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  br label %270

247:                                              ; preds = %242
  %248 = load ptr, ptr %7, align 8, !tbaa !5
  %249 = getelementptr inbounds %struct.StioStream, ptr %248, i32 0, i32 1
  %250 = load ptr, ptr %249, align 8, !tbaa !20
  %251 = load i64, ptr %13, align 8, !tbaa !13
  %252 = call i64 @stream_read(ptr noundef %250, i64 noundef %251, ptr noundef %24)
  %253 = load i8, ptr %11, align 1, !tbaa !11, !range !22, !noundef !23
  %254 = trunc i8 %253 to i1
  br i1 %254, label %255, label %259

255:                                              ; preds = %247
  %256 = load i64, ptr %13, align 8, !tbaa !13
  %257 = trunc i64 %256 to i32
  %258 = load ptr, ptr %25, align 8, !tbaa !5
  call void @byteswap(i32 noundef %257, ptr noundef %258)
  br label %259

259:                                              ; preds = %255, %247
  %260 = load i32, ptr %12, align 4, !tbaa !9
  %261 = load ptr, ptr %25, align 8, !tbaa !5
  %262 = load i32, ptr %15, align 4, !tbaa !9
  %263 = call zeroext i1 @anyp_cast(i32 noundef %260, ptr noundef %261, i32 noundef %262, ptr noundef %24)
  %264 = load i64, ptr %16, align 8, !tbaa !13
  %265 = load ptr, ptr %25, align 8, !tbaa !5
  %266 = getelementptr inbounds i8, ptr %265, i64 %264
  store ptr %266, ptr %25, align 8, !tbaa !5
  br label %267

267:                                              ; preds = %259
  %268 = load i32, ptr %26, align 4, !tbaa !9
  %269 = add i32 %268, 1
  store i32 %269, ptr %26, align 4, !tbaa !9
  br label %242, !llvm.loop !27

270:                                              ; preds = %246
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  br label %271

271:                                              ; preds = %270, %234
  br label %272

272:                                              ; preds = %271, %97
  store i32 2, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %273

273:                                              ; preds = %272, %230, %155, %125, %96
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %274

274:                                              ; preds = %273, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %275 = load i32, ptr %6, align 4
  ret i32 %275
}

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"Any", !17, i64 0, !17, i64 2, !10, i64 4, !7, i64 8}
!17 = !{!"short", !7, i64 0}
!18 = !{!16, !10, i64 4}
!19 = !{!7, !7, i64 0}
!20 = !{!21, !6, i64 8}
!21 = !{!"StioStream", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = distinct !{!27, !25}


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

%union.AnyPayload = type { i64 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__.stio_read_chunk_vector = external hidden unnamed_addr constant [78 x i8], align 1

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @stream_commit(ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #2

declare zeroext i1 @anyp_cast(i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @stio_read_chunk_vector(ptr nocapture noundef readonly %0, ptr nocapture noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #5 {
  %6 = alloca ptr, align 8
  %7 = alloca %union.AnyPayload, align 8
  %8 = tail call zeroext i1 @anyb_pointer_is(i32 noundef %2)
  br i1 %8, label %10, label %9

9:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 217, ptr noundef nonnull @__PRETTY_FUNCTION__.stio_read_chunk_vector) #6
  unreachable

10:                                               ; preds = %5
  %11 = tail call i32 @anyb_pointer_deref(i32 noundef %2)
  %12 = tail call i64 @anyb_size(i32 noundef %11)
  %13 = load i16, ptr %1, align 8, !tbaa !5
  %14 = icmp eq i16 %13, 13
  br i1 %14, label %15, label %22

15:                                               ; preds = %10
  %16 = trunc i32 %2 to i16
  store i16 %16, ptr %1, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = zext i32 %18 to i64
  %20 = udiv i64 %19, %12
  %21 = trunc nuw i64 %20 to i32
  store i32 %21, ptr %17, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %15, %10
  %23 = phi i16 [ %16, %15 ], [ %13, %10 ]
  %24 = zext i16 %23 to i32
  %25 = tail call zeroext i1 @anyb_pointer_is(i32 noundef %24)
  br i1 %25, label %26, label %.thread

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %1, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = icmp ugt i32 %28, %3
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  store i32 %3, ptr %27, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %30, %26
  %32 = load i16, ptr %1, align 8, !tbaa !5
  %33 = zext i16 %32 to i32
  %34 = tail call i32 @anyb_pointer_deref(i32 noundef %33)
  %35 = tail call i64 @anyb_size(i32 noundef %34)
  %36 = getelementptr inbounds i8, ptr %1, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !12
  %.not = icmp eq ptr %37, null
  br i1 %.not, label %38, label %46

38:                                               ; preds = %31
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  %41 = load i32, ptr %27, align 4, !tbaa !11
  %42 = zext i32 %41 to i64
  %43 = mul i64 %12, %42
  %44 = tail call i32 @stream_seek(ptr noundef %40, i64 noundef %43, i32 noundef 1)
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %.thread, label %.critedge

46:                                               ; preds = %31
  %47 = icmp eq i32 %34, %11
  br i1 %47, label %48, label %97

48:                                               ; preds = %46
  %49 = icmp eq i64 %35, 1
  br i1 %49, label %50, label %58

50:                                               ; preds = %48
  %51 = getelementptr inbounds i8, ptr %0, i64 8
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr %27, align 4, !tbaa !11
  %54 = zext i32 %53 to i64
  %55 = tail call i64 @stream_read(ptr noundef %52, i64 noundef %54, ptr noundef nonnull %37)
  %56 = load i32, ptr %27, align 4, !tbaa !11
  %57 = zext i32 %56 to i64
  %.not105 = icmp eq i64 %55, %57
  br i1 %.not105, label %.critedge, label %.thread

58:                                               ; preds = %48
  br i1 %4, label %69, label %59

59:                                               ; preds = %58
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = load i32, ptr %27, align 4, !tbaa !11
  %63 = zext i32 %62 to i64
  %64 = mul i64 %35, %63
  %65 = tail call i64 @stream_read(ptr noundef %61, i64 noundef %64, ptr noundef nonnull %37)
  %66 = load i32, ptr %27, align 4, !tbaa !11
  %67 = zext i32 %66 to i64
  %68 = mul i64 %35, %67
  %.not102 = icmp eq i64 %65, %68
  br i1 %.not102, label %.critedge, label %.thread

69:                                               ; preds = %58
  %70 = load i32, ptr %27, align 4, !tbaa !11
  %71 = zext i32 %70 to i64
  %72 = mul i64 %12, %71
  %73 = getelementptr inbounds i8, ptr %37, i64 %72
  %74 = getelementptr inbounds i8, ptr %0, i64 8
  %75 = ptrtoint ptr %73 to i64
  %76 = trunc i64 %12 to i32
  %.not104123 = icmp sgt i64 %72, 0
  br i1 %.not104123, label %.lr.ph126, label %.critedge

.lr.ph126:                                        ; preds = %69, %._crit_edge113
  %.092124 = phi ptr [ %.193.lcssa, %._crit_edge113 ], [ %37, %69 ]
  %77 = load ptr, ptr %74, align 8, !tbaa !13
  %78 = ptrtoint ptr %.092124 to i64
  %79 = sub i64 %75, %78
  %80 = mul i64 %79, %12
  %81 = call i32 @stream_read_prep(ptr noundef %77, i64 noundef %80) #7
  %82 = sext i32 %81 to i64
  %.not103 = icmp ugt i64 %12, %82
  br i1 %.not103, label %.thread, label %83

83:                                               ; preds = %.lr.ph126
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %84 = load ptr, ptr %74, align 8, !tbaa !13
  %85 = call ptr @stream_buffer_get_(ptr noundef %84, ptr noundef nonnull %6)
  %86 = getelementptr inbounds i8, ptr %85, i64 %12
  %87 = load ptr, ptr %6, align 8, !tbaa !16
  %88 = icmp ult ptr %86, %87
  br i1 %88, label %.lr.ph112, label %._crit_edge113

.lr.ph112:                                        ; preds = %83, %.lr.ph112
  %89 = phi ptr [ %91, %.lr.ph112 ], [ %86, %83 ]
  %.087110 = phi ptr [ %89, %.lr.ph112 ], [ %85, %83 ]
  %.193109 = phi ptr [ %90, %.lr.ph112 ], [ %.092124, %83 ]
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.193109, ptr align 1 %.087110, i64 %12, i1 false)
  call void @byteswap(i32 noundef %76, ptr noundef %.193109)
  %90 = getelementptr inbounds i8, ptr %.193109, i64 %12
  %91 = getelementptr inbounds i8, ptr %89, i64 %12
  %92 = load ptr, ptr %6, align 8, !tbaa !16
  %93 = icmp ult ptr %91, %92
  %94 = icmp ult ptr %90, %73
  %95 = select i1 %93, i1 %94, i1 false
  br i1 %95, label %.lr.ph112, label %._crit_edge113, !llvm.loop !17

._crit_edge113:                                   ; preds = %.lr.ph112, %83
  %.193.lcssa = phi ptr [ %.092124, %83 ], [ %90, %.lr.ph112 ]
  %.087.lcssa = phi ptr [ %85, %83 ], [ %89, %.lr.ph112 ]
  %96 = load ptr, ptr %74, align 8, !tbaa !13
  call void @stream_commit(ptr noundef %96, ptr noundef %.087.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  %.not104 = icmp ult ptr %.193.lcssa, %73
  br i1 %.not104, label %.lr.ph126, label %.critedge

97:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  %98 = load i32, ptr %27, align 4, !tbaa !11
  %.not115 = icmp eq i32 %98, 0
  br i1 %.not115, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %97
  %99 = getelementptr inbounds i8, ptr %0, i64 8
  %100 = trunc i64 %12 to i32
  br i1 %4, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.085108.us = phi i32 [ %105, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %.086107.us = phi ptr [ %104, %.lr.ph.split.us ], [ %37, %.lr.ph ]
  %101 = load ptr, ptr %99, align 8, !tbaa !13
  %102 = call i64 @stream_read(ptr noundef %101, i64 noundef %12, ptr noundef nonnull %7)
  call void @byteswap(i32 noundef %100, ptr noundef %.086107.us)
  %103 = call zeroext i1 @anyp_cast(i32 noundef %11, ptr noundef %.086107.us, i32 noundef %34, ptr noundef nonnull %7) #7
  %104 = getelementptr inbounds i8, ptr %.086107.us, i64 %35
  %105 = add nuw i32 %.085108.us, 1
  %exitcond118.not = icmp eq i32 %105, %98
  br i1 %exitcond118.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  br label %.critedge

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %.085108 = phi i32 [ %110, %.lr.ph.split ], [ 0, %.lr.ph ]
  %.086107 = phi ptr [ %109, %.lr.ph.split ], [ %37, %.lr.ph ]
  %106 = load ptr, ptr %99, align 8, !tbaa !13
  %107 = call i64 @stream_read(ptr noundef %106, i64 noundef %12, ptr noundef nonnull %7)
  %108 = call zeroext i1 @anyp_cast(i32 noundef %11, ptr noundef %.086107, i32 noundef %34, ptr noundef nonnull %7) #7
  %109 = getelementptr inbounds i8, ptr %.086107, i64 %35
  %110 = add nuw i32 %.085108, 1
  %exitcond.not = icmp eq i32 %110, %98
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !19

.critedge:                                        ; preds = %._crit_edge113, %69, %._crit_edge, %59, %50, %38
  br label %.thread

.thread:                                          ; preds = %.lr.ph126, %.critedge, %59, %50, %38, %22
  %.6 = phi i32 [ -521, %22 ], [ 2, %.critedge ], [ -515, %50 ], [ -516, %59 ], [ -517, %38 ], [ -516, %.lr.ph126 ]
  ret i32 %.6
}

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

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

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

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

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


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