; 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.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 }

; 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: alwaysinline nounwind uwtable
declare hidden i64 @brotli_min_size_t(i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define hidden i64 @BrotliEncoderEstimatePeakMemoryUsage(i32 noundef %0, i32 noundef %1, i64 noundef %2) #2 {
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca %struct.BrotliEncoderParams, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca [4 x i64], align 16
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i64, align 8
  %26 = alloca i64, align 8
  %27 = alloca i64, align 8
  %28 = alloca i64, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1400, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %29 = load i64, ptr %9, align 8, !tbaa !9
  %30 = mul i64 %29, 8
  store i64 %30, ptr %10, align 8, !tbaa !9
  call void @BrotliEncoderInitParams(ptr noundef %8)
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  store i32 %31, ptr %32, align 4, !tbaa !11
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 2
  store i32 %33, ptr %34, align 8, !tbaa !22
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 5
  store i64 %35, ptr %36, align 8, !tbaa !23
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, 24
  %39 = zext i1 %38 to i32
  %40 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 7
  store i32 %39, ptr %40, align 4, !tbaa !24
  call void @SanitizeParams(ptr noundef %8)
  %41 = call i32 @ComputeLgBlock(ptr noundef %8)
  %42 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 3
  store i32 %41, ptr %42, align 4, !tbaa !25
  %43 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 8
  call void @ChooseHasher(ptr noundef %8, ptr noundef %43)
  %44 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %51, label %47

47:                                               ; preds = %3
  %48 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !11
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %51, label %96

51:                                               ; preds = %47, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 6976, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %52 = load i64, ptr %7, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !22
  %55 = zext i32 %54 to i64
  %56 = shl i64 1, %55
  %57 = call i64 @brotli_min_size_t(i64 noundef %52, i64 noundef %56)
  store i64 %57, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %58 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %59 = load i32, ptr %58, align 4, !tbaa !11
  %60 = call i64 @MaxHashTableSize(i32 noundef %59)
  %61 = load i64, ptr %12, align 8, !tbaa !9
  %62 = call i64 @HashTableSize(i64 noundef %60, i64 noundef %61)
  store i64 %62, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %63 = load i64, ptr %13, align 8, !tbaa !9
  %64 = icmp ult i64 %63, 1024
  br i1 %64, label %65, label %66

65:                                               ; preds = %51
  br label %69

66:                                               ; preds = %51
  %67 = load i64, ptr %13, align 8, !tbaa !9
  %68 = mul i64 4, %67
  br label %69

69:                                               ; preds = %66, %65
  %70 = phi i64 [ 0, %65 ], [ %68, %66 ]
  store i64 %70, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %71 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = icmp eq i32 %72, 1
  br i1 %73, label %74, label %78

74:                                               ; preds = %69
  %75 = load i64, ptr %12, align 8, !tbaa !9
  %76 = call i64 @brotli_min_size_t(i64 noundef %75, i64 noundef 131072)
  %77 = mul i64 5, %76
  br label %79

78:                                               ; preds = %69
  br label %79

79:                                               ; preds = %78, %74
  %80 = phi i64 [ %77, %74 ], [ 0, %78 ]
  store i64 %80, ptr %15, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !11
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %87

84:                                               ; preds = %79
  %85 = load i64, ptr %11, align 8, !tbaa !9
  %86 = add i64 %85, 8144
  store i64 %86, ptr %11, align 8, !tbaa !9
  br label %90

87:                                               ; preds = %79
  %88 = load i64, ptr %11, align 8, !tbaa !9
  %89 = add i64 %88, 7624
  store i64 %89, ptr %11, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %87, %84
  %91 = load i64, ptr %14, align 8, !tbaa !9
  %92 = load i64, ptr %15, align 8, !tbaa !9
  %93 = add i64 %91, %92
  %94 = load i64, ptr %11, align 8, !tbaa !9
  %95 = add i64 %93, %94
  store i64 %95, ptr %4, align 8
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %193

96:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %97 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 3
  %98 = load i32, ptr %97, align 4, !tbaa !25
  %99 = zext i32 %98 to i64
  %100 = shl i64 1, %99
  store i64 %100, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %101 = call i32 @ComputeRbBits(ptr noundef %8)
  store i32 %101, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %102 = load i64, ptr %7, align 8, !tbaa !9
  %103 = load i64, ptr %17, align 8, !tbaa !9
  %104 = icmp ult i64 %102, %103
  br i1 %104, label %105, label %107

105:                                              ; preds = %96
  %106 = load i64, ptr %7, align 8, !tbaa !9
  br label %113

107:                                              ; preds = %96
  %108 = load i32, ptr %18, align 4, !tbaa !5
  %109 = shl i32 1, %108
  %110 = zext i32 %109 to i64
  %111 = load i64, ptr %17, align 8, !tbaa !9
  %112 = add i64 %110, %111
  br label %113

113:                                              ; preds = %107, %105
  %114 = phi i64 [ %106, %105 ], [ %112, %107 ]
  store i64 %114, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #4
  call void @llvm.memset.p0.i64(ptr align 16 %20, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %115 = load i64, ptr %7, align 8, !tbaa !9
  %116 = call i64 @MaxMetablockSize(ptr noundef %8)
  %117 = call i64 @brotli_min_size_t(i64 noundef %115, i64 noundef %116)
  store i64 %117, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %118 = load i64, ptr %7, align 8, !tbaa !9
  %119 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 3
  %120 = load i32, ptr %119, align 4, !tbaa !25
  %121 = zext i32 %120 to i64
  %122 = shl i64 1, %121
  %123 = call i64 @brotli_min_size_t(i64 noundef %118, i64 noundef %122)
  store i64 %123, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %124 = load i64, ptr %21, align 8, !tbaa !9
  %125 = mul i64 %124, 2
  %126 = load i64, ptr %22, align 8, !tbaa !9
  %127 = mul i64 %126, 6
  %128 = add i64 %125, %127
  store i64 %128, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %129 = load i64, ptr %21, align 8, !tbaa !9
  %130 = mul i64 %129, 2
  %131 = add i64 %130, 503
  store i64 %131, ptr %24, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  store i64 0, ptr %25, align 8, !tbaa !9
  %132 = load i64, ptr %7, align 8, !tbaa !9
  %133 = getelementptr inbounds [4 x i64], ptr %20, i64 0, i64 0
  call void @HasherSize(ptr noundef %8, i32 noundef 1, i64 noundef %132, ptr noundef %133)
  %134 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %135 = load i32, ptr %134, align 4, !tbaa !11
  %136 = icmp slt i32 %135, 4
  br i1 %136, label %137, label %143

137:                                              ; preds = %113
  %138 = load i64, ptr %23, align 8, !tbaa !9
  %139 = load i64, ptr %22, align 8, !tbaa !9
  %140 = mul i64 %139, 12
  %141 = add i64 196592, %140
  %142 = call i64 @brotli_min_size_t(i64 noundef %138, i64 noundef %141)
  store i64 %142, ptr %23, align 8, !tbaa !9
  br label %143

143:                                              ; preds = %137, %113
  %144 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %145 = load i32, ptr %144, align 4, !tbaa !11
  %146 = icmp sge i32 %145, 10
  br i1 %146, label %147, label %148

147:                                              ; preds = %143
  store i64 209715200, ptr %25, align 8, !tbaa !9
  br label %171

148:                                              ; preds = %143
  %149 = getelementptr inbounds %struct.BrotliEncoderParams, ptr %8, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !11
  %151 = icmp sge i32 %150, 4
  br i1 %151, label %152, label %170

152:                                              ; preds = %148
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %153 = load i64, ptr %21, align 8, !tbaa !9
  %154 = udiv i64 %153, 6144
  %155 = call i64 @brotli_min_size_t(i64 noundef %154, i64 noundef 256)
  store i64 %155, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #4
  %156 = load i64, ptr %21, align 8, !tbaa !9
  %157 = udiv i64 %156, 6144
  %158 = call i64 @brotli_min_size_t(i64 noundef %157, i64 noundef 256)
  store i64 %158, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  %159 = load i64, ptr %21, align 8, !tbaa !9
  %160 = udiv i64 %159, 6144
  %161 = call i64 @brotli_min_size_t(i64 noundef %160, i64 noundef 256)
  store i64 %161, ptr %28, align 8, !tbaa !9
  %162 = load i64, ptr %26, align 8, !tbaa !9
  %163 = mul i64 %162, 1040
  %164 = load i64, ptr %27, align 8, !tbaa !9
  %165 = mul i64 %164, 2832
  %166 = add i64 %163, %165
  %167 = load i64, ptr %28, align 8, !tbaa !9
  %168 = mul i64 %167, 2192
  %169 = add i64 %166, %168
  store i64 %169, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  br label %170

170:                                              ; preds = %152, %148
  br label %171

171:                                              ; preds = %170, %147
  %172 = load i64, ptr %10, align 8, !tbaa !9
  %173 = load i64, ptr %19, align 8, !tbaa !9
  %174 = add i64 %172, %173
  %175 = getelementptr inbounds [4 x i64], ptr %20, i64 0, i64 0
  %176 = load i64, ptr %175, align 16, !tbaa !9
  %177 = add i64 %174, %176
  %178 = getelementptr inbounds [4 x i64], ptr %20, i64 0, i64 1
  %179 = load i64, ptr %178, align 8, !tbaa !9
  %180 = add i64 %177, %179
  %181 = getelementptr inbounds [4 x i64], ptr %20, i64 0, i64 2
  %182 = load i64, ptr %181, align 16, !tbaa !9
  %183 = add i64 %180, %182
  %184 = getelementptr inbounds [4 x i64], ptr %20, i64 0, i64 3
  %185 = load i64, ptr %184, align 8, !tbaa !9
  %186 = add i64 %183, %185
  %187 = load i64, ptr %23, align 8, !tbaa !9
  %188 = add i64 %186, %187
  %189 = load i64, ptr %24, align 8, !tbaa !9
  %190 = add i64 %188, %189
  %191 = load i64, ptr %25, align 8, !tbaa !9
  %192 = add i64 %190, %191
  store i64 %192, ptr %4, align 8
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %193

193:                                              ; preds = %171, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1400, ptr %8) #4
  %194 = load i64, ptr %4, align 8
  ret i64 %194
}

; Function Attrs: nounwind uwtable
declare hidden void @BrotliEncoderInitParams(ptr noundef) #2

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

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i64 @MaxHashTableSize(i32 noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 4}
!12 = !{!"BrotliEncoderParams", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !6, i64 32, !6, i64 36, !13, i64 40, !14, i64 56, !15, i64 80}
!13 = !{!"BrotliHasherParams", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!14 = !{!"BrotliDistanceParams", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16}
!15 = !{!"SharedEncoderDictionary", !6, i64 0, !16, i64 8, !17, i64 544, !6, i64 1312}
!16 = !{!"CompoundDictionary", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 144, !7, i64 272, !10, i64 400, !7, i64 408}
!17 = !{!"ContextualEncoderDictionary", !6, i64 0, !7, i64 4, !7, i64 5, !7, i64 72, !10, i64 584, !18, i64 592, !19, i64 760}
!18 = !{!"BrotliEncoderDictionary", !19, i64 0, !6, i64 8, !6, i64 12, !10, i64 16, !19, i64 24, !19, i64 32, !19, i64 40, !19, i64 48, !20, i64 56, !6, i64 96, !19, i64 104, !19, i64 112, !19, i64 120, !10, i64 128, !19, i64 136, !10, i64 144, !19, i64 152, !19, i64 160}
!19 = !{!"any pointer", !7, i64 0}
!20 = !{!"BrotliTrie", !19, i64 0, !10, i64 8, !10, i64 16, !21, i64 24}
!21 = !{!"BrotliTrieNode", !7, i64 0, !7, i64 1, !7, i64 2, !6, i64 4, !6, i64 8}
!22 = !{!12, !6, i64 8}
!23 = !{!12, !10, i64 24}
!24 = !{!12, !6, i64 36}
!25 = !{!12, !6, i64 12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.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 }

; 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: alwaysinline nounwind uwtable
declare hidden i64 @brotli_min_size_t(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define hidden i64 @BrotliEncoderEstimatePeakMemoryUsage(i32 noundef %0, i32 noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.BrotliEncoderParams, align 8
  %5 = alloca [4 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 1400, ptr nonnull %4) #5
  call void @BrotliEncoderInitParams(ptr noundef nonnull %4)
  %6 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %1, ptr %7, align 8, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %4, i64 24
  store i64 %2, ptr %8, align 8, !tbaa !21
  %9 = icmp sgt i32 %1, 24
  %10 = zext i1 %9 to i32
  %11 = getelementptr inbounds i8, ptr %4, i64 36
  store i32 %10, ptr %11, align 4, !tbaa !22
  call void @SanitizeParams(ptr noundef nonnull %4)
  %12 = call i32 @ComputeLgBlock(ptr noundef nonnull %4)
  %13 = getelementptr inbounds i8, ptr %4, i64 12
  store i32 %12, ptr %13, align 4, !tbaa !23
  %14 = getelementptr inbounds i8, ptr %4, i64 40
  call void @ChooseHasher(ptr noundef nonnull %4, ptr noundef nonnull %14)
  %15 = load i32, ptr %6, align 4
  %or.cond = icmp ult i32 %15, 2
  br i1 %or.cond, label %16, label %38

16:                                               ; preds = %3
  %17 = load i32, ptr %7, align 8, !tbaa !20
  %18 = zext nneg i32 %17 to i64
  %19 = shl nuw i64 1, %18
  %20 = call i64 @brotli_min_size_t(i64 noundef %2, i64 noundef %19)
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = call i64 @MaxHashTableSize(i32 noundef %21)
  %23 = call i64 @HashTableSize(i64 noundef %22, i64 noundef %20)
  %24 = icmp ult i64 %23, 1024
  %25 = shl i64 %23, 2
  %26 = select i1 %24, i64 0, i64 %25
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %32

29:                                               ; preds = %16
  %30 = call i64 @brotli_min_size_t(i64 noundef %20, i64 noundef 131072)
  %31 = mul i64 %30, 5
  %.pre = load i32, ptr %6, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %16, %29
  %33 = phi i32 [ %.pre, %29 ], [ %27, %16 ]
  %34 = phi i64 [ %31, %29 ], [ 0, %16 ]
  %35 = icmp eq i32 %33, 0
  %. = select i1 %35, i64 15120, i64 14600
  %36 = add i64 %34, %26
  %37 = add i64 %36, %.
  br label %81

38:                                               ; preds = %3
  %39 = load i32, ptr %13, align 4, !tbaa !23
  %40 = zext nneg i32 %39 to i64
  %41 = shl nuw i64 1, %40
  %42 = call i32 @ComputeRbBits(ptr noundef nonnull %4)
  %43 = icmp ugt i64 %41, %2
  %44 = shl nuw i32 1, %42
  %45 = zext i32 %44 to i64
  %46 = add nuw i64 %41, %45
  %47 = select i1 %43, i64 %2, i64 %46
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %5, i8 0, i64 32, i1 false)
  %48 = call i64 @MaxMetablockSize(ptr noundef nonnull %4)
  %49 = call i64 @brotli_min_size_t(i64 noundef %2, i64 noundef %48)
  %50 = load i32, ptr %13, align 4, !tbaa !23
  %51 = zext nneg i32 %50 to i64
  %52 = shl nuw i64 1, %51
  %53 = call i64 @brotli_min_size_t(i64 noundef %2, i64 noundef %52)
  %54 = shl i64 %49, 1
  %55 = mul i64 %53, 6
  %56 = add i64 %55, %54
  call void @HasherSize(ptr noundef nonnull %4, i32 noundef 1, i64 noundef %2, ptr noundef nonnull %5)
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = icmp slt i32 %57, 4
  br i1 %58, label %59, label %63

59:                                               ; preds = %38
  %60 = mul i64 %53, 12
  %61 = add i64 %60, 196592
  %62 = call i64 @brotli_min_size_t(i64 noundef %56, i64 noundef %61)
  %.pr = load i32, ptr %6, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %59, %38
  %64 = phi i32 [ %.pr, %59 ], [ %57, %38 ]
  %.044 = phi i64 [ %62, %59 ], [ %56, %38 ]
  %65 = icmp sgt i32 %64, 9
  br i1 %65, label %78, label %66

66:                                               ; preds = %63
  %67 = icmp sgt i32 %64, 3
  br i1 %67, label %68, label %78

68:                                               ; preds = %66
  %69 = udiv i64 %49, 6144
  %70 = call i64 @brotli_min_size_t(i64 noundef %69, i64 noundef 256)
  %71 = call i64 @brotli_min_size_t(i64 noundef %69, i64 noundef 256)
  %72 = call i64 @brotli_min_size_t(i64 noundef %69, i64 noundef 256)
  %73 = mul i64 %70, 1040
  %74 = mul i64 %71, 2832
  %75 = add i64 %74, %73
  %76 = mul i64 %72, 2192
  %77 = add i64 %75, %76
  br label %78

78:                                               ; preds = %63, %66, %68
  %.043 = phi i64 [ %77, %68 ], [ 0, %66 ], [ 209715200, %63 ]
  %79 = load <4 x i64>, ptr %5, align 16, !tbaa !24
  %80 = call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> %79)
  %op.rdx = add i64 %80, %.043
  %op.rdx48 = add i64 %.044, 503
  %op.rdx49 = add i64 %54, %47
  %op.rdx50 = add i64 %op.rdx, %op.rdx48
  %op.rdx51 = add i64 %op.rdx50, %op.rdx49
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #5
  br label %81

81:                                               ; preds = %78, %32
  %.0 = phi i64 [ %37, %32 ], [ %op.rdx51, %78 ]
  call void @llvm.lifetime.end.p0(i64 1400, ptr nonnull %4) #5
  ret i64 %.0
}

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @ChooseHasher(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @HasherSize(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 4}
!6 = !{!"BrotliEncoderParams", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !11, i64 40, !12, i64 56, !13, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"BrotliHasherParams", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!12 = !{!"BrotliDistanceParams", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!13 = !{!"SharedEncoderDictionary", !7, i64 0, !14, i64 8, !15, i64 544, !7, i64 1312}
!14 = !{!"CompoundDictionary", !10, i64 0, !10, i64 8, !8, i64 16, !8, i64 144, !8, i64 272, !10, i64 400, !8, i64 408}
!15 = !{!"ContextualEncoderDictionary", !7, i64 0, !8, i64 4, !8, i64 5, !8, i64 72, !10, i64 584, !16, i64 592, !17, i64 760}
!16 = !{!"BrotliEncoderDictionary", !17, i64 0, !7, i64 8, !7, i64 12, !10, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !17, i64 48, !18, i64 56, !7, i64 96, !17, i64 104, !17, i64 112, !17, i64 120, !10, i64 128, !17, i64 136, !10, i64 144, !17, i64 152, !17, i64 160}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!"BrotliTrie", !17, i64 0, !10, i64 8, !10, i64 16, !19, i64 24}
!19 = !{!"BrotliTrieNode", !8, i64 0, !8, i64 1, !8, i64 2, !7, i64 4, !7, i64 8}
!20 = !{!6, !7, i64 8}
!21 = !{!6, !10, i64 24}
!22 = !{!6, !7, i64 36}
!23 = !{!6, !7, i64 12}
!24 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass