; 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.2 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__.stio_write_chunk_vector = external hidden unnamed_addr constant [75 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

32:                                               ; preds = %4
  br label %34

33:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 147, ptr noundef @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

34:                                               ; preds = %32
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Any, ptr %35, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  br label %41

40:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 148, ptr noundef @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

41:                                               ; preds = %39
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Any, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !17
  %45 = icmp ne i32 %44, -1
  br i1 %45, label %46, label %47

46:                                               ; preds = %41
  br label %48

47:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 149, ptr noundef @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

48:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Any, ptr %49, i32 0, i32 0
  %51 = load i16, ptr %50, align 8, !tbaa !13
  %52 = zext i16 %51 to i32
  %53 = call i32 @anyb_pointer_deref(i32 noundef %52)
  store i32 %53, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = call i64 @anyb_size(i32 noundef %54)
  store i64 %55, ptr %11, align 8, !tbaa !18
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = call zeroext i1 @anyb_pointer_is(i32 noundef %56)
  br i1 %57, label %58, label %252

58:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = call i32 @anyb_pointer_deref(i32 noundef %59)
  store i32 %60, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = call i64 @anyb_size(i32 noundef %61)
  store i64 %62, ptr %13, align 8, !tbaa !18
  %63 = load i64, ptr %13, align 8, !tbaa !18
  %64 = icmp ugt i64 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %58
  br label %67

66:                                               ; preds = %58
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 158, ptr noundef @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

67:                                               ; preds = %65
  %68 = load i32, ptr %12, align 4, !tbaa !9
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %204

71:                                               ; preds = %67
  %72 = load i64, ptr %13, align 8, !tbaa !18
  %73 = icmp eq i64 %72, 1
  br i1 %73, label %74, label %97

74:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.StioStream, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !20
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Any, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 4, !tbaa !17
  %81 = zext i32 %80 to i64
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.Any, ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %83, align 8, !tbaa !16
  %85 = call i64 @stream_write(ptr noundef %77, i64 noundef %81, ptr noundef %84)
  store i64 %85, ptr %14, align 8, !tbaa !18
  %86 = load i64, ptr %14, align 8, !tbaa !18
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.Any, ptr %87, i32 0, i32 2
  %89 = load i32, ptr %88, align 4, !tbaa !17
  %90 = zext i32 %89 to i64
  %91 = icmp ne i64 %86, %90
  br i1 %91, label %92, label %93

92:                                               ; preds = %74
  store i32 -516, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %94

93:                                               ; preds = %74
  store i32 0, ptr %15, align 4
  br label %94

94:                                               ; preds = %93, %92
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  %95 = load i32, ptr %15, align 4
  switch i32 %95, label %249 [
    i32 0, label %96
  ]

96:                                               ; preds = %94
  br label %203

97:                                               ; preds = %71
  %98 = load i8, ptr %9, align 1, !tbaa !11, !range !22, !noundef !23
  %99 = trunc i8 %98 to i1
  br i1 %99, label %127, label %100

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

122:                                              ; preds = %100
  store i32 -516, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %124

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

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

126:                                              ; preds = %124
  br label %202

127:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.Any, ptr %128, i32 0, i32 3
  %130 = load ptr, ptr %129, align 8, !tbaa !16
  store ptr %130, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %131 = load ptr, ptr %17, align 8, !tbaa !5
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.Any, ptr %132, i32 0, i32 2
  %134 = load i32, ptr %133, align 4, !tbaa !17
  %135 = zext i32 %134 to i64
  %136 = load i64, ptr %11, align 8, !tbaa !18
  %137 = mul i64 %135, %136
  %138 = getelementptr inbounds i8, ptr %131, i64 %137
  store ptr %138, ptr %18, align 8, !tbaa !5
  br label %139

139:                                              ; preds = %197, %127
  %140 = load ptr, ptr %17, align 8, !tbaa !5
  %141 = load ptr, ptr %18, align 8, !tbaa !5
  %142 = icmp ult ptr %140, %141
  br i1 %142, label %143, label %198

143:                                              ; preds = %139
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.StioStream, ptr %144, i32 0, i32 1
  %146 = load ptr, ptr %145, align 8, !tbaa !20
  %147 = load ptr, ptr %18, align 8, !tbaa !5
  %148 = load ptr, ptr %17, align 8, !tbaa !5
  %149 = ptrtoint ptr %147 to i64
  %150 = ptrtoint ptr %148 to i64
  %151 = sub i64 %149, %150
  %152 = load i64, ptr %11, align 8, !tbaa !18
  %153 = mul i64 %151, %152
  %154 = call i32 @stream_write_prep(ptr noundef %146, i64 noundef %153)
  %155 = sext i32 %154 to i64
  store i64 %155, ptr %19, align 8, !tbaa !18
  %156 = load i64, ptr %19, align 8, !tbaa !18
  %157 = load i64, ptr %11, align 8, !tbaa !18
  %158 = icmp ult i64 %156, %157
  br i1 %158, label %159, label %160

159:                                              ; preds = %143
  store i32 -516, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %195

160:                                              ; preds = %143
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %161 = load ptr, ptr %6, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.StioStream, ptr %161, i32 0, i32 1
  %163 = load ptr, ptr %162, align 8, !tbaa !20
  %164 = call ptr @stream_buffer_get_(ptr noundef %163, ptr noundef %20)
  store ptr %164, ptr %21, align 8, !tbaa !5
  br label %165

165:                                              ; preds = %177, %160
  %166 = load ptr, ptr %21, align 8, !tbaa !5
  %167 = load i64, ptr %11, align 8, !tbaa !18
  %168 = getelementptr inbounds i8, ptr %166, i64 %167
  %169 = load ptr, ptr %20, align 8, !tbaa !5
  %170 = icmp ult ptr %168, %169
  br i1 %170, label %171, label %175

171:                                              ; preds = %165
  %172 = load ptr, ptr %17, align 8, !tbaa !5
  %173 = load ptr, ptr %18, align 8, !tbaa !5
  %174 = icmp ult ptr %172, %173
  br label %175

175:                                              ; preds = %171, %165
  %176 = phi i1 [ false, %165 ], [ %174, %171 ]
  br i1 %176, label %177, label %190

177:                                              ; preds = %175
  %178 = load ptr, ptr %21, align 8, !tbaa !5
  %179 = load ptr, ptr %17, align 8, !tbaa !5
  %180 = load i64, ptr %11, align 8, !tbaa !18
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %178, ptr align 1 %179, i64 %180, i1 false)
  %181 = load i64, ptr %11, align 8, !tbaa !18
  %182 = trunc i64 %181 to i32
  %183 = load ptr, ptr %21, align 8, !tbaa !5
  call void @byteswap(i32 noundef %182, ptr noundef %183)
  %184 = load i64, ptr %11, align 8, !tbaa !18
  %185 = load ptr, ptr %21, align 8, !tbaa !5
  %186 = getelementptr inbounds i8, ptr %185, i64 %184
  store ptr %186, ptr %21, align 8, !tbaa !5
  %187 = load i64, ptr %11, align 8, !tbaa !18
  %188 = load ptr, ptr %17, align 8, !tbaa !5
  %189 = getelementptr inbounds i8, ptr %188, i64 %187
  store ptr %189, ptr %17, align 8, !tbaa !5
  br label %165, !llvm.loop !24

190:                                              ; preds = %175
  %191 = load ptr, ptr %6, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.StioStream, ptr %191, i32 0, i32 1
  %193 = load ptr, ptr %192, align 8, !tbaa !20
  %194 = load ptr, ptr %21, align 8, !tbaa !5
  call void @stream_commit(ptr noundef %193, ptr noundef %194)
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  store i32 0, ptr %15, align 4
  br label %195

195:                                              ; preds = %190, %159
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  %196 = load i32, ptr %15, align 4
  switch i32 %196, label %199 [
    i32 0, label %197
  ]

197:                                              ; preds = %195
  br label %139, !llvm.loop !26

198:                                              ; preds = %139
  store i32 0, ptr %15, align 4
  br label %199

199:                                              ; preds = %198, %195
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  %200 = load i32, ptr %15, align 4
  switch i32 %200, label %249 [
    i32 0, label %201
  ]

201:                                              ; preds = %199
  br label %202

202:                                              ; preds = %201, %126
  br label %203

203:                                              ; preds = %202, %96
  br label %248

204:                                              ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %205 = load ptr, ptr %7, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.Any, ptr %205, i32 0, i32 3
  %207 = load ptr, ptr %206, align 8, !tbaa !16
  store ptr %207, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  store i32 0, ptr %24, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %208 = load ptr, ptr %7, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.Any, ptr %208, i32 0, i32 2
  %210 = load i32, ptr %209, align 4, !tbaa !17
  store i32 %210, ptr %25, align 4, !tbaa !9
  br label %211

