; LLVM IR from DanEngelbrecht/longtail :: lib/brotli/ext/enc (encode)

; 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.BrotliEncoderStateStruct = type { %struct.BrotliEncoderParams, %struct.MemoryManager, i64, %struct.RingBuffer, i64, ptr, i64, i64, i64, i64, i64, [16 x i32], [4 x i32], i16, i8, i8, i8, i8, i64, ptr, %struct.Hasher, [1024 x i32], ptr, i64, ptr, ptr, ptr, ptr, i64, ptr, i64, i64, %union.anon.0, i32, i32, i32, i32 }
%struct.BrotliEncoderParams = type { i32, i32, i32, i32, i64, i64, i32, i32, %struct.BrotliHasherParams, %struct.BrotliDistanceParams, %struct.SharedEncoderDictionary }
%struct.BrotliHasherParams = type { i32, i32, i32, i32 }
%struct.BrotliDistanceParams = type { i32, i32, i32, i32, i64 }
%struct.SharedEncoderDictionary = type { i32, %struct.CompoundDictionary, %struct.ContextualEncoderDictionary, i32 }
%struct.CompoundDictionary = type { i64, i64, [16 x ptr], [16 x ptr], [16 x i64], i64, [16 x ptr] }
%struct.ContextualEncoderDictionary = type { i32, i8, [64 x i8], [64 x ptr], i64, %struct.BrotliEncoderDictionary, ptr }
%struct.BrotliEncoderDictionary = type { ptr, i32, i32, i64, ptr, ptr, ptr, ptr, %struct.BrotliTrie, i32, ptr, ptr, ptr, i64, ptr, i64, ptr, ptr }
%struct.BrotliTrie = type { ptr, i64, i64, %struct.BrotliTrieNode }
%struct.BrotliTrieNode = type { i8, i8, i8, i32, i32 }
%struct.MemoryManager = type { ptr, ptr, ptr }
%struct.RingBuffer = type { i32, i32, i32, i32, i32, i32, ptr, ptr }
%struct.Hasher = type { %struct.HasherCommon, %union.anon }
%struct.HasherCommon = type { [4 x ptr], i32, i64, i64, %struct.BrotliHasherParams, i32 }
%union.anon = type { %struct.H42 }
%struct.H42 = type { [512 x i16], i64, [2 x ptr], ptr }
%union.anon.0 = type { [2 x i64] }

; 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: nounwind uwtable
define dso_local i32 @BrotliEncoderCompressStream(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = call i32 @EnsureInitialized(ptr noundef %22)
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %7
  store i32 0, ptr %8, align 4
  br label %277

26:                                               ; preds = %7
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %27, i32 0, i32 33
  %29 = load i32, ptr %28, align 8, !tbaa !11
  %30 = icmp ne i32 %29, -1
  br i1 %30, label %31, label %45

31:                                               ; preds = %26
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = load i64, ptr %32, align 8, !tbaa !28
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %34, i32 0, i32 33
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = zext i32 %36 to i64
  %38 = icmp ne i64 %33, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store i32 0, ptr %8, align 4
  br label %277

40:                                               ; preds = %31
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 3
  br i1 %42, label %43, label %44

43:                                               ; preds = %40
  store i32 0, ptr %8, align 4
  br label %277

44:                                               ; preds = %40
  br label %45

45:                                               ; preds = %44, %26
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 3
  br i1 %47, label %48, label %57

48:                                               ; preds = %45
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  call void @UpdateSizeHint(ptr noundef %49, i64 noundef 0)
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = load ptr, ptr %15, align 8, !tbaa !5
  %56 = call i32 @ProcessMetadata(ptr noundef %50, ptr noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %54, ptr noundef %55)
  store i32 %56, ptr %8, align 4
  br label %277

57:                                               ; preds = %45
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %58, i32 0, i32 34
  %60 = load i32, ptr %59, align 4, !tbaa !29
  %61 = icmp eq i32 %60, 3
  br i1 %61, label %67, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %63, i32 0, i32 34
  %65 = load i32, ptr %64, align 4, !tbaa !29
  %66 = icmp eq i32 %65, 4
  br i1 %66, label %67, label %68

67:                                               ; preds = %62, %57
  store i32 0, ptr %8, align 4
  br label %277

68:                                               ; preds = %62
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %69, i32 0, i32 34
  %71 = load i32, ptr %70, align 4, !tbaa !29
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %78

73:                                               ; preds = %68
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = load i64, ptr %74, align 8, !tbaa !28
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %73
  store i32 0, ptr %8, align 4
  br label %277

78:                                               ; preds = %73, %68
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !30
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %90, label %84

84:                                               ; preds = %78
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %86, i32 0, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !30
  %89 = icmp eq i32 %88, 1
  br i1 %89, label %90, label %99

90:                                               ; preds = %84, %78
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = load ptr, ptr %13, align 8, !tbaa !5
  %96 = load ptr, ptr %14, align 8, !tbaa !5
  %97 = load ptr, ptr %15, align 8, !tbaa !5
  %98 = call i32 @BrotliEncoderCompressStreamFast(ptr noundef %91, i32 noundef %92, ptr noundef %93, ptr noundef %94, ptr noundef %95, ptr noundef %96, ptr noundef %97)
  store i32 %98, ptr %8, align 4
  br label %277

99:                                               ; preds = %84
  br label %100

100:                                              ; preds = %273, %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = call i64 @RemainingInputBlockSize(ptr noundef %101)
  store i64 %102, ptr %16, align 8, !tbaa !28
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %103, i32 0, i32 15
  %105 = load i8, ptr %104, align 1, !tbaa !31
  %106 = sext i8 %105 to i32
  %107 = icmp sge i32 %106, 0
  br i1 %107, label %108, label %120

108:                                              ; preds = %100
  %109 = load i64, ptr %16, align 8, !tbaa !28
  %110 = load ptr, ptr %9, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %110, i32 0, i32 15
  %112 = load i8, ptr %111, align 1, !tbaa !31
  %113 = sext i8 %112 to i64
  %114 = icmp ugt i64 %109, %113
  br i1 %114, label %115, label %120

115:                                              ; preds = %108
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %116, i32 0, i32 15
  %118 = load i8, ptr %117, align 1, !tbaa !31
  %119 = sext i8 %118 to i64
  store i64 %119, ptr %16, align 8, !tbaa !28
  br label %120

120:                                              ; preds = %115, %108, %100
  %121 = load i64, ptr %16, align 8, !tbaa !28
  %122 = icmp ne i64 %121, 0
  br i1 %122, label %123, label %166

123:                                              ; preds = %120
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = load i64, ptr %124, align 8, !tbaa !28
  %126 = icmp ne i64 %125, 0
  br i1 %126, label %127, label %166

127:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %128 = load i64, ptr %16, align 8, !tbaa !28
  %129 = load ptr, ptr %11, align 8, !tbaa !5
  %130 = load i64, ptr %129, align 8, !tbaa !28
  %131 = call i64 @brotli_min_size_t(i64 noundef %128, i64 noundef %130)
  store i64 %131, ptr %17, align 8, !tbaa !28
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = load i64, ptr %17, align 8, !tbaa !28
  %134 = load ptr, ptr %12, align 8, !tbaa !5
  %135 = load ptr, ptr %134, align 8, !tbaa !5
  call void @CopyInputToRingBuffer(ptr noundef %132, i64 noundef %133, ptr noundef %135)
  %136 = load i64, ptr %17, align 8, !tbaa !28
  %137 = load ptr, ptr %12, align 8, !tbaa !5
  %138 = load ptr, ptr %137, align 8, !tbaa !5
  %139 = getelementptr inbounds i8, ptr %138, i64 %136
  store ptr %139, ptr %137, align 8, !tbaa !5
  %140 = load i64, ptr %17, align 8, !tbaa !28
  %141 = load ptr, ptr %11, align 8, !tbaa !5
  %142 = load i64, ptr %141, align 8, !tbaa !28
  %143 = sub i64 %142, %140
  store i64 %143, ptr %141, align 8, !tbaa !28
  %144 = load i64, ptr %17, align 8, !tbaa !28
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %145, i32 0, i32 28
  %147 = load i64, ptr %146, align 8, !tbaa !32
  %148 = add i64 %147, %144
  store i64 %148, ptr %146, align 8, !tbaa !32
  %149 = load ptr, ptr %9, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %149, i32 0, i32 15
  %151 = load i8, ptr %150, align 1, !tbaa !31
  %152 = sext i8 %151 to i32
  %153 = icmp sgt i32 %152, 0
  br i1 %153, label %154, label %165

154:                                              ; preds = %127
  %155 = load ptr, ptr %9, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %155, i32 0, i32 15
  %157 = load i8, ptr %156, align 1, !tbaa !31
  %158 = sext i8 %157 to i32
  %159 = load i64, ptr %17, align 8, !tbaa !28
  %160 = trunc i64 %159 to i32
  %161 = sub nsw i32 %158, %160
  %162 = trunc i32 %161 to i8
  %163 = load ptr, ptr %9, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %163, i32 0, i32 15
  store i8 %162, ptr %164, align 1, !tbaa !31
  br label %165

165:                                              ; preds = %154, %127
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %273

166:                                              ; preds = %123, %120
  %167 = load ptr, ptr %9, align 8, !tbaa !5
  %168 = load ptr, ptr %13, align 8, !tbaa !5
  %169 = load ptr, ptr %14, align 8, !tbaa !5
  %170 = load ptr, ptr %15, align 8, !tbaa !5
  %171 = call i32 @InjectFlushOrPushOutput(ptr noundef %167, ptr noundef %168, ptr noundef %169, ptr noundef %170)
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %190

173:                                              ; preds = %166
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %174, i32 0, i32 15
  %176 = load i8, ptr %175, align 1, !tbaa !31
  %177 = sext i8 %176 to i32
  %178 = icmp eq i32 %177, -1
  br i1 %178, label %179, label %189

179:                                              ; preds = %173
  %180 = load ptr, ptr %9, align 8, !tbaa !5
  call void @CheckFlushComplete(ptr noundef %180)
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %181, i32 0, i32 34
  %183 = load i32, ptr %182, align 4, !tbaa !29
  %184 = icmp eq i32 %183, 0
  br i1 %184, label %185, label %188

185:                                              ; preds = %179
  %186 = load ptr, ptr %9, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %186, i32 0, i32 15
  store i8 -2, ptr %187, align 1, !tbaa !31
  br label %188

188:                                              ; preds = %185, %179
  br label %189

189:                                              ; preds = %188, %173
  store i32 2, ptr %18, align 4
  br label %273

190:                                              ; preds = %166
  %191 = load ptr, ptr %9, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %191, i32 0, i32 30
  %193 = load i64, ptr %192, align 8, !tbaa !33
  %194 = icmp eq i64 %193, 0
  br i1 %194, label %195, label %272

195:                                              ; preds = %190
  %196 = load ptr, ptr %9, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %196, i32 0, i32 34
  %198 = load i32, ptr %197, align 4, !tbaa !29
  %199 = icmp eq i32 %198, 0
  br i1 %199, label %200, label %272

200:                                              ; preds = %195
  %201 = load i64, ptr %16, align 8, !tbaa !28
  %202 = icmp eq i64 %201, 0
  br i1 %202, label %206, label %203

203:                                              ; preds = %200
  %204 = load i32, ptr %10, align 4, !tbaa !9
  %205 = icmp ne i32 %204, 0
  br i1 %205, label %206, label %271

206:                                              ; preds = %203, %200
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %207 = load ptr, ptr %11, align 8, !tbaa !5
  %208 = load i64, ptr %207, align 8, !tbaa !28
  %209 = icmp eq i64 %208, 0
  br i1 %209, label %210, label %213

210:                                              ; preds = %206
  %211 = load i32, ptr %10, align 4, !tbaa !9
  %212 = icmp eq i32 %211, 2
  br label %213

213:                                              ; preds = %210, %206
  %214 = phi i1 [ false, %206 ], [ %212, %210 ]
  %215 = xor i1 %214, true
  %216 = xor i1 %215, true
  %217 = zext i1 %216 to i64
  %218 = select i1 %216, i32 1, i32 0
  store i32 %218, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %219 = load ptr, ptr %11, align 8, !tbaa !5
  %220 = load i64, ptr %219, align 8, !tbaa !28
  %221 = icmp eq i64 %220, 0
  br i1 %221, label %222, label %225

222:                                              ; preds = %213
  %223 = load i32, ptr %10, align 4, !tbaa !9
  %224 = icmp eq i32 %223, 1
  br label %225

225:                                              ; preds = %222, %213
  %226 = phi i1 [ false, %213 ], [ %224, %222 ]
  %227 = xor i1 %226, true
  %228 = xor i1 %227, true
  %229 = zext i1 %228 to i64
  %230 = select i1 %228, i32 1, i32 0
  store i32 %230, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %231 = load i32, ptr %19, align 4, !tbaa !9
  %232 = icmp ne i32 %231, 0
  br i1 %232, label %242, label %233

233:                                              ; preds = %225
  %234 = load ptr, ptr %9, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %234, i32 0, i32 15
  %236 = load i8, ptr %235, align 1, !tbaa !31
  %237 = sext i8 %236 to i32
  %238 = icmp eq i32 %237, 0
  br i1 %238, label %239, label %242

239:                                              ; preds = %233
  %240 = load ptr, ptr %9, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %240, i32 0, i32 15
  store i8 -1, ptr %241, align 1, !tbaa !31
  store i32 1, ptr %20, align 4, !tbaa !9
  br label %242

242:                                              ; preds = %239, %233, %225
  %243 = load ptr, ptr %9, align 8, !tbaa !5
  %244 = load ptr, ptr %11, align 8, !tbaa !5
  %245 = load i64, ptr %244, align 8, !tbaa !28
  call void @UpdateSizeHint(ptr noundef %243, i64 noundef %245)
  %246 = load ptr, ptr %9, align 8, !tbaa !5
  %247 = load i32, ptr %19, align 4, !tbaa !9
  %248 = load i32, ptr %20, align 4, !tbaa !9
  %249 = load ptr, ptr %9, align 8, !tbaa !5
  %250 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %249, i32 0, i32 30
  %251 = load ptr, ptr %9, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %251, i32 0, i32 29
  %253 = call i32 @EncodeData(ptr noundef %246, i32 noundef %247, i32 noundef %248, ptr noundef %250, ptr noundef %252)
  store i32 %253, ptr %21, align 4, !tbaa !9
  %254 = load i32, ptr %21, align 4, !tbaa !9
  %255 = icmp ne i32 %254, 0
  br i1 %255, label %257, label %256

256:                                              ; preds = %242
  store i32 0, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %270

257:                                              ; preds = %242
  %258 = load i32, ptr %20, align 4, !tbaa !9
  %259 = icmp ne i32 %258, 0
  br i1 %259, label %260, label %263

260:                                              ; preds = %257
  %261 = load ptr, ptr %9, align 8, !tbaa !5
  %262 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %261, i32 0, i32 34
  store i32 1, ptr %262, align 4, !tbaa !29
  br label %263

263:                                              ; preds = %260, %257
  %264 = load i32, ptr %19, align 4, !tbaa !9
  %265 = icmp ne i32 %264, 0
  br i1 %265, label %266, label %269

266:                                              ; preds = %263
  %267 = load ptr, ptr %9, align 8, !tbaa !5
  %268 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %267, i32 0, i32 34
  store i32 2, ptr %268, align 4, !tbaa !29
  br label %269

269:                                              ; preds = %266, %263
  store i32 2, ptr %18, align 4
  br label %270

270:                                              ; preds = %269, %256
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %273

271:                                              ; preds = %203
  br label %272

272:                                              ; preds = %271, %195, %190
  store i32 3, ptr %18, align 4
  br label %273

273:                                              ; preds = %272, %270, %189, %165
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %274 = load i32, ptr %18, align 4
  switch i32 %274, label %279 [
    i32 2, label %100
    i32 1, label %277
    i32 3, label %275
  ]

275:                                              ; preds = %273
  %276 = load ptr, ptr %9, align 8, !tbaa !5
  call void @CheckFlushComplete(ptr noundef %276)
  store i32 1, ptr %8, align 4
  br label %277

277:                                              ; preds = %275, %273, %90, %77, %67, %48, %43, %39, %25
  %278 = load i32, ptr %8, align 4
  ret i32 %278

279:                                              ; preds = %273
  unreachable
}

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

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

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i64 @brotli_min_size_t(i64 noundef, i64 noundef) #2

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { alwaysinline 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 = { 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, !10, i64 6960}
!12 = !{!"BrotliEncoderStateStruct", !13, i64 0, !23, i64 1400, !14, i64 1424, !24, i64 1432, !14, i64 1472, !6, i64 1480, !14, i64 1488, !14, i64 1496, !14, i64 1504, !14, i64 1512, !14, i64 1520, !7, i64 1528, !7, i64 1592, !25, i64 1608, !7, i64 1610, !7, i64 1611, !7, i64 1612, !7, i64 1613, !14, i64 1616, !6, i64 1624, !26, i64 1632, !7, i64 2768, !6, i64 6864, !14, i64 6872, !6, i64 6880, !6, i64 6888, !6, i64 6896, !6, i64 6904, !14, i64 6912, !6, i64 6920, !14, i64 6928, !14, i64 6936, !7, i64 6944, !10, i64 6960, !10, i64 6964, !10, i64 6968, !10, i64 6972}
!13 = !{!"BrotliEncoderParams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16, !14, i64 24, !10, i64 32, !10, i64 36, !15, i64 40, !16, i64 56, !17, i64 80}
!14 = !{!"long", !7, i64 0}
!15 = !{!"BrotliHasherParams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!16 = !{!"BrotliDistanceParams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16}
!17 = !{!"SharedEncoderDictionary", !10, i64 0, !18, i64 8, !19, i64 544, !10, i64 1312}
!18 = !{!"CompoundDictionary", !14, i64 0, !14, i64 8, !7, i64 16, !7, i64 144, !7, i64 272, !14, i64 400, !7, i64 408}
!19 = !{!"ContextualEncoderDictionary", !10, i64 0, !7, i64 4, !7, i64 5, !7, i64 72, !14, i64 584, !20, i64 592, !6, i64 760}
!20 = !{!"BrotliEncoderDictionary", !6, i64 0, !10, i64 8, !10, i64 12, !14, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !21, i64 56, !10, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !14, i64 128, !6, i64 136, !14, i64 144, !6, i64 152, !6, i64 160}
!21 = !{!"BrotliTrie", !6, i64 0, !14, i64 8, !14, i64 16, !22, i64 24}
!22 = !{!"BrotliTrieNode", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 4, !10, i64 8}
!23 = !{!"MemoryManager", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"RingBuffer", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32}
!25 = !{!"short", !7, i64 0}
!26 = !{!"", !27, i64 0, !7, i64 80}
!27 = !{!"", !7, i64 0, !10, i64 32, !14, i64 40, !14, i64 48, !15, i64 56, !10, i64 72}
!28 = !{!14, !14, i64 0}
!29 = !{!12, !10, i64 6964}
!30 = !{!12, !10, i64 4}
!31 = !{!12, !7, i64 1611}
!32 = !{!12, !14, i64 6912}
!33 = !{!12, !14, i64 6928}


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

; Function Attrs: nounwind uwtable
define dso_local i32 @BrotliEncoderCompressStream(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #0 {
  %8 = tail call i32 @EnsureInitialized(ptr noundef %0)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.thread106, label %9

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 6960
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %.not94 = icmp eq i32 %11, -1
  br i1 %.not94, label %15, label %12

12:                                               ; preds = %9
  %13 = load i64, ptr %2, align 8, !tbaa !26
  %14 = zext i32 %11 to i64
  %.not95 = icmp eq i64 %13, %14
  %cond = icmp eq i32 %1, 3
  %or.cond104 = and i1 %cond, %.not95
  br i1 %or.cond104, label %17, label %.thread106

15:                                               ; preds = %9
  %16 = icmp eq i32 %1, 3
  br i1 %16, label %17, label %19

17:                                               ; preds = %12, %15
  tail call void @UpdateSizeHint(ptr noundef nonnull %0, i64 noundef 0)
  %18 = tail call i32 @ProcessMetadata(ptr noundef nonnull %0, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  br label %.thread106

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %0, i64 6964
  %21 = load i32, ptr %20, align 4, !tbaa !27
  switch i32 %21, label %22 [
    i32 3, label %.thread106
    i32 4, label %.thread106
    i32 0, label %24
  ]

22:                                               ; preds = %19
  %23 = load i64, ptr %2, align 8, !tbaa !26
  %.not98 = icmp eq i64 %23, 0
  br i1 %.not98, label %24, label %.thread106

24:                                               ; preds = %19, %22
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !28
  %switch = icmp ult i32 %26, 2
  br i1 %switch, label %34, label %.preheader

.preheader:                                       ; preds = %24
  %27 = getelementptr inbounds i8, ptr %0, i64 1611
  %28 = getelementptr inbounds i8, ptr %0, i64 6912
  %29 = getelementptr inbounds i8, ptr %0, i64 6928
  %30 = icmp ne i32 %1, 0
  %31 = icmp eq i32 %1, 2
  %32 = icmp eq i32 %1, 1
  %33 = getelementptr inbounds i8, ptr %0, i64 6920
  br label %36

34:                                               ; preds = %24
  %35 = tail call i32 @BrotliEncoderCompressStreamFast(ptr noundef nonnull %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  br label %.thread106

36:                                               ; preds = %.backedge, %.preheader
  %37 = tail call i64 @RemainingInputBlockSize(ptr noundef nonnull %0)
  %38 = load i8, ptr %27, align 1, !tbaa !29
  %39 = zext nneg i8 %38 to i64
  %spec.select = tail call i64 @llvm.umin.i64(i64 %37, i64 %39)
  %40 = icmp slt i8 %38, 0
  %.083 = select i1 %40, i64 %37, i64 %spec.select
  %.not99 = icmp eq i64 %.083, 0
  br i1 %.not99, label %57, label %41

41:                                               ; preds = %36
  %42 = load i64, ptr %2, align 8, !tbaa !26
  %.not100 = icmp eq i64 %42, 0
  br i1 %.not100, label %57, label %43

43:                                               ; preds = %41
  %44 = tail call i64 @brotli_min_size_t(i64 noundef %.083, i64 noundef %42)
  %45 = load ptr, ptr %3, align 8, !tbaa !30
  tail call void @CopyInputToRingBuffer(ptr noundef nonnull %0, i64 noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %3, align 8, !tbaa !30
  %47 = getelementptr inbounds i8, ptr %46, i64 %44
  store ptr %47, ptr %3, align 8, !tbaa !30
  %48 = load i64, ptr %2, align 8, !tbaa !26
  %49 = sub i64 %48, %44
  store i64 %49, ptr %2, align 8, !tbaa !26
  %50 = load i64, ptr %28, align 8, !tbaa !31
  %51 = add i64 %50, %44
  store i64 %51, ptr %28, align 8, !tbaa !31
  %52 = load i8, ptr %27, align 1, !tbaa !29
  %53 = icmp sgt i8 %52, 0
  br i1 %53, label %54, label %.backedge

54:                                               ; preds = %43
  %55 = trunc i64 %44 to i8
  %56 = sub i8 %52, %55
  store i8 %56, ptr %27, align 1, !tbaa !29
  br label %.backedge

57:                                               ; preds = %41, %36
  %58 = tail call i32 @InjectFlushOrPushOutput(ptr noundef nonnull %0, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %.not101 = icmp eq i32 %58, 0
  br i1 %.not101, label %66, label %59

59:                                               ; preds = %57
  %60 = load i8, ptr %27, align 1, !tbaa !29
  %61 = icmp eq i8 %60, -1
  br i1 %61, label %62, label %.backedge

62:                                               ; preds = %59
  tail call void @CheckFlushComplete(ptr noundef nonnull %0)
  %63 = load i32, ptr %20, align 4, !tbaa !27
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %.backedge

65:                                               ; preds = %62
  store i8 -2, ptr %27, align 1, !tbaa !29
  br label %.backedge

66:                                               ; preds = %57
  %67 = load i64, ptr %29, align 8, !tbaa !32
  %68 = icmp eq i64 %67, 0
  br i1 %68, label %69, label %87

69:                                               ; preds = %66
  %70 = load i32, ptr %20, align 4, !tbaa !27
  %71 = icmp eq i32 %70, 0
  %or.cond = or i1 %30, %.not99
  %or.cond108 = and i1 %or.cond, %71
  br i1 %or.cond108, label %72, label %87

72:                                               ; preds = %69
  %73 = load i64, ptr %2, align 8, !tbaa !26
  %74 = icmp eq i64 %73, 0
  %75 = and i1 %31, %74
  %76 = zext i1 %75 to i32
  %77 = and i1 %32, %74
  br i1 %75, label %82, label %78

78:                                               ; preds = %72
  %79 = load i8, ptr %27, align 1, !tbaa !29
  %80 = icmp eq i8 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %78
  store i8 -1, ptr %27, align 1, !tbaa !29
  br label %82

82:                                               ; preds = %81, %78, %72
  %.082.shrunk = phi i1 [ %77, %72 ], [ true, %81 ], [ %77, %78 ]
  %.082 = zext i1 %.082.shrunk to i32
  tail call void @UpdateSizeHint(ptr noundef nonnull %0, i64 noundef %73)
  %83 = tail call i32 @EncodeData(ptr noundef nonnull %0, i32 noundef %76, i32 noundef %.082, ptr noundef nonnull %29, ptr noundef nonnull %33)
  %.not102 = icmp eq i32 %83, 0
  br i1 %.not102, label %.thread106, label %84

84:                                               ; preds = %82
  %85 = or i1 %75, %.082.shrunk
  br i1 %85, label %86, label %.backedge

.backedge:                                        ; preds = %84, %86, %59, %65, %62, %43, %54
  br label %36

86:                                               ; preds = %84
  %spec.select103 = select i1 %75, i32 2, i32 1
  store i32 %spec.select103, ptr %20, align 4, !tbaa !27
  br label %.backedge

87:                                               ; preds = %69, %66
  tail call void @CheckFlushComplete(ptr noundef nonnull %0)
  br label %.thread106

.thread106:                                       ; preds = %82, %22, %19, %19, %12, %7, %87, %34, %17
  %.3 = phi i32 [ %18, %17 ], [ %35, %34 ], [ 1, %87 ], [ 0, %7 ], [ 0, %12 ], [ 0, %19 ], [ 0, %19 ], [ 0, %22 ], [ 0, %82 ]
  ret i32 %.3
}

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

; Function Attrs: nounwind uwtable
declare hidden void @UpdateSizeHint(ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i64 @brotli_min_size_t(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @CopyInputToRingBuffer(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden void @CheckFlushComplete(ptr noundef) local_unnamed_addr #0

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { alwaysinline 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 6960}
!6 = !{!"BrotliEncoderStateStruct", !7, i64 0, !21, i64 1400, !11, i64 1424, !22, i64 1432, !11, i64 1472, !18, i64 1480, !11, i64 1488, !11, i64 1496, !11, i64 1504, !11, i64 1512, !11, i64 1520, !9, i64 1528, !9, i64 1592, !23, i64 1608, !9, i64 1610, !9, i64 1611, !9, i64 1612, !9, i64 1613, !11, i64 1616, !18, i64 1624, !24, i64 1632, !9, i64 2768, !18, i64 6864, !11, i64 6872, !18, i64 6880, !18, i64 6888, !18, i64 6896, !18, i64 6904, !11, i64 6912, !18, i64 6920, !11, i64 6928, !11, i64 6936, !9, i64 6944, !8, i64 6960, !8, i64 6964, !8, i64 6968, !8, i64 6972}
!7 = !{!"BrotliEncoderParams", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !11, i64 24, !8, i64 32, !8, i64 36, !12, i64 40, !13, i64 56, !14, i64 80}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"BrotliHasherParams", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!13 = !{!"BrotliDistanceParams", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16}
!14 = !{!"SharedEncoderDictionary", !8, i64 0, !15, i64 8, !16, i64 544, !8, i64 1312}
!15 = !{!"CompoundDictionary", !11, i64 0, !11, i64 8, !9, i64 16, !9, i64 144, !9, i64 272, !11, i64 400, !9, i64 408}
!16 = !{!"ContextualEncoderDictionary", !8, i64 0, !9, i64 4, !9, i64 5, !9, i64 72, !11, i64 584, !17, i64 592, !18, i64 760}
!17 = !{!"BrotliEncoderDictionary", !18, i64 0, !8, i64 8, !8, i64 12, !11, i64 16, !18, i64 24, !18, i64 32, !18, i64 40, !18, i64 48, !19, i64 56, !8, i64 96, !18, i64 104, !18, i64 112, !18, i64 120, !11, i64 128, !18, i64 136, !11, i64 144, !18, i64 152, !18, i64 160}
!18 = !{!"any pointer", !9, i64 0}
!19 = !{!"BrotliTrie", !18, i64 0, !11, i64 8, !11, i64 16, !20, i64 24}
!20 = !{!"BrotliTrieNode", !9, i64 0, !9, i64 1, !9, i64 2, !8, i64 4, !8, i64 8}
!21 = !{!"MemoryManager", !18, i64 0, !18, i64 8, !18, i64 16}
!22 = !{!"RingBuffer", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !18, i64 24, !18, i64 32}
!23 = !{!"short", !9, i64 0}
!24 = !{!"", !25, i64 0, !9, i64 80}
!25 = !{!"", !9, i64 0, !8, i64 32, !11, i64 40, !11, i64 48, !12, i64 56, !8, i64 72}
!26 = !{!11, !11, i64 0}
!27 = !{!6, !8, i64 6964}
!28 = !{!6, !8, i64 4}
!29 = !{!6, !9, i64 1611}
!30 = !{!18, !18, i64 0}
!31 = !{!6, !11, i64 6912}
!32 = !{!6, !11, i64 6928}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass