; LLVM IR from DanEngelbrecht/longtail :: lib/brotli/ext/enc (histogram)

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

@_kBrotliContextLookupTable = external constant [2048 x i8], align 16

; Function Attrs: nounwind uwtable
define hidden void @BrotliBuildHistogramsWithContext(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i64 noundef %6, i64 noundef %7, i8 noundef zeroext %8, i8 noundef zeroext %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13) #0 {
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i8, align 1
  %24 = alloca i8, align 1
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  %30 = alloca %struct.BlockSplitIterator, align 8
  %31 = alloca %struct.BlockSplitIterator, align 8
  %32 = alloca %struct.BlockSplitIterator, align 8
  %33 = alloca i64, align 8
  %34 = alloca ptr, align 8
  %35 = alloca i64, align 8
  %36 = alloca i64, align 8
  %37 = alloca ptr, align 8
  %38 = alloca i64, align 8
  store ptr %0, ptr %15, align 8, !tbaa !5
  store i64 %1, ptr %16, align 8, !tbaa !9
  store ptr %2, ptr %17, align 8, !tbaa !5
  store ptr %3, ptr %18, align 8, !tbaa !5
  store ptr %4, ptr %19, align 8, !tbaa !5
  store ptr %5, ptr %20, align 8, !tbaa !5
  store i64 %6, ptr %21, align 8, !tbaa !9
  store i64 %7, ptr %22, align 8, !tbaa !9
  store i8 %8, ptr %23, align 1, !tbaa !11
  store i8 %9, ptr %24, align 1, !tbaa !11
  store ptr %10, ptr %25, align 8, !tbaa !5
  store ptr %11, ptr %26, align 8, !tbaa !5
  store ptr %12, ptr %27, align 8, !tbaa !5
  store ptr %13, ptr %28, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #3
  %39 = load i64, ptr %21, align 8, !tbaa !9
  store i64 %39, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %30) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %31) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %32) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #3
  %40 = load ptr, ptr %17, align 8, !tbaa !5
  call void @InitBlockSplitIterator(ptr noundef %30, ptr noundef %40)
  %41 = load ptr, ptr %18, align 8, !tbaa !5
  call void @InitBlockSplitIterator(ptr noundef %31, ptr noundef %41)
  %42 = load ptr, ptr %19, align 8, !tbaa !5
  call void @InitBlockSplitIterator(ptr noundef %32, ptr noundef %42)
  store i64 0, ptr %33, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %168, %14
  %44 = load i64, ptr %33, align 8, !tbaa !9
  %45 = load i64, ptr %16, align 8, !tbaa !9
  %46 = icmp ult i64 %44, %45
  br i1 %46, label %47, label %171

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %34) #3
  %48 = load ptr, ptr %15, align 8, !tbaa !5
  %49 = load i64, ptr %33, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.Command, ptr %48, i64 %49
  store ptr %50, ptr %34, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #3
  call void @BlockSplitIteratorNext(ptr noundef %31)
  %51 = load ptr, ptr %27, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.BlockSplitIterator, ptr %31, i32 0, i32 2
  %53 = load i64, ptr %52, align 8, !tbaa !12
  %54 = getelementptr inbounds %struct.HistogramCommand, ptr %51, i64 %53
  %55 = load ptr, ptr %34, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Command, ptr %55, i32 0, i32 3
  %57 = load i16, ptr %56, align 4, !tbaa !14
  %58 = zext i16 %57 to i64
  call void @HistogramAddCommand(ptr noundef %54, i64 noundef %58)
  %59 = load ptr, ptr %34, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Command, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 4, !tbaa !18
  %62 = zext i32 %61 to i64
  store i64 %62, ptr %35, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %117, %47
  %64 = load i64, ptr %35, align 8, !tbaa !9
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %66, label %120

66:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %36) #3
  call void @BlockSplitIteratorNext(ptr noundef %30)
  %67 = getelementptr inbounds %struct.BlockSplitIterator, ptr %30, i32 0, i32 2
  %68 = load i64, ptr %67, align 8, !tbaa !12
  store i64 %68, ptr %36, align 8, !tbaa !9
  %69 = load ptr, ptr %25, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %97

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %37) #3
  %72 = load ptr, ptr %25, align 8, !tbaa !5
  %73 = load i64, ptr %36, align 8, !tbaa !9
  %74 = getelementptr inbounds i32, ptr %72, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !19
  %76 = shl i32 %75, 9
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds [2048 x i8], ptr @_kBrotliContextLookupTable, i64 0, i64 %77
  store ptr %78, ptr %37, align 8, !tbaa !5
  %79 = load i64, ptr %36, align 8, !tbaa !9
  %80 = shl i64 %79, 6
  %81 = load ptr, ptr %37, align 8, !tbaa !5
  %82 = load i8, ptr %23, align 1, !tbaa !11
  %83 = zext i8 %82 to i64
  %84 = getelementptr inbounds i8, ptr %81, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !11
  %86 = zext i8 %85 to i32
  %87 = load ptr, ptr %37, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 256
  %89 = load i8, ptr %24, align 1, !tbaa !11
  %90 = zext i8 %89 to i64
  %91 = getelementptr inbounds i8, ptr %88, i64 %90
  %92 = load i8, ptr %91, align 1, !tbaa !11
  %93 = zext i8 %92 to i32
  %94 = or i32 %86, %93
  %95 = sext i32 %94 to i64
  %96 = add i64 %80, %95
  store i64 %96, ptr %36, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %37) #3
  br label %97

97:                                               ; preds = %71, %66
  %98 = load ptr, ptr %26, align 8, !tbaa !5
  %99 = load i64, ptr %36, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.HistogramLiteral, ptr %98, i64 %99
  %101 = load ptr, ptr %20, align 8, !tbaa !5
  %102 = load i64, ptr %29, align 8, !tbaa !9
  %103 = load i64, ptr %22, align 8, !tbaa !9
  %104 = and i64 %102, %103
  %105 = getelementptr inbounds i8, ptr %101, i64 %104
  %106 = load i8, ptr %105, align 1, !tbaa !11
  %107 = zext i8 %106 to i64
  call void @HistogramAddLiteral(ptr noundef %100, i64 noundef %107)
  %108 = load i8, ptr %23, align 1, !tbaa !11
  store i8 %108, ptr %24, align 1, !tbaa !11
  %109 = load ptr, ptr %20, align 8, !tbaa !5
  %110 = load i64, ptr %29, align 8, !tbaa !9
  %111 = load i64, ptr %22, align 8, !tbaa !9
  %112 = and i64 %110, %111
  %113 = getelementptr inbounds i8, ptr %109, i64 %112
  %114 = load i8, ptr %113, align 1, !tbaa !11
  store i8 %114, ptr %23, align 1, !tbaa !11
  %115 = load i64, ptr %29, align 8, !tbaa !9
  %116 = add i64 %115, 1
  store i64 %116, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #3
  br label %117

117:                                              ; preds = %97
  %118 = load i64, ptr %35, align 8, !tbaa !9
  %119 = add i64 %118, -1
  store i64 %119, ptr %35, align 8, !tbaa !9
  br label %63, !llvm.loop !20

120:                                              ; preds = %63
  %121 = load ptr, ptr %34, align 8, !tbaa !5
  %122 = call i32 @CommandCopyLen(ptr noundef %121)
  %123 = zext i32 %122 to i64
  %124 = load i64, ptr %29, align 8, !tbaa !9
  %125 = add i64 %124, %123
  store i64 %125, ptr %29, align 8, !tbaa !9
  %126 = load ptr, ptr %34, align 8, !tbaa !5
  %127 = call i32 @CommandCopyLen(ptr noundef %126)
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %167

129:                                              ; preds = %120
  %130 = load ptr, ptr %20, align 8, !tbaa !5
  %131 = load i64, ptr %29, align 8, !tbaa !9
  %132 = sub i64 %131, 2
  %133 = load i64, ptr %22, align 8, !tbaa !9
  %134 = and i64 %132, %133
  %135 = getelementptr inbounds i8, ptr %130, i64 %134
  %136 = load i8, ptr %135, align 1, !tbaa !11
  store i8 %136, ptr %24, align 1, !tbaa !11
  %137 = load ptr, ptr %20, align 8, !tbaa !5
  %138 = load i64, ptr %29, align 8, !tbaa !9
  %139 = sub i64 %138, 1
  %140 = load i64, ptr %22, align 8, !tbaa !9
  %141 = and i64 %139, %140
  %142 = getelementptr inbounds i8, ptr %137, i64 %141
  %143 = load i8, ptr %142, align 1, !tbaa !11
  store i8 %143, ptr %23, align 1, !tbaa !11
  %144 = load ptr, ptr %34, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.Command, ptr %144, i32 0, i32 3
  %146 = load i16, ptr %145, align 4, !tbaa !14
  %147 = zext i16 %146 to i32
  %148 = icmp sge i32 %147, 128
  br i1 %148, label %149, label %166

149:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 8, ptr %38) #3
  call void @BlockSplitIteratorNext(ptr noundef %32)
  %150 = getelementptr inbounds %struct.BlockSplitIterator, ptr %32, i32 0, i32 2
  %151 = load i64, ptr %150, align 8, !tbaa !12
  %152 = shl i64 %151, 2
  %153 = load ptr, ptr %34, align 8, !tbaa !5
  %154 = call i32 @CommandDistanceContext(ptr noundef %153)
  %155 = zext i32 %154 to i64
  %156 = add i64 %152, %155
  store i64 %156, ptr %38, align 8, !tbaa !9
  %157 = load ptr, ptr %28, align 8, !tbaa !5
  %158 = load i64, ptr %38, align 8, !tbaa !9
  %159 = getelementptr inbounds %struct.HistogramDistance, ptr %157, i64 %158
  %160 = load ptr, ptr %34, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.Command, ptr %160, i32 0, i32 4
  %162 = load i16, ptr %161, align 2, !tbaa !22
  %163 = zext i16 %162 to i32
  %164 = and i32 %163, 1023
  %165 = sext i32 %164 to i64
  call void @HistogramAddDistance(ptr noundef %159, i64 noundef %165)
  call void @llvm.lifetime.end.p0(i64 8, ptr %38) #3
  br label %166

166:                                              ; preds = %149, %129
  br label %167

167:                                              ; preds = %166, %120
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #3
  br label %168

168:                                              ; preds = %167
  %169 = load i64, ptr %33, align 8, !tbaa !9
  %170 = add i64 %169, 1
  store i64 %170, ptr %33, align 8, !tbaa !9
  br label %43, !llvm.loop !23

171:                                              ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %32) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %31) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %30) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #3
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @BlockSplitIteratorNext(ptr noundef) #0

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

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

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @HistogramAddDistance(ptr noundef, i64 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 = { 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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 16}
!13 = !{!"BlockSplitIterator", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!14 = !{!15, !17, i64 12}
!15 = !{!"Command", !16, i64 0, !16, i64 4, !16, i64 8, !17, i64 12, !17, i64 14}
!16 = !{!"int", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!15, !16, i64 0}
!19 = !{!16, !16, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!15, !17, i64 14}
!23 = distinct !{!23, !21}


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

@_kBrotliContextLookupTable = external local_unnamed_addr constant [2048 x i8], align 16

; Function Attrs: nounwind uwtable
define hidden void @BrotliBuildHistogramsWithContext(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef readonly %5, i64 noundef %6, i64 noundef %7, i8 noundef zeroext %8, i8 noundef zeroext %9, ptr noundef readonly %10, ptr noundef %11, ptr noundef %12, ptr noundef %13) local_unnamed_addr #0 {
  %15 = alloca %struct.BlockSplitIterator, align 8
  %16 = alloca %struct.BlockSplitIterator, align 8
  %17 = alloca %struct.BlockSplitIterator, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %15) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %16) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %17) #3
  call void @InitBlockSplitIterator(ptr noundef nonnull %15, ptr noundef %2)
  call void @InitBlockSplitIterator(ptr noundef nonnull %16, ptr noundef %3)
  call void @InitBlockSplitIterator(ptr noundef nonnull %17, ptr noundef %4)
  %.not72 = icmp eq i64 %1, 0
  br i1 %.not72, label %._crit_edge71, label %.lr.ph70

.lr.ph70:                                         ; preds = %14
  %18 = getelementptr inbounds i8, ptr %16, i64 16
  %19 = getelementptr inbounds i8, ptr %15, i64 16
  %.not55 = icmp eq ptr %10, null
  %20 = getelementptr inbounds i8, ptr %17, i64 16
  br i1 %.not55, label %.lr.ph70.split.us, label %.lr.ph70.split

.lr.ph70.split.us:                                ; preds = %.lr.ph70, %46
  %.05066.us = phi i64 [ %31, %46 ], [ %6, %.lr.ph70 ]
  %.05265.us = phi i64 [ %47, %46 ], [ 0, %.lr.ph70 ]
  %21 = getelementptr inbounds %struct.Command, ptr %0, i64 %.05265.us
  call void @BlockSplitIteratorNext(ptr noundef nonnull %16)
  %22 = load i64, ptr %18, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.HistogramCommand, ptr %12, i64 %22
  %24 = getelementptr inbounds i8, ptr %21, i64 12
  %25 = load i16, ptr %24, align 4, !tbaa !11
  %26 = zext i16 %25 to i64
  call void @HistogramAddCommand(ptr noundef %23, i64 noundef %26)
  %27 = load i32, ptr %21, align 4, !tbaa !15
  %.not56.us = icmp eq i32 %27, 0
  br i1 %.not56.us, label %._crit_edge.split.us.us, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %.lr.ph70.split.us
  %28 = zext i32 %27 to i64
  br label %.lr.ph.us

._crit_edge.split.us.us:                          ; preds = %.lr.ph.us, %.lr.ph70.split.us
  %.151.lcssa.us = phi i64 [ %.05066.us, %.lr.ph70.split.us ], [ %54, %.lr.ph.us ]
  %29 = call i32 @CommandCopyLen(ptr noundef nonnull %21)
  %30 = zext i32 %29 to i64
  %31 = add i64 %.151.lcssa.us, %30
  %32 = call i32 @CommandCopyLen(ptr noundef nonnull %21)
  %.not54.us = icmp eq i32 %32, 0
  br i1 %.not54.us, label %46, label %33

33:                                               ; preds = %._crit_edge.split.us.us
  %34 = load i16, ptr %24, align 4, !tbaa !11
  %35 = icmp ugt i16 %34, 127
  br i1 %35, label %36, label %46

36:                                               ; preds = %33
  call void @BlockSplitIteratorNext(ptr noundef nonnull %17)
  %37 = load i64, ptr %20, align 8, !tbaa !5
  %38 = call i32 @CommandDistanceContext(ptr noundef nonnull %21)
  %39 = zext i32 %38 to i64
  %.idx.us = mul i64 %37, 8768
  %40 = getelementptr i8, ptr %13, i64 %.idx.us
  %41 = getelementptr %struct.HistogramDistance, ptr %40, i64 %39
  %42 = getelementptr inbounds i8, ptr %21, i64 14
  %43 = load i16, ptr %42, align 2, !tbaa !16
  %44 = and i16 %43, 1023
  %45 = zext nneg i16 %44 to i64
  call void @HistogramAddDistance(ptr noundef %41, i64 noundef %45)
  br label %46

46:                                               ; preds = %36, %33, %._crit_edge.split.us.us
  %47 = add nuw i64 %.05265.us, 1
  %exitcond77.not = icmp eq i64 %47, %1
  br i1 %exitcond77.not, label %._crit_edge71, label %.lr.ph70.split.us, !llvm.loop !17

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.lr.ph.us
  %.04958.us.us = phi i64 [ %55, %.lr.ph.us ], [ %28, %.lr.ph.us.preheader ]
  %.15157.us.us = phi i64 [ %54, %.lr.ph.us ], [ %.05066.us, %.lr.ph.us.preheader ]
  call void @BlockSplitIteratorNext(ptr noundef nonnull %15)
  %48 = load i64, ptr %19, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.HistogramLiteral, ptr %11, i64 %48
  %50 = and i64 %.15157.us.us, %7
  %51 = getelementptr inbounds i8, ptr %5, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !19
  %53 = zext i8 %52 to i64
  call void @HistogramAddLiteral(ptr noundef %49, i64 noundef %53)
  %54 = add i64 %.15157.us.us, 1
  %55 = add nsw i64 %.04958.us.us, -1
  %.not.us.us = icmp eq i64 %55, 0
  br i1 %.not.us.us, label %._crit_edge.split.us.us, label %.lr.ph.us, !llvm.loop !20

.lr.ph70.split:                                   ; preds = %.lr.ph70, %113
  %.068 = phi i8 [ %.2, %113 ], [ %8, %.lr.ph70 ]
  %.04567 = phi i8 [ %.247, %113 ], [ %9, %.lr.ph70 ]
  %.05066 = phi i64 [ %90, %113 ], [ %6, %.lr.ph70 ]
  %.05265 = phi i64 [ %114, %113 ], [ 0, %.lr.ph70 ]
  %56 = getelementptr inbounds %struct.Command, ptr %0, i64 %.05265
  call void @BlockSplitIteratorNext(ptr noundef nonnull %16)
  %57 = load i64, ptr %18, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.HistogramCommand, ptr %12, i64 %57
  %59 = getelementptr inbounds i8, ptr %56, i64 12
  %60 = load i16, ptr %59, align 4, !tbaa !11
  %61 = zext i16 %60 to i64
  call void @HistogramAddCommand(ptr noundef %58, i64 noundef %61)
  %62 = load i32, ptr %56, align 4, !tbaa !15
  %.not56 = icmp eq i32 %62, 0
  br i1 %.not56, label %._crit_edge.split, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph70.split
  %63 = zext i32 %62 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.160 = phi i8 [ %85, %.lr.ph ], [ %.068, %.lr.ph.preheader ]
  %.14659 = phi i8 [ %.160, %.lr.ph ], [ %.04567, %.lr.ph.preheader ]
  %.04958 = phi i64 [ %87, %.lr.ph ], [ %63, %.lr.ph.preheader ]
  %.15157 = phi i64 [ %86, %.lr.ph ], [ %.05066, %.lr.ph.preheader ]
  call void @BlockSplitIteratorNext(ptr noundef nonnull %15)
  %64 = load i64, ptr %19, align 8, !tbaa !5
  %65 = getelementptr inbounds i32, ptr %10, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !21
  %67 = shl i32 %66, 9
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds [2048 x i8], ptr @_kBrotliContextLookupTable, i64 0, i64 %68
  %70 = zext i8 %.160 to i64
  %71 = getelementptr inbounds i8, ptr %69, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !19
  %73 = getelementptr inbounds i8, ptr %69, i64 256
  %74 = zext i8 %.14659 to i64
  %75 = getelementptr inbounds i8, ptr %73, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !19
  %77 = or i8 %76, %72
  %78 = zext i8 %77 to i64
  %.idx73 = mul i64 %64, 66560
  %79 = getelementptr i8, ptr %11, i64 %.idx73
  %80 = getelementptr %struct.HistogramLiteral, ptr %79, i64 %78
  %81 = and i64 %.15157, %7
  %82 = getelementptr inbounds i8, ptr %5, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !19
  %84 = zext i8 %83 to i64
  call void @HistogramAddLiteral(ptr noundef %80, i64 noundef %84)
  %85 = load i8, ptr %82, align 1, !tbaa !19
  %86 = add i64 %.15157, 1
  %87 = add nsw i64 %.04958, -1
  %.not = icmp eq i64 %87, 0
  br i1 %.not, label %._crit_edge.split, label %.lr.ph, !llvm.loop !20

