; LLVM IR from pixelsdb/mini-pixels :: pixels-core/lib/encoding (RunLenIntEncoder)

; 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"

%class.RunLenIntEncoder = type { i32, i32, i32, i32, i8, i8, i64, i64, i32, i8, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i64, ptr, ptr, ptr, ptr, %class.EncodingUtils, %"class.std::shared_ptr" }
%class.EncodingUtils = type { ptr, ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN16RunLenIntEncoder18findClosestNumBitsEl(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef) #2 align 2

declare noundef i32 @_ZN13EncodingUtils19getClosestFixedBitsEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16RunLenIntEncoder22writePatchedBaseValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %18 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 17
  %19 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %19, ptr %3, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %20 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 24
  %21 = load i32, ptr %3, align 4, !tbaa !19
  %22 = call noundef i32 @_ZN13EncodingUtils14encodeBitWidthEi(ptr noundef nonnull align 8 dereferenceable(16) %20, i32 noundef %21)
  %23 = shl i32 %22, 1
  store i32 %23, ptr %4, align 4, !tbaa !19
  %24 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !20
  %26 = sub nsw i32 %25, 1
  store i32 %26, ptr %24, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %27 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !20
  %29 = and i32 %28, 256
  %30 = lshr i32 %29, 8
  store i32 %30, ptr %5, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %31 = call noundef i32 @_ZN16RunLenIntEncoder9getOpcodeEv(ptr noundef nonnull align 8 dereferenceable(168) %17)
  %32 = load i32, ptr %4, align 4, !tbaa !19
  %33 = or i32 %31, %32
  %34 = load i32, ptr %5, align 4, !tbaa !19
  %35 = or i32 %33, %34
  store i32 %35, ptr %6, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %36 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 3
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %38 = and i32 %37, 255
  store i32 %38, ptr %7, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %39 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %40 = load i64, ptr %39, align 8, !tbaa !21
  %41 = icmp slt i64 %40, 0
  %42 = zext i1 %41 to i8
  store i8 %42, ptr %8, align 1, !tbaa !22
  %43 = load i8, ptr %8, align 1, !tbaa !22, !range !23, !noundef !24
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %49

45:                                               ; preds = %1
  %46 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %47 = load i64, ptr %46, align 8, !tbaa !21
  %48 = sub nsw i64 0, %47
  br label %52

49:                                               ; preds = %1
  %50 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %51 = load i64, ptr %50, align 8, !tbaa !21
  br label %52

52:                                               ; preds = %49, %45
  %53 = phi i64 [ %48, %45 ], [ %51, %49 ]
  %54 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  store i64 %53, ptr %54, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %55 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %56 = load i64, ptr %55, align 8, !tbaa !21
  %57 = call noundef i32 @_ZN16RunLenIntEncoder18findClosestNumBitsEl(ptr noundef nonnull align 8 dereferenceable(168) %17, i64 noundef %56)
  store i32 %57, ptr %9, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %58 = load i32, ptr %9, align 4, !tbaa !19
  %59 = srem i32 %58, 8
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %52
  %62 = load i32, ptr %9, align 4, !tbaa !19
  %63 = sdiv i32 %62, 8
  br label %68

64:                                               ; preds = %52
  %65 = load i32, ptr %9, align 4, !tbaa !19
  %66 = sdiv i32 %65, 8
  %67 = add nsw i32 %66, 1
  br label %68

68:                                               ; preds = %64, %61
  %69 = phi i32 [ %63, %61 ], [ %67, %64 ]
  store i32 %69, ptr %10, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %70 = load i32, ptr %10, align 4, !tbaa !19
  %71 = sub nsw i32 %70, 1
  %72 = shl i32 %71, 5
  store i32 %72, ptr %11, align 4, !tbaa !19
  %73 = load i8, ptr %8, align 1, !tbaa !22, !range !23, !noundef !24
  %74 = trunc i8 %73 to i1
  br i1 %74, label %75, label %84

75:                                               ; preds = %68
  %76 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %77 = load i64, ptr %76, align 8, !tbaa !21
  %78 = load i32, ptr %10, align 4, !tbaa !19
  %79 = mul nsw i32 %78, 8
  %80 = sub nsw i32 %79, 1
  %81 = zext i32 %80 to i64
  %82 = shl i64 1, %81
  %83 = or i64 %77, %82
  br label %87

84:                                               ; preds = %68
  %85 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %86 = load i64, ptr %85, align 8, !tbaa !21
  br label %87

87:                                               ; preds = %84, %75
  %88 = phi i64 [ %83, %75 ], [ %86, %84 ]
  %89 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  store i64 %88, ptr %89, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %90 = load i32, ptr %11, align 4, !tbaa !19
  %91 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 24
  %92 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 10
  %93 = load i32, ptr %92, align 8, !tbaa !25
  %94 = call noundef i32 @_ZN13EncodingUtils14encodeBitWidthEi(ptr noundef nonnull align 8 dereferenceable(16) %91, i32 noundef %93)
  %95 = or i32 %90, %94
  store i32 %95, ptr %12, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %96 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 11
  %97 = load i32, ptr %96, align 4, !tbaa !26
  %98 = sub nsw i32 %97, 1
  %99 = shl i32 %98, 5
  %100 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 12
  %101 = load i32, ptr %100, align 8, !tbaa !27
  %102 = or i32 %99, %101
  store i32 %102, ptr %13, align 4, !tbaa !19
  %103 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 25
  %104 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %103) #4
  %105 = load i32, ptr %6, align 4, !tbaa !19
  %106 = trunc i32 %105 to i8
  call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %104, i8 noundef zeroext %106)
  %107 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 25
  %108 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %107) #4
  %109 = load i32, ptr %7, align 4, !tbaa !19
  %110 = trunc i32 %109 to i8
  call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %108, i8 noundef zeroext %110)
  %111 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 25
  %112 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %111) #4
  %113 = load i32, ptr %12, align 4, !tbaa !19
  %114 = trunc i32 %113 to i8
  call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %112, i8 noundef zeroext %114)
  %115 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 25
  %116 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %115) #4
  %117 = load i32, ptr %13, align 4, !tbaa !19
  %118 = trunc i32 %117 to i8
  call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %116, i8 noundef zeroext %118)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %119 = load i32, ptr %10, align 4, !tbaa !19
  %120 = sub nsw i32 %119, 1
  store i32 %120, ptr %14, align 4, !tbaa !19
  br label %121

121:                                              ; preds = %137, %87
  %122 = load i32, ptr %14, align 4, !tbaa !19
  %123 = icmp sge i32 %122, 0
  br i1 %123, label %125, label %124

124:                                              ; preds = %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %140

125:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #4
  %126 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 19
  %127 = load i64, ptr %126, align 8, !tbaa !21
  %128 = load i32, ptr %14, align 4, !tbaa !19
  %129 = mul nsw i32 %128, 8
  %130 = zext i32 %129 to i64
  %131 = lshr i64 %127, %130
  %132 = and i64 %131, 255
  %133 = trunc i64 %132 to i8
  store i8 %133, ptr %15, align 1, !tbaa !28
  %134 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 25
  %135 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %134) #4
  %136 = load i8, ptr %15, align 1, !tbaa !28
  call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %135, i8 noundef zeroext %136)
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #4
  br label %137

137:                                              ; preds = %125
  %138 = load i32, ptr %14, align 4, !tbaa !19
  %139 = add nsw i32 %138, -1
  store i32 %139, ptr %14, align 4, !tbaa !19
  br label %121, !llvm.loop !29

140:                                              ; preds = %124
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %141 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 24
  %142 = load i32, ptr %3, align 4, !tbaa !19
  %143 = call noundef i32 @_ZN13EncodingUtils19getClosestFixedBitsEi(ptr noundef nonnull align 8 dereferenceable(16) %141, i32 noundef %142)
  store i32 %143, ptr %16, align 4, !tbaa !19
  %144 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 22
  %145 = load ptr, ptr %144, align 8, !tbaa !31
  %146 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 1
  %147 = load i32, ptr %146, align 4, !tbaa !32
  %148 = load i32, ptr %16, align 4, !tbaa !19
  call void @_ZN16RunLenIntEncoder9writeIntsEPliii(ptr noundef nonnull align 8 dereferenceable(168) %17, ptr noundef %145, i32 noundef 0, i32 noundef %147, i32 noundef %148)
  %149 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 24
  %150 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 11
  %151 = load i32, ptr %150, align 4, !tbaa !26
  %152 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 10
  %153 = load i32, ptr %152, align 8, !tbaa !25
  %154 = add nsw i32 %151, %153
  %155 = call noundef i32 @_ZN13EncodingUtils19getClosestFixedBitsEi(ptr noundef nonnull align 8 dereferenceable(16) %149, i32 noundef %154)
  store i32 %155, ptr %16, align 4, !tbaa !19
  %156 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 13
  %157 = load ptr, ptr %156, align 8, !tbaa !33
  %158 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 14
  %159 = load i32, ptr %158, align 8, !tbaa !34
  %160 = load i32, ptr %16, align 4, !tbaa !19
  call void @_ZN16RunLenIntEncoder9writeIntsEPliii(ptr noundef nonnull align 8 dereferenceable(168) %17, ptr noundef %157, i32 noundef 0, i32 noundef %159, i32 noundef %160)
  %161 = getelementptr inbounds %class.RunLenIntEncoder, ptr %17, i32 0, i32 3
  store i32 0, ptr %161, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN16RunLenIntEncoder9getOpcodeEv(ptr noundef nonnull align 8 dereferenceable(168)) #1 align 2

