; LLVM IR from ryanlayer/giggle :: src (giggle_index)

; 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.giggle_def = type { %struct.cache_handler, %struct.cache_handler, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cache_handler = type { ptr, ptr, ptr }

@giggle_data_handler = external dso_local global %struct.giggle_def, align 8
@uint64_t_ll_leading_cache_handler = external dso_local global %struct.cache_handler, align 8
@uint64_t_ll_non_leading_cache_handler = external dso_local global %struct.cache_handler, align 8
@bpt_node_repair = external dso_local global ptr, align 8
@uint64_t_ll_giggle_data_handler = external dso_local global %struct.giggle_def, align 8

; Function Attrs: nounwind uwtable
declare dso_local ptr @giggle_collect_intersection_data_in_block(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local void @giggle_write_tree_cache_dump(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @leaf_data_map_intersection_to_offset_list(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @block_store_giggle_set_data_handler() #0 {
  store ptr @uint64_t_ll_leading_repair, ptr @bpt_node_repair, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @uint64_t_ll_giggle_data_handler, ptr align 8 @uint64_t_ll_non_leading_cache_handler, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 1), ptr align 8 @uint64_t_ll_leading_cache_handler, i64 24, i1 false), !tbaa.struct !9
  store ptr @uint64_t_ll_new_non_leading, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 2), align 8, !tbaa !10
  store ptr @uint64_t_ll_new_leading, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 3), align 8, !tbaa !13
  store ptr @uint64_t_ll_non_leading_SA_add_scalar, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 4), align 8, !tbaa !14
  store ptr @uint64_t_ll_non_leading_SE_add_scalar, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 5), align 8, !tbaa !15
  store ptr @uint64_t_ll_leading_B_add_scalar, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 6), align 8, !tbaa !16
  store ptr @uint64_t_ll_leading_union_with_B, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 7), align 8, !tbaa !17
  store ptr @uint64_t_ll_non_leading_union_with_SA, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 8), align 8, !tbaa !18
  store ptr @uint64_t_ll_non_leading_union_with_SA_subtract_SE, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 9), align 8, !tbaa !19
  store ptr @giggle_write_tree_cache_dump, ptr getelementptr inbounds (%struct.giggle_def, ptr @uint64_t_ll_giggle_data_handler, i32 0, i32 10), align 8, !tbaa !20
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @giggle_data_handler, ptr align 8 @uint64_t_ll_giggle_data_handler, i64 136, i1 false), !tbaa.struct !21
  store ptr @giggle_collect_intersection_data_in_block, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 11), align 8, !tbaa !22
  store ptr @leaf_data_map_intersection_to_offset_list, ptr getelementptr inbounds (%struct.giggle_def, ptr @giggle_data_handler, i32 0, i32 12), align 8, !tbaa !23
  ret void
}

declare void @uint64_t_ll_leading_repair(i32 noundef, ptr noundef, ptr noundef) #2

declare ptr @uint64_t_ll_new_non_leading(i32 noundef) #2

declare ptr @uint64_t_ll_new_leading(i32 noundef) #2

declare void @uint64_t_ll_non_leading_SA_add_scalar(i32 noundef, ptr noundef, ptr noundef) #2

declare void @uint64_t_ll_non_leading_SE_add_scalar(i32 noundef, ptr noundef, ptr noundef) #2

declare void @uint64_t_ll_leading_B_add_scalar(i32 noundef, ptr noundef, ptr noundef) #2

declare void @uint64_t_ll_leading_union_with_B(i32 noundef, ptr noundef, ptr noundef) #2

declare void @uint64_t_ll_non_leading_union_with_SA(i32 noundef, ptr noundef, ptr noundef) #2

declare void @uint64_t_ll_non_leading_union_with_SA_subtract_SE(i32 noundef, ptr noundef, ptr 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 nounwind willreturn memory(argmem: readwrite) }
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" }

!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 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5}
!10 = !{!11, !6, i64 48}
!11 = !{!"giggle_def", !12, i64 0, !12, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!12 = !{!"cache_handler", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!11, !6, i64 56}
!14 = !{!11, !6, i64 64}
!15 = !{!11, !6, i64 72}
!16 = !{!11, !6, i64 80}
!17 = !{!11, !6, i64 88}
!18 = !{!11, !6, i64 96}
!19 = !{!11, !6, i64 104}
!20 = !{!11, !6, i64 112}
!21 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 8, !5, i64 56, i64 8, !5, i64 64, i64 8, !5, i64 72, i64 8, !5, i64 80, i64 8, !5, i64 88, i64 8, !5, i64 96, i64 8, !5, i64 104, i64 8, !5, i64 112, i64 8, !5, i64 120, i64 8, !5, i64 128, i64 8, !5}
!22 = !{!11, !6, i64 120}
!23 = !{!11, !6, i64 128}


; 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.giggle_def = type { %struct.cache_handler, %struct.cache_handler, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cache_handler = type { ptr, ptr, ptr }

@giggle_data_handler = external dso_local local_unnamed_addr global %struct.giggle_def, align 8
@uint64_t_ll_leading_cache_handler = external dso_local local_unnamed_addr global %struct.cache_handler, align 8
@uint64_t_ll_non_leading_cache_handler = external dso_local local_unnamed_addr global %struct.cache_handler, align 8
@bpt_node_repair = external dso_local local_unnamed_addr global ptr, align 8
@uint64_t_ll_giggle_data_handler = external dso_local local_unnamed_addr global %struct.giggle_def, align 8

; Function Attrs: nounwind uwtable
declare dso_local ptr @giggle_collect_intersection_data_in_block(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local void @giggle_write_tree_cache_dump(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @leaf_data_map_intersection_to_offset_list(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @block_store_giggle_set_data_handler() local_unnamed_addr #2 {
  store ptr @uint64_t_ll_leading_repair, ptr @bpt_node_repair, align 8, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) @uint64_t_ll_giggle_data_handler, ptr noundef nonnull align 8 dereferenceable(24) @uint64_t_ll_non_leading_cache_handler, i64 24, i1 false), !tbaa.struct !9
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 24), ptr noundef nonnull align 8 dereferenceable(24) @uint64_t_ll_leading_cache_handler, i64 24, i1 false), !tbaa.struct !9
  store ptr @uint64_t_ll_new_non_leading, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 48), align 8, !tbaa !10
  store ptr @uint64_t_ll_new_leading, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 56), align 8, !tbaa !13
  store ptr @uint64_t_ll_non_leading_SA_add_scalar, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 64), align 8, !tbaa !14
  store ptr @uint64_t_ll_non_leading_SE_add_scalar, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 72), align 8, !tbaa !15
  store ptr @uint64_t_ll_leading_B_add_scalar, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 80), align 8, !tbaa !16
  store ptr @uint64_t_ll_leading_union_with_B, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 88), align 8, !tbaa !17
  store ptr @uint64_t_ll_non_leading_union_with_SA, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 96), align 8, !tbaa !18
  store ptr @uint64_t_ll_non_leading_union_with_SA_subtract_SE, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 104), align 8, !tbaa !19
  store ptr @giggle_write_tree_cache_dump, ptr getelementptr inbounds (i8, ptr @uint64_t_ll_giggle_data_handler, i64 112), align 8, !tbaa !20
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) @giggle_data_handler, ptr noundef nonnull align 8 dereferenceable(136) @uint64_t_ll_giggle_data_handler, i64 120, i1 false), !tbaa.struct !21
  store ptr @giggle_collect_intersection_data_in_block, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 120), align 8, !tbaa !22
  store ptr @leaf_data_map_intersection_to_offset_list, ptr getelementptr inbounds (i8, ptr @giggle_data_handler, i64 128), align 8, !tbaa !23
  ret void
}

declare void @uint64_t_ll_leading_repair(i32 noundef, ptr noundef, ptr noundef) #3

declare ptr @uint64_t_ll_new_non_leading(i32 noundef) #3

declare ptr @uint64_t_ll_new_leading(i32 noundef) #3

declare void @uint64_t_ll_non_leading_SA_add_scalar(i32 noundef, ptr noundef, ptr noundef) #3

declare void @uint64_t_ll_non_leading_SE_add_scalar(i32 noundef, ptr noundef, ptr noundef) #3

declare void @uint64_t_ll_leading_B_add_scalar(i32 noundef, ptr noundef, ptr noundef) #3

declare void @uint64_t_ll_leading_union_with_B(i32 noundef, ptr noundef, ptr noundef) #3

declare void @uint64_t_ll_non_leading_union_with_SA(i32 noundef, ptr noundef, ptr noundef) #3

declare void @uint64_t_ll_non_leading_union_with_SA_subtract_SE(i32 noundef, ptr noundef, ptr noundef) #3

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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) 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" }

!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 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5}
!10 = !{!11, !6, i64 48}
!11 = !{!"giggle_def", !12, i64 0, !12, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!12 = !{!"cache_handler", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!11, !6, i64 56}
!14 = !{!11, !6, i64 64}
!15 = !{!11, !6, i64 72}
!16 = !{!11, !6, i64 80}
!17 = !{!11, !6, i64 88}
!18 = !{!11, !6, i64 96}
!19 = !{!11, !6, i64 104}
!20 = !{!11, !6, i64 112}
!21 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 8, !5, i64 56, i64 8, !5, i64 64, i64 8, !5, i64 72, i64 8, !5, i64 80, i64 8, !5, i64 88, i64 8, !5, i64 96, i64 8, !5, i64 104, i64 8, !5, i64 112, i64 8, !5, i64 120, i64 8, !5, i64 128, i64 8, !5}
!22 = !{!11, !6, i64 120}
!23 = !{!11, !6, i64 128}


; Effective O3 passes: DSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,TailCallElimPass