; LLVM IR from itchio/go-brotli :: 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 { [520 x i32], i64, double }

; 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 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
  %38 = load i64, ptr %21, align 8, !tbaa !9
  store i64 %38, 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
  %39 = load ptr, ptr %17, align 8, !tbaa !5
  call void @InitBlockSplitIterator(ptr noundef %30, ptr noundef %39)
  %40 = load ptr, ptr %18, align 8, !tbaa !5
  call void @InitBlockSplitIterator(ptr noundef %31, ptr noundef %40)
  %41 = load ptr, ptr %19, align 8, !tbaa !5
  call void @InitBlockSplitIterator(ptr noundef %32, ptr noundef %41)
  store i64 0, ptr %33, align 8, !tbaa !9
  br label %42

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

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

62:                                               ; preds = %106, %46
  %63 = load i64, ptr %35, align 8, !tbaa !9
  %64 = icmp ne i64 %63, 0
  br i1 %64, label %65, label %109

65:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %36) #3
  call void @BlockSplitIteratorNext(ptr noundef %30)
  %66 = load ptr, ptr %25, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %82

68:                                               ; preds = %65
  %69 = getelementptr inbounds %struct.BlockSplitIterator, ptr %30, i32 0, i32 2
  %70 = load i64, ptr %69, align 8, !tbaa !12
  %71 = shl i64 %70, 6
  %72 = load i8, ptr %23, align 1, !tbaa !11
  %73 = load i8, ptr %24, align 1, !tbaa !11
  %74 = load ptr, ptr %25, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.BlockSplitIterator, ptr %30, i32 0, i32 2
  %76 = load i64, ptr %75, align 8, !tbaa !12
  %77 = getelementptr inbounds i32, ptr %74, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !19
  %79 = call zeroext i8 @Context(i8 noundef zeroext %72, i8 noundef zeroext %73, i32 noundef %78)
  %80 = zext i8 %79 to i64
  %81 = add i64 %71, %80
  br label %85

82:                                               ; preds = %65
  %83 = getelementptr inbounds %struct.BlockSplitIterator, ptr %30, i32 0, i32 2
  %84 = load i64, ptr %83, align 8, !tbaa !12
  br label %85

85:                                               ; preds = %82, %68
  %86 = phi i64 [ %81, %68 ], [ %84, %82 ]
  store i64 %86, ptr %36, align 8, !tbaa !9
  %87 = load ptr, ptr %26, align 8, !tbaa !5
  %88 = load i64, ptr %36, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.HistogramLiteral, ptr %87, i64 %88
  %90 = load ptr, ptr %20, align 8, !tbaa !5
  %91 = load i64, ptr %29, align 8, !tbaa !9
  %92 = load i64, ptr %22, align 8, !tbaa !9
  %93 = and i64 %91, %92
  %94 = getelementptr inbounds i8, ptr %90, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !11
  %96 = zext i8 %95 to i64
  call void @HistogramAddLiteral(ptr noundef %89, i64 noundef %96)
  %97 = load i8, ptr %23, align 1, !tbaa !11
  store i8 %97, ptr %24, align 1, !tbaa !11
  %98 = load ptr, ptr %20, align 8, !tbaa !5
  %99 = load i64, ptr %29, align 8, !tbaa !9
  %100 = load i64, ptr %22, align 8, !tbaa !9
  %101 = and i64 %99, %100
  %102 = getelementptr inbounds i8, ptr %98, i64 %101
  %103 = load i8, ptr %102, align 1, !tbaa !11
  store i8 %103, ptr %23, align 1, !tbaa !11
  %104 = load i64, ptr %29, align 8, !tbaa !9
  %105 = add i64 %104, 1
  store i64 %105, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #3
  br label %106

106:                                              ; preds = %85
  %107 = load i64, ptr %35, align 8, !tbaa !9
  %108 = add i64 %107, -1
  store i64 %108, ptr %35, align 8, !tbaa !9
  br label %62, !llvm.loop !20

109:                                              ; preds = %62
  %110 = load ptr, ptr %34, align 8, !tbaa !5
  %111 = call i32 @CommandCopyLen(ptr noundef %110)
  %112 = zext i32 %111 to i64
  %113 = load i64, ptr %29, align 8, !tbaa !9
  %114 = add i64 %113, %112
  store i64 %114, ptr %29, align 8, !tbaa !9
  %115 = load ptr, ptr %34, align 8, !tbaa !5
  %116 = call i32 @CommandCopyLen(ptr noundef %115)
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %154

