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

; 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.Command = type { i32, i32, i32, i16, i16 }
%struct.HistogramLiteral = type { [256 x i32], i64, double }
%struct.HistogramCommand = type { [704 x i32], i64, double }
%struct.HistogramDistance = type { [520 x i32], i64, double }

@kStaticCommandCodeDepth = external hidden constant [704 x i8], align 16
@kStaticCommandCodeBits = external hidden constant [704 x i16], align 16
@kStaticDistanceCodeDepth = external hidden constant [64 x i8], align 16
@kStaticDistanceCodeBits = external hidden constant [64 x i16], align 16

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; 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
declare hidden void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @BrotliWriteBits(i64 noundef, i64 noundef, ptr noalias noundef, ptr noalias noundef) #3

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

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

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define hidden void @BrotliStoreMetaBlockFast(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i32 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, ptr noundef %9) #2 {
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca [256 x i32], align 16
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca [256 x i8], align 16
  %26 = alloca [256 x i16], align 16
  %27 = alloca %struct.Command, align 4
  %28 = alloca i64, align 8
  %29 = alloca %struct.HistogramLiteral, align 8
  %30 = alloca %struct.HistogramCommand, align 8
  %31 = alloca %struct.HistogramDistance, align 8
  %32 = alloca [256 x i8], align 16
  %33 = alloca [256 x i16], align 16
  %34 = alloca [704 x i8], align 16
  %35 = alloca [704 x i16], align 16
  %36 = alloca [64 x i8], align 16
  %37 = alloca [64 x i16], align 16
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store i64 %2, ptr %13, align 8, !tbaa !9
  store i64 %3, ptr %14, align 8, !tbaa !9
  store i64 %4, ptr %15, align 8, !tbaa !9
  store i32 %5, ptr %16, align 4, !tbaa !11
  store ptr %6, ptr %17, align 8, !tbaa !5
  store i64 %7, ptr %18, align 8, !tbaa !9
  store ptr %8, ptr %19, align 8, !tbaa !5
  store ptr %9, ptr %20, align 8, !tbaa !5
  %38 = load i32, ptr %16, align 4, !tbaa !11
  %39 = load i64, ptr %14, align 8, !tbaa !9
  %40 = load ptr, ptr %19, align 8, !tbaa !5
  %41 = load ptr, ptr %20, align 8, !tbaa !5
  call void @StoreCompressedMetaBlockHeader(i32 noundef %38, i64 noundef %39, ptr noundef %40, ptr noundef %41)
  %42 = load ptr, ptr %19, align 8, !tbaa !5
  %43 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 13, i64 noundef 0, ptr noundef %42, ptr noundef %43)
  %44 = load i64, ptr %18, align 8, !tbaa !9
  %45 = icmp ule i64 %44, 128
  br i1 %45, label %46, label %112

46:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1024, ptr %21) #5
  call void @llvm.memset.p0.i64(ptr align 16 %21, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %47 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %47, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  store i64 0, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %25) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr %26) #5
  store i64 0, ptr %24, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %88, %46
  %49 = load i64, ptr %24, align 8, !tbaa !9
  %50 = load i64, ptr %18, align 8, !tbaa !9
  %51 = icmp ult i64 %49, %50
  br i1 %51, label %52, label %91

52:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 16, ptr %27) #5
  %53 = load ptr, ptr %17, align 8, !tbaa !5
  %54 = load i64, ptr %24, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.Command, ptr %53, i64 %54
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %55, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #5
  %56 = getelementptr inbounds %struct.Command, ptr %27, i32 0, i32 0
  %57 = load i32, ptr %56, align 4, !tbaa !16
  %58 = zext i32 %57 to i64
  store i64 %58, ptr %28, align 8, !tbaa !9
  br label %59

59:                                               ; preds = %75, %52
  %60 = load i64, ptr %28, align 8, !tbaa !9
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %78

