; 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.7 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [28 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_find_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 ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  %15 = load i64, ptr %3, align 8, !tbaa !5
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i64 noundef %15, i64 noundef %16)
  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
  %18 = 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 %18)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %19 = call ptr @usearch_init(ptr noundef %6, ptr noundef %5)
  store ptr %19, ptr %7, align 8, !tbaa !9
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  %21 = load i64, ptr %3, align 8, !tbaa !5
  call void @usearch_reserve(ptr noundef %20, i64 noundef %21, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %22 = load i64, ptr %3, align 8, !tbaa !5
  %23 = mul i64 %22, 8
  %24 = call noalias ptr @malloc(i64 noundef %23) #6
  store ptr %24, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %25 = load i64, ptr %3, align 8, !tbaa !5
  %26 = mul i64 %25, 4
  %27 = call noalias ptr @malloc(i64 noundef %26) #6
  store ptr %27, ptr %9, align 8, !tbaa !9
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %2
  %31 = load ptr, ptr %9, align 8, !tbaa !9
  %32 = icmp ne ptr %31, null
  br label %33

33:                                               ; preds = %30, %2
  %34 = phi i1 [ false, %2 ], [ %32, %30 ]
  call void @expect(i1 noundef zeroext %34, ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = load i64, ptr %4, align 8, !tbaa !5
  %37 = call ptr @create_vectors(i64 noundef %35, i64 noundef %36)
  store ptr %37, 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 %38

38:                                               ; preds = %56, %33
  %39 = load i64, ptr %11, align 8, !tbaa !5
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = icmp ult i64 %39, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %44 = load i64, ptr %11, align 8, !tbaa !5
  store i64 %44, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = load i64, ptr %12, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = load i64, ptr %11, align 8, !tbaa !5
  %49 = load i64, ptr %4, align 8, !tbaa !5
  %50 = mul i64 %48, %49
  %51 = getelementptr inbounds float, ptr %47, i64 %50
  call void @usearch_add(ptr noundef %45, i64 noundef %46, ptr noundef %51, i32 noundef 1, ptr noundef %5)
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = icmp ne ptr %52, null
  %54 = xor i1 %53, true
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %54, ptr noundef %55)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %56

56:                                               ; preds = %43
  %57 = load i64, ptr %11, align 8, !tbaa !5
  %58 = add i64 %57, 1
  store i64 %58, ptr %11, align 8, !tbaa !5
  br label %38, !llvm.loop !11

59:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store i64 0, ptr %13, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %88, %59
  %61 = load i64, ptr %13, align 8, !tbaa !5
  %62 = load i64, ptr %3, align 8, !tbaa !5
  %63 = icmp ult i64 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %91

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %66 = load ptr, ptr %7, align 8, !tbaa !9
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = load i64, ptr %13, align 8, !tbaa !5
  %69 = load i64, ptr %4, align 8, !tbaa !5
  %70 = mul i64 %68, %69
  %71 = getelementptr inbounds float, ptr %67, i64 %70
  %72 = load i64, ptr %3, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !9
  %74 = load ptr, ptr %9, align 8, !tbaa !9
  %75 = call i64 @usearch_search(ptr noundef %66, ptr noundef %71, i32 noundef 1, i64 noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %5)
  store i64 %75, ptr %14, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !9
  %77 = icmp ne ptr %76, null
  %78 = xor i1 %77, true
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %78, ptr noundef %79)
  %80 = load i64, ptr %14, align 8, !tbaa !5
  %81 = icmp uge i64 %80, 1
  br i1 %81, label %82, label %86

82:                                               ; preds = %65
  %83 = load i64, ptr %14, align 8, !tbaa !5
  %84 = load i64, ptr %3, align 8, !tbaa !5
  %85 = icmp ule i64 %83, %84
  br label %86

86:                                               ; preds = %82, %65
  %87 = phi i1 [ false, %65 ], [ %85, %82 ]
  call void @expect(i1 noundef zeroext %87, ptr noundef @.str.8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %88

88:                                               ; preds = %86
  %89 = load i64, ptr %13, align 8, !tbaa !5
  %90 = add i64 %89, 1
  store i64 %90, ptr %13, align 8, !tbaa !5
  br label %60, !llvm.loop !13

91:                                               ; preds = %64
  %92 = load ptr, ptr %10, align 8, !tbaa !9
  call void @free(ptr noundef %92) #5
  %93 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %93) #5
  %94 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %94) #5
  %95 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_free(ptr noundef %95, ptr noundef %5)
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  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_search(ptr noundef, ptr noundef, i32 noundef, i64 noundef, ptr noundef, ptr 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.7 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [28 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_find_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.7, 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 = call ptr @usearch_init(ptr noundef nonnull %4, ptr noundef nonnull %3) #6
  call void @usearch_reserve(ptr noundef %6, i64 noundef %0, ptr noundef nonnull %3) #6
  %7 = shl i64 %0, 3
  %8 = call noalias ptr @malloc(i64 noundef %7) #7
  %9 = shl i64 %0, 2
  %10 = call noalias ptr @malloc(i64 noundef %9) #7
  %11 = icmp ne ptr %8, null
  %12 = icmp ne ptr %10, null
  %13 = and i1 %11, %12
  call void @expect(i1 noundef zeroext %13, ptr noundef nonnull @.str.2)
  %14 = call ptr @create_vectors(i64 noundef %0, i64 noundef %1)
  %.not42 = icmp eq i64 %0, 0
  br i1 %.not42, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %.lr.ph41, %2
  call void @free(ptr noundef %14) #6
  call void @free(ptr noundef %8) #6
  call void @free(ptr noundef %10) #6
  call void @usearch_free(ptr noundef %6, ptr noundef nonnull %3) #6
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  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.ph41:                                         ; preds = %.lr.ph, %.lr.ph41
  %.03640 = phi i64 [ %26, %.lr.ph41 ], [ 0, %.lr.ph ]
  %20 = mul i64 %.03640, %1
  %21 = getelementptr inbounds float, ptr %14, i64 %20
  %22 = call i64 @usearch_search(ptr noundef %6, ptr noundef %21, i32 noundef 1, i64 noundef %0, ptr noundef %8, ptr noundef %10, ptr noundef nonnull %3) #6
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %23, null
  call void @expect(i1 noundef zeroext %.not, ptr noundef %23)
  %24 = add i64 %22, -1
  %25 = icmp ult i64 %24, %0
  call void @expect(i1 noundef zeroext %25, ptr noundef nonnull @.str.8)
  %26 = add nuw i64 %.03640, 1
  %exitcond44.not = icmp eq i64 %26, %0
  br i1 %exitcond44.not, label %._crit_edge, label %.lr.ph41, !llvm.loop !11
}

declare i64 @usearch_search(ptr noundef, ptr noundef, i32 noundef, i64 noundef, ptr noundef, ptr 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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