; 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.HistogramPair = type { i32, i32, double, double }
%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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @HistogramPairIsLess(ptr noundef, ptr noundef) #2

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

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

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

; Function Attrs: nounwind uwtable
define hidden i64 @BrotliHistogramCombineCommand(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, i64 noundef %8) #3 {
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca double, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i64, align 8
  %27 = alloca i32, align 4
  %28 = alloca i64, align 8
  %29 = alloca ptr, align 8
  %30 = alloca %struct.HistogramPair, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store i64 %5, ptr %15, align 8, !tbaa !9
  store i64 %6, ptr %16, align 8, !tbaa !9
  store i64 %7, ptr %17, align 8, !tbaa !9
  store i64 %8, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  store double 0.000000e+00, ptr %19, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  store i64 1, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  store i64 0, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  store i64 0, ptr %22, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %60, %9
  %32 = load i64, ptr %22, align 8, !tbaa !9
  %33 = load i64, ptr %15, align 8, !tbaa !9
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %35, label %63

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %36 = load i64, ptr %22, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %23, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %56, %35
  %39 = load i64, ptr %23, align 8, !tbaa !9
  %40 = load i64, ptr %15, align 8, !tbaa !9
  %41 = icmp ult i64 %39, %40
  br i1 %41, label %42, label %59

42:                                               ; preds = %38
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %13, align 8, !tbaa !5
  %46 = load i64, ptr %22, align 8, !tbaa !9
  %47 = getelementptr inbounds i32, ptr %45, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = load ptr, ptr %13, align 8, !tbaa !5
  %50 = load i64, ptr %23, align 8, !tbaa !9
  %51 = getelementptr inbounds i32, ptr %49, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !13
  %53 = load i64, ptr %18, align 8, !tbaa !9
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.HistogramPair, ptr %54, i64 0
  call void @BrotliCompareAndPushToQueueCommand(ptr noundef %43, ptr noundef %44, i32 noundef %48, i32 noundef %52, i64 noundef %53, ptr noundef %55, ptr noundef %21)
  br label %56

56:                                               ; preds = %42
  %57 = load i64, ptr %23, align 8, !tbaa !9
  %58 = add i64 %57, 1
  store i64 %58, ptr %23, align 8, !tbaa !9
  br label %38, !llvm.loop !15

59:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %22, align 8, !tbaa !9
  %62 = add i64 %61, 1
  store i64 %62, ptr %22, align 8, !tbaa !9
  br label %31, !llvm.loop !17

63:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  br label %64

64:                                               ; preds = %250, %248, %63
  %65 = load i64, ptr %15, align 8, !tbaa !9
  %66 = load i64, ptr %20, align 8, !tbaa !9
  %67 = icmp ugt i64 %65, %66
  br i1 %67, label %68, label %251

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.HistogramPair, ptr %69, i64 0
  %71 = getelementptr inbounds %struct.HistogramPair, ptr %70, i32 0, i32 3
  %72 = load double, ptr %71, align 8, !tbaa !18
  %73 = load double, ptr %19, align 8, !tbaa !11
  %74 = fcmp oge double %72, %73
  br i1 %74, label %75, label %77

75:                                               ; preds = %68
  store double 0x547D42AEA2879F2E, ptr %19, align 8, !tbaa !11
  %76 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %76, ptr %20, align 8, !tbaa !9
  store i32 8, ptr %27, align 4
  br label %248, !llvm.loop !20

77:                                               ; preds = %68
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.HistogramPair, ptr %78, i64 0
  %80 = getelementptr inbounds %struct.HistogramPair, ptr %79, i32 0, i32 0
  %81 = load i32, ptr %80, align 8, !tbaa !21
  store i32 %81, ptr %24, align 4, !tbaa !13
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.HistogramPair, ptr %82, i64 0
  %84 = getelementptr inbounds %struct.HistogramPair, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !22
  store i32 %85, ptr %25, align 4, !tbaa !13
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load i32, ptr %24, align 4, !tbaa !13
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds %struct.HistogramCommand, ptr %86, i64 %88
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = load i32, ptr %25, align 4, !tbaa !13
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds %struct.HistogramCommand, ptr %90, i64 %92
  call void @HistogramAddHistogramCommand(ptr noundef %89, ptr noundef %93)
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.HistogramPair, ptr %94, i64 0
  %96 = getelementptr inbounds %struct.HistogramPair, ptr %95, i32 0, i32 2
  %97 = load double, ptr %96, align 8, !tbaa !23
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = load i32, ptr %24, align 4, !tbaa !13
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds %struct.HistogramCommand, ptr %98, i64 %100
  %102 = getelementptr inbounds %struct.HistogramCommand, ptr %101, i32 0, i32 2
  store double %97, ptr %102, align 8, !tbaa !24
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = load i32, ptr %25, align 4, !tbaa !13
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds i32, ptr %103, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !13
  %108 = load ptr, ptr %11, align 8, !tbaa !5
  %109 = load i32, ptr %24, align 4, !tbaa !13
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds i32, ptr %108, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !13
  %113 = add i32 %112, %107
  store i32 %113, ptr %111, align 4, !tbaa !13
  store i64 0, ptr %26, align 8, !tbaa !9
  br label %114

114:                                              ; preds = %131, %77
  %115 = load i64, ptr %26, align 8, !tbaa !9
  %116 = load i64, ptr %16, align 8, !tbaa !9
  %117 = icmp ult i64 %115, %116
  br i1 %117, label %118, label %134

118:                                              ; preds = %114
  %119 = load ptr, ptr %12, align 8, !tbaa !5
  %120 = load i64, ptr %26, align 8, !tbaa !9
  %121 = getelementptr inbounds i32, ptr %119, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !13
  %123 = load i32, ptr %25, align 4, !tbaa !13
  %124 = icmp eq i32 %122, %123
  br i1 %124, label %125, label %130

125:                                              ; preds = %118
  %126 = load i32, ptr %24, align 4, !tbaa !13
  %127 = load ptr, ptr %12, align 8, !tbaa !5
  %128 = load i64, ptr %26, align 8, !tbaa !9
  %129 = getelementptr inbounds i32, ptr %127, i64 %128
  store i32 %126, ptr %129, align 4, !tbaa !13
  br label %130

130:                                              ; preds = %125, %118
  br label %131

131:                                              ; preds = %130
  %132 = load i64, ptr %26, align 8, !tbaa !9
  %133 = add i64 %132, 1
  store i64 %133, ptr %26, align 8, !tbaa !9
  br label %114, !llvm.loop !26

134:                                              ; preds = %114
  store i64 0, ptr %26, align 8, !tbaa !9
  br label %135

135:                                              ; preds = %160, %134
  %136 = load i64, ptr %26, align 8, !tbaa !9
  %137 = load i64, ptr %15, align 8, !tbaa !9
  %138 = icmp ult i64 %136, %137
  br i1 %138, label %139, label %163

139:                                              ; preds = %135
  %140 = load ptr, ptr %13, align 8, !tbaa !5
  %141 = load i64, ptr %26, align 8, !tbaa !9
  %142 = getelementptr inbounds i32, ptr %140, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !13
  %144 = load i32, ptr %25, align 4, !tbaa !13
  %145 = icmp eq i32 %143, %144
  br i1 %145, label %146, label %159

146:                                              ; preds = %139
  %147 = load ptr, ptr %13, align 8, !tbaa !5
  %148 = load i64, ptr %26, align 8, !tbaa !9
  %149 = getelementptr inbounds i32, ptr %147, i64 %148
  %150 = load ptr, ptr %13, align 8, !tbaa !5
  %151 = load i64, ptr %26, align 8, !tbaa !9
  %152 = add i64 %151, 1
  %153 = getelementptr inbounds i32, ptr %150, i64 %152
  %154 = load i64, ptr %15, align 8, !tbaa !9
  %155 = load i64, ptr %26, align 8, !tbaa !9
  %156 = sub i64 %154, %155
  %157 = sub i64 %156, 1
  %158 = mul i64 %157, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %149, ptr align 4 %153, i64 %158, i1 false)
  br label %163

159:                                              ; preds = %139
  br label %160

160:                                              ; preds = %159
  %161 = load i64, ptr %26, align 8, !tbaa !9
  %162 = add i64 %161, 1
  store i64 %162, ptr %26, align 8, !tbaa !9
  br label %135, !llvm.loop !27

163:                                              ; preds = %146, %135
  %164 = load i64, ptr %15, align 8, !tbaa !9
  %165 = add i64 %164, -1
  store i64 %165, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  store i64 0, ptr %28, align 8, !tbaa !9
  store i64 0, ptr %26, align 8, !tbaa !9
  br label %166

166:                                              ; preds = %224, %163
  %167 = load i64, ptr %26, align 8, !tbaa !9
  %168 = load i64, ptr %21, align 8, !tbaa !9
  %169 = icmp ult i64 %167, %168
  br i1 %169, label %170, label %227

170:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #4
  %171 = load ptr, ptr %14, align 8, !tbaa !5
  %172 = load i64, ptr %26, align 8, !tbaa !9
  %173 = getelementptr inbounds %struct.HistogramPair, ptr %171, i64 %172
  store ptr %173, ptr %29, align 8, !tbaa !5
  %174 = load ptr, ptr %29, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.HistogramPair, ptr %174, i32 0, i32 0
  %176 = load i32, ptr %175, align 8, !tbaa !21
  %177 = load i32, ptr %24, align 4, !tbaa !13
  %178 = icmp eq i32 %176, %177
  br i1 %178, label %197, label %179

179:                                              ; preds = %170
  %180 = load ptr, ptr %29, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.HistogramPair, ptr %180, i32 0, i32 1
  %182 = load i32, ptr %181, align 4, !tbaa !22
  %183 = load i32, ptr %24, align 4, !tbaa !13
  %184 = icmp eq i32 %182, %183
  br i1 %184, label %197, label %185

185:                                              ; preds = %179
  %186 = load ptr, ptr %29, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.HistogramPair, ptr %186, i32 0, i32 0
  %188 = load i32, ptr %187, align 8, !tbaa !21
  %189 = load i32, ptr %25, align 4, !tbaa !13
  %190 = icmp eq i32 %188, %189
  br i1 %190, label %197, label %191

191:                                              ; preds = %185
  %192 = load ptr, ptr %29, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.HistogramPair, ptr %192, i32 0, i32 1
  %194 = load i32, ptr %193, align 4, !tbaa !22
  %195 = load i32, ptr %25, align 4, !tbaa !13
  %196 = icmp eq i32 %194, %195
  br i1 %196, label %197, label %198

197:                                              ; preds = %191, %185, %179, %170
  store i32 18, ptr %27, align 4
  br label %221

198:                                              ; preds = %191
  %199 = load ptr, ptr %14, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.HistogramPair, ptr %199, i64 0
  %201 = load ptr, ptr %29, align 8, !tbaa !5
  %202 = call i32 @HistogramPairIsLess(ptr noundef %200, ptr noundef %201)
  %203 = icmp ne i32 %202, 0
  br i1 %203, label %204, label %213

204:                                              ; preds = %198
  call void @llvm.lifetime.start.p0(i64 24, ptr %30) #4
  %205 = load ptr, ptr %14, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.HistogramPair, ptr %205, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %30, ptr align 8 %206, i64 24, i1 false), !tbaa.struct !28
  %207 = load ptr, ptr %14, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.HistogramPair, ptr %207, i64 0
  %209 = load ptr, ptr %29, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %208, ptr align 8 %209, i64 24, i1 false), !tbaa.struct !28
  %210 = load ptr, ptr %14, align 8, !tbaa !5
  %211 = load i64, ptr %28, align 8, !tbaa !9
  %212 = getelementptr inbounds %struct.HistogramPair, ptr %210, i64 %211
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %212, ptr align 8 %30, i64 24, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.end.p0(i64 24, ptr %30) #4
  br label %218

213:                                              ; preds = %198
  %214 = load ptr, ptr %14, align 8, !tbaa !5
  %215 = load i64, ptr %28, align 8, !tbaa !9
  %216 = getelementptr inbounds %struct.HistogramPair, ptr %214, i64 %215
  %217 = load ptr, ptr %29, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %216, ptr align 8 %217, i64 24, i1 false), !tbaa.struct !28
  br label %218

218:                                              ; preds = %213, %204
  %219 = load i64, ptr %28, align 8, !tbaa !9
  %220 = add i64 %219, 1
  store i64 %220, ptr %28, align 8, !tbaa !9
  store i32 0, ptr %27, align 4
  br label %221

221:                                              ; preds = %218, %197
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #4
  %222 = load i32, ptr %27, align 4
  switch i32 %222, label %253 [
    i32 0, label %223
    i32 18, label %224
  ]

223:                                              ; preds = %221
  br label %224

224:                                              ; preds = %223, %221
  %225 = load i64, ptr %26, align 8, !tbaa !9
  %226 = add i64 %225, 1
  store i64 %226, ptr %26, align 8, !tbaa !9
  br label %166, !llvm.loop !29

227:                                              ; preds = %166
  %228 = load i64, ptr %28, align 8, !tbaa !9
  store i64 %228, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  store i64 0, ptr %26, align 8, !tbaa !9
  br label %229

229:                                              ; preds = %244, %227
  %230 = load i64, ptr %26, align 8, !tbaa !9
  %231 = load i64, ptr %15, align 8, !tbaa !9
  %232 = icmp ult i64 %230, %231
  br i1 %232, label %233, label %247

233:                                              ; preds = %229
  %234 = load ptr, ptr %10, align 8, !tbaa !5
  %235 = load ptr, ptr %11, align 8, !tbaa !5
  %236 = load i32, ptr %24, align 4, !tbaa !13
  %237 = load ptr, ptr %13, align 8, !tbaa !5
  %238 = load i64, ptr %26, align 8, !tbaa !9
  %239 = getelementptr inbounds i32, ptr %237, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !13
  %241 = load i64, ptr %18, align 8, !tbaa !9
  %242 = load ptr, ptr %14, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.HistogramPair, ptr %242, i64 0
  call void @BrotliCompareAndPushToQueueCommand(ptr noundef %234, ptr noundef %235, i32 noundef %236, i32 noundef %240, i64 noundef %241, ptr noundef %243, ptr noundef %21)
  br label %244

244:                                              ; preds = %233
  %245 = load i64, ptr %26, align 8, !tbaa !9
  %246 = add i64 %245, 1
  store i64 %246, ptr %26, align 8, !tbaa !9
  br label %229, !llvm.loop !30

247:                                              ; preds = %229
  store i32 0, ptr %27, align 4
  br label %248

248:                                              ; preds = %247, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  %249 = load i32, ptr %27, align 4
  switch i32 %249, label %253 [
    i32 0, label %250
    i32 8, label %64
  ]

250:                                              ; preds = %248
  br label %64, !llvm.loop !20

251:                                              ; preds = %64
  %252 = load i64, ptr %15, align 8, !tbaa !9
  store i32 1, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  ret i64 %252

253:                                              ; preds = %248, %221
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!19, !12, i64 16}
!19 = !{!"HistogramPair", !14, i64 0, !14, i64 4, !12, i64 8, !12, i64 16}
!20 = distinct !{!20, !16}
!21 = !{!19, !14, i64 0}
!22 = !{!19, !14, i64 4}
!23 = !{!19, !12, i64 8}
!24 = !{!25, !12, i64 2824}
!25 = !{!"HistogramCommand", !7, i64 0, !10, i64 2816, !12, i64 2824}
!26 = distinct !{!26, !16}
!27 = distinct !{!27, !16}
!28 = !{i64 0, i64 4, !13, i64 4, i64 4, !13, i64 8, i64 8, !11, i64 16, i64 8, !11}
!29 = distinct !{!29, !16}
!30 = distinct !{!30, !16}


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

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @HistogramPairIsLess(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
define hidden i64 @BrotliHistogramCombineCommand(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, i64 noundef %8) local_unnamed_addr #3 {
  %10 = alloca i64, align 8
  %11 = alloca %struct.HistogramPair, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  store i64 0, ptr %10, align 8, !tbaa !5
  %.not129 = icmp eq i64 %5, 0
  br i1 %.not129, label %._crit_edge127, label %.lr.ph113

.loopexit109:                                     ; preds = %18, %.lr.ph113
  %exitcond.not = icmp eq i64 %15, %5
  br i1 %exitcond.not, label %.preheader108, label %.lr.ph113, !llvm.loop !9

.preheader108:                                    ; preds = %.loopexit109
  %.not144 = icmp eq i64 %5, 1
  br i1 %.not144, label %._crit_edge127, label %.lr.ph126

.lr.ph126:                                        ; preds = %.preheader108
  %12 = getelementptr inbounds i8, ptr %4, i64 16
  %13 = getelementptr inbounds i8, ptr %4, i64 4
  %14 = getelementptr inbounds i8, ptr %4, i64 8
  %.not130 = icmp eq i64 %6, 0
  %min.iters.check = icmp ult i64 %6, 8
  %n.vec = and i64 %6, -8
  %cmp.n = icmp eq i64 %n.vec, %6
  br label %24

.lr.ph113:                                        ; preds = %9, %.loopexit109
  %.098112 = phi i64 [ %15, %.loopexit109 ], [ 0, %9 ]
  %15 = add nuw i64 %.098112, 1
  %16 = icmp ult i64 %15, %5
  br i1 %16, label %.lr.ph, label %.loopexit109

.lr.ph:                                           ; preds = %.lr.ph113
  %17 = getelementptr inbounds i32, ptr %3, i64 %.098112
  br label %18

18:                                               ; preds = %.lr.ph, %18
  %.097111 = phi i64 [ %15, %.lr.ph ], [ %22, %18 ]
  %19 = load i32, ptr %17, align 4, !tbaa !11
  %20 = getelementptr inbounds i32, ptr %3, i64 %.097111
  %21 = load i32, ptr %20, align 4, !tbaa !11
  call void @BrotliCompareAndPushToQueueCommand(ptr noundef %0, ptr noundef %1, i32 noundef %19, i32 noundef %21, i64 noundef %8, ptr noundef %4, ptr noundef nonnull %10)
  %22 = add nuw i64 %.097111, 1
  %23 = icmp ult i64 %22, %5
  br i1 %23, label %18, label %.loopexit109, !llvm.loop !13

24:                                               ; preds = %.lr.ph126, %.loopexit
  %.0125 = phi i64 [ %5, %.lr.ph126 ], [ %.1, %.loopexit ]
  %.093124 = phi double [ 0.000000e+00, %.lr.ph126 ], [ %.194, %.loopexit ]
  %.095123 = phi i64 [ 1, %.lr.ph126 ], [ %.196, %.loopexit ]
  %25 = load double, ptr %12, align 8, !tbaa !14
  %26 = fcmp ult double %25, %.093124
  br i1 %26, label %27, label %.loopexit, !llvm.loop !17

27:                                               ; preds = %24
  %28 = load i32, ptr %4, align 8, !tbaa !18
  %29 = load i32, ptr %13, align 4, !tbaa !19
  %30 = zext i32 %28 to i64
  %31 = getelementptr inbounds %struct.HistogramCommand, ptr %0, i64 %30
  %32 = zext i32 %29 to i64
  %33 = getelementptr inbounds %struct.HistogramCommand, ptr %0, i64 %32
  call void @HistogramAddHistogramCommand(ptr noundef %31, ptr noundef %33)
  %34 = load double, ptr %14, align 8, !tbaa !20
  %35 = getelementptr inbounds i8, ptr %31, i64 2824
  store double %34, ptr %35, align 8, !tbaa !21
  %36 = getelementptr inbounds i32, ptr %1, i64 %32
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = getelementptr inbounds i32, ptr %1, i64 %30
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = add i32 %39, %37
  store i32 %40, ptr %38, align 4, !tbaa !11
  br i1 %.not130, label %.preheader, label %.lr.ph115.preheader

.lr.ph115.preheader:                              ; preds = %27
  br i1 %min.iters.check, label %.lr.ph115.preheader161, label %vector.ph

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

vector.ph:                                        ; preds = %.lr.ph115.preheader
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %29, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %pred.store.continue160, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %pred.store.continue160 ]
  %41 = or disjoint i64 %index, 4
  %42 = getelementptr inbounds i32, ptr %2, i64 %index
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %wide.load = load <4 x i32>, ptr %42, align 4, !tbaa !11
  %wide.load146 = load <4 x i32>, ptr %43, align 4, !tbaa !11
  %44 = icmp eq <4 x i32> %wide.load, %broadcast.splat
  %45 = icmp eq <4 x i32> %wide.load146, %broadcast.splat
  %46 = extractelement <4 x i1> %44, i64 0
  br i1 %46, label %pred.store.if, label %pred.store.continue

pred.store.if:                                    ; preds = %vector.body
  %47 = getelementptr inbounds i32, ptr %2, i64 %index
  store i32 %28, ptr %47, align 4, !tbaa !11
  br label %pred.store.continue

pred.store.continue:                              ; preds = %pred.store.if, %vector.body
  %48 = extractelement <4 x i1> %44, i64 1
  br i1 %48, label %pred.store.if147, label %pred.store.continue148

pred.store.if147:                                 ; preds = %pred.store.continue
  %49 = or disjoint i64 %index, 1
  %50 = getelementptr inbounds i32, ptr %2, i64 %49
  store i32 %28, ptr %50, align 4, !tbaa !11
  br label %pred.store.continue148

pred.store.continue148:                           ; preds = %pred.store.if147, %pred.store.continue
  %51 = extractelement <4 x i1> %44, i64 2
  br i1 %51, label %pred.store.if149, label %pred.store.continue150

pred.store.if149:                                 ; preds = %pred.store.continue148
  %52 = or disjoint i64 %index, 2
  %53 = getelementptr inbounds i32, ptr %2, i64 %52
  store i32 %28, ptr %53, align 4, !tbaa !11
  br label %pred.store.continue150

pred.store.continue150:                           ; preds = %pred.store.if149, %pred.store.continue148
  %54 = extractelement <4 x i1> %44, i64 3
  br i1 %54, label %pred.store.if151, label %pred.store.continue152

pred.store.if151:                                 ; preds = %pred.store.continue150
  %55 = or disjoint i64 %index, 3
  %56 = getelementptr inbounds i32, ptr %2, i64 %55
  store i32 %28, ptr %56, align 4, !tbaa !11
  br label %pred.store.continue152

pred.store.continue152:                           ; preds = %pred.store.if151, %pred.store.continue150
  %57 = extractelement <4 x i1> %45, i64 0
  br i1 %57, label %pred.store.if153, label %pred.store.continue154

pred.store.if153:                                 ; preds = %pred.store.continue152
  %58 = getelementptr inbounds i32, ptr %2, i64 %41
  store i32 %28, ptr %58, align 4, !tbaa !11
  br label %pred.store.continue154

pred.store.continue154:                           ; preds = %pred.store.if153, %pred.store.continue152
  %59 = extractelement <4 x i1> %45, i64 1
  br i1 %59, label %pred.store.if155, label %pred.store.continue156

pred.store.if155:                                 ; preds = %pred.store.continue154
  %60 = or disjoint i64 %index, 5
  %61 = getelementptr inbounds i32, ptr %2, i64 %60
  store i32 %28, ptr %61, align 4, !tbaa !11
  br label %pred.store.continue156

pred.store.continue156:                           ; preds = %pred.store.if155, %pred.store.continue154
  %62 = extractelement <4 x i1> %45, i64 2
  br i1 %62, label %pred.store.if157, label %pred.store.continue158

pred.store.if157:                                 ; preds = %pred.store.continue156
  %63 = or disjoint i64 %index, 6
  %64 = getelementptr inbounds i32, ptr %2, i64 %63
  store i32 %28, ptr %64, align 4, !tbaa !11
  br label %pred.store.continue158

pred.store.continue158:                           ; preds = %pred.store.if157, %pred.store.continue156
  %65 = extractelement <4 x i1> %45, i64 3
  br i1 %65, label %pred.store.if159, label %pred.store.continue160

pred.store.if159:                                 ; preds = %pred.store.continue158
  %66 = or disjoint i64 %index, 7
  %67 = getelementptr inbounds i32, ptr %2, i64 %66
  store i32 %28, ptr %67, align 4, !tbaa !11
  br label %pred.store.continue160

pred.store.continue160:                           ; preds = %pred.store.if159, %pred.store.continue158
  %index.next = add nuw i64 %index, 8
  %68 = icmp eq i64 %index.next, %n.vec
  br i1 %68, label %middle.block, label %vector.body, !llvm.loop !23

middle.block:                                     ; preds = %pred.store.continue160
  br i1 %cmp.n, label %.preheader, label %.lr.ph115.preheader161

.preheader:                                       ; preds = %73, %middle.block, %27
  %umax = call i64 @llvm.umax.i64(i64 %.0125, i64 1)
  br label %75

.lr.ph115:                                        ; preds = %.lr.ph115.preheader161, %73
  %.091114 = phi i64 [ %74, %73 ], [ %.091114.ph, %.lr.ph115.preheader161 ]
  %69 = getelementptr inbounds i32, ptr %2, i64 %.091114
  %70 = load i32, ptr %69, align 4, !tbaa !11
  %71 = icmp eq i32 %70, %29
  br i1 %71, label %72, label %73

72:                                               ; preds = %.lr.ph115
  store i32 %28, ptr %69, align 4, !tbaa !11
  br label %73

73:                                               ; preds = %.lr.ph115, %72
  %74 = add nuw i64 %.091114, 1
  %exitcond134.not = icmp eq i64 %74, %6
  br i1 %exitcond134.not, label %.preheader, label %.lr.ph115, !llvm.loop !26

75:                                               ; preds = %.preheader, %85
  %.192116 = phi i64 [ 0, %.preheader ], [ %86, %85 ]
  %76 = getelementptr inbounds i32, ptr %3, i64 %.192116
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = icmp eq i32 %77, %29
  br i1 %78, label %79, label %85

79:                                               ; preds = %75
  %80 = getelementptr inbounds i32, ptr %3, i64 %.192116
  %81 = getelementptr i8, ptr %80, i64 4
  %82 = xor i64 %.192116, -1
  %83 = add i64 %.0125, %82
  %84 = shl i64 %83, 2
  call void @llvm.memmove.p0.p0.i64(ptr nonnull align 4 %80, ptr align 4 %81, i64 %84, i1 false)
  br label %.loopexit107

85:                                               ; preds = %75
  %86 = add nuw i64 %.192116, 1
  %exitcond135.not = icmp eq i64 %86, %umax
  br i1 %exitcond135.not, label %.loopexit107, label %75, !llvm.loop !27

.loopexit107:                                     ; preds = %85, %79
  %87 = add i64 %.0125, -1
  %88 = load i64, ptr %10, align 8, !tbaa !5
  %.not131 = icmp eq i64 %88, 0
  br i1 %.not131, label %._crit_edge, label %.lr.ph119

.lr.ph119:                                        ; preds = %.loopexit107, %107
  %89 = phi i64 [ %108, %107 ], [ %88, %.loopexit107 ]
  %.089118 = phi i64 [ %.190, %107 ], [ 0, %.loopexit107 ]
  %.2117 = phi i64 [ %109, %107 ], [ 0, %.loopexit107 ]
  %90 = getelementptr inbounds %struct.HistogramPair, ptr %4, i64 %.2117
  %91 = load i32, ptr %90, align 8, !tbaa !18
  %92 = icmp eq i32 %91, %28
  br i1 %92, label %107, label %93

93:                                               ; preds = %.lr.ph119
  %94 = getelementptr inbounds i8, ptr %90, i64 4
  %95 = load i32, ptr %94, align 4, !tbaa !19
  %96 = icmp eq i32 %95, %28
  %97 = icmp eq i32 %91, %29
  %or.cond = or i1 %97, %96
  %98 = icmp eq i32 %95, %29
  %or.cond106 = or i1 %98, %or.cond
  br i1 %or.cond106, label %107, label %99

99:                                               ; preds = %93
  %100 = call i32 @HistogramPairIsLess(ptr noundef nonnull %4, ptr noundef nonnull %90)
  %.not = icmp eq i32 %100, 0
  br i1 %.not, label %103, label %101

101:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !28
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %90, i64 24, i1 false), !tbaa.struct !28
  %102 = getelementptr inbounds %struct.HistogramPair, ptr %4, i64 %.089118
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %102, ptr noundef nonnull align 8 dereferenceable(24) %11, i64 24, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11)
  br label %105

103:                                              ; preds = %99
  %104 = getelementptr inbounds %struct.HistogramPair, ptr %4, i64 %.089118
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %104, ptr noundef nonnull align 8 dereferenceable(24) %90, i64 24, i1 false), !tbaa.struct !28
  br label %105

105:                                              ; preds = %103, %101
  %106 = add i64 %.089118, 1
  %.pre = load i64, ptr %10, align 8, !tbaa !5
  br label %107

107:                                              ; preds = %.lr.ph119, %93, %105
  %108 = phi i64 [ %.pre, %105 ], [ %89, %93 ], [ %89, %.lr.ph119 ]
  %.190 = phi i64 [ %106, %105 ], [ %.089118, %93 ], [ %.089118, %.lr.ph119 ]
  %109 = add nuw i64 %.2117, 1
  %110 = icmp ult i64 %109, %108
  br i1 %110, label %.lr.ph119, label %._crit_edge, !llvm.loop !30

._crit_edge:                                      ; preds = %107, %.loopexit107
  %.089.lcssa = phi i64 [ 0, %.loopexit107 ], [ %.190, %107 ]
  store i64 %.089.lcssa, ptr %10, align 8, !tbaa !5
  %.not132 = icmp eq i64 %87, 0
  br i1 %.not132, label %._crit_edge127, label %.lr.ph122

.lr.ph122:                                        ; preds = %._crit_edge, %.lr.ph122
  %.3120 = phi i64 [ %113, %.lr.ph122 ], [ 0, %._crit_edge ]
  %111 = getelementptr inbounds i32, ptr %3, i64 %.3120
  %112 = load i32, ptr %111, align 4, !tbaa !11
  call void @BrotliCompareAndPushToQueueCommand(ptr noundef %0, ptr noundef %1, i32 noundef %28, i32 noundef %112, i64 noundef %8, ptr noundef nonnull %4, ptr noundef nonnull %10)
  %113 = add nuw i64 %.3120, 1
  %exitcond136.not = icmp eq i64 %113, %87
  br i1 %exitcond136.not, label %.loopexit, label %.lr.ph122, !llvm.loop !31

.loopexit:                                        ; preds = %.lr.ph122, %24
  %.196 = phi i64 [ %7, %24 ], [ %.095123, %.lr.ph122 ]
  %.194 = phi double [ 0x547D42AEA2879F2E, %24 ], [ %.093124, %.lr.ph122 ]
  %.1 = phi i64 [ %.0125, %24 ], [ %87, %.lr.ph122 ]
  %114 = icmp ugt i64 %.1, %.196
  br i1 %114, label %24, label %._crit_edge127

._crit_edge127:                                   ; preds = %._crit_edge, %.loopexit, %9, %.preheader108
  %.0.lcssa = phi i64 [ %5, %.preheader108 ], [ 0, %9 ], [ 0, %._crit_edge ], [ %.1, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  ret i64 %.0.lcssa
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{!15, !16, i64 16}
!15 = !{!"HistogramPair", !12, i64 0, !12, i64 4, !16, i64 8, !16, i64 16}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = !{!15, !12, i64 0}
!19 = !{!15, !12, i64 4}
!20 = !{!15, !16, i64 8}
!21 = !{!22, !16, i64 2824}
!22 = !{!"HistogramCommand", !7, i64 0, !6, i64 2816, !16, i64 2824}
!23 = distinct !{!23, !10, !24, !25}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !10, !25, !24}
!27 = distinct !{!27, !10}
!28 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 8, !29, i64 16, i64 8, !29}
!29 = !{!16, !16, i64 0}
!30 = distinct !{!30, !10}
!31 = distinct !{!31, !10}


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