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

; 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.ColumnVector = type { ptr, i64, i64, i64, i64, i8, i8, ptr, i8, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12ColumnVector7addNullEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.ColumnVector, ptr %3, i32 0, i32 2
  %5 = load i64, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.ColumnVector, ptr %3, i32 0, i32 1
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %8 = icmp uge i64 %5, %7
  br i1 %8, label %9, label %16

9:                                                ; preds = %1
  %10 = getelementptr inbounds %class.ColumnVector, ptr %3, i32 0, i32 2
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = mul i64 %11, 2
  %13 = load ptr, ptr %3, align 8, !tbaa !14
  %14 = getelementptr inbounds ptr, ptr %13, i64 4
  %15 = load ptr, ptr %14, align 8
  call void %15(ptr noundef nonnull align 8 dereferenceable(72) %3, i64 noundef %12, i1 noundef zeroext true)
  br label %16

16:                                               ; preds = %9, %1
  %17 = getelementptr inbounds %class.ColumnVector, ptr %3, i32 0, i32 7
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds %class.ColumnVector, ptr %3, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = add i64 %20, 1
  store i64 %21, ptr %19, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %18, i64 %20
  store i8 1, ptr %22, align 1, !tbaa !17
  %23 = getelementptr inbounds %class.ColumnVector, ptr %3, i32 0, i32 8
  store i8 0, ptr %23, align 8, !tbaa !18
  ret void
}

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

!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, !11, i64 16}
!10 = !{!"_ZTS12ColumnVector", !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !12, i64 40, !12, i64 41, !6, i64 48, !12, i64 56, !6, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !8, i64 0}
!16 = !{!10, !6, i64 48}
!17 = !{!7, !7, i64 0}
!18 = !{!10, !12, i64 56}


; 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 @_ZN12ColumnVector7addNullEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !12
  %.not = icmp ult i64 %3, %5
  br i1 %.not, label %11, label %6

6:                                                ; preds = %1
  %7 = shl i64 %3, 1
  %8 = load ptr, ptr %0, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %8, i64 32
  %10 = load ptr, ptr %9, align 8
  tail call void %10(ptr noundef nonnull align 8 dereferenceable(72) %0, i64 noundef %7, i1 noundef zeroext true)
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %6, %1
  %12 = phi i64 [ %.pre, %6 ], [ %3, %1 ]
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = add i64 %12, 1
  store i64 %15, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %14, i64 %12
  store i8 1, ptr %16, align 1, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  store i8 0, ptr %17, align 8, !tbaa !17
  ret void
}

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

!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, !7, i64 16}
!6 = !{!"_ZTS12ColumnVector", !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 41, !11, i64 48, !10, i64 56, !11, i64 64}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !9, i64 0}
!15 = !{!6, !11, i64 48}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !10, i64 56}


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