; LLVM IR from DanEngelbrecht/longtail :: lib/brotli/ext/dec (huffman)

; 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.HuffmanCode = type { i8, i16 }

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @ConstructHuffmanCode(i8 noundef zeroext, i16 noundef zeroext) #1

; 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) #2

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

; Function Attrs: nounwind uwtable
define hidden i32 @BrotliBuildSimpleHuffmanTable(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.HuffmanCode, align 2
  %12 = alloca %struct.HuffmanCode, align 2
  %13 = alloca %struct.HuffmanCode, align 2
  %14 = alloca %struct.HuffmanCode, align 2
  %15 = alloca %struct.HuffmanCode, align 2
  %16 = alloca %struct.HuffmanCode, align 2
  %17 = alloca %struct.HuffmanCode, align 2
  %18 = alloca %struct.HuffmanCode, align 2
  %19 = alloca %struct.HuffmanCode, align 2
  %20 = alloca %struct.HuffmanCode, align 2
  %21 = alloca %struct.HuffmanCode, align 2
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i16, align 2
  %25 = alloca %struct.HuffmanCode, align 2
  %26 = alloca %struct.HuffmanCode, align 2
  %27 = alloca %struct.HuffmanCode, align 2
  %28 = alloca %struct.HuffmanCode, align 2
  %29 = alloca i16, align 2
  %30 = alloca %struct.HuffmanCode, align 2
  %31 = alloca %struct.HuffmanCode, align 2
  %32 = alloca %struct.HuffmanCode, align 2
  %33 = alloca %struct.HuffmanCode, align 2
  %34 = alloca %struct.HuffmanCode, align 2
  %35 = alloca %struct.HuffmanCode, align 2
  %36 = alloca %struct.HuffmanCode, align 2
  %37 = alloca %struct.HuffmanCode, align 2
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = shl i32 1, %38
  store i32 %39, ptr %10, align 4, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %40, label %282 [
    i32 0, label %41
    i32 1, label %48
    i32 2, label %85
    i32 3, label %134
    i32 4, label %211
  ]

41:                                               ; preds = %4
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.HuffmanCode, ptr %42, i64 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds i16, ptr %44, i64 0
  %46 = load i16, ptr %45, align 2, !tbaa !11
  %47 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 0, i16 noundef zeroext %46)
  store i32 %47, ptr %11, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %43, ptr align 2 %11, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %282

48:                                               ; preds = %4
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds i16, ptr %49, i64 1
  %51 = load i16, ptr %50, align 2, !tbaa !11
  %52 = zext i16 %51 to i32
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds i16, ptr %53, i64 0
  %55 = load i16, ptr %54, align 2, !tbaa !11
  %56 = zext i16 %55 to i32
  %57 = icmp sgt i32 %52, %56
  br i1 %57, label %58, label %71

58:                                               ; preds = %48
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.HuffmanCode, ptr %59, i64 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds i16, ptr %61, i64 0
  %63 = load i16, ptr %62, align 2, !tbaa !11
  %64 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %63)
  store i32 %64, ptr %12, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %60, ptr align 2 %12, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.HuffmanCode, ptr %65, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds i16, ptr %67, i64 1
  %69 = load i16, ptr %68, align 2, !tbaa !11
  %70 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %69)
  store i32 %70, ptr %13, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %66, ptr align 2 %13, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %84

71:                                               ; preds = %48
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.HuffmanCode, ptr %72, i64 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds i16, ptr %74, i64 1
  %76 = load i16, ptr %75, align 2, !tbaa !11
  %77 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %76)
  store i32 %77, ptr %14, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %73, ptr align 2 %14, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.HuffmanCode, ptr %78, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds i16, ptr %80, i64 0
  %82 = load i16, ptr %81, align 2, !tbaa !11
  %83 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %82)
  store i32 %83, ptr %15, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %79, ptr align 2 %15, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %84

84:                                               ; preds = %71, %58
  store i32 2, ptr %9, align 4, !tbaa !9
  br label %282

85:                                               ; preds = %4
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.HuffmanCode, ptr %86, i64 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds i16, ptr %88, i64 0
  %90 = load i16, ptr %89, align 2, !tbaa !11
  %91 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %90)
  store i32 %91, ptr %16, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %87, ptr align 2 %16, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.HuffmanCode, ptr %92, i64 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds i16, ptr %94, i64 0
  %96 = load i16, ptr %95, align 2, !tbaa !11
  %97 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %96)
  store i32 %97, ptr %17, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %93, ptr align 2 %17, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds i16, ptr %98, i64 2
  %100 = load i16, ptr %99, align 2, !tbaa !11
  %101 = zext i16 %100 to i32
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = getelementptr inbounds i16, ptr %102, i64 1
  %104 = load i16, ptr %103, align 2, !tbaa !11
  %105 = zext i16 %104 to i32
  %106 = icmp sgt i32 %101, %105
  br i1 %106, label %107, label %120

107:                                              ; preds = %85
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.HuffmanCode, ptr %108, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds i16, ptr %110, i64 1
  %112 = load i16, ptr %111, align 2, !tbaa !11
  %113 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %112)
  store i32 %113, ptr %18, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %109, ptr align 2 %18, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.HuffmanCode, ptr %114, i64 3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  %117 = getelementptr inbounds i16, ptr %116, i64 2
  %118 = load i16, ptr %117, align 2, !tbaa !11
  %119 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %118)
  store i32 %119, ptr %19, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %115, ptr align 2 %19, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %133

120:                                              ; preds = %85
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.HuffmanCode, ptr %121, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds i16, ptr %123, i64 2
  %125 = load i16, ptr %124, align 2, !tbaa !11
  %126 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %125)
  store i32 %126, ptr %20, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %122, ptr align 2 %20, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.HuffmanCode, ptr %127, i64 3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = getelementptr inbounds i16, ptr %129, i64 1
  %131 = load i16, ptr %130, align 2, !tbaa !11
  %132 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %131)
  store i32 %132, ptr %21, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %128, ptr align 2 %21, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %133

133:                                              ; preds = %120, %107
  store i32 4, ptr %9, align 4, !tbaa !9
  br label %282

134:                                              ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %135

135:                                              ; preds = %183, %134
  %136 = load i32, ptr %22, align 4, !tbaa !9
  %137 = icmp slt i32 %136, 3
  br i1 %137, label %138, label %186

138:                                              ; preds = %135
  %139 = load i32, ptr %22, align 4, !tbaa !9
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %23, align 4, !tbaa !9
  br label %141

141:                                              ; preds = %179, %138
  %142 = load i32, ptr %23, align 4, !tbaa !9
  %143 = icmp slt i32 %142, 4
  br i1 %143, label %144, label %182

144:                                              ; preds = %141
  %145 = load ptr, ptr %7, align 8, !tbaa !5
  %146 = load i32, ptr %23, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i16, ptr %145, i64 %147
  %149 = load i16, ptr %148, align 2, !tbaa !11
  %150 = zext i16 %149 to i32
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  %152 = load i32, ptr %22, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds i16, ptr %151, i64 %153
  %155 = load i16, ptr %154, align 2, !tbaa !11
  %156 = zext i16 %155 to i32
  %157 = icmp slt i32 %150, %156
  br i1 %157, label %158, label %178

158:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 2, ptr %24) #4
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = load i32, ptr %23, align 4, !tbaa !9
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds i16, ptr %159, i64 %161
  %163 = load i16, ptr %162, align 2, !tbaa !11
  store i16 %163, ptr %24, align 2, !tbaa !11
  %164 = load ptr, ptr %7, align 8, !tbaa !5
  %165 = load i32, ptr %22, align 4, !tbaa !9
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i16, ptr %164, i64 %166
  %168 = load i16, ptr %167, align 2, !tbaa !11
  %169 = load ptr, ptr %7, align 8, !tbaa !5
  %170 = load i32, ptr %23, align 4, !tbaa !9
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds i16, ptr %169, i64 %171
  store i16 %168, ptr %172, align 2, !tbaa !11
  %173 = load i16, ptr %24, align 2, !tbaa !11
  %174 = load ptr, ptr %7, align 8, !tbaa !5
  %175 = load i32, ptr %22, align 4, !tbaa !9
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds i16, ptr %174, i64 %176
  store i16 %173, ptr %177, align 2, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 2, ptr %24) #4
  br label %178

178:                                              ; preds = %158, %144
  br label %179

179:                                              ; preds = %178
  %180 = load i32, ptr %23, align 4, !tbaa !9
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %23, align 4, !tbaa !9
  br label %141, !llvm.loop !15

182:                                              ; preds = %141
  br label %183

183:                                              ; preds = %182
  %184 = load i32, ptr %22, align 4, !tbaa !9
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %22, align 4, !tbaa !9
  br label %135, !llvm.loop !17

186:                                              ; preds = %135
  %187 = load ptr, ptr %5, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.HuffmanCode, ptr %187, i64 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  %189 = load ptr, ptr %7, align 8, !tbaa !5
  %190 = getelementptr inbounds i16, ptr %189, i64 0
  %191 = load i16, ptr %190, align 2, !tbaa !11
  %192 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %191)
  store i32 %192, ptr %25, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %188, ptr align 2 %25, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.HuffmanCode, ptr %193, i64 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #4
  %195 = load ptr, ptr %7, align 8, !tbaa !5
  %196 = getelementptr inbounds i16, ptr %195, i64 1
  %197 = load i16, ptr %196, align 2, !tbaa !11
  %198 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %197)
  store i32 %198, ptr %26, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %194, ptr align 2 %26, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #4
  %199 = load ptr, ptr %5, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.HuffmanCode, ptr %199, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #4
  %201 = load ptr, ptr %7, align 8, !tbaa !5
  %202 = getelementptr inbounds i16, ptr %201, i64 2
  %203 = load i16, ptr %202, align 2, !tbaa !11
  %204 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %203)
  store i32 %204, ptr %27, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %200, ptr align 2 %27, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #4
  %205 = load ptr, ptr %5, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.HuffmanCode, ptr %205, i64 3
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #4
  %207 = load ptr, ptr %7, align 8, !tbaa !5
  %208 = getelementptr inbounds i16, ptr %207, i64 3
  %209 = load i16, ptr %208, align 2, !tbaa !11
  %210 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %209)
  store i32 %210, ptr %28, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %206, ptr align 2 %28, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #4
  store i32 4, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br label %282

211:                                              ; preds = %4
  %212 = load ptr, ptr %7, align 8, !tbaa !5
  %213 = getelementptr inbounds i16, ptr %212, i64 3
  %214 = load i16, ptr %213, align 2, !tbaa !11
  %215 = zext i16 %214 to i32
  %216 = load ptr, ptr %7, align 8, !tbaa !5
  %217 = getelementptr inbounds i16, ptr %216, i64 2
  %218 = load i16, ptr %217, align 2, !tbaa !11
  %219 = zext i16 %218 to i32
  %220 = icmp slt i32 %215, %219
  br i1 %220, label %221, label %233

221:                                              ; preds = %211
  call void @llvm.lifetime.start.p0(i64 2, ptr %29) #4
  %222 = load ptr, ptr %7, align 8, !tbaa !5
  %223 = getelementptr inbounds i16, ptr %222, i64 3
  %224 = load i16, ptr %223, align 2, !tbaa !11
  store i16 %224, ptr %29, align 2, !tbaa !11
  %225 = load ptr, ptr %7, align 8, !tbaa !5
  %226 = getelementptr inbounds i16, ptr %225, i64 2
  %227 = load i16, ptr %226, align 2, !tbaa !11
  %228 = load ptr, ptr %7, align 8, !tbaa !5
  %229 = getelementptr inbounds i16, ptr %228, i64 3
  store i16 %227, ptr %229, align 2, !tbaa !11
  %230 = load i16, ptr %29, align 2, !tbaa !11
  %231 = load ptr, ptr %7, align 8, !tbaa !5
  %232 = getelementptr inbounds i16, ptr %231, i64 2
  store i16 %230, ptr %232, align 2, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 2, ptr %29) #4
  br label %233

233:                                              ; preds = %221, %211
  %234 = load ptr, ptr %5, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.HuffmanCode, ptr %234, i64 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #4
  %236 = load ptr, ptr %7, align 8, !tbaa !5
  %237 = getelementptr inbounds i16, ptr %236, i64 0
  %238 = load i16, ptr %237, align 2, !tbaa !11
  %239 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %238)
  store i32 %239, ptr %30, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %235, ptr align 2 %30, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #4
  %240 = load ptr, ptr %5, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.HuffmanCode, ptr %240, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #4
  %242 = load ptr, ptr %7, align 8, !tbaa !5
  %243 = getelementptr inbounds i16, ptr %242, i64 1
  %244 = load i16, ptr %243, align 2, !tbaa !11
  %245 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %244)
  store i32 %245, ptr %31, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %241, ptr align 2 %31, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #4
  %246 = load ptr, ptr %5, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.HuffmanCode, ptr %246, i64 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #4
  %248 = load ptr, ptr %7, align 8, !tbaa !5
  %249 = getelementptr inbounds i16, ptr %248, i64 0
  %250 = load i16, ptr %249, align 2, !tbaa !11
  %251 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %250)
  store i32 %251, ptr %32, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %247, ptr align 2 %32, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #4
  %252 = load ptr, ptr %5, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.HuffmanCode, ptr %252, i64 3
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #4
  %254 = load ptr, ptr %7, align 8, !tbaa !5
  %255 = getelementptr inbounds i16, ptr %254, i64 2
  %256 = load i16, ptr %255, align 2, !tbaa !11
  %257 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 3, i16 noundef zeroext %256)
  store i32 %257, ptr %33, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %253, ptr align 2 %33, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #4
  %258 = load ptr, ptr %5, align 8, !tbaa !5
  %259 = getelementptr inbounds %struct.HuffmanCode, ptr %258, i64 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #4
  %260 = load ptr, ptr %7, align 8, !tbaa !5
  %261 = getelementptr inbounds i16, ptr %260, i64 0
  %262 = load i16, ptr %261, align 2, !tbaa !11
  %263 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %262)
  store i32 %263, ptr %34, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %259, ptr align 2 %34, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #4
  %264 = load ptr, ptr %5, align 8, !tbaa !5
  %265 = getelementptr inbounds %struct.HuffmanCode, ptr %264, i64 5
  call void @llvm.lifetime.start.p0(i64 4, ptr %35) #4
  %266 = load ptr, ptr %7, align 8, !tbaa !5
  %267 = getelementptr inbounds i16, ptr %266, i64 1
  %268 = load i16, ptr %267, align 2, !tbaa !11
  %269 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %268)
  store i32 %269, ptr %35, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %265, ptr align 2 %35, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #4
  %270 = load ptr, ptr %5, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.HuffmanCode, ptr %270, i64 6
  call void @llvm.lifetime.start.p0(i64 4, ptr %36) #4
  %272 = load ptr, ptr %7, align 8, !tbaa !5
  %273 = getelementptr inbounds i16, ptr %272, i64 0
  %274 = load i16, ptr %273, align 2, !tbaa !11
  %275 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %274)
  store i32 %275, ptr %36, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %271, ptr align 2 %36, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %36) #4
  %276 = load ptr, ptr %5, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.HuffmanCode, ptr %276, i64 7
  call void @llvm.lifetime.start.p0(i64 4, ptr %37) #4
  %278 = load ptr, ptr %7, align 8, !tbaa !5
  %279 = getelementptr inbounds i16, ptr %278, i64 3
  %280 = load i16, ptr %279, align 2, !tbaa !11
  %281 = call i32 @ConstructHuffmanCode(i8 noundef zeroext 3, i16 noundef zeroext %280)
  store i32 %281, ptr %37, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %277, ptr align 2 %37, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %37) #4
  store i32 8, ptr %9, align 4, !tbaa !9
  br label %282

282:                                              ; preds = %233, %186, %133, %84, %41, %4
  br label %283

283:                                              ; preds = %287, %282
  %284 = load i32, ptr %9, align 4, !tbaa !9
  %285 = load i32, ptr %10, align 4, !tbaa !9
  %286 = icmp ne i32 %284, %285
  br i1 %286, label %287, label %299

287:                                              ; preds = %283
  %288 = load ptr, ptr %5, align 8, !tbaa !5
  %289 = load i32, ptr %9, align 4, !tbaa !9
  %290 = zext i32 %289 to i64
  %291 = getelementptr inbounds %struct.HuffmanCode, ptr %288, i64 %290
  %292 = load ptr, ptr %5, align 8, !tbaa !5
  %293 = getelementptr inbounds %struct.HuffmanCode, ptr %292, i64 0
  %294 = load i32, ptr %9, align 4, !tbaa !9
  %295 = zext i32 %294 to i64
  %296 = mul i64 %295, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %291, ptr align 2 %293, i64 %296, i1 false)
  %297 = load i32, ptr %9, align 4, !tbaa !9
  %298 = shl i32 %297, 1
  store i32 %298, ptr %9, align 4, !tbaa !9
  br label %283, !llvm.loop !18

299:                                              ; preds = %283
  %300 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret i32 %300
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{i64 0, i64 1, !14, i64 2, i64 2, !11}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !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.HuffmanCode = type { i8, i16 }

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @ConstructHuffmanCode(i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #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: nounwind uwtable
define hidden i32 @BrotliBuildSimpleHuffmanTable(ptr nocapture noundef %0, i32 noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = shl nuw i32 1, %1
  switch i32 %3, label %112 [
    i32 0, label %.sink.split
    i32 1, label %6
    i32 2, label %16
    i32 3, label %.lr.ph
    i32 4, label %80
  ]

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %2, i64 2
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %9 = load i16, ptr %2, align 2, !tbaa !5
  %10 = icmp ugt i16 %8, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  br i1 %10, label %12, label %14

12:                                               ; preds = %6
  %13 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %9)
  store i32 %13, ptr %0, align 2
  br label %.sink.split

14:                                               ; preds = %6
  %15 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %8)
  store i32 %15, ptr %0, align 2
  br label %.sink.split

16:                                               ; preds = %4
  %17 = load i16, ptr %2, align 2, !tbaa !5
  %18 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %17)
  store i32 %18, ptr %0, align 2
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i16, ptr %2, align 2, !tbaa !5
  %21 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %20)
  store i32 %21, ptr %19, align 2
  %22 = getelementptr inbounds i8, ptr %2, i64 4
  %23 = load i16, ptr %22, align 2, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %2, i64 2
  %25 = load i16, ptr %24, align 2, !tbaa !5
  %26 = icmp ugt i16 %23, %25
  %27 = getelementptr inbounds i8, ptr %0, i64 4
  %28 = getelementptr inbounds i8, ptr %0, i64 12
  br i1 %26, label %29, label %31

29:                                               ; preds = %16
  %30 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %25)
  store i32 %30, ptr %27, align 2
  br label %.sink.split

31:                                               ; preds = %16
  %32 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %23)
  store i32 %32, ptr %27, align 2
  br label %.sink.split

.lr.ph.1:                                         ; preds = %79, %74
  %33 = getelementptr inbounds i8, ptr %2, i64 2
  %34 = getelementptr inbounds i8, ptr %2, i64 4
  %35 = load i16, ptr %34, align 2, !tbaa !5
  %36 = load i16, ptr %33, align 2, !tbaa !5
  %37 = icmp ult i16 %35, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %.lr.ph.1
  store i16 %36, ptr %34, align 2, !tbaa !5
  store i16 %35, ptr %33, align 2, !tbaa !5
  br label %39