._crit_edge.split:                                ; preds = %.lr.ph, %.lr.ph70.split
  %.151.lcssa = phi i64 [ %.05066, %.lr.ph70.split ], [ %86, %.lr.ph ]
  %.146.lcssa = phi i8 [ %.04567, %.lr.ph70.split ], [ %.160, %.lr.ph ]
  %.1.lcssa = phi i8 [ %.068, %.lr.ph70.split ], [ %85, %.lr.ph ]
  %88 = call i32 @CommandCopyLen(ptr noundef nonnull %56)
  %89 = zext i32 %88 to i64
  %90 = add i64 %.151.lcssa, %89
  %91 = call i32 @CommandCopyLen(ptr noundef nonnull %56)
  %.not54 = icmp eq i32 %91, 0
  br i1 %.not54, label %113, label %92

92:                                               ; preds = %._crit_edge.split
  %93 = add i64 %90, -2
  %94 = and i64 %93, %7
  %95 = getelementptr inbounds i8, ptr %5, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !19
  %97 = add i64 %90, -1
  %98 = and i64 %97, %7
  %99 = getelementptr inbounds i8, ptr %5, i64 %98
  %100 = load i8, ptr %99, align 1, !tbaa !19
  %101 = load i16, ptr %59, align 4, !tbaa !11
  %102 = icmp ugt i16 %101, 127
  br i1 %102, label %103, label %113

103:                                              ; preds = %92
  call void @BlockSplitIteratorNext(ptr noundef nonnull %17)
  %104 = load i64, ptr %20, align 8, !tbaa !5
  %105 = call i32 @CommandDistanceContext(ptr noundef nonnull %56)
  %106 = zext i32 %105 to i64
  %.idx = mul i64 %104, 8768
  %107 = getelementptr i8, ptr %13, i64 %.idx
  %108 = getelementptr %struct.HistogramDistance, ptr %107, i64 %106
  %109 = getelementptr inbounds i8, ptr %56, i64 14
  %110 = load i16, ptr %109, align 2, !tbaa !16
  %111 = and i16 %110, 1023
  %112 = zext nneg i16 %111 to i64
  call void @HistogramAddDistance(ptr noundef %108, i64 noundef %112)
  br label %113

113:                                              ; preds = %92, %103, %._crit_edge.split
  %.247 = phi i8 [ %96, %103 ], [ %96, %92 ], [ %.146.lcssa, %._crit_edge.split ]
  %.2 = phi i8 [ %100, %103 ], [ %100, %92 ], [ %.1.lcssa, %._crit_edge.split ]
  %114 = add nuw i64 %.05265, 1
  %exitcond.not = icmp eq i64 %114, %1
  br i1 %exitcond.not, label %._crit_edge71, label %.lr.ph70.split, !llvm.loop !17

._crit_edge71:                                    ; preds = %113, %46, %14
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %17) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %16) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %15) #3
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @BlockSplitIteratorNext(ptr noundef) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @HistogramAddDistance(ptr noundef, i64 noundef) local_unnamed_addr #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, !10, i64 16}
!6 = !{!"BlockSplitIterator", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !14, i64 12}
!12 = !{!"Command", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 12, !14, i64 14}
!13 = !{!"int", !8, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!12, !13, i64 0}
!16 = !{!12, !14, i64 14}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !18}
!21 = !{!13, !13, i64 0}


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