118:                                              ; preds = %109
  %119 = load ptr, ptr %20, align 8, !tbaa !5
  %120 = load i64, ptr %29, align 8, !tbaa !9
  %121 = sub i64 %120, 2
  %122 = load i64, ptr %22, align 8, !tbaa !9
  %123 = and i64 %121, %122
  %124 = getelementptr inbounds i8, ptr %119, i64 %123
  %125 = load i8, ptr %124, align 1, !tbaa !11
  store i8 %125, ptr %24, align 1, !tbaa !11
  %126 = load ptr, ptr %20, align 8, !tbaa !5
  %127 = load i64, ptr %29, align 8, !tbaa !9
  %128 = sub i64 %127, 1
  %129 = load i64, ptr %22, align 8, !tbaa !9
  %130 = and i64 %128, %129
  %131 = getelementptr inbounds i8, ptr %126, i64 %130
  %132 = load i8, ptr %131, align 1, !tbaa !11
  store i8 %132, ptr %23, align 1, !tbaa !11
  %133 = load ptr, ptr %34, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.Command, ptr %133, i32 0, i32 3
  %135 = load i16, ptr %134, align 4, !tbaa !14
  %136 = zext i16 %135 to i32
  %137 = icmp sge i32 %136, 128
  br i1 %137, label %138, label %153

138:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 8, ptr %37) #3
  call void @BlockSplitIteratorNext(ptr noundef %32)
  %139 = getelementptr inbounds %struct.BlockSplitIterator, ptr %32, i32 0, i32 2
  %140 = load i64, ptr %139, align 8, !tbaa !12
  %141 = shl i64 %140, 2
  %142 = load ptr, ptr %34, align 8, !tbaa !5
  %143 = call i32 @CommandDistanceContext(ptr noundef %142)
  %144 = zext i32 %143 to i64
  %145 = add i64 %141, %144
  store i64 %145, ptr %37, align 8, !tbaa !9
  %146 = load ptr, ptr %28, align 8, !tbaa !5
  %147 = load i64, ptr %37, align 8, !tbaa !9
  %148 = getelementptr inbounds %struct.HistogramDistance, ptr %146, i64 %147
  %149 = load ptr, ptr %34, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.Command, ptr %149, i32 0, i32 4
  %151 = load i16, ptr %150, align 2, !tbaa !22
  %152 = zext i16 %151 to i64
  call void @HistogramAddDistance(ptr noundef %148, i64 noundef %152)
  call void @llvm.lifetime.end.p0(i64 8, ptr %37) #3
  br label %153

153:                                              ; preds = %138, %118
  br label %154

154:                                              ; preds = %153, %109
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #3
  br label %155

155:                                              ; preds = %154
  %156 = load i64, ptr %33, align 8, !tbaa !9
  %157 = add i64 %156, 1
  store i64 %157, ptr %33, align 8, !tbaa !9
  br label %42, !llvm.loop !23

158:                                              ; preds = %42
  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: alwaysinline nounwind uwtable
declare hidden zeroext i8 @Context(i8 noundef zeroext, i8 noundef zeroext, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @HistogramAddLiteral(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 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 { [520 x i32], i64, double }
%struct.HistogramLiteral = type { [256 x i32], i64, double }

; 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)
  %.not67 = icmp eq i64 %1, 0
  br i1 %.not67, label %._crit_edge66, label %.lr.ph65

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

.lr.ph65.split.us:                                ; preds = %.lr.ph65, %45
  %.04561.us = phi i64 [ %31, %45 ], [ %6, %.lr.ph65 ]
  %.04760.us = phi i64 [ %46, %45 ], [ 0, %.lr.ph65 ]
  %21 = getelementptr inbounds %struct.Command, ptr %0, i64 %.04760.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
  %.not51.us = icmp eq i32 %27, 0
  br i1 %.not51.us, label %._crit_edge.split.us.us, label %.lr.ph.us.preheader

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

._crit_edge.split.us.us:                          ; preds = %.lr.ph.us, %.lr.ph65.split.us
  %.146.lcssa.us = phi i64 [ %.04561.us, %.lr.ph65.split.us ], [ %53, %.lr.ph.us ]
  %29 = call i32 @CommandCopyLen(ptr noundef nonnull %21)
  %30 = zext i32 %29 to i64
  %31 = add i64 %.146.lcssa.us, %30
  %32 = call i32 @CommandCopyLen(ptr noundef nonnull %21)
  %.not49.us = icmp eq i32 %32, 0
  br i1 %.not49.us, label %45, 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 %45

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, 8384
  %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 = zext i16 %43 to i64
  call void @HistogramAddDistance(ptr noundef %41, i64 noundef %44)
  br label %45

45:                                               ; preds = %36, %33, %._crit_edge.split.us.us
  %46 = add nuw i64 %.04760.us, 1
  %exitcond72.not = icmp eq i64 %46, %1
  br i1 %exitcond72.not, label %._crit_edge66, label %.lr.ph65.split.us, !llvm.loop !17

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

.lr.ph65.split:                                   ; preds = %.lr.ph65, %101
  %.063 = phi i8 [ %.2, %101 ], [ %8, %.lr.ph65 ]
  %.04162 = phi i8 [ %.243, %101 ], [ %9, %.lr.ph65 ]
  %.04561 = phi i64 [ %79, %101 ], [ %6, %.lr.ph65 ]
  %.04760 = phi i64 [ %102, %101 ], [ 0, %.lr.ph65 ]
  %55 = getelementptr inbounds %struct.Command, ptr %0, i64 %.04760
  call void @BlockSplitIteratorNext(ptr noundef nonnull %16)
  %56 = load i64, ptr %18, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.HistogramCommand, ptr %12, i64 %56
  %58 = getelementptr inbounds i8, ptr %55, i64 12
  %59 = load i16, ptr %58, align 4, !tbaa !11
  %60 = zext i16 %59 to i64
  call void @HistogramAddCommand(ptr noundef %57, i64 noundef %60)
  %61 = load i32, ptr %55, align 4, !tbaa !15
  %.not51 = icmp eq i32 %61, 0
  br i1 %.not51, label %._crit_edge.split, label %.lr.ph.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.155 = phi i8 [ %74, %.lr.ph ], [ %.063, %.lr.ph.preheader ]
  %.14254 = phi i8 [ %.155, %.lr.ph ], [ %.04162, %.lr.ph.preheader ]
  %.04453 = phi i64 [ %76, %.lr.ph ], [ %62, %.lr.ph.preheader ]
  %.14652 = phi i64 [ %75, %.lr.ph ], [ %.04561, %.lr.ph.preheader ]
  call void @BlockSplitIteratorNext(ptr noundef nonnull %15)
  %63 = load i64, ptr %19, align 8, !tbaa !5
  %64 = getelementptr inbounds i32, ptr %10, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !21
  %66 = call zeroext i8 @Context(i8 noundef zeroext %.155, i8 noundef zeroext %.14254, i32 noundef %65)
  %67 = zext i8 %66 to i64
  %.idx68 = mul i64 %63, 66560
  %68 = getelementptr i8, ptr %11, i64 %.idx68
  %69 = getelementptr %struct.HistogramLiteral, ptr %68, i64 %67
  %70 = and i64 %.14652, %7
  %71 = getelementptr inbounds i8, ptr %5, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !19
  %73 = zext i8 %72 to i64
  call void @HistogramAddLiteral(ptr noundef %69, i64 noundef %73)
  %74 = load i8, ptr %71, align 1, !tbaa !19
  %75 = add i64 %.14652, 1
  %76 = add nsw i64 %.04453, -1
  %.not = icmp eq i64 %76, 0
  br i1 %.not, label %._crit_edge.split, label %.lr.ph, !llvm.loop !20

._crit_edge.split:                                ; preds = %.lr.ph, %.lr.ph65.split
  %.146.lcssa = phi i64 [ %.04561, %.lr.ph65.split ], [ %75, %.lr.ph ]
  %.142.lcssa = phi i8 [ %.04162, %.lr.ph65.split ], [ %.155, %.lr.ph ]
  %.1.lcssa = phi i8 [ %.063, %.lr.ph65.split ], [ %74, %.lr.ph ]
  %77 = call i32 @CommandCopyLen(ptr noundef nonnull %55)
  %78 = zext i32 %77 to i64
  %79 = add i64 %.146.lcssa, %78
  %80 = call i32 @CommandCopyLen(ptr noundef nonnull %55)
  %.not49 = icmp eq i32 %80, 0
  br i1 %.not49, label %101, label %81

81:                                               ; preds = %._crit_edge.split
  %82 = add i64 %79, -2
  %83 = and i64 %82, %7
  %84 = getelementptr inbounds i8, ptr %5, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !19
  %86 = add i64 %79, -1
  %87 = and i64 %86, %7
  %88 = getelementptr inbounds i8, ptr %5, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !19
  %90 = load i16, ptr %58, align 4, !tbaa !11
  %91 = icmp ugt i16 %90, 127
  br i1 %91, label %92, label %101

92:                                               ; preds = %81
  call void @BlockSplitIteratorNext(ptr noundef nonnull %17)
  %93 = load i64, ptr %20, align 8, !tbaa !5
  %94 = call i32 @CommandDistanceContext(ptr noundef nonnull %55)
  %95 = zext i32 %94 to i64
  %.idx = mul i64 %93, 8384
  %96 = getelementptr i8, ptr %13, i64 %.idx
  %97 = getelementptr %struct.HistogramDistance, ptr %96, i64 %95
  %98 = getelementptr inbounds i8, ptr %55, i64 14
  %99 = load i16, ptr %98, align 2, !tbaa !16
  %100 = zext i16 %99 to i64
  call void @HistogramAddDistance(ptr noundef %97, i64 noundef %100)
  br label %101

101:                                              ; preds = %81, %92, %._crit_edge.split
  %.243 = phi i8 [ %85, %92 ], [ %85, %81 ], [ %.142.lcssa, %._crit_edge.split ]
  %.2 = phi i8 [ %89, %92 ], [ %89, %81 ], [ %.1.lcssa, %._crit_edge.split ]
  %102 = add nuw i64 %.04760, 1
  %exitcond.not = icmp eq i64 %102, %1
  br i1 %exitcond.not, label %._crit_edge66, label %.lr.ph65.split, !llvm.loop !17

._crit_edge66:                                    ; preds = %101, %45, %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: alwaysinline nounwind uwtable
declare hidden zeroext i8 @Context(i8 noundef zeroext, i8 noundef zeroext, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @HistogramAddLiteral(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 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