62:                                               ; preds = %59
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = load i64, ptr %22, align 8, !tbaa !9
  %65 = load i64, ptr %15, align 8, !tbaa !9
  %66 = and i64 %64, %65
  %67 = getelementptr inbounds i8, ptr %63, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !18
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [256 x i32], ptr %21, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = add i32 %71, 1
  store i32 %72, ptr %70, align 4, !tbaa !11
  %73 = load i64, ptr %22, align 8, !tbaa !9
  %74 = add i64 %73, 1
  store i64 %74, ptr %22, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %62
  %76 = load i64, ptr %28, align 8, !tbaa !9
  %77 = add i64 %76, -1
  store i64 %77, ptr %28, align 8, !tbaa !9
  br label %59, !llvm.loop !19

78:                                               ; preds = %59
  %79 = getelementptr inbounds %struct.Command, ptr %27, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !16
  %81 = zext i32 %80 to i64
  %82 = load i64, ptr %23, align 8, !tbaa !9
  %83 = add i64 %82, %81
  store i64 %83, ptr %23, align 8, !tbaa !9
  %84 = call i32 @CommandCopyLen(ptr noundef %27)
  %85 = zext i32 %84 to i64
  %86 = load i64, ptr %22, align 8, !tbaa !9
  %87 = add i64 %86, %85
  store i64 %87, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %27) #5
  br label %88

88:                                               ; preds = %78
  %89 = load i64, ptr %24, align 8, !tbaa !9
  %90 = add i64 %89, 1
  store i64 %90, ptr %24, align 8, !tbaa !9
  br label %48, !llvm.loop !21

91:                                               ; preds = %48
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = getelementptr inbounds [256 x i32], ptr %21, i64 0, i64 0
  %94 = load i64, ptr %23, align 8, !tbaa !9
  %95 = getelementptr inbounds [256 x i8], ptr %25, i64 0, i64 0
  %96 = getelementptr inbounds [256 x i16], ptr %26, i64 0, i64 0
  %97 = load ptr, ptr %19, align 8, !tbaa !5
  %98 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %92, ptr noundef %93, i64 noundef %94, i64 noundef 8, ptr noundef %95, ptr noundef %96, ptr noundef %97, ptr noundef %98)
  %99 = load ptr, ptr %19, align 8, !tbaa !5
  %100 = load ptr, ptr %20, align 8, !tbaa !5
  call void @StoreStaticCommandHuffmanTree(ptr noundef %99, ptr noundef %100)
  %101 = load ptr, ptr %19, align 8, !tbaa !5
  %102 = load ptr, ptr %20, align 8, !tbaa !5
  call void @StoreStaticDistanceHuffmanTree(ptr noundef %101, ptr noundef %102)
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = load i64, ptr %13, align 8, !tbaa !9
  %105 = load i64, ptr %15, align 8, !tbaa !9
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = load i64, ptr %18, align 8, !tbaa !9
  %108 = getelementptr inbounds [256 x i8], ptr %25, i64 0, i64 0
  %109 = getelementptr inbounds [256 x i16], ptr %26, i64 0, i64 0
  %110 = load ptr, ptr %19, align 8, !tbaa !5
  %111 = load ptr, ptr %20, align 8, !tbaa !5
  call void @StoreDataWithHuffmanCodes(ptr noundef %103, i64 noundef %104, i64 noundef %105, ptr noundef %106, i64 noundef %107, ptr noundef %108, ptr noundef %109, ptr noundef @kStaticCommandCodeDepth, ptr noundef @kStaticCommandCodeBits, ptr noundef @kStaticDistanceCodeDepth, ptr noundef @kStaticDistanceCodeBits, ptr noundef %110, ptr noundef %111)
  call void @llvm.lifetime.end.p0(i64 512, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %21) #5
  br label %158

112:                                              ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1040, ptr %29) #5
  call void @llvm.lifetime.start.p0(i64 2832, ptr %30) #5
  call void @llvm.lifetime.start.p0(i64 2096, ptr %31) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %32) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr %33) #5
  call void @llvm.lifetime.start.p0(i64 704, ptr %34) #5
  call void @llvm.lifetime.start.p0(i64 1408, ptr %35) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %36) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %37) #5
  call void @HistogramClearLiteral(ptr noundef %29)
  call void @HistogramClearCommand(ptr noundef %30)
  call void @HistogramClearDistance(ptr noundef %31)
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = load i64, ptr %13, align 8, !tbaa !9
  %115 = load i64, ptr %15, align 8, !tbaa !9
  %116 = load ptr, ptr %17, align 8, !tbaa !5
  %117 = load i64, ptr %18, align 8, !tbaa !9
  call void @BuildHistograms(ptr noundef %113, i64 noundef %114, i64 noundef %115, ptr noundef %116, i64 noundef %117, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  %118 = load ptr, ptr %11, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.HistogramLiteral, ptr %29, i32 0, i32 0
  %120 = getelementptr inbounds [256 x i32], ptr %119, i64 0, i64 0
  %121 = getelementptr inbounds %struct.HistogramLiteral, ptr %29, i32 0, i32 1
  %122 = load i64, ptr %121, align 8, !tbaa !22
  %123 = getelementptr inbounds [256 x i8], ptr %32, i64 0, i64 0
  %124 = getelementptr inbounds [256 x i16], ptr %33, i64 0, i64 0
  %125 = load ptr, ptr %19, align 8, !tbaa !5
  %126 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %118, ptr noundef %120, i64 noundef %122, i64 noundef 8, ptr noundef %123, ptr noundef %124, ptr noundef %125, ptr noundef %126)
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.HistogramCommand, ptr %30, i32 0, i32 0
  %129 = getelementptr inbounds [704 x i32], ptr %128, i64 0, i64 0
  %130 = getelementptr inbounds %struct.HistogramCommand, ptr %30, i32 0, i32 1
  %131 = load i64, ptr %130, align 8, !tbaa !25
  %132 = getelementptr inbounds [704 x i8], ptr %34, i64 0, i64 0
  %133 = getelementptr inbounds [704 x i16], ptr %35, i64 0, i64 0
  %134 = load ptr, ptr %19, align 8, !tbaa !5
  %135 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %127, ptr noundef %129, i64 noundef %131, i64 noundef 10, ptr noundef %132, ptr noundef %133, ptr noundef %134, ptr noundef %135)
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.HistogramDistance, ptr %31, i32 0, i32 0
  %138 = getelementptr inbounds [520 x i32], ptr %137, i64 0, i64 0
  %139 = getelementptr inbounds %struct.HistogramDistance, ptr %31, i32 0, i32 1
  %140 = load i64, ptr %139, align 8, !tbaa !27
  %141 = getelementptr inbounds [64 x i8], ptr %36, i64 0, i64 0
  %142 = getelementptr inbounds [64 x i16], ptr %37, i64 0, i64 0
  %143 = load ptr, ptr %19, align 8, !tbaa !5
  %144 = load ptr, ptr %20, align 8, !tbaa !5
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %136, ptr noundef %138, i64 noundef %140, i64 noundef 6, ptr noundef %141, ptr noundef %142, ptr noundef %143, ptr noundef %144)
  %145 = load ptr, ptr %12, align 8, !tbaa !5
  %146 = load i64, ptr %13, align 8, !tbaa !9
  %147 = load i64, ptr %15, align 8, !tbaa !9
  %148 = load ptr, ptr %17, align 8, !tbaa !5
  %149 = load i64, ptr %18, align 8, !tbaa !9
  %150 = getelementptr inbounds [256 x i8], ptr %32, i64 0, i64 0
  %151 = getelementptr inbounds [256 x i16], ptr %33, i64 0, i64 0
  %152 = getelementptr inbounds [704 x i8], ptr %34, i64 0, i64 0
  %153 = getelementptr inbounds [704 x i16], ptr %35, i64 0, i64 0
  %154 = getelementptr inbounds [64 x i8], ptr %36, i64 0, i64 0
  %155 = getelementptr inbounds [64 x i16], ptr %37, i64 0, i64 0
  %156 = load ptr, ptr %19, align 8, !tbaa !5
  %157 = load ptr, ptr %20, align 8, !tbaa !5
  call void @StoreDataWithHuffmanCodes(ptr noundef %145, i64 noundef %146, i64 noundef %147, ptr noundef %148, i64 noundef %149, ptr noundef %150, ptr noundef %151, ptr noundef %152, ptr noundef %153, ptr noundef %154, ptr noundef %155, ptr noundef %156, ptr noundef %157)
  call void @llvm.lifetime.end.p0(i64 128, ptr %37) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %36) #5
  call void @llvm.lifetime.end.p0(i64 1408, ptr %35) #5
  call void @llvm.lifetime.end.p0(i64 704, ptr %34) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr %33) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %32) #5
  call void @llvm.lifetime.end.p0(i64 2096, ptr %31) #5
  call void @llvm.lifetime.end.p0(i64 2832, ptr %30) #5
  call void @llvm.lifetime.end.p0(i64 1040, ptr %29) #5
  br label %158

158:                                              ; preds = %112, %91
  %159 = load i32, ptr %16, align 4, !tbaa !11
  %160 = icmp ne i32 %159, 0
  br i1 %160, label %161, label %164

161:                                              ; preds = %158
  %162 = load ptr, ptr %19, align 8, !tbaa !5
  %163 = load ptr, ptr %20, align 8, !tbaa !5
  call void @JumpToByteBoundary(ptr noundef %162, ptr noundef %163)
  br label %164

164:                                              ; preds = %161, %158
  ret void
}

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 4, !11, i64 12, i64 2, !14, i64 14, i64 2, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"Command", !12, i64 0, !12, i64 4, !12, i64 8, !15, i64 12, !15, i64 14}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!23, !10, i64 1024}
!23 = !{!"HistogramLiteral", !7, i64 0, !10, i64 1024, !24, i64 1032}
!24 = !{!"double", !7, i64 0}
!25 = !{!26, !10, i64 2816}
!26 = !{!"HistogramCommand", !7, i64 0, !10, i64 2816, !24, i64 2824}
!27 = !{!28, !10, i64 2080}
!28 = !{!"HistogramDistance", !7, i64 0, !10, i64 2080, !24, i64 2088}


; 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.Command = type { i32, i32, i32, i16, i16 }
%struct.HistogramLiteral = type { [256 x i32], i64, double }
%struct.HistogramCommand = type { [704 x i32], i64, double }
%struct.HistogramDistance = type { [520 x i32], i64, double }

@kStaticCommandCodeDepth = external hidden constant [704 x i8], align 16
@kStaticCommandCodeBits = external hidden constant [704 x i16], align 16
@kStaticDistanceCodeDepth = external hidden constant [64 x i8], align 16
@kStaticDistanceCodeBits = external hidden constant [64 x i16], align 16

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

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

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

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

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define hidden void @BrotliStoreMetaBlockFast(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i32 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, ptr noundef %9) local_unnamed_addr #2 {
  %11 = alloca [256 x i32], align 16
  %12 = alloca [256 x i8], align 16
  %13 = alloca [256 x i16], align 16
  %14 = alloca %struct.Command, align 4
  %15 = alloca %struct.HistogramLiteral, align 8
  %16 = alloca %struct.HistogramCommand, align 8
  %17 = alloca %struct.HistogramDistance, align 8
  %18 = alloca [256 x i8], align 16
  %19 = alloca [256 x i16], align 16
  %20 = alloca [704 x i8], align 16
  %21 = alloca [704 x i16], align 16
  %22 = alloca [64 x i8], align 16
  %23 = alloca [64 x i16], align 16
  tail call void @StoreCompressedMetaBlockHeader(i32 noundef %5, i64 noundef %3, ptr noundef %8, ptr noundef %9)
  tail call void @BrotliWriteBits(i64 noundef 13, i64 noundef 0, ptr noundef %8, ptr noundef %9)
  %24 = icmp ult i64 %7, 129
  br i1 %24, label %25, label %61

25:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %11) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %11, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %12) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %13) #5
  %.not74 = icmp eq i64 %7, 0
  br i1 %.not74, label %._crit_edge72, label %.lr.ph71

.lr.ph71:                                         ; preds = %25, %._crit_edge
  %.05969 = phi i64 [ %60, %._crit_edge ], [ 0, %25 ]
  %.06068 = phi i64 [ %56, %._crit_edge ], [ 0, %25 ]
  %.06167 = phi i64 [ %59, %._crit_edge ], [ %2, %25 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %14) #5
  %26 = getelementptr inbounds %struct.Command, ptr %6, i64 %.05969
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %14, ptr noundef nonnull align 4 dereferenceable(16) %26, i64 16, i1 false), !tbaa.struct !5
  %27 = load i32, ptr %14, align 4, !tbaa !12
  %28 = zext i32 %27 to i64
  %.not6364 = icmp eq i32 %27, 0
  br i1 %.not6364, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph71
  %xtraiter = and i64 %28, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %29 = and i64 %.06167, %4
  %30 = getelementptr inbounds i8, ptr %1, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !14
  %32 = zext i8 %31 to i64
  %33 = getelementptr inbounds [256 x i32], ptr %11, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !6
  %35 = add i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !6
  %36 = add i64 %.06167, 1
  %37 = add nsw i64 %28, -1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.lcssa.unr = phi i64 [ poison, %.lr.ph.preheader ], [ %36, %.lr.ph.prol ]
  %.066.unr = phi i64 [ %28, %.lr.ph.preheader ], [ %37, %.lr.ph.prol ]
  %.165.unr = phi i64 [ %.06167, %.lr.ph.preheader ], [ %36, %.lr.ph.prol ]
  %38 = icmp eq i32 %27, 1
  br i1 %38, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.066 = phi i64 [ %55, %.lr.ph ], [ %.066.unr, %.lr.ph.prol.loopexit ]
  %.165 = phi i64 [ %54, %.lr.ph ], [ %.165.unr, %.lr.ph.prol.loopexit ]
  %39 = and i64 %.165, %4
  %40 = getelementptr inbounds i8, ptr %1, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !14
  %42 = zext i8 %41 to i64
  %43 = getelementptr inbounds [256 x i32], ptr %11, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !6
  %45 = add i32 %44, 1
  store i32 %45, ptr %43, align 4, !tbaa !6
  %46 = add i64 %.165, 1
  %47 = and i64 %46, %4
  %48 = getelementptr inbounds i8, ptr %1, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !14
  %50 = zext i8 %49 to i64
  %51 = getelementptr inbounds [256 x i32], ptr %11, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !6
  %53 = add i32 %52, 1
  store i32 %53, ptr %51, align 4, !tbaa !6
  %54 = add i64 %.165, 2
  %55 = add nsw i64 %.066, -2
  %.not63.1 = icmp eq i64 %55, 0
  br i1 %.not63.1, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %.lr.ph71
  %.1.lcssa = phi i64 [ %.06167, %.lr.ph71 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %54, %.lr.ph ]
  %56 = add i64 %.06068, %28
  %57 = call i32 @CommandCopyLen(ptr noundef nonnull %14)
  %58 = zext i32 %57 to i64
  %59 = add i64 %.1.lcssa, %58
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %14) #5
  %60 = add nuw i64 %.05969, 1
  %exitcond.not = icmp eq i64 %60, %7
  br i1 %exitcond.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !17

