; LLVM IR from pixelsdb/mini-pixels :: pixels-core/lib/vector/LongColumnVector.ll (ZN16LongColumnVectorC2Embb)

; 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.LongColumnVector = type <{ %class.ColumnVector, ptr, ptr, i8, [7 x i8] }>
%class.ColumnVector = type { ptr, i64, i64, i64, i64, i8, i8, ptr, i8, ptr }

@_ZTV16LongColumnVector = external dso_local unnamed_addr constant { [11 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16LongColumnVectorC2Embb(ptr noundef nonnull align 8 dereferenceable(89) %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %7, align 1, !tbaa !11
  %10 = zext i1 %3 to i8
  store i8 %10, ptr %8, align 1, !tbaa !11
  %11 = load ptr, ptr %5, align 8
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %14 = trunc i8 %13 to i1
  call void @_ZN12ColumnVectorC2Emb(ptr noundef nonnull align 8 dereferenceable(72) %11, i64 noundef %12, i1 noundef zeroext %14)
  store ptr getelementptr inbounds inrange(-16, 72) ({ [11 x ptr] }, ptr @_ZTV16LongColumnVector, i32 0, i32 0, i32 2), ptr %11, align 8, !tbaa !15
  %15 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %23

17:                                               ; preds = %4
  %18 = getelementptr inbounds %class.LongColumnVector, ptr %11, i32 0, i32 1
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = mul i64 %19, 8
  %21 = call i32 @posix_memalign(ptr noundef %18, i64 noundef 32, i64 noundef %20) #3
  %22 = getelementptr inbounds %class.LongColumnVector, ptr %11, i32 0, i32 2
  store ptr null, ptr %22, align 8, !tbaa !17
  br label %29

23:                                               ; preds = %4
  %24 = getelementptr inbounds %class.LongColumnVector, ptr %11, i32 0, i32 1
  store ptr null, ptr %24, align 8, !tbaa !20
  %25 = getelementptr inbounds %class.LongColumnVector, ptr %11, i32 0, i32 2
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = mul i64 %26, 4
  %28 = call i32 @posix_memalign(ptr noundef %25, i64 noundef 32, i64 noundef %27) #3
  br label %29

29:                                               ; preds = %23, %17
  %30 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %31 = trunc i8 %30 to i1
  %32 = getelementptr inbounds %class.LongColumnVector, ptr %11, i32 0, i32 3
  %33 = zext i1 %31 to i8
  store i8 %33, ptr %32, align 8, !tbaa !21
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = mul i64 8, %34
  %36 = getelementptr inbounds %class.ColumnVector, ptr %11, i32 0, i32 4
  %37 = load i64, ptr %36, align 8, !tbaa !22
  %38 = add i64 %37, %35
  store i64 %38, ptr %36, align 8, !tbaa !22
  ret void
}

declare void @_ZN12ColumnVectorC2Emb(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef, i1 noundef zeroext) unnamed_addr #1

; Function Attrs: nounwind
declare i32 @posix_memalign(ptr noundef, i64 noundef, i64 noundef) #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 = { "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 = { nounwind "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !6, i64 80}
!18 = !{!"_ZTS16LongColumnVector", !19, i64 0, !6, i64 72, !6, i64 80, !12, i64 88}
!19 = !{!"_ZTS12ColumnVector", !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !12, i64 40, !12, i64 41, !6, i64 48, !12, i64 56, !6, i64 64}
!20 = !{!18, !6, i64 72}
!21 = !{!18, !12, i64 88}
!22 = !{!19, !10, i64 32}


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

@_ZTV16LongColumnVector = external dso_local unnamed_addr constant { [11 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16LongColumnVectorC2Embb(ptr noundef nonnull align 8 dereferenceable(89) %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) unnamed_addr #0 align 2 {
  tail call void @_ZN12ColumnVectorC2Emb(ptr noundef nonnull align 8 dereferenceable(72) %0, i64 noundef %1, i1 noundef zeroext %2)
  store ptr getelementptr inbounds inrange(-16, 72) (i8, ptr @_ZTV16LongColumnVector, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  br i1 %3, label %6, label %10

6:                                                ; preds = %4
  %7 = shl i64 %1, 3
  %8 = tail call i32 @posix_memalign(ptr noundef nonnull %5, i64 noundef 32, i64 noundef %7) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr null, ptr %9, align 8, !tbaa !8
  br label %14

10:                                               ; preds = %4
  store ptr null, ptr %5, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = shl i64 %1, 2
  %13 = tail call i32 @posix_memalign(ptr noundef nonnull %11, i64 noundef 32, i64 noundef %12) #3
  %.pre = shl i64 %1, 3
  br label %14

14:                                               ; preds = %10, %6
  %.pre-phi = phi i64 [ %.pre, %10 ], [ %7, %6 ]
  %15 = zext i1 %3 to i8
  %16 = getelementptr inbounds i8, ptr %0, i64 88
  store i8 %15, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load i64, ptr %17, align 8, !tbaa !17
  %19 = add i64 %18, %.pre-phi
  store i64 %19, ptr %17, align 8, !tbaa !17
  ret void
}

declare void @_ZN12ColumnVectorC2Emb(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef, i1 noundef zeroext) unnamed_addr #1

; Function Attrs: nofree nounwind
declare i32 @posix_memalign(ptr noundef, i64 noundef, i64 noundef) 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 = { "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 = { nofree nounwind "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !14, i64 80}
!9 = !{!"_ZTS16LongColumnVector", !10, i64 0, !14, i64 72, !14, i64 80, !13, i64 88}
!10 = !{!"_ZTS12ColumnVector", !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !13, i64 40, !13, i64 41, !14, i64 48, !13, i64 56, !14, i64 64}
!11 = !{!"long", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"bool", !12, i64 0}
!14 = !{!"any pointer", !12, i64 0}
!15 = !{!9, !14, i64 72}
!16 = !{!9, !13, i64 88}
!17 = !{!10, !11, i64 32}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass