; LLVM IR from pixelsdb/mini-pixels :: pixels-core/lib/utils (EncodingUtils)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13EncodingUtils15unrolledUnPack1EPliiRKSt10shared_ptrI10ByteBufferE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(16) %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 8, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = srem i32 %20, %21
  store i32 %22, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = add nsw i32 %23, %24
  store i32 %25, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %26 = load i32, ptr %13, align 4, !tbaa !9
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = sub nsw i32 %26, %27
  store i32 %28, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %29 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %29, ptr %16, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %110, %5
  %31 = load i32, ptr %16, align 4, !tbaa !9
  %32 = load i32, ptr %14, align 4, !tbaa !9
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %114

35:                                               ; preds = %30
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %36) #4
  %38 = call noundef zeroext i8 @_ZN10ByteBuffer3getEv(ptr noundef nonnull align 8 dereferenceable(62) %37)
  %39 = zext i8 %38 to i32
  store i32 %39, ptr %15, align 4, !tbaa !9
  %40 = load i32, ptr %15, align 4, !tbaa !9
  %41 = lshr i32 %40, 7
  %42 = and i32 %41, 1
  %43 = zext i32 %42 to i64
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i64, ptr %44, i64 %46
  store i64 %43, ptr %47, align 8, !tbaa !11
  %48 = load i32, ptr %15, align 4, !tbaa !9
  %49 = lshr i32 %48, 6
  %50 = and i32 %49, 1
  %51 = zext i32 %50 to i64
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load i32, ptr %16, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i64, ptr %52, i64 %55
  store i64 %51, ptr %56, align 8, !tbaa !11
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = lshr i32 %57, 5
  %59 = and i32 %58, 1
  %60 = zext i32 %59 to i64
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load i32, ptr %16, align 4, !tbaa !9
  %63 = add nsw i32 %62, 2
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i64, ptr %61, i64 %64
  store i64 %60, ptr %65, align 8, !tbaa !11
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = lshr i32 %66, 4
  %68 = and i32 %67, 1
  %69 = zext i32 %68 to i64
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = load i32, ptr %16, align 4, !tbaa !9
  %72 = add nsw i32 %71, 3
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i64, ptr %70, i64 %73
  store i64 %69, ptr %74, align 8, !tbaa !11
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = lshr i32 %75, 3
  %77 = and i32 %76, 1
  %78 = zext i32 %77 to i64
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = load i32, ptr %16, align 4, !tbaa !9
  %81 = add nsw i32 %80, 4
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds i64, ptr %79, i64 %82
  store i64 %78, ptr %83, align 8, !tbaa !11
  %84 = load i32, ptr %15, align 4, !tbaa !9
  %85 = lshr i32 %84, 2
  %86 = and i32 %85, 1
  %87 = zext i32 %86 to i64
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = load i32, ptr %16, align 4, !tbaa !9
  %90 = add nsw i32 %89, 5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i64, ptr %88, i64 %91
  store i64 %87, ptr %92, align 8, !tbaa !11
  %93 = load i32, ptr %15, align 4, !tbaa !9
  %94 = lshr i32 %93, 1
  %95 = and i32 %94, 1
  %96 = zext i32 %95 to i64
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = load i32, ptr %16, align 4, !tbaa !9
  %99 = add nsw i32 %98, 6
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds i64, ptr %97, i64 %100
  store i64 %96, ptr %101, align 8, !tbaa !11
  %102 = load i32, ptr %15, align 4, !tbaa !9
  %103 = and i32 %102, 1
  %104 = sext i32 %103 to i64
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = load i32, ptr %16, align 4, !tbaa !9
  %107 = add nsw i32 %106, 7
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds i64, ptr %105, i64 %108
  store i64 %104, ptr %109, align 8, !tbaa !11
  br label %110

110:                                              ; preds = %35
  %111 = load i32, ptr %16, align 4, !tbaa !9
  %112 = load i32, ptr %11, align 4, !tbaa !9
  %113 = add nsw i32 %111, %112
  store i32 %113, ptr %16, align 4, !tbaa !9
  br label %30, !llvm.loop !13

114:                                              ; preds = %34
  %115 = load i32, ptr %12, align 4, !tbaa !9
  %116 = icmp sgt i32 %115, 0
  br i1 %116, label %117, label %144

117:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 7, ptr %17, align 4, !tbaa !9
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %118) #4
  %120 = call noundef zeroext i8 @_ZN10ByteBuffer3getEv(ptr noundef nonnull align 8 dereferenceable(62) %119)
  %121 = zext i8 %120 to i32
  store i32 %121, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %122 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %122, ptr %18, align 4, !tbaa !9
  br label %123

123:                                              ; preds = %140, %117
  %124 = load i32, ptr %18, align 4, !tbaa !9
  %125 = load i32, ptr %13, align 4, !tbaa !9
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %128, label %127

127:                                              ; preds = %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %143

128:                                              ; preds = %123
  %129 = load i32, ptr %15, align 4, !tbaa !9
  %130 = load i32, ptr %17, align 4, !tbaa !9
  %131 = lshr i32 %129, %130
  %132 = and i32 %131, 1
  %133 = zext i32 %132 to i64
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  %135 = load i32, ptr %18, align 4, !tbaa !9
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds i64, ptr %134, i64 %136
  store i64 %133, ptr %137, align 8, !tbaa !11
  %138 = load i32, ptr %17, align 4, !tbaa !9
  %139 = sub nsw i32 %138, 1
  store i32 %139, ptr %17, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %128
  %141 = load i32, ptr %18, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %18, align 4, !tbaa !9
  br label %123, !llvm.loop !15

143:                                              ; preds = %127
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %144

144:                                              ; preds = %143, %114
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #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
  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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

declare noundef zeroext i8 @_ZN10ByteBuffer3getEv(ptr noundef nonnull align 8 dereferenceable(62)) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13EncodingUtils15unrolledUnPack1EPliiRKSt10shared_ptrI10ByteBufferE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(16) %0, ptr nocapture noundef writeonly %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(16) %4) local_unnamed_addr #0 align 2 {
  %6 = srem i32 %3, 8
  %7 = add nsw i32 %3, %2
  %8 = sub nsw i32 %7, %6
  %9 = icmp sgt i32 %8, %2
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %5
  %10 = sext i32 %2 to i64
  %11 = sext i32 %8 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %5
  %12 = icmp sgt i32 %6, 0
  br i1 %12, label %.lr.ph54.preheader, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %10, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %13 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %4) #3
  %14 = tail call noundef zeroext i8 @_ZN10ByteBuffer3getEv(ptr noundef nonnull align 8 dereferenceable(62) %13)
  %15 = zext i8 %14 to i32
  %16 = lshr i32 %15, 7
  %17 = zext nneg i32 %16 to i64
  %18 = getelementptr inbounds i64, ptr %1, i64 %indvars.iv
  store i64 %17, ptr %18, align 8, !tbaa !5
  %19 = lshr i32 %15, 6
  %20 = and i32 %19, 1
  %21 = zext nneg i32 %20 to i64
  %22 = getelementptr i8, ptr %18, i64 8
  store i64 %21, ptr %22, align 8, !tbaa !5
  %23 = lshr i32 %15, 5
  %24 = and i32 %23, 1
  %25 = zext nneg i32 %24 to i64
  %26 = getelementptr i8, ptr %18, i64 16
  store i64 %25, ptr %26, align 8, !tbaa !5
  %27 = lshr i32 %15, 4
  %28 = and i32 %27, 1
  %29 = zext nneg i32 %28 to i64
  %30 = getelementptr i8, ptr %18, i64 24
  store i64 %29, ptr %30, align 8, !tbaa !5
  %31 = lshr i32 %15, 3
  %32 = and i32 %31, 1
  %33 = zext nneg i32 %32 to i64
  %34 = getelementptr i8, ptr %18, i64 32
  store i64 %33, ptr %34, align 8, !tbaa !5
  %35 = lshr i32 %15, 2
  %36 = and i32 %35, 1
  %37 = zext nneg i32 %36 to i64
  %38 = getelementptr i8, ptr %18, i64 40
  store i64 %37, ptr %38, align 8, !tbaa !5
  %39 = lshr i32 %15, 1
  %40 = and i32 %39, 1
  %41 = zext nneg i32 %40 to i64
  %42 = getelementptr i8, ptr %18, i64 48
  store i64 %41, ptr %42, align 8, !tbaa !5
  %43 = and i32 %15, 1
  %44 = zext nneg i32 %43 to i64
  %45 = getelementptr i8, ptr %18, i64 56
  store i64 %44, ptr %45, align 8, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 8
  %46 = icmp slt i64 %indvars.iv.next, %11
  br i1 %46, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph54.preheader:                               ; preds = %._crit_edge
  %47 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI10ByteBufferLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %4) #3
  %48 = tail call noundef zeroext i8 @_ZN10ByteBuffer3getEv(ptr noundef nonnull align 8 dereferenceable(62) %47)
  %49 = zext i8 %48 to i32
  %50 = sext i32 %8 to i64
  %51 = sext i32 %7 to i64
  br label %.lr.ph54

.lr.ph54:                                         ; preds = %.lr.ph54.preheader, %.lr.ph54
  %indvars.iv56 = phi i64 [ %50, %.lr.ph54.preheader ], [ %indvars.iv.next57, %.lr.ph54 ]
  %.04751 = phi i32 [ 7, %.lr.ph54.preheader ], [ %56, %.lr.ph54 ]
  %52 = lshr i32 %49, %.04751
  %53 = and i32 %52, 1
  %54 = zext nneg i32 %53 to i64
  %55 = getelementptr inbounds i64, ptr %1, i64 %indvars.iv56
  store i64 %54, ptr %55, align 8, !tbaa !5
  %56 = add nsw i32 %.04751, -1
  %indvars.iv.next57 = add nsw i64 %indvars.iv56, 1
  %57 = icmp slt i64 %indvars.iv.next57, %51
  br i1 %57, label %.lr.ph54, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph54, %._crit_edge
  ret void
}

; 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 #1 align 2

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

attributes #0 = { 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 #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 = { "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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