._crit_edge72:                                    ; preds = %._crit_edge, %25
  %.060.lcssa = phi i64 [ 0, %25 ], [ %56, %._crit_edge ]
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %0, ptr noundef nonnull %11, i64 noundef %.060.lcssa, i64 noundef 8, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef %8, ptr noundef %9)
  call void @StoreStaticCommandHuffmanTree(ptr noundef %8, ptr noundef %9)
  call void @StoreStaticDistanceHuffmanTree(ptr noundef %8, ptr noundef %9)
  call void @StoreDataWithHuffmanCodes(ptr noundef %1, i64 noundef %2, i64 noundef %4, ptr noundef %6, i64 noundef %7, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull @kStaticCommandCodeDepth, ptr noundef nonnull @kStaticCommandCodeBits, ptr noundef nonnull @kStaticDistanceCodeDepth, ptr noundef nonnull @kStaticDistanceCodeBits, ptr noundef %8, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %11) #5
  br label %68

61:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1040, ptr nonnull %15) #5
  call void @llvm.lifetime.start.p0(i64 2832, ptr nonnull %16) #5
  call void @llvm.lifetime.start.p0(i64 2096, ptr nonnull %17) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %18) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %19) #5
  call void @llvm.lifetime.start.p0(i64 704, ptr nonnull %20) #5
  call void @llvm.lifetime.start.p0(i64 1408, ptr nonnull %21) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %22) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %23) #5
  call void @HistogramClearLiteral(ptr noundef nonnull %15)
  call void @HistogramClearCommand(ptr noundef nonnull %16)
  call void @HistogramClearDistance(ptr noundef nonnull %17)
  call void @BuildHistograms(ptr noundef %1, i64 noundef %2, i64 noundef %4, ptr noundef %6, i64 noundef %7, ptr noundef nonnull %15, ptr noundef nonnull %16, ptr noundef nonnull %17)
  %62 = getelementptr inbounds i8, ptr %15, i64 1024
  %63 = load i64, ptr %62, align 8, !tbaa !18
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %0, ptr noundef nonnull %15, i64 noundef %63, i64 noundef 8, ptr noundef nonnull %18, ptr noundef nonnull %19, ptr noundef %8, ptr noundef %9)
  %64 = getelementptr inbounds i8, ptr %16, i64 2816
  %65 = load i64, ptr %64, align 8, !tbaa !22
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %0, ptr noundef nonnull %16, i64 noundef %65, i64 noundef 10, ptr noundef nonnull %20, ptr noundef nonnull %21, ptr noundef %8, ptr noundef %9)
  %66 = getelementptr inbounds i8, ptr %17, i64 2080
  %67 = load i64, ptr %66, align 8, !tbaa !24
  call void @BrotliBuildAndStoreHuffmanTreeFast(ptr noundef %0, ptr noundef nonnull %17, i64 noundef %67, i64 noundef 6, ptr noundef nonnull %22, ptr noundef nonnull %23, ptr noundef %8, ptr noundef %9)
  call void @StoreDataWithHuffmanCodes(ptr noundef %1, i64 noundef %2, i64 noundef %4, ptr noundef %6, i64 noundef %7, ptr noundef nonnull %18, ptr noundef nonnull %19, ptr noundef nonnull %20, ptr noundef nonnull %21, ptr noundef nonnull %22, ptr noundef nonnull %23, ptr noundef %8, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %23) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %22) #5
  call void @llvm.lifetime.end.p0(i64 1408, ptr nonnull %21) #5
  call void @llvm.lifetime.end.p0(i64 704, ptr nonnull %20) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %19) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %18) #5
  call void @llvm.lifetime.end.p0(i64 2096, ptr nonnull %17) #5
  call void @llvm.lifetime.end.p0(i64 2832, ptr nonnull %16) #5
  call void @llvm.lifetime.end.p0(i64 1040, ptr nonnull %15) #5
  br label %68

68:                                               ; preds = %61, %._crit_edge72
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %70, label %69

69:                                               ; preds = %68
  call void @JumpToByteBoundary(ptr noundef %8, ptr noundef %9)
  br label %70

70:                                               ; preds = %69, %68
  ret void
}

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

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

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


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