declare void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62), i8 noundef zeroext) #3

declare noundef i32 @_ZN13EncodingUtils14encodeBitWidthEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16RunLenIntEncoder9writeIntsEPliii(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2 align 2

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 84}
!10 = !{!"_ZTS16RunLenIntEncoder", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !13, i64 16, !13, i64 17, !14, i64 24, !14, i64 32, !12, i64 40, !13, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !14, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !15, i64 136, !16, i64 152}
!11 = !{!"_ZTSN16RunLenIntEncoder12EncodingTypeE", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTS13EncodingUtils", !6, i64 0, !6, i64 8}
!16 = !{!"_ZTSSt10shared_ptrI10ByteBufferE", !17, i64 0}
!17 = !{!"_ZTSSt12__shared_ptrI10ByteBufferLN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !18, i64 8}
!18 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!19 = !{!12, !12, i64 0}
!20 = !{!10, !12, i64 12}
!21 = !{!10, !14, i64 96}
!22 = !{!13, !13, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!10, !12, i64 48}
!26 = !{!10, !12, i64 52}
!27 = !{!10, !12, i64 56}
!28 = !{!7, !7, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!10, !6, i64 120}
!32 = !{!10, !12, i64 4}
!33 = !{!10, !6, i64 64}
!34 = !{!10, !12, i64 72}


; 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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN16RunLenIntEncoder18findClosestNumBitsEl(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef) local_unnamed_addr #1 align 2

declare noundef i32 @_ZN13EncodingUtils19getClosestFixedBitsEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16RunLenIntEncoder22writePatchedBaseValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 84
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 136
  %5 = tail call noundef i32 @_ZN13EncodingUtils14encodeBitWidthEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %3)
  %6 = shl i32 %5, 1
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !18
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr %7, align 4, !tbaa !18
  %10 = lshr i32 %9, 8
  %11 = and i32 %10, 1
  %12 = tail call noundef i32 @_ZN16RunLenIntEncoder9getOpcodeEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  %13 = or i32 %12, %6
  %14 = or i32 %13, %11
  %15 = load i32, ptr %7, align 4, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  %17 = load i64, ptr %16, align 8, !tbaa !19
  %18 = icmp slt i64 %17, 0
  %19 = tail call i64 @llvm.abs.i64(i64 %17, i1 true)
  store i64 %19, ptr %16, align 8, !tbaa !19
  %20 = tail call noundef i32 @_ZN16RunLenIntEncoder18findClosestNumBitsEl(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %19)
  %21 = and i32 %20, 7
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %25

23:                                               ; preds = %1
  %24 = ashr exact i32 %20, 3
  br label %28

25:                                               ; preds = %1
  %26 = sdiv i32 %20, 8
  %27 = add nsw i32 %26, 1
  br label %28

28:                                               ; preds = %25, %23
  %29 = phi i32 [ %24, %23 ], [ %27, %25 ]
  %30 = add nsw i32 %29, -1
  %31 = shl i32 %30, 5
  %32 = load i64, ptr %16, align 8, !tbaa !19
  %33 = shl nsw i32 %29, 3
  %34 = add nsw i32 %33, -1
  %35 = zext nneg i32 %34 to i64
  %36 = shl nuw i64 1, %35
  %37 = select i1 %18, i64 %36, i64 0
  %38 = or i64 %32, %37
  store i64 %38, ptr %16, align 8, !tbaa !19
  %39 = getelementptr inbounds i8, ptr %0, i64 48
  %40 = load i32, ptr %39, align 8, !tbaa !20
  %41 = tail call noundef i32 @_ZN13EncodingUtils14encodeBitWidthEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %40)
  %42 = or i32 %41, %31
  %43 = getelementptr inbounds i8, ptr %0, i64 52
  %44 = load i32, ptr %43, align 4, !tbaa !21
  %45 = shl i32 %44, 5
  %46 = add i32 %45, 224
  %47 = getelementptr inbounds i8, ptr %0, i64 56
  %48 = load i32, ptr %47, align 8, !tbaa !22
  %49 = or i32 %46, %48
  %50 = getelementptr inbounds i8, ptr %0, i64 152
  %51 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %50) #4
  %52 = trunc i32 %14 to i8
  tail call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %51, i8 noundef zeroext %52)
  %53 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %50) #4
  %54 = trunc i32 %15 to i8
  tail call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %53, i8 noundef zeroext %54)
  %55 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %50) #4
  %56 = trunc i32 %42 to i8
  tail call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %55, i8 noundef zeroext %56)
  %57 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %50) #4
  %58 = trunc i32 %49 to i8
  tail call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %57, i8 noundef zeroext %58)
  %59 = icmp sgt i32 %29, 0
  br i1 %59, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %28
  %60 = zext nneg i32 %30 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %28
  %61 = tail call noundef i32 @_ZN13EncodingUtils19getClosestFixedBitsEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %3)
  %62 = getelementptr inbounds i8, ptr %0, i64 120
  %63 = load ptr, ptr %62, align 8, !tbaa !23
  %64 = getelementptr inbounds i8, ptr %0, i64 4
  %65 = load i32, ptr %64, align 4, !tbaa !24
  tail call void @_ZN16RunLenIntEncoder9writeIntsEPliii(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef %63, i32 noundef 0, i32 noundef %65, i32 noundef %61)
  %66 = load i32, ptr %43, align 4, !tbaa !21
  %67 = load i32, ptr %39, align 8, !tbaa !20
  %68 = add nsw i32 %67, %66
  %69 = tail call noundef i32 @_ZN13EncodingUtils19getClosestFixedBitsEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %68)
  %70 = getelementptr inbounds i8, ptr %0, i64 64
  %71 = load ptr, ptr %70, align 8, !tbaa !25
  %72 = getelementptr inbounds i8, ptr %0, i64 72
  %73 = load i32, ptr %72, align 8, !tbaa !26
  tail call void @_ZN16RunLenIntEncoder9writeIntsEPliii(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef %71, i32 noundef 0, i32 noundef %73, i32 noundef %69)
  store i32 0, ptr %7, align 4, !tbaa !18
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %60, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %74 = load i64, ptr %16, align 8, !tbaa !19
  %75 = shl nuw nsw i64 %indvars.iv, 3
  %76 = lshr i64 %74, %75
  %77 = trunc i64 %76 to i8
  %78 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %50) #4
  tail call void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62) %78, i8 noundef zeroext %77)
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not = icmp eq i64 %indvars.iv, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !27
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN16RunLenIntEncoder9getOpcodeEv(ptr noundef nonnull align 8 dereferenceable(168)) local_unnamed_addr #0 align 2

declare void @_ZN10ByteBuffer3putEh(ptr noundef nonnull align 8 dereferenceable(62), i8 noundef zeroext) local_unnamed_addr #2

declare noundef i32 @_ZN13EncodingUtils14encodeBitWidthEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16RunLenIntEncoder9writeIntsEPliii(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #3

attributes #0 = { mustprogress 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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 84}
!6 = !{!"_ZTS16RunLenIntEncoder", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 17, !12, i64 24, !12, i64 32, !10, i64 40, !11, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !13, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !12, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !14, i64 136, !15, i64 152}
!7 = !{!"_ZTSN16RunLenIntEncoder12EncodingTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"_ZTS13EncodingUtils", !13, i64 0, !13, i64 8}
!15 = !{!"_ZTSSt10shared_ptrI10ByteBufferE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrI10ByteBufferLN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0}
!18 = !{!6, !10, i64 12}
!19 = !{!6, !12, i64 96}
!20 = !{!6, !10, i64 48}
!21 = !{!6, !10, i64 52}
!22 = !{!6, !10, i64 56}
!23 = !{!6, !13, i64 120}
!24 = !{!6, !10, i64 4}
!25 = !{!6, !13, i64 64}
!26 = !{!6, !10, i64 72}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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