; LLVM IR from unum-cloud/usearch :: c (test)

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

@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1

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

declare i32 @printf(ptr noundef, ...) #1

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @create_options(ptr dead_on_unwind noalias writable sret(%struct.usearch_init_options_t) align 8, i64 noundef) #0

declare ptr @usearch_init(ptr noundef, ptr noundef) #1

declare void @usearch_free(ptr noundef, ptr noundef) #1

declare void @usearch_reserve(ptr noundef, i64 noundef, ptr noundef) #1

declare void @usearch_add(ptr noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @test_get_vector(i64 noundef %0, i64 noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.usearch_init_options_t, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  %13 = load i64, ptr %3, align 8, !tbaa !5
  %14 = load i64, ptr %4, align 8, !tbaa !5
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, i64 noundef %13, i64 noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store ptr null, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 64, ptr %6) #5
  %16 = load i64, ptr %4, align 8, !tbaa !5
  call void @create_options(ptr dead_on_unwind writable sret(%struct.usearch_init_options_t) align 8 %6, i64 noundef %16)
  %17 = getelementptr inbounds %struct.usearch_init_options_t, ptr %6, i32 0, i32 7
  store i8 1, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %18 = call ptr @usearch_init(ptr noundef %6, ptr noundef %5)
  store ptr %18, ptr %7, align 8, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !9
  %20 = load i64, ptr %3, align 8, !tbaa !5
  call void @usearch_reserve(ptr noundef %19, i64 noundef %20, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = load i64, ptr %3, align 8, !tbaa !5
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = mul i64 %21, %22
  %24 = mul i64 %23, 4
  %25 = call noalias ptr @malloc(i64 noundef %24) #6
  store ptr %25, ptr %8, align 8, !tbaa !9
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = icmp ne ptr %26, null
  call void @expect(i1 noundef zeroext %27, ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 1, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %28 = load i64, ptr %3, align 8, !tbaa !5
  %29 = load i64, ptr %4, align 8, !tbaa !5
  %30 = call ptr @create_vectors(i64 noundef %28, i64 noundef %29)
  store ptr %30, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %47, %2
  %32 = load i64, ptr %11, align 8, !tbaa !5
  %33 = load i64, ptr %3, align 8, !tbaa !5
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %50

36:                                               ; preds = %31
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = load ptr, ptr %10, align 8, !tbaa !9
  %39 = load i64, ptr %11, align 8, !tbaa !5
  %40 = load i64, ptr %4, align 8, !tbaa !5
  %41 = mul i64 %39, %40
  %42 = getelementptr inbounds float, ptr %38, i64 %41
  call void @usearch_add(ptr noundef %37, i64 noundef 1, ptr noundef %42, i32 noundef 1, ptr noundef %5)
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = icmp ne ptr %43, null
  %45 = xor i1 %44, true
  %46 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %45, ptr noundef %46)
  br label %47

47:                                               ; preds = %36
  %48 = load i64, ptr %11, align 8, !tbaa !5
  %49 = add i64 %48, 1
  store i64 %49, ptr %11, align 8, !tbaa !5
  br label %31, !llvm.loop !15

50:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  %52 = load i64, ptr %3, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !9
  %54 = call i64 @usearch_get(ptr noundef %51, i64 noundef 1, i64 noundef %52, ptr noundef %53, i32 noundef 1, ptr noundef %5)
  store i64 %54, ptr %12, align 8, !tbaa !5
  %55 = load i64, ptr %12, align 8, !tbaa !5
  %56 = load i64, ptr %3, align 8, !tbaa !5
  %57 = icmp eq i64 %55, %56
  call void @expect(i1 noundef zeroext %57, ptr noundef @.str.8)
  %58 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %58) #5
  %59 = load ptr, ptr %10, align 8, !tbaa !9
  call void @free(ptr noundef %59) #5
  %60 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_free(ptr noundef %60, ptr noundef %5)
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

declare i64 @usearch_get(ptr noundef, i64 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) #1

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !14, i64 56}
!12 = !{!"usearch_init_options_t", !13, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @expect(i1 noundef zeroext, ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_vectors(i64 noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @create_options(ptr dead_on_unwind noalias writable sret(%struct.usearch_init_options_t) align 8, i64 noundef) local_unnamed_addr #0

declare ptr @usearch_init(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @usearch_free(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @usearch_reserve(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

declare void @usearch_add(ptr noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local void @test_get_vector(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.usearch_init_options_t, align 8
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, i64 noundef %0, i64 noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #6
  call void @create_options(ptr dead_on_unwind nonnull writable sret(%struct.usearch_init_options_t) align 8 %4, i64 noundef %1)
  %6 = getelementptr inbounds i8, ptr %4, i64 56
  store i8 1, ptr %6, align 8, !tbaa !9
  %7 = call ptr @usearch_init(ptr noundef nonnull %4, ptr noundef nonnull %3) #6
  call void @usearch_reserve(ptr noundef %7, i64 noundef %0, ptr noundef nonnull %3) #6
  %8 = shl i64 %0, 2
  %9 = mul i64 %8, %1
  %10 = call noalias ptr @malloc(i64 noundef %9) #7
  %11 = icmp ne ptr %10, null
  call void @expect(i1 noundef zeroext %11, ptr noundef nonnull @.str.2)
  %12 = call ptr @create_vectors(i64 noundef %0, i64 noundef %1)
  %.not26 = icmp eq i64 %0, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  %13 = call i64 @usearch_get(ptr noundef %7, i64 noundef 1, i64 noundef %0, ptr noundef %10, i32 noundef 1, ptr noundef nonnull %3) #6
  %14 = icmp eq i64 %13, %0
  call void @expect(i1 noundef zeroext %14, ptr noundef nonnull @.str.8)
  call void @free(ptr noundef %10) #6
  call void @free(ptr noundef %12) #6
  call void @usearch_free(ptr noundef %7, ptr noundef nonnull %3) #6
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.025 = phi i64 [ %19, %.lr.ph ], [ 0, %2 ]
  %16 = mul i64 %.025, %1
  %17 = getelementptr inbounds float, ptr %12, i64 %16
  call void @usearch_add(ptr noundef %7, i64 noundef 1, ptr noundef %17, i32 noundef 1, ptr noundef nonnull %3) #6
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %18, null
  call void @expect(i1 noundef zeroext %.not, ptr noundef %18)
  %19 = add nuw i64 %.025, 1
  %exitcond.not = icmp eq i64 %19, %0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14
}

declare i64 @usearch_get(ptr noundef, i64 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!10, !13, i64 56}
!10 = !{!"usearch_init_options_t", !11, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !13, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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