211:                                              ; preds = %239, %204
  %212 = load i32, ptr %24, align 4, !tbaa !9
  %213 = load i32, ptr %25, align 4, !tbaa !9
  %214 = icmp ult i32 %212, %213
  br i1 %214, label %216, label %215

215:                                              ; preds = %211
  store i32 6, ptr %15, align 4
  br label %242

216:                                              ; preds = %211
  %217 = load i32, ptr %12, align 4, !tbaa !9
  %218 = load i32, ptr %10, align 4, !tbaa !9
  %219 = load ptr, ptr %23, align 8, !tbaa !5
  %220 = call zeroext i1 @anyp_cast(i32 noundef %217, ptr noundef %22, i32 noundef %218, ptr noundef %219)
  %221 = load i8, ptr %9, align 1, !tbaa !11, !range !22, !noundef !23
  %222 = trunc i8 %221 to i1
  br i1 %222, label %223, label %226

223:                                              ; preds = %216
  %224 = load i64, ptr %13, align 8, !tbaa !18
  %225 = trunc i64 %224 to i32
  call void @byteswap(i32 noundef %225, ptr noundef %22)
  br label %226

226:                                              ; preds = %223, %216
  %227 = load ptr, ptr %6, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.StioStream, ptr %227, i32 0, i32 1
  %229 = load ptr, ptr %228, align 8, !tbaa !20
  %230 = load i64, ptr %13, align 8, !tbaa !18
  %231 = call i64 @stream_write(ptr noundef %229, i64 noundef %230, ptr noundef %22)
  %232 = load i64, ptr %13, align 8, !tbaa !18
  %233 = icmp ne i64 %231, %232
  br i1 %233, label %234, label %235

234:                                              ; preds = %226
  store i32 -516, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %242

235:                                              ; preds = %226
  %236 = load i64, ptr %11, align 8, !tbaa !18
  %237 = load ptr, ptr %23, align 8, !tbaa !5
  %238 = getelementptr inbounds i8, ptr %237, i64 %236
  store ptr %238, ptr %23, align 8, !tbaa !5
  br label %239

239:                                              ; preds = %235
  %240 = load i32, ptr %24, align 4, !tbaa !9
  %241 = add i32 %240, 1
  store i32 %241, ptr %24, align 4, !tbaa !9
  br label %211, !llvm.loop !27

242:                                              ; preds = %234, %215
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  %243 = load i32, ptr %15, align 4
  switch i32 %243, label %245 [
    i32 6, label %244
  ]

244:                                              ; preds = %242
  store i32 0, ptr %15, align 4
  br label %245

245:                                              ; preds = %244, %242
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  %246 = load i32, ptr %15, align 4
  switch i32 %246, label %249 [
    i32 0, label %247
  ]

247:                                              ; preds = %245
  br label %248

248:                                              ; preds = %247, %203
  store i32 0, ptr %15, align 4
  br label %249

249:                                              ; preds = %248, %245, %199, %124, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %250 = load i32, ptr %15, align 4
  switch i32 %250, label %254 [
    i32 0, label %251
  ]

251:                                              ; preds = %249
  br label %253

252:                                              ; preds = %48
  store i32 -522, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %254

253:                                              ; preds = %251
  store i32 2, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %254

254:                                              ; preds = %253, %252, %249
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %255 = load i32, ptr %5, align 4
  ret i32 %255
}

; 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 i64 @stream_write(ptr noalias noundef, i64 noundef, ptr noalias noundef) #2

declare i32 @stream_write_prep(ptr noundef, i64 noundef) #5

; 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) #5

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 = { 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 #5 = { "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, !15, i64 0}
!14 = !{!"Any", !15, i64 0, !15, i64 2, !10, i64 4, !7, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!14, !10, i64 4}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !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.2 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__.stio_write_chunk_vector = external hidden unnamed_addr constant [75 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

10:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 147, ptr noundef nonnull @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

11:                                               ; preds = %4
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %15

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 148, ptr noundef nonnull @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %1, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %.not98 = icmp eq i32 %17, -1
  br i1 %.not98, label %18, label %19

18:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 149, ptr noundef nonnull @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

19:                                               ; preds = %15
  %20 = load i16, ptr %1, align 8, !tbaa !5
  %21 = zext i16 %20 to i32
  %22 = tail call i32 @anyb_pointer_deref(i32 noundef %21)
  %23 = tail call i64 @anyb_size(i32 noundef %22)
  %24 = tail call zeroext i1 @anyb_pointer_is(i32 noundef %2)
  br i1 %24, label %25, label %.loopexit

25:                                               ; preds = %19
  %26 = tail call i32 @anyb_pointer_deref(i32 noundef %2)
  %27 = tail call i64 @anyb_size(i32 noundef %26)
  %.not99 = icmp eq i64 %27, 0
  br i1 %.not99, label %28, label %29

28:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 158, ptr noundef nonnull @__PRETTY_FUNCTION__.stio_write_chunk_vector) #6
  unreachable

29:                                               ; preds = %25
  %30 = icmp eq i32 %26, %22
  br i1 %30, label %31, label %83

31:                                               ; preds = %29
  %32 = icmp eq i64 %27, 1
  br i1 %32, label %33, label %42

33:                                               ; preds = %31
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load i32, ptr %16, align 4, !tbaa !12
  %37 = zext i32 %36 to i64
  %38 = load ptr, ptr %12, align 8, !tbaa !11
  %39 = tail call i64 @stream_write(ptr noundef %35, i64 noundef %37, ptr noundef %38)
  %40 = load i32, ptr %16, align 4, !tbaa !12
  %41 = zext i32 %40 to i64
  %.not105 = icmp eq i64 %39, %41
  br i1 %.not105, label %.loopexit, label %.thread109

42:                                               ; preds = %31
  br i1 %3, label %54, label %43

43:                                               ; preds = %42
  %44 = getelementptr inbounds i8, ptr %0, i64 8
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = load i32, ptr %16, align 4, !tbaa !12
  %47 = zext i32 %46 to i64
  %48 = mul i64 %23, %47
  %49 = load ptr, ptr %12, align 8, !tbaa !11
  %50 = tail call i64 @stream_write(ptr noundef %45, i64 noundef %48, ptr noundef %49)
  %51 = load i32, ptr %16, align 4, !tbaa !12
  %52 = zext i32 %51 to i64
  %53 = mul i64 %23, %52
  %.not102 = icmp eq i64 %50, %53
  br i1 %.not102, label %.loopexit, label %.thread109

54:                                               ; preds = %42
  %55 = load ptr, ptr %12, align 8, !tbaa !11
  %56 = load i32, ptr %16, align 4, !tbaa !12
  %57 = zext i32 %56 to i64
  %58 = mul i64 %23, %57
  %59 = getelementptr inbounds i8, ptr %55, i64 %58
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  %61 = ptrtoint ptr %59 to i64
  %62 = trunc i64 %23 to i32
  %.not104131 = icmp sgt i64 %58, 0
  br i1 %.not104131, label %.lr.ph134, label %.loopexit

.lr.ph134:                                        ; preds = %54, %._crit_edge119
  %.090132 = phi ptr [ %.191.lcssa, %._crit_edge119 ], [ %55, %54 ]
  %63 = load ptr, ptr %60, align 8, !tbaa !13
  %64 = ptrtoint ptr %.090132 to i64
  %65 = sub i64 %61, %64
  %66 = mul i64 %65, %23
  %67 = call i32 @stream_write_prep(ptr noundef %63, i64 noundef %66) #7
  %68 = sext i32 %67 to i64
  %.not103 = icmp ugt i64 %23, %68
  br i1 %.not103, label %.thread109, label %69

69:                                               ; preds = %.lr.ph134
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %70 = load ptr, ptr %60, align 8, !tbaa !13
  %71 = call ptr @stream_buffer_get_(ptr noundef %70, ptr noundef nonnull %5)
  %72 = getelementptr inbounds i8, ptr %71, i64 %23
  %73 = load ptr, ptr %5, align 8, !tbaa !16
  %74 = icmp ult ptr %72, %73
  br i1 %74, label %.lr.ph118, label %._crit_edge119

.lr.ph118:                                        ; preds = %69, %.lr.ph118
  %75 = phi ptr [ %77, %.lr.ph118 ], [ %72, %69 ]
  %.083116 = phi ptr [ %75, %.lr.ph118 ], [ %71, %69 ]
  %.191115 = phi ptr [ %76, %.lr.ph118 ], [ %.090132, %69 ]
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.083116, ptr align 1 %.191115, i64 %23, i1 false)
  call void @byteswap(i32 noundef %62, ptr noundef %.083116)
  %76 = getelementptr inbounds i8, ptr %.191115, i64 %23
  %77 = getelementptr inbounds i8, ptr %75, i64 %23
  %78 = load ptr, ptr %5, align 8, !tbaa !16
  %79 = icmp ult ptr %77, %78
  %80 = icmp ult ptr %76, %59
  %81 = select i1 %79, i1 %80, i1 false
  br i1 %81, label %.lr.ph118, label %._crit_edge119, !llvm.loop !17

._crit_edge119:                                   ; preds = %.lr.ph118, %69
  %.191.lcssa = phi ptr [ %.090132, %69 ], [ %76, %.lr.ph118 ]
  %.083.lcssa = phi ptr [ %71, %69 ], [ %75, %.lr.ph118 ]
  %82 = load ptr, ptr %60, align 8, !tbaa !13
  call void @stream_commit(ptr noundef %82, ptr noundef %.083.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  %.not104 = icmp ult ptr %.191.lcssa, %59
  br i1 %.not104, label %.lr.ph134, label %.loopexit

83:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %84 = load i32, ptr %16, align 4, !tbaa !12
  %.not101112.not = icmp eq i32 %84, 0
  br i1 %.not101112.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %83
  %85 = load ptr, ptr %12, align 8, !tbaa !11
  %86 = trunc i64 %27 to i32
  %87 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %3, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %91
  %.081114.us = phi i32 [ %93, %91 ], [ 0, %.lr.ph ]
  %.082113.us = phi ptr [ %92, %91 ], [ %85, %.lr.ph ]
  %88 = call zeroext i1 @anyp_cast(i32 noundef %26, ptr noundef nonnull %6, i32 noundef %22, ptr noundef %.082113.us) #7
  call void @byteswap(i32 noundef %86, ptr noundef nonnull %6)
  %89 = load ptr, ptr %87, align 8, !tbaa !13
  %90 = call i64 @stream_write(ptr noundef %89, i64 noundef %27, ptr noundef nonnull %6)
  %.not100.us = icmp eq i64 %90, %27
  br i1 %.not100.us, label %91, label %.thread107

91:                                               ; preds = %.lr.ph.split.us
  %92 = getelementptr inbounds i8, ptr %.082113.us, i64 %23
  %93 = add nuw i32 %.081114.us, 1
  %exitcond124.not = icmp eq i32 %93, %84
  br i1 %exitcond124.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !19

.lr.ph.split:                                     ; preds = %.lr.ph, %97
  %.081114 = phi i32 [ %99, %97 ], [ 0, %.lr.ph ]
  %.082113 = phi ptr [ %98, %97 ], [ %85, %.lr.ph ]
  %94 = call zeroext i1 @anyp_cast(i32 noundef %26, ptr noundef nonnull %6, i32 noundef %22, ptr noundef %.082113) #7
  %95 = load ptr, ptr %87, align 8, !tbaa !13
  %96 = call i64 @stream_write(ptr noundef %95, i64 noundef %27, ptr noundef nonnull %6)
  %.not100 = icmp eq i64 %96, %27
  br i1 %.not100, label %97, label %.thread107

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

97:                                               ; preds = %.lr.ph.split
  %98 = getelementptr inbounds i8, ptr %.082113, i64 %23
  %99 = add nuw i32 %.081114, 1
  %exitcond.not = icmp eq i32 %99, %84
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !19

._crit_edge:                                      ; preds = %97, %91, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %.loopexit

.thread109:                                       ; preds = %.lr.ph134, %33, %43, %.thread107
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge119, %54, %.thread109, %._crit_edge, %33, %43, %19
  %.8 = phi i32 [ -522, %19 ], [ -516, %.thread109 ], [ 2, %._crit_edge ], [ 2, %33 ], [ 2, %43 ], [ 2, %54 ], [ 2, %._crit_edge119 ]
  ret i32 %.8
}

; 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 i64 @stream_write(ptr noalias noundef, i64 noundef, ptr noalias noundef) local_unnamed_addr #2

declare i32 @stream_write_prep(ptr noundef, i64 noundef) local_unnamed_addr #5

; 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 #5

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 = { 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 #5 = { "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 = !{!8, !8, i64 0}
!12 = !{!6, !10, i64 4}
!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