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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.HuffmanTree = type { i32, i16, i16 }

; Function Attrs: nounwind uwtable
declare hidden i32 @BrotliSetDepth(i32 noundef, ptr noundef, ptr noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define hidden void @BrotliCreateHuffmanTree(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.HuffmanTree, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @InitHuffmanTree(ptr noundef %12, i32 noundef -1, i16 noundef signext -1, i16 noundef signext -1)
  store i32 1, ptr %11, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %173, %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %23 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %23, ptr %14, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %49, %22
  %25 = load i64, ptr %14, align 8, !tbaa !9
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %50

27:                                               ; preds = %24
  %28 = load i64, ptr %14, align 8, !tbaa !9
  %29 = add i64 %28, -1
  store i64 %29, ptr %14, align 8, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i64, ptr %14, align 8, !tbaa !9
  %32 = getelementptr inbounds i32, ptr %30, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %49

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i64, ptr %14, align 8, !tbaa !9
  %38 = getelementptr inbounds i32, ptr %36, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = load i32, ptr %11, align 4, !tbaa !11
  %41 = call i32 @brotli_max_uint32_t(i32 noundef %39, i32 noundef %40)
  store i32 %41, ptr %17, align 4, !tbaa !11
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i64, ptr %13, align 8, !tbaa !9
  %44 = add i64 %43, 1
  store i64 %44, ptr %13, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.HuffmanTree, ptr %42, i64 %43
  %46 = load i32, ptr %17, align 4, !tbaa !11
  %47 = load i64, ptr %14, align 8, !tbaa !9
  %48 = trunc i64 %47 to i16
  call void @InitHuffmanTree(ptr noundef %45, i32 noundef %46, i16 noundef signext -1, i16 noundef signext %48)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %49

49:                                               ; preds = %35, %27
  br label %24, !llvm.loop !13

50:                                               ; preds = %24
  %51 = load i64, ptr %13, align 8, !tbaa !9
  %52 = icmp eq i64 %51, 1
  br i1 %52, label %53, label %61

53:                                               ; preds = %50
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.HuffmanTree, ptr %55, i64 0
  %57 = getelementptr inbounds %struct.HuffmanTree, ptr %56, i32 0, i32 2
  %58 = load i16, ptr %57, align 2, !tbaa !15
  %59 = sext i16 %58 to i64
  %60 = getelementptr inbounds i8, ptr %54, i64 %59
  store i8 1, ptr %60, align 1, !tbaa !18
  store i32 2, ptr %18, align 4
  br label %170

61:                                               ; preds = %50
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load i64, ptr %13, align 8, !tbaa !9
  call void @SortHuffmanTreeItems(ptr noundef %62, i64 noundef %63, ptr noundef @SortHuffmanTree)
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load i64, ptr %13, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.HuffmanTree, ptr %64, i64 %65
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %66, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !19
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load i64, ptr %13, align 8, !tbaa !9
  %69 = add i64 %68, 1
  %70 = getelementptr inbounds %struct.HuffmanTree, ptr %67, i64 %69
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %70, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !19
  store i64 0, ptr %14, align 8, !tbaa !9
  %71 = load i64, ptr %13, align 8, !tbaa !9
  %72 = add i64 %71, 1
  store i64 %72, ptr %15, align 8, !tbaa !9
  %73 = load i64, ptr %13, align 8, !tbaa !9
  %74 = sub i64 %73, 1
  store i64 %74, ptr %16, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %154, %61
  %76 = load i64, ptr %16, align 8, !tbaa !9
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %157

78:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load i64, ptr %14, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.HuffmanTree, ptr %79, i64 %80
  %82 = getelementptr inbounds %struct.HuffmanTree, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 4, !tbaa !21
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = load i64, ptr %15, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.HuffmanTree, ptr %84, i64 %85
  %87 = getelementptr inbounds %struct.HuffmanTree, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !21
  %89 = icmp ule i32 %83, %88
  br i1 %89, label %90, label %94

90:                                               ; preds = %78
  %91 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %91, ptr %19, align 8, !tbaa !9
  %92 = load i64, ptr %14, align 8, !tbaa !9
  %93 = add i64 %92, 1
  store i64 %93, ptr %14, align 8, !tbaa !9
  br label %98

94:                                               ; preds = %78
  %95 = load i64, ptr %15, align 8, !tbaa !9
  store i64 %95, ptr %19, align 8, !tbaa !9
  %96 = load i64, ptr %15, align 8, !tbaa !9
  %97 = add i64 %96, 1
  store i64 %97, ptr %15, align 8, !tbaa !9
  br label %98

98:                                               ; preds = %94, %90
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = load i64, ptr %14, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.HuffmanTree, ptr %99, i64 %100
  %102 = getelementptr inbounds %struct.HuffmanTree, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 4, !tbaa !21
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = load i64, ptr %15, align 8, !tbaa !9
  %106 = getelementptr inbounds %struct.HuffmanTree, ptr %104, i64 %105
  %107 = getelementptr inbounds %struct.HuffmanTree, ptr %106, i32 0, i32 0
  %108 = load i32, ptr %107, align 4, !tbaa !21
  %109 = icmp ule i32 %103, %108
  br i1 %109, label %110, label %114

110:                                              ; preds = %98
  %111 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %111, ptr %20, align 8, !tbaa !9
  %112 = load i64, ptr %14, align 8, !tbaa !9
  %113 = add i64 %112, 1
  store i64 %113, ptr %14, align 8, !tbaa !9
  br label %118

114:                                              ; preds = %98
  %115 = load i64, ptr %15, align 8, !tbaa !9
  store i64 %115, ptr %20, align 8, !tbaa !9
  %116 = load i64, ptr %15, align 8, !tbaa !9
  %117 = add i64 %116, 1
  store i64 %117, ptr %15, align 8, !tbaa !9
  br label %118

118:                                              ; preds = %114, %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %119 = load i64, ptr %13, align 8, !tbaa !9
  %120 = mul i64 2, %119
  %121 = load i64, ptr %16, align 8, !tbaa !9
  %122 = sub i64 %120, %121
  store i64 %122, ptr %21, align 8, !tbaa !9
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = load i64, ptr %19, align 8, !tbaa !9
  %125 = getelementptr inbounds %struct.HuffmanTree, ptr %123, i64 %124
  %126 = getelementptr inbounds %struct.HuffmanTree, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 4, !tbaa !21
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  %129 = load i64, ptr %20, align 8, !tbaa !9
  %130 = getelementptr inbounds %struct.HuffmanTree, ptr %128, i64 %129
  %131 = getelementptr inbounds %struct.HuffmanTree, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 4, !tbaa !21
  %133 = add i32 %127, %132
  %134 = load ptr, ptr %9, align 8, !tbaa !5
  %135 = load i64, ptr %21, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.HuffmanTree, ptr %134, i64 %135
  %137 = getelementptr inbounds %struct.HuffmanTree, ptr %136, i32 0, i32 0
  store i32 %133, ptr %137, align 4, !tbaa !21
  %138 = load i64, ptr %19, align 8, !tbaa !9
  %139 = trunc i64 %138 to i16
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = load i64, ptr %21, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct.HuffmanTree, ptr %140, i64 %141
  %143 = getelementptr inbounds %struct.HuffmanTree, ptr %142, i32 0, i32 1
  store i16 %139, ptr %143, align 4, !tbaa !22
  %144 = load i64, ptr %20, align 8, !tbaa !9
  %145 = trunc i64 %144 to i16
  %146 = load ptr, ptr %9, align 8, !tbaa !5
  %147 = load i64, ptr %21, align 8, !tbaa !9
  %148 = getelementptr inbounds %struct.HuffmanTree, ptr %146, i64 %147
  %149 = getelementptr inbounds %struct.HuffmanTree, ptr %148, i32 0, i32 2
  store i16 %145, ptr %149, align 2, !tbaa !15
  %150 = load ptr, ptr %9, align 8, !tbaa !5
  %151 = load i64, ptr %21, align 8, !tbaa !9
  %152 = add i64 %151, 1
  %153 = getelementptr inbounds %struct.HuffmanTree, ptr %150, i64 %152
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %153, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !19
  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
  br label %154

154:                                              ; preds = %118
  %155 = load i64, ptr %16, align 8, !tbaa !9
  %156 = add i64 %155, -1
  store i64 %156, ptr %16, align 8, !tbaa !9
  br label %75, !llvm.loop !23

157:                                              ; preds = %75
  %158 = load i64, ptr %13, align 8, !tbaa !9
  %159 = mul i64 2, %158
  %160 = sub i64 %159, 1
  %161 = trunc i64 %160 to i32
  %162 = load ptr, ptr %9, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.HuffmanTree, ptr %162, i64 0
  %164 = load ptr, ptr %10, align 8, !tbaa !5
  %165 = load i32, ptr %8, align 4, !tbaa !11
  %166 = call i32 @BrotliSetDepth(i32 noundef %161, ptr noundef %163, ptr noundef %164, i32 noundef %165)
  %167 = icmp ne i32 %166, 0
  br i1 %167, label %168, label %169

168:                                              ; preds = %157
  store i32 2, ptr %18, align 4
  br label %170

169:                                              ; preds = %157
  store i32 0, ptr %18, align 4
  br label %170

170:                                              ; preds = %169, %168, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %171 = load i32, ptr %18, align 4
  switch i32 %171, label %177 [
    i32 0, label %172
    i32 2, label %176
  ]

172:                                              ; preds = %170
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %11, align 4, !tbaa !11
  %175 = mul i32 %174, 2
  store i32 %175, ptr %11, align 4, !tbaa !11
  br label %22

176:                                              ; preds = %170
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void

177:                                              ; preds = %170
  unreachable
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @InitHuffmanTree(ptr noundef, i32 noundef, i16 noundef signext, i16 noundef signext) #2

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @BrotliSetDepth(i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define hidden void @BrotliCreateHuffmanTree(ptr nocapture noundef readonly %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.HuffmanTree, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @InitHuffmanTree(ptr noundef nonnull %6, i32 noundef -1, i16 noundef signext -1, i16 noundef signext -1)
  %.not80 = icmp eq i64 %1, 0
  br label %7

7:                                                ; preds = %._crit_edge90, %5
  %.0 = phi i32 [ 1, %5 ], [ %56, %._crit_edge90 ]
  br i1 %.not80, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %7, %16
  %.06582 = phi i64 [ %.1, %16 ], [ 0, %7 ]
  %.06981 = phi i64 [ %8, %16 ], [ %1, %7 ]
  %8 = add i64 %.06981, -1
  %9 = getelementptr inbounds i32, ptr %0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %.not77 = icmp eq i32 %10, 0
  br i1 %.not77, label %16, label %11

11:                                               ; preds = %.lr.ph
  %12 = call i32 @brotli_max_uint32_t(i32 noundef %10, i32 noundef %.0)
  %13 = add i64 %.06582, 1
  %14 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.06582
  %15 = trunc i64 %8 to i16
  call void @InitHuffmanTree(ptr noundef %14, i32 noundef %12, i16 noundef signext -1, i16 noundef signext %15)
  br label %16

16:                                               ; preds = %11, %.lr.ph
  %.1 = phi i64 [ %13, %11 ], [ %.06582, %.lr.ph ]
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %16
  %17 = icmp eq i64 %.1, 1
  br i1 %17, label %18, label %._crit_edge.thread

18:                                               ; preds = %._crit_edge
  %19 = getelementptr inbounds i8, ptr %3, i64 6
  %20 = load i16, ptr %19, align 2, !tbaa !11
  %21 = sext i16 %20 to i64
  %22 = getelementptr inbounds i8, ptr %4, i64 %21
  store i8 1, ptr %22, align 1, !tbaa !14
  br label %.loopexit

._crit_edge.thread:                               ; preds = %7, %._crit_edge
  %.065.lcssa92 = phi i64 [ %.1, %._crit_edge ], [ 0, %7 ]
  call void @SortHuffmanTreeItems(ptr noundef %3, i64 noundef %.065.lcssa92, ptr noundef nonnull @SortHuffmanTree)
  %23 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.065.lcssa92
  %24 = load i64, ptr %6, align 8
  store i64 %24, ptr %23, align 4
  %25 = add i64 %.065.lcssa92, 1
  %26 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %25
  store i64 %24, ptr %26, align 4
  %.06683 = add i64 %.065.lcssa92, -1
  %27 = shl i64 %.065.lcssa92, 1
  br label %28

28:                                               ; preds = %._crit_edge.thread, %28
  %.06687 = phi i64 [ %.06683, %._crit_edge.thread ], [ %.066, %28 ]
  %.06786 = phi i64 [ %25, %._crit_edge.thread ], [ %.2, %28 ]
  %.17085 = phi i64 [ 0, %._crit_edge.thread ], [ %.3, %28 ]
  %29 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.17085
  %30 = load i32, ptr %29, align 4, !tbaa !15
  %31 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.06786
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %.not75 = icmp ule i32 %30, %32
  %33 = zext i1 %.not75 to i64
  %.271 = add i64 %.17085, %33
  %not..not75 = xor i1 %.not75, true
  %34 = zext i1 %not..not75 to i64
  %.168 = add i64 %.06786, %34
  %.063 = select i1 %.not75, i64 %.17085, i64 %.06786
  %35 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.271
  %36 = load i32, ptr %35, align 4, !tbaa !15
  %37 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.168
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %.not76 = icmp ule i32 %36, %38
  %39 = zext i1 %.not76 to i64
  %.3 = add i64 %.271, %39
  %not..not76 = xor i1 %.not76, true
  %40 = zext i1 %not..not76 to i64
  %.2 = add i64 %.168, %40
  %.062 = select i1 %.not76, i64 %.271, i64 %.168
  %41 = sub i64 %27, %.06687
  %42 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.063
  %43 = load i32, ptr %42, align 4, !tbaa !15
  %44 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %.062
  %45 = load i32, ptr %44, align 4, !tbaa !15
  %46 = add i32 %45, %43
  %47 = getelementptr inbounds %struct.HuffmanTree, ptr %3, i64 %41
  store i32 %46, ptr %47, align 4, !tbaa !15
  %48 = trunc i64 %.063 to i16
  %49 = getelementptr inbounds i8, ptr %47, i64 4
  store i16 %48, ptr %49, align 4, !tbaa !16
  %50 = trunc i64 %.062 to i16
  %51 = getelementptr inbounds i8, ptr %47, i64 6
  store i16 %50, ptr %51, align 2, !tbaa !11
  %52 = getelementptr i8, ptr %47, i64 8
  store i64 %24, ptr %52, align 4
  %.066 = add i64 %.06687, -1
  %.not73 = icmp eq i64 %.066, 0
  br i1 %.not73, label %._crit_edge90, label %28, !llvm.loop !17

._crit_edge90:                                    ; preds = %28
  %.065.tr = trunc i64 %.065.lcssa92 to i32
  %53 = shl i32 %.065.tr, 1
  %54 = add i32 %53, -1
  %55 = call i32 @BrotliSetDepth(i32 noundef %54, ptr noundef nonnull %3, ptr noundef %4, i32 noundef %2)
  %.not74 = icmp eq i32 %55, 0
  %56 = shl i32 %.0, 1
  br i1 %.not74, label %7, label %.loopexit

.loopexit:                                        ; preds = %._crit_edge90, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @InitHuffmanTree(ptr noundef, i32 noundef, i16 noundef signext, i16 noundef signext) local_unnamed_addr #2

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

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

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

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

!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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !13, i64 6}
!12 = !{!"HuffmanTree", !6, i64 0, !13, i64 4, !13, i64 6}
!13 = !{!"short", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !13, i64 4}
!17 = distinct !{!17, !10}


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