39:                                               ; preds = %38, %.lr.ph.1
  %40 = phi i16 [ %35, %38 ], [ %36, %.lr.ph.1 ]
  %41 = getelementptr inbounds i8, ptr %2, i64 6
  %42 = load i16, ptr %41, align 2, !tbaa !5
  %43 = icmp ult i16 %42, %40
  br i1 %43, label %44, label %.lr.ph.2

44:                                               ; preds = %39
  store i16 %40, ptr %41, align 2, !tbaa !5
  store i16 %42, ptr %33, align 2, !tbaa !5
  br label %.lr.ph.2

.lr.ph.2:                                         ; preds = %44, %39
  %45 = getelementptr inbounds i8, ptr %2, i64 4
  %46 = getelementptr inbounds i8, ptr %2, i64 6
  %47 = load i16, ptr %46, align 2, !tbaa !5
  %48 = load i16, ptr %45, align 2, !tbaa !5
  %49 = icmp ult i16 %47, %48
  br i1 %49, label %50, label %.loopexit.2

50:                                               ; preds = %.lr.ph.2
  store i16 %48, ptr %46, align 2, !tbaa !5
  store i16 %47, ptr %45, align 2, !tbaa !5
  br label %.loopexit.2

.loopexit.2:                                      ; preds = %.lr.ph.2, %50
  %51 = load i16, ptr %2, align 2, !tbaa !5
  %52 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %51)
  store i32 %52, ptr %0, align 2
  %53 = getelementptr inbounds i8, ptr %0, i64 8
  %54 = getelementptr inbounds i8, ptr %2, i64 2
  %55 = load i16, ptr %54, align 2, !tbaa !5
  %56 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %55)
  store i32 %56, ptr %53, align 2
  %57 = getelementptr inbounds i8, ptr %0, i64 4
  %58 = getelementptr inbounds i8, ptr %2, i64 4
  %59 = load i16, ptr %58, align 2, !tbaa !5
  %60 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %59)
  store i32 %60, ptr %57, align 2
  %61 = getelementptr inbounds i8, ptr %0, i64 12
  %62 = getelementptr inbounds i8, ptr %2, i64 6
  br label %.sink.split

.lr.ph:                                           ; preds = %4
  %63 = getelementptr inbounds i8, ptr %2, i64 2
  %64 = load i16, ptr %63, align 2, !tbaa !5
  %65 = load i16, ptr %2, align 2, !tbaa !5
  %66 = icmp ult i16 %64, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %.lr.ph
  store i16 %65, ptr %63, align 2, !tbaa !5
  store i16 %64, ptr %2, align 2, !tbaa !5
  br label %68

68:                                               ; preds = %.lr.ph, %67
  %69 = phi i16 [ %65, %.lr.ph ], [ %64, %67 ]
  %70 = getelementptr inbounds i8, ptr %2, i64 4
  %71 = load i16, ptr %70, align 2, !tbaa !5
  %72 = icmp ult i16 %71, %69
  br i1 %72, label %73, label %74

73:                                               ; preds = %68
  store i16 %69, ptr %70, align 2, !tbaa !5
  store i16 %71, ptr %2, align 2, !tbaa !5
  br label %74

74:                                               ; preds = %73, %68
  %75 = phi i16 [ %71, %73 ], [ %69, %68 ]
  %76 = getelementptr inbounds i8, ptr %2, i64 6
  %77 = load i16, ptr %76, align 2, !tbaa !5
  %78 = icmp ult i16 %77, %75
  br i1 %78, label %79, label %.lr.ph.1

79:                                               ; preds = %74
  store i16 %75, ptr %76, align 2, !tbaa !5
  store i16 %77, ptr %2, align 2, !tbaa !5
  br label %.lr.ph.1

80:                                               ; preds = %4
  %81 = getelementptr inbounds i8, ptr %2, i64 6
  %82 = load i16, ptr %81, align 2, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %2, i64 4
  %84 = load i16, ptr %83, align 2, !tbaa !5
  %85 = icmp ult i16 %82, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %80
  store i16 %84, ptr %81, align 2, !tbaa !5
  store i16 %82, ptr %83, align 2, !tbaa !5
  br label %87

87:                                               ; preds = %86, %80
  %88 = load i16, ptr %2, align 2, !tbaa !5
  %89 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %88)
  store i32 %89, ptr %0, align 2
  %90 = getelementptr inbounds i8, ptr %0, i64 4
  %91 = getelementptr inbounds i8, ptr %2, i64 2
  %92 = load i16, ptr %91, align 2, !tbaa !5
  %93 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %92)
  store i32 %93, ptr %90, align 2
  %94 = getelementptr inbounds i8, ptr %0, i64 8
  %95 = load i16, ptr %2, align 2, !tbaa !5
  %96 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %95)
  store i32 %96, ptr %94, align 2
  %97 = getelementptr inbounds i8, ptr %0, i64 12
  %98 = load i16, ptr %83, align 2, !tbaa !5
  %99 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 3, i16 noundef zeroext %98)
  store i32 %99, ptr %97, align 2
  %100 = getelementptr inbounds i8, ptr %0, i64 16
  %101 = load i16, ptr %2, align 2, !tbaa !5
  %102 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %101)
  store i32 %102, ptr %100, align 2
  %103 = getelementptr inbounds i8, ptr %0, i64 20
  %104 = load i16, ptr %91, align 2, !tbaa !5
  %105 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 2, i16 noundef zeroext %104)
  store i32 %105, ptr %103, align 2
  %106 = getelementptr inbounds i8, ptr %0, i64 24
  %107 = load i16, ptr %2, align 2, !tbaa !5
  %108 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext 1, i16 noundef zeroext %107)
  store i32 %108, ptr %106, align 2
  %109 = getelementptr inbounds i8, ptr %0, i64 28
  br label %.sink.split

.sink.split:                                      ; preds = %4, %.loopexit.2, %87, %14, %12, %31, %29
  %.sink = phi ptr [ %22, %29 ], [ %24, %31 ], [ %7, %12 ], [ %2, %14 ], [ %81, %87 ], [ %62, %.loopexit.2 ], [ %2, %4 ]
  %.sink122 = phi i8 [ 2, %29 ], [ 2, %31 ], [ 1, %12 ], [ 1, %14 ], [ 3, %87 ], [ 2, %.loopexit.2 ], [ 0, %4 ]
  %.sink121 = phi ptr [ %28, %29 ], [ %28, %31 ], [ %11, %12 ], [ %11, %14 ], [ %109, %87 ], [ %61, %.loopexit.2 ], [ %0, %4 ]
  %.0.ph = phi i32 [ 4, %29 ], [ 4, %31 ], [ 2, %12 ], [ 2, %14 ], [ 8, %87 ], [ 4, %.loopexit.2 ], [ 1, %4 ]
  %110 = load i16, ptr %.sink, align 2, !tbaa !5
  %111 = tail call i32 @ConstructHuffmanCode(i8 noundef zeroext %.sink122, i16 noundef zeroext %110)
  store i32 %111, ptr %.sink121, align 2
  br label %112

112:                                              ; preds = %.sink.split, %4
  %.0 = phi i32 [ 1, %4 ], [ %.0.ph, %.sink.split ]
  %.not111 = icmp eq i32 %.0, %5
  br i1 %.not111, label %._crit_edge, label %.lr.ph113

.lr.ph113:                                        ; preds = %112, %.lr.ph113
  %.1112 = phi i32 [ %116, %.lr.ph113 ], [ %.0, %112 ]
  %113 = zext i32 %.1112 to i64
  %114 = getelementptr inbounds %struct.HuffmanCode, ptr %0, i64 %113
  %115 = shl nuw nsw i64 %113, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 2 %114, ptr align 2 %0, i64 %115, i1 false)
  %116 = shl i32 %.1112, 1
  %.not = icmp eq i32 %116, %5
  br i1 %.not, label %._crit_edge, label %.lr.ph113, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph113, %112
  ret i32 %5
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass