; LLVM IR from itchio/go-brotli :: 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, ptr, i64, %struct.RingBuffer, i64, ptr, i64, i64, i64, i64, i64, [16 x i32], [4 x i32], i8, i8, i8, i8, i64, ptr, [1024 x i32], ptr, i64, [128 x i8], [128 x i16], [512 x i8], i64, ptr, ptr, ptr, i64, i64, %union.anon, i32, i32, i32, i32 }
%struct.BrotliEncoderParams = type { i32, i32, i32, i32, i64, i32, %struct.BrotliHasherParams }
%struct.BrotliHasherParams = type { i32, i32, i32, i32, i32 }
%struct.MemoryManager = type { ptr, ptr, ptr }
%struct.RingBuffer = type { i32, i32, i32, i32, i32, i32, ptr, ptr }
%union.anon = 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 %209

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 !18
  %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 %209

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 %209

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 %209

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 !19
  %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 !19
  %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 %209

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 !19
  %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 !18
  %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 %209

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 !20
  %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 !20
  %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 %209

99:                                               ; preds = %84
  br label %100

100:                                              ; preds = %205, %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 !18
  %103 = load i64, ptr %16, align 8, !tbaa !18
  %104 = icmp ne i64 %103, 0
  br i1 %104, label %105, label %126

105:                                              ; preds = %100
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = load i64, ptr %106, align 8, !tbaa !18
  %108 = icmp ne i64 %107, 0
  br i1 %108, label %109, label %126

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %110 = load i64, ptr %16, align 8, !tbaa !18
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = load i64, ptr %111, align 8, !tbaa !18
  %113 = call i64 @brotli_min_size_t(i64 noundef %110, i64 noundef %112)
  store i64 %113, ptr %17, align 8, !tbaa !18
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  %115 = load i64, ptr %17, align 8, !tbaa !18
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = load ptr, ptr %116, align 8, !tbaa !5
  call void @CopyInputToRingBuffer(ptr noundef %114, i64 noundef %115, ptr noundef %117)
  %118 = load i64, ptr %17, align 8, !tbaa !18
  %119 = load ptr, ptr %12, align 8, !tbaa !5
  %120 = load ptr, ptr %119, align 8, !tbaa !5
  %121 = getelementptr inbounds i8, ptr %120, i64 %118
  store ptr %121, ptr %119, align 8, !tbaa !5
  %122 = load i64, ptr %17, align 8, !tbaa !18
  %123 = load ptr, ptr %11, align 8, !tbaa !5
  %124 = load i64, ptr %123, align 8, !tbaa !18
  %125 = sub i64 %124, %122
  store i64 %125, ptr %123, align 8, !tbaa !18
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %205

126:                                              ; preds = %105, %100
  %127 = load ptr, ptr %9, align 8, !tbaa !5
  %128 = load ptr, ptr %13, align 8, !tbaa !5
  %129 = load ptr, ptr %14, align 8, !tbaa !5
  %130 = load ptr, ptr %15, align 8, !tbaa !5
  %131 = call i32 @InjectFlushOrPushOutput(ptr noundef %127, ptr noundef %128, ptr noundef %129, ptr noundef %130)
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %126
  store i32 2, ptr %18, align 4
  br label %205

134:                                              ; preds = %126
  %135 = load ptr, ptr %9, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %135, i32 0, i32 30
  %137 = load i64, ptr %136, align 8, !tbaa !21
  %138 = icmp eq i64 %137, 0
  br i1 %138, label %139, label %204

139:                                              ; preds = %134
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %140, i32 0, i32 34
  %142 = load i32, ptr %141, align 4, !tbaa !19
  %143 = icmp eq i32 %142, 0
  br i1 %143, label %144, label %204

144:                                              ; preds = %139
  %145 = load i64, ptr %16, align 8, !tbaa !18
  %146 = icmp eq i64 %145, 0
  br i1 %146, label %150, label %147

147:                                              ; preds = %144
  %148 = load i32, ptr %10, align 4, !tbaa !9
  %149 = icmp ne i32 %148, 0
  br i1 %149, label %150, label %203

150:                                              ; preds = %147, %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %151 = load ptr, ptr %11, align 8, !tbaa !5
  %152 = load i64, ptr %151, align 8, !tbaa !18
  %153 = icmp eq i64 %152, 0
  br i1 %153, label %154, label %157

154:                                              ; preds = %150
  %155 = load i32, ptr %10, align 4, !tbaa !9
  %156 = icmp eq i32 %155, 2
  br label %157

157:                                              ; preds = %154, %150
  %158 = phi i1 [ false, %150 ], [ %156, %154 ]
  %159 = xor i1 %158, true
  %160 = xor i1 %159, true
  %161 = zext i1 %160 to i64
  %162 = select i1 %160, i32 1, i32 0
  store i32 %162, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %163 = load ptr, ptr %11, align 8, !tbaa !5
  %164 = load i64, ptr %163, align 8, !tbaa !18
  %165 = icmp eq i64 %164, 0
  br i1 %165, label %166, label %169

166:                                              ; preds = %157
  %167 = load i32, ptr %10, align 4, !tbaa !9
  %168 = icmp eq i32 %167, 1
  br label %169

169:                                              ; preds = %166, %157
  %170 = phi i1 [ false, %157 ], [ %168, %166 ]
  %171 = xor i1 %170, true
  %172 = xor i1 %171, true
  %173 = zext i1 %172 to i64
  %174 = select i1 %172, i32 1, i32 0
  store i32 %174, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %175 = load ptr, ptr %9, align 8, !tbaa !5
  %176 = load ptr, ptr %11, align 8, !tbaa !5
  %177 = load i64, ptr %176, align 8, !tbaa !18
  call void @UpdateSizeHint(ptr noundef %175, i64 noundef %177)
  %178 = load ptr, ptr %9, align 8, !tbaa !5
  %179 = load i32, ptr %19, align 4, !tbaa !9
  %180 = load i32, ptr %20, align 4, !tbaa !9
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %181, i32 0, i32 30
  %183 = load ptr, ptr %9, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %183, i32 0, i32 29
  %185 = call i32 @EncodeData(ptr noundef %178, i32 noundef %179, i32 noundef %180, ptr noundef %182, ptr noundef %184)
  store i32 %185, ptr %21, align 4, !tbaa !9
  %186 = load i32, ptr %21, align 4, !tbaa !9
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %189, label %188

188:                                              ; preds = %169
  store i32 0, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %202

189:                                              ; preds = %169
  %190 = load i32, ptr %20, align 4, !tbaa !9
  %191 = icmp ne i32 %190, 0
  br i1 %191, label %192, label %195

192:                                              ; preds = %189
  %193 = load ptr, ptr %9, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %193, i32 0, i32 34
  store i32 1, ptr %194, align 4, !tbaa !19
  br label %195

195:                                              ; preds = %192, %189
  %196 = load i32, ptr %19, align 4, !tbaa !9
  %197 = icmp ne i32 %196, 0
  br i1 %197, label %198, label %201

198:                                              ; preds = %195
  %199 = load ptr, ptr %9, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.BrotliEncoderStateStruct, ptr %199, i32 0, i32 34
  store i32 2, ptr %200, align 4, !tbaa !19
  br label %201

201:                                              ; preds = %198, %195
  store i32 2, ptr %18, align 4
  br label %202

202:                                              ; preds = %201, %188
  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 %205

203:                                              ; preds = %147
  br label %204

204:                                              ; preds = %203, %139, %134
  store i32 3, ptr %18, align 4
  br label %205

205:                                              ; preds = %204, %202, %133, %109
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %206 = load i32, ptr %18, align 4
  switch i32 %206, label %211 [
    i32 2, label %100
    i32 1, label %209
    i32 3, label %207
  ]

207:                                              ; preds = %205
  %208 = load ptr, ptr %9, align 8, !tbaa !5
  call void @CheckFlushComplete(ptr noundef %208)
  store i32 1, ptr %8, align 4
  br label %209

209:                                              ; preds = %207, %205, %90, %77, %67, %48, %43, %39, %25
  %210 = load i32, ptr %8, align 4
  ret i32 %210

211:                                              ; preds = %205
  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 i32 @EncodeData(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @CheckFlushComplete(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 5360}
!12 = !{!"BrotliEncoderStateStruct", !13, i64 0, !16, i64 48, !6, i64 72, !14, i64 80, !17, i64 88, !14, i64 128, !6, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !14, i64 168, !14, i64 176, !7, i64 184, !7, i64 248, !7, i64 264, !7, i64 265, !7, i64 266, !7, i64 267, !14, i64 272, !6, i64 280, !7, i64 288, !6, i64 4384, !14, i64 4392, !7, i64 4400, !7, i64 4528, !7, i64 4784, !14, i64 5296, !6, i64 5304, !6, i64 5312, !6, i64 5320, !14, i64 5328, !14, i64 5336, !7, i64 5344, !10, i64 5360, !10, i64 5364, !10, i64 5368, !10, i64 5372}
!13 = !{!"BrotliEncoderParams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16, !10, i64 24, !15, i64 28}
!14 = !{!"long", !7, i64 0}
!15 = !{!"BrotliHasherParams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!16 = !{!"MemoryManager", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"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}
!18 = !{!14, !14, i64 0}
!19 = !{!12, !10, i64 5364}
!20 = !{!12, !10, i64 4}
!21 = !{!12, !14, i64 5328}


; 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 %.thread84, label %9

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

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

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 %.thread84

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

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

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

.preheader:                                       ; preds = %24
  %27 = getelementptr inbounds i8, ptr %0, i64 5328
  %28 = icmp ne i32 %1, 0
  %29 = icmp eq i32 %1, 2
  %30 = icmp eq i32 %1, 1
  %31 = getelementptr inbounds i8, ptr %0, i64 5320
  br label %34

32:                                               ; preds = %24
  %33 = 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 %.thread84

34:                                               ; preds = %.backedge, %.preheader
  %35 = tail call i64 @RemainingInputBlockSize(ptr noundef %0)
  %.not78 = icmp eq i64 %35, 0
  br i1 %.not78, label %45, label %36

36:                                               ; preds = %34
  %37 = load i64, ptr %2, align 8, !tbaa !16
  %.not79 = icmp eq i64 %37, 0
  br i1 %.not79, label %45, label %38

38:                                               ; preds = %36
  %39 = tail call i64 @brotli_min_size_t(i64 noundef %35, i64 noundef %37)
  %40 = load ptr, ptr %3, align 8, !tbaa !19
  tail call void @CopyInputToRingBuffer(ptr noundef %0, i64 noundef %39, ptr noundef %40)
  %41 = load ptr, ptr %3, align 8, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %41, i64 %39
  store ptr %42, ptr %3, align 8, !tbaa !19
  %43 = load i64, ptr %2, align 8, !tbaa !16
  %44 = sub i64 %43, %39
  store i64 %44, ptr %2, align 8, !tbaa !16
  br label %.backedge

45:                                               ; preds = %36, %34
  %46 = tail call i32 @InjectFlushOrPushOutput(ptr noundef %0, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %.not80 = icmp eq i32 %46, 0
  br i1 %.not80, label %47, label %.backedge

47:                                               ; preds = %45
  %48 = load i64, ptr %27, align 8, !tbaa !20
  %49 = icmp eq i64 %48, 0
  br i1 %49, label %50, label %64

50:                                               ; preds = %47
  %51 = load i32, ptr %20, align 4, !tbaa !17
  %52 = icmp eq i32 %51, 0
  %or.cond = or i1 %28, %.not78
  %or.cond86 = and i1 %or.cond, %52
  br i1 %or.cond86, label %53, label %64

53:                                               ; preds = %50
  %54 = load i64, ptr %2, align 8, !tbaa !16
  %55 = icmp eq i64 %54, 0
  %56 = and i1 %29, %55
  %57 = zext i1 %56 to i32
  %58 = and i1 %30, %55
  %59 = zext i1 %58 to i32
  tail call void @UpdateSizeHint(ptr noundef nonnull %0, i64 noundef %54)
  %60 = tail call i32 @EncodeData(ptr noundef nonnull %0, i32 noundef %57, i32 noundef %59, ptr noundef nonnull %27, ptr noundef nonnull %31)
  %.not81 = icmp eq i32 %60, 0
  br i1 %.not81, label %.thread84, label %61

61:                                               ; preds = %53
  %62 = or i1 %58, %56
  br i1 %62, label %63, label %.backedge

.backedge:                                        ; preds = %61, %63, %45, %38
  br label %34

63:                                               ; preds = %61
  %spec.select = select i1 %56, i32 2, i32 1
  store i32 %spec.select, ptr %20, align 4, !tbaa !17
  br label %.backedge

64:                                               ; preds = %50, %47
  tail call void @CheckFlushComplete(ptr noundef nonnull %0)
  br label %.thread84

.thread84:                                        ; preds = %53, %22, %19, %19, %12, %7, %64, %32, %17
  %.3 = phi i32 [ %18, %17 ], [ %33, %32 ], [ 1, %64 ], [ 0, %7 ], [ 0, %12 ], [ 0, %19 ], [ 0, %19 ], [ 0, %22 ], [ 0, %53 ]
  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 i32 @EncodeData(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

!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 5360}
!6 = !{!"BrotliEncoderStateStruct", !7, i64 0, !13, i64 48, !14, i64 72, !11, i64 80, !15, i64 88, !11, i64 128, !14, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !9, i64 184, !9, i64 248, !9, i64 264, !9, i64 265, !9, i64 266, !9, i64 267, !11, i64 272, !14, i64 280, !9, i64 288, !14, i64 4384, !11, i64 4392, !9, i64 4400, !9, i64 4528, !9, i64 4784, !11, i64 5296, !14, i64 5304, !14, i64 5312, !14, i64 5320, !11, i64 5328, !11, i64 5336, !9, i64 5344, !8, i64 5360, !8, i64 5364, !8, i64 5368, !8, i64 5372}
!7 = !{!"BrotliEncoderParams", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !8, i64 24, !12, i64 28}
!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, !8, i64 16}
!13 = !{!"MemoryManager", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"RingBuffer", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !14, i64 24, !14, i64 32}
!16 = !{!11, !11, i64 0}
!17 = !{!6, !8, i64 5364}
!18 = !{!6, !8, i64 4}
!19 = !{!14, !14, i64 0}
!20 = !{!6, !11, i64 5328}


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