; LLVM IR from itchio/go-brotli :: enc (cluster)

; 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.HistogramCommand = type { [704 x i32], i64, double }

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

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

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

declare hidden ptr @BrotliAllocate(ptr noundef, i64 noundef) #2

declare hidden void @BrotliFree(ptr noundef, ptr noundef) #2

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

declare hidden double @BrotliPopulationCostCommand(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @BrotliHistogramCombineCommand(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #4

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

; Function Attrs: nounwind uwtable
declare hidden i64 @BrotliHistogramReindexCommand(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
define hidden void @BrotliClusterHistogramsCommand(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #4 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %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 ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !9
  store i64 %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = icmp ugt i64 %28, 0
  br i1 %29, label %30, label %35

30:                                               ; preds = %7
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load i64, ptr %10, align 8, !tbaa !9
  %33 = mul i64 %32, 4
  %34 = call ptr @BrotliAllocate(ptr noundef %31, i64 noundef %33)
  br label %36

35:                                               ; preds = %7
  br label %36

36:                                               ; preds = %35, %30
  %37 = phi ptr [ %34, %30 ], [ null, %35 ]
  store ptr %37, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %38 = load i64, ptr %10, align 8, !tbaa !9
  %39 = icmp ugt i64 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %36
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i64, ptr %10, align 8, !tbaa !9
  %43 = mul i64 %42, 4
  %44 = call ptr @BrotliAllocate(ptr noundef %41, i64 noundef %43)
  br label %46

45:                                               ; preds = %36
  br label %46

46:                                               ; preds = %45, %40
  %47 = phi ptr [ %44, %40 ], [ null, %45 ]
  store ptr %47, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store i64 0, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store i64 64, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  store i64 2048, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %48 = load i64, ptr %19, align 8, !tbaa !9
  %49 = add i64 %48, 1
  %50 = icmp ugt i64 %49, 0
  br i1 %50, label %51, label %57

51:                                               ; preds = %46
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i64, ptr %19, align 8, !tbaa !9
  %54 = add i64 %53, 1
  %55 = mul i64 %54, 24
  %56 = call ptr @BrotliAllocate(ptr noundef %52, i64 noundef %55)
  br label %58

57:                                               ; preds = %46
  br label %58

58:                                               ; preds = %57, %51
  %59 = phi ptr [ %56, %51 ], [ null, %57 ]
  store ptr %59, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %68, %58
  %61 = load i64, ptr %21, align 8, !tbaa !9
  %62 = load i64, ptr %10, align 8, !tbaa !9
  %63 = icmp ult i64 %61, %62
  br i1 %63, label %64, label %71

64:                                               ; preds = %60
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = load i64, ptr %21, align 8, !tbaa !9
  %67 = getelementptr inbounds i32, ptr %65, i64 %66
  store i32 1, ptr %67, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %64
  %69 = load i64, ptr %21, align 8, !tbaa !9
  %70 = add i64 %69, 1
  store i64 %70, ptr %21, align 8, !tbaa !9
  br label %60, !llvm.loop !13

71:                                               ; preds = %60
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %72

72:                                               ; preds = %96, %71
  %73 = load i64, ptr %21, align 8, !tbaa !9
  %74 = load i64, ptr %10, align 8, !tbaa !9
  %75 = icmp ult i64 %73, %74
  br i1 %75, label %76, label %99

76:                                               ; preds = %72
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load i64, ptr %21, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.HistogramCommand, ptr %77, i64 %78
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load i64, ptr %21, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.HistogramCommand, ptr %80, i64 %81
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %79, ptr align 8 %82, i64 2832, i1 false), !tbaa.struct !15
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = load i64, ptr %21, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct.HistogramCommand, ptr %83, i64 %84
  %86 = call double @BrotliPopulationCostCommand(ptr noundef %85)
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = load i64, ptr %21, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.HistogramCommand, ptr %87, i64 %88
  %90 = getelementptr inbounds %struct.HistogramCommand, ptr %89, i32 0, i32 2
  store double %86, ptr %90, align 8, !tbaa !19
  %91 = load i64, ptr %21, align 8, !tbaa !9
  %92 = trunc i64 %91 to i32
  %93 = load ptr, ptr %14, align 8, !tbaa !5
  %94 = load i64, ptr %21, align 8, !tbaa !9
  %95 = getelementptr inbounds i32, ptr %93, i64 %94
  store i32 %92, ptr %95, align 4, !tbaa !11
  br label %96

96:                                               ; preds = %76
  %97 = load i64, ptr %21, align 8, !tbaa !9
  %98 = add i64 %97, 1
  store i64 %98, ptr %21, align 8, !tbaa !9
  br label %72, !llvm.loop !21

99:                                               ; preds = %72
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %100

100:                                              ; preds = %144, %99
  %101 = load i64, ptr %21, align 8, !tbaa !9
  %102 = load i64, ptr %10, align 8, !tbaa !9
  %103 = icmp ult i64 %101, %102
  br i1 %103, label %104, label %147

104:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %105 = load i64, ptr %10, align 8, !tbaa !9
  %106 = load i64, ptr %21, align 8, !tbaa !9
  %107 = sub i64 %105, %106
  %108 = call i64 @brotli_min_size_t(i64 noundef %107, i64 noundef 64)
  store i64 %108, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  store i64 0, ptr %24, align 8, !tbaa !9
  br label %109

109:                                              ; preds = %123, %104
  %110 = load i64, ptr %24, align 8, !tbaa !9
  %111 = load i64, ptr %22, align 8, !tbaa !9
  %112 = icmp ult i64 %110, %111
  br i1 %112, label %113, label %126

113:                                              ; preds = %109
  %114 = load i64, ptr %21, align 8, !tbaa !9
  %115 = load i64, ptr %24, align 8, !tbaa !9
  %116 = add i64 %114, %115
  %117 = trunc i64 %116 to i32
  %118 = load ptr, ptr %16, align 8, !tbaa !5
  %119 = load i64, ptr %17, align 8, !tbaa !9
  %120 = load i64, ptr %24, align 8, !tbaa !9
  %121 = add i64 %119, %120
  %122 = getelementptr inbounds i32, ptr %118, i64 %121
  store i32 %117, ptr %122, align 4, !tbaa !11
  br label %123

123:                                              ; preds = %113
  %124 = load i64, ptr %24, align 8, !tbaa !9
  %125 = add i64 %124, 1
  store i64 %125, ptr %24, align 8, !tbaa !9
  br label %109, !llvm.loop !22

126:                                              ; preds = %109
  %127 = load ptr, ptr %12, align 8, !tbaa !5
  %128 = load ptr, ptr %15, align 8, !tbaa !5
  %129 = load ptr, ptr %14, align 8, !tbaa !5
  %130 = load i64, ptr %21, align 8, !tbaa !9
  %131 = getelementptr inbounds i32, ptr %129, i64 %130
  %132 = load ptr, ptr %16, align 8, !tbaa !5
  %133 = load i64, ptr %17, align 8, !tbaa !9
  %134 = getelementptr inbounds i32, ptr %132, i64 %133
  %135 = load ptr, ptr %20, align 8, !tbaa !5
  %136 = load i64, ptr %22, align 8, !tbaa !9
  %137 = load i64, ptr %22, align 8, !tbaa !9
  %138 = load i64, ptr %11, align 8, !tbaa !9
  %139 = load i64, ptr %19, align 8, !tbaa !9
  %140 = call i64 @BrotliHistogramCombineCommand(ptr noundef %127, ptr noundef %128, ptr noundef %131, ptr noundef %134, ptr noundef %135, i64 noundef %136, i64 noundef %137, i64 noundef %138, i64 noundef %139)
  store i64 %140, ptr %23, align 8, !tbaa !9
  %141 = load i64, ptr %23, align 8, !tbaa !9
  %142 = load i64, ptr %17, align 8, !tbaa !9
  %143 = add i64 %142, %141
  store i64 %143, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  br label %144

144:                                              ; preds = %126
  %145 = load i64, ptr %21, align 8, !tbaa !9
  %146 = add i64 %145, 64
  store i64 %146, ptr %21, align 8, !tbaa !9
  br label %100, !llvm.loop !23

147:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #5
  %148 = load i64, ptr %17, align 8, !tbaa !9
  %149 = mul i64 64, %148
  %150 = load i64, ptr %17, align 8, !tbaa !9
  %151 = udiv i64 %150, 2
  %152 = load i64, ptr %17, align 8, !tbaa !9
  %153 = mul i64 %151, %152
  %154 = call i64 @brotli_min_size_t(i64 noundef %149, i64 noundef %153)
  store i64 %154, ptr %25, align 8, !tbaa !9
  %155 = load i64, ptr %19, align 8, !tbaa !9
  %156 = load i64, ptr %25, align 8, !tbaa !9
  %157 = add i64 %156, 1
  %158 = icmp ult i64 %155, %157
  br i1 %158, label %159, label %200

159:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  %160 = load i64, ptr %19, align 8, !tbaa !9
  %161 = icmp eq i64 %160, 0
  br i1 %161, label %162, label %165

162:                                              ; preds = %159
  %163 = load i64, ptr %25, align 8, !tbaa !9
  %164 = add i64 %163, 1
  br label %167

165:                                              ; preds = %159
  %166 = load i64, ptr %19, align 8, !tbaa !9
  br label %167

167:                                              ; preds = %165, %162
  %168 = phi i64 [ %164, %162 ], [ %166, %165 ]
  store i64 %168, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #5
  br label %169

169:                                              ; preds = %174, %167
  %170 = load i64, ptr %26, align 8, !tbaa !9
  %171 = load i64, ptr %25, align 8, !tbaa !9
  %172 = add i64 %171, 1
  %173 = icmp ult i64 %170, %172
  br i1 %173, label %174, label %177

174:                                              ; preds = %169
  %175 = load i64, ptr %26, align 8, !tbaa !9
  %176 = mul i64 %175, 2
  store i64 %176, ptr %26, align 8, !tbaa !9
  br label %169, !llvm.loop !24

177:                                              ; preds = %169
  %178 = load i64, ptr %26, align 8, !tbaa !9
  %179 = icmp ugt i64 %178, 0
  br i1 %179, label %180, label %185

180:                                              ; preds = %177
  %181 = load ptr, ptr %8, align 8, !tbaa !5
  %182 = load i64, ptr %26, align 8, !tbaa !9
  %183 = mul i64 %182, 24
  %184 = call ptr @BrotliAllocate(ptr noundef %181, i64 noundef %183)
  br label %186

185:                                              ; preds = %177
  br label %186

186:                                              ; preds = %185, %180
  %187 = phi ptr [ %184, %180 ], [ null, %185 ]
  store ptr %187, ptr %27, align 8, !tbaa !5
  %188 = load i64, ptr %19, align 8, !tbaa !9
  %189 = icmp ne i64 %188, 0
  br i1 %189, label %190, label %195

190:                                              ; preds = %186
  %191 = load ptr, ptr %27, align 8, !tbaa !5
  %192 = load ptr, ptr %20, align 8, !tbaa !5
  %193 = load i64, ptr %19, align 8, !tbaa !9
  %194 = mul i64 %193, 24
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %191, ptr align 8 %192, i64 %194, i1 false)
  br label %195

195:                                              ; preds = %190, %186
  %196 = load ptr, ptr %8, align 8, !tbaa !5
  %197 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliFree(ptr noundef %196, ptr noundef %197)
  store ptr null, ptr %20, align 8, !tbaa !5
  %198 = load ptr, ptr %27, align 8, !tbaa !5
  store ptr %198, ptr %20, align 8, !tbaa !5
  %199 = load i64, ptr %26, align 8, !tbaa !9
  store i64 %199, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  br label %200

200:                                              ; preds = %195, %147
  %201 = load ptr, ptr %12, align 8, !tbaa !5
  %202 = load ptr, ptr %15, align 8, !tbaa !5
  %203 = load ptr, ptr %14, align 8, !tbaa !5
  %204 = load ptr, ptr %16, align 8, !tbaa !5
  %205 = load ptr, ptr %20, align 8, !tbaa !5
  %206 = load i64, ptr %17, align 8, !tbaa !9
  %207 = load i64, ptr %10, align 8, !tbaa !9
  %208 = load i64, ptr %11, align 8, !tbaa !9
  %209 = load i64, ptr %25, align 8, !tbaa !9
  %210 = call i64 @BrotliHistogramCombineCommand(ptr noundef %201, ptr noundef %202, ptr noundef %203, ptr noundef %204, ptr noundef %205, i64 noundef %206, i64 noundef %207, i64 noundef %208, i64 noundef %209)
  store i64 %210, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #5
  %211 = load ptr, ptr %8, align 8, !tbaa !5
  %212 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliFree(ptr noundef %211, ptr noundef %212)
  store ptr null, ptr %20, align 8, !tbaa !5
  %213 = load ptr, ptr %8, align 8, !tbaa !5
  %214 = load ptr, ptr %15, align 8, !tbaa !5
  call void @BrotliFree(ptr noundef %213, ptr noundef %214)
  store ptr null, ptr %15, align 8, !tbaa !5
  %215 = load ptr, ptr %9, align 8, !tbaa !5
  %216 = load i64, ptr %10, align 8, !tbaa !9
  %217 = load ptr, ptr %16, align 8, !tbaa !5
  %218 = load i64, ptr %17, align 8, !tbaa !9
  %219 = load ptr, ptr %12, align 8, !tbaa !5
  %220 = load ptr, ptr %14, align 8, !tbaa !5
  call void @BrotliHistogramRemapCommand(ptr noundef %215, i64 noundef %216, ptr noundef %217, i64 noundef %218, ptr noundef %219, ptr noundef %220)
  %221 = load ptr, ptr %8, align 8, !tbaa !5
  %222 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliFree(ptr noundef %221, ptr noundef %222)
  store ptr null, ptr %16, align 8, !tbaa !5
  %223 = load ptr, ptr %8, align 8, !tbaa !5
  %224 = load ptr, ptr %12, align 8, !tbaa !5
  %225 = load ptr, ptr %14, align 8, !tbaa !5
  %226 = load i64, ptr %10, align 8, !tbaa !9
  %227 = call i64 @BrotliHistogramReindexCommand(ptr noundef %223, ptr noundef %224, ptr noundef %225, i64 noundef %226)
  %228 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %227, ptr %228, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i64 0, i64 2816, !16, i64 2816, i64 8, !9, i64 2824, i64 8, !17}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!20, !18, i64 2824}
!20 = !{!"HistogramCommand", !7, i64 0, !10, i64 2816, !18, i64 2824}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}
!24 = distinct !{!24, !14}


; 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.HistogramCommand = type { [704 x i32], i64, double }

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

declare hidden ptr @BrotliAllocate(ptr noundef, i64 noundef) local_unnamed_addr #1

declare hidden void @BrotliFree(ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare hidden double @BrotliPopulationCostCommand(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @BrotliHistogramCombineCommand(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden i64 @BrotliHistogramReindexCommand(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define hidden void @BrotliClusterHistogramsCommand(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr nocapture noundef writeonly %5, ptr noundef %6) local_unnamed_addr #3 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %.preheader110.thread, label %.lr.ph.preheader

.preheader110.thread:                             ; preds = %7
  %8 = tail call ptr @BrotliAllocate(ptr noundef %0, i64 noundef 49176) #4
  br label %._crit_edge120

.lr.ph.preheader:                                 ; preds = %7
  %9 = shl i64 %2, 2
  %10 = tail call ptr @BrotliAllocate(ptr noundef %0, i64 noundef %9) #4
  %11 = tail call ptr @BrotliAllocate(ptr noundef %0, i64 noundef %9) #4
  %12 = tail call ptr @BrotliAllocate(ptr noundef %0, i64 noundef 49176) #4
  %min.iters.check = icmp ult i64 %2, 8
  br i1 %min.iters.check, label %.lr.ph.preheader140, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %2, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %13 = getelementptr inbounds i32, ptr %10, i64 %index
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %13, align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %14, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %15 = icmp eq i64 %index.next, %n.vec
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %2
  br i1 %cmp.n, label %.lr.ph114.preheader, label %.lr.ph.preheader140

.lr.ph.preheader140:                              ; preds = %middle.block, %.lr.ph.preheader
  %.0103112.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader140, %.lr.ph
  %.0103112 = phi i64 [ %17, %.lr.ph ], [ %.0103112.ph, %.lr.ph.preheader140 ]
  %16 = getelementptr inbounds i32, ptr %10, i64 %.0103112
  store i32 1, ptr %16, align 4, !tbaa !5
  %17 = add nuw i64 %.0103112, 1
  %exitcond.not = icmp eq i64 %17, %2
  br i1 %exitcond.not, label %.lr.ph114.preheader, label %.lr.ph, !llvm.loop !13

.lr.ph114.preheader:                              ; preds = %.lr.ph, %middle.block
  br label %.lr.ph114

.lr.ph114:                                        ; preds = %.lr.ph114.preheader, %.lr.ph114
  %.1113 = phi i64 [ %24, %.lr.ph114 ], [ 0, %.lr.ph114.preheader ]
  %18 = getelementptr inbounds %struct.HistogramCommand, ptr %4, i64 %.1113
  %19 = getelementptr inbounds %struct.HistogramCommand, ptr %1, i64 %.1113
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(2832) %18, ptr noundef nonnull align 8 dereferenceable(2832) %19, i64 2832, i1 false), !tbaa.struct !14
  %20 = tail call double @BrotliPopulationCostCommand(ptr noundef %19) #4
  %21 = getelementptr inbounds i8, ptr %18, i64 2824
  store double %20, ptr %21, align 8, !tbaa !20
  %22 = trunc i64 %.1113 to i32
  %23 = getelementptr inbounds i32, ptr %6, i64 %.1113
  store i32 %22, ptr %23, align 4, !tbaa !5
  %24 = add nuw i64 %.1113, 1
  %exitcond125.not = icmp eq i64 %24, %2
  br i1 %exitcond125.not, label %.lr.ph119, label %.lr.ph114, !llvm.loop !22

.lr.ph119:                                        ; preds = %.lr.ph114, %._crit_edge
  %.0102118 = phi i64 [ %39, %._crit_edge ], [ 0, %.lr.ph114 ]
  %.2117 = phi i64 [ %40, %._crit_edge ], [ 0, %.lr.ph114 ]
  %25 = sub i64 %2, %.2117
  %26 = tail call i64 @brotli_min_size_t(i64 noundef %25, i64 noundef 64)
  %.not124 = icmp eq i64 %26, 0
  br i1 %.not124, label %._crit_edge, label %.lr.ph116.preheader

.lr.ph116.preheader:                              ; preds = %.lr.ph119
  %min.iters.check129 = icmp ult i64 %26, 8
  br i1 %min.iters.check129, label %.lr.ph116.preheader139, label %vector.ph130

vector.ph130:                                     ; preds = %.lr.ph116.preheader
  %n.vec132 = and i64 %26, -8
  %broadcast.splatinsert = insertelement <4 x i64> poison, i64 %.2117, i64 0
  %broadcast.splat = shufflevector <4 x i64> %broadcast.splatinsert, <4 x i64> poison, <4 x i32> zeroinitializer
  %invariant.gep = getelementptr i32, ptr %11, i64 %.0102118
  br label %vector.body134

vector.body134:                                   ; preds = %vector.body134, %vector.ph130
  %index135 = phi i64 [ 0, %vector.ph130 ], [ %index.next137, %vector.body134 ]
  %vec.ind = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %vector.ph130 ], [ %vec.ind.next, %vector.body134 ]
  %step.add = add <4 x i64> %vec.ind, <i64 4, i64 4, i64 4, i64 4>
  %27 = add <4 x i64> %vec.ind, %broadcast.splat
  %28 = add <4 x i64> %step.add, %broadcast.splat
  %29 = trunc <4 x i64> %27 to <4 x i32>
  %30 = trunc <4 x i64> %28 to <4 x i32>
  %gep = getelementptr i32, ptr %invariant.gep, i64 %index135
  %31 = getelementptr i8, ptr %gep, i64 16
  store <4 x i32> %29, ptr %gep, align 4, !tbaa !5
  store <4 x i32> %30, ptr %31, align 4, !tbaa !5
  %index.next137 = add nuw i64 %index135, 8
  %vec.ind.next = add <4 x i64> %vec.ind, <i64 8, i64 8, i64 8, i64 8>
  %32 = icmp eq i64 %index.next137, %n.vec132
  br i1 %32, label %middle.block127, label %vector.body134, !llvm.loop !23

middle.block127:                                  ; preds = %vector.body134
  %cmp.n138 = icmp eq i64 %26, %n.vec132
  br i1 %cmp.n138, label %._crit_edge, label %.lr.ph116.preheader139

.lr.ph116.preheader139:                           ; preds = %middle.block127, %.lr.ph116.preheader
  %.0101115.ph = phi i64 [ 0, %.lr.ph116.preheader ], [ %n.vec132, %middle.block127 ]
  %invariant.gep141 = getelementptr i32, ptr %11, i64 %.0102118
  br label %.lr.ph116

.lr.ph116:                                        ; preds = %.lr.ph116.preheader139, %.lr.ph116
  %.0101115 = phi i64 [ %35, %.lr.ph116 ], [ %.0101115.ph, %.lr.ph116.preheader139 ]
  %33 = add i64 %.0101115, %.2117
  %34 = trunc i64 %33 to i32
  %gep142 = getelementptr i32, ptr %invariant.gep141, i64 %.0101115
  store i32 %34, ptr %gep142, align 4, !tbaa !5
  %35 = add nuw i64 %.0101115, 1
  %exitcond126.not = icmp eq i64 %35, %26
  br i1 %exitcond126.not, label %._crit_edge, label %.lr.ph116, !llvm.loop !24

._crit_edge:                                      ; preds = %.lr.ph116, %middle.block127, %.lr.ph119
  %36 = getelementptr inbounds i32, ptr %6, i64 %.2117
  %37 = getelementptr inbounds i32, ptr %11, i64 %.0102118
  %38 = tail call i64 @BrotliHistogramCombineCommand(ptr noundef %4, ptr noundef %10, ptr noundef %36, ptr noundef %37, ptr noundef %12, i64 noundef %26, i64 noundef %26, i64 noundef %3, i64 noundef 2048)
  %39 = add i64 %38, %.0102118
  %40 = add i64 %.2117, 64
  %41 = icmp ult i64 %40, %2
  br i1 %41, label %.lr.ph119, label %._crit_edge120, !llvm.loop !25

._crit_edge120:                                   ; preds = %._crit_edge, %.preheader110.thread
  %42 = phi ptr [ %8, %.preheader110.thread ], [ %12, %._crit_edge ]
  %43 = phi ptr [ null, %.preheader110.thread ], [ %11, %._crit_edge ]
  %44 = phi ptr [ null, %.preheader110.thread ], [ %10, %._crit_edge ]
  %.0102.lcssa = phi i64 [ 0, %.preheader110.thread ], [ %39, %._crit_edge ]
  %45 = shl i64 %.0102.lcssa, 6
  %46 = lshr i64 %.0102.lcssa, 1
  %47 = mul i64 %46, %.0102.lcssa
  %48 = tail call i64 @brotli_min_size_t(i64 noundef %45, i64 noundef %47)
  %49 = add i64 %48, 1
  %50 = icmp ugt i64 %49, 2048
  br i1 %50, label %.preheader, label %56

.preheader:                                       ; preds = %._crit_edge120, %.preheader
  %.0 = phi i64 [ %52, %.preheader ], [ 2048, %._crit_edge120 ]
  %51 = icmp ult i64 %.0, %49
  %52 = shl i64 %.0, 1
  br i1 %51, label %.preheader, label %53, !llvm.loop !26

53:                                               ; preds = %.preheader
  %54 = mul i64 %.0, 24
  %55 = tail call ptr @BrotliAllocate(ptr noundef %0, i64 noundef %54) #4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(49152) %55, ptr noundef nonnull align 8 dereferenceable(49152) %42, i64 49152, i1 false)
  tail call void @BrotliFree(ptr noundef %0, ptr noundef %42) #4
  br label %56

56:                                               ; preds = %53, %._crit_edge120
  %.0104 = phi ptr [ %55, %53 ], [ %42, %._crit_edge120 ]
  %57 = tail call i64 @BrotliHistogramCombineCommand(ptr noundef %4, ptr noundef %44, ptr noundef %6, ptr noundef %43, ptr noundef %.0104, i64 noundef %.0102.lcssa, i64 noundef %2, i64 noundef %3, i64 noundef %48)
  tail call void @BrotliFree(ptr noundef %0, ptr noundef %.0104) #4
  tail call void @BrotliFree(ptr noundef %0, ptr noundef %44) #4
  tail call void @BrotliHistogramRemapCommand(ptr noundef %1, i64 noundef %2, ptr noundef %43, i64 noundef %57, ptr noundef %4, ptr noundef %6)
  tail call void @BrotliFree(ptr noundef %0, ptr noundef %43) #4
  %58 = tail call i64 @BrotliHistogramReindexCommand(ptr noundef %0, ptr noundef %4, ptr noundef %6, i64 noundef %2)
  store i64 %58, ptr %5, align 8, !tbaa !16
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = !{i64 0, i64 2816, !15, i64 2816, i64 8, !16, i64 2824, i64 8, !18}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!21, !19, i64 2824}
!21 = !{!"HistogramCommand", !7, i64 0, !17, i64 2816, !19, i64 2824}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10, !11, !12}
!24 = distinct !{!24, !10, !12, !11}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}


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