; 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.12 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [30 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: 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) #3

; Function Attrs: nounwind uwtable
define dso_local void @test_remove_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 i64, 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.12, i64 noundef %13, i64 noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 64, ptr %6) #4
  %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)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = call ptr @usearch_init(ptr noundef %6, ptr noundef %5)
  store ptr %17, ptr %7, align 8, !tbaa !9
  %18 = load ptr, ptr %7, align 8, !tbaa !9
  %19 = load i64, ptr %3, align 8, !tbaa !5
  call void @usearch_reserve(ptr noundef %18, i64 noundef %19, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = call ptr @create_vectors(i64 noundef %20, i64 noundef %21)
  store ptr %22, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %41, %2
  %24 = load i64, ptr %9, align 8, !tbaa !5
  %25 = load i64, ptr %3, align 8, !tbaa !5
  %26 = icmp ult i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %44

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %29 = load i64, ptr %9, align 8, !tbaa !5
  store i64 %29, ptr %10, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = load i64, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = load i64, ptr %9, align 8, !tbaa !5
  %34 = load i64, ptr %4, align 8, !tbaa !5
  %35 = mul i64 %33, %34
  %36 = getelementptr inbounds float, ptr %32, i64 %35
  call void @usearch_add(ptr noundef %30, i64 noundef %31, ptr noundef %36, i32 noundef 1, ptr noundef %5)
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = icmp ne ptr %37, null
  %39 = xor i1 %38, true
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %39, ptr noundef %40)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %41

41:                                               ; preds = %28
  %42 = load i64, ptr %9, align 8, !tbaa !5
  %43 = add i64 %42, 1
  store i64 %43, ptr %9, align 8, !tbaa !5
  br label %23, !llvm.loop !11

44:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %58, %44
  %46 = load i64, ptr %11, align 8, !tbaa !5
  %47 = load i64, ptr %3, align 8, !tbaa !5
  %48 = icmp ult i64 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %61

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %51 = load i64, ptr %11, align 8, !tbaa !5
  store i64 %51, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !9
  %53 = load i64, ptr %12, align 8, !tbaa !5
  %54 = call i64 @usearch_remove(ptr noundef %52, i64 noundef %53, ptr noundef %5)
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = icmp ne ptr %55, null
  %57 = xor i1 %56, true
  call void @expect(i1 noundef zeroext %57, ptr noundef @.str.13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %58

58:                                               ; preds = %50
  %59 = load i64, ptr %11, align 8, !tbaa !5
  %60 = add i64 %59, 1
  store i64 %60, ptr %11, align 8, !tbaa !5
  br label %45, !llvm.loop !13

61:                                               ; preds = %49
  %62 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %62) #4
  %63 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_free(ptr noundef %63, ptr noundef %5)
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

declare i64 @usearch_remove(ptr noundef, i64 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 "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 }

!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.12 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [30 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 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 #3

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_remove_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.12, i64 noundef %0, i64 noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #5
  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) #5
  call void @usearch_reserve(ptr noundef %6, i64 noundef %0, ptr noundef nonnull %3) #5
  %7 = call ptr @create_vectors(i64 noundef %0, i64 noundef %1)
  %.not29 = icmp eq i64 %0, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.026 = phi i64 [ %11, %.lr.ph ], [ 0, %2 ]
  %8 = mul i64 %.026, %1
  %9 = getelementptr inbounds float, ptr %7, i64 %8
  call void @usearch_add(ptr noundef %6, i64 noundef %.026, ptr noundef %9, i32 noundef 1, ptr noundef nonnull %3) #5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %.not25 = icmp eq ptr %10, null
  call void @expect(i1 noundef zeroext %.not25, ptr noundef %10)
  %11 = add nuw i64 %.026, 1
  %exitcond.not = icmp eq i64 %11, %0
  br i1 %exitcond.not, label %.lr.ph28, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph28, %2
  call void @free(ptr noundef %7) #5
  call void @usearch_free(ptr noundef %6, ptr noundef nonnull %3) #5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret void

.lr.ph28:                                         ; preds = %.lr.ph, %.lr.ph28
  %.02327 = phi i64 [ %15, %.lr.ph28 ], [ 0, %.lr.ph ]
  %13 = call i64 @usearch_remove(ptr noundef %6, i64 noundef %.02327, ptr noundef nonnull %3) #5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %14, null
  call void @expect(i1 noundef zeroext %.not, ptr noundef nonnull @.str.13)
  %15 = add nuw i64 %.02327, 1
  %exitcond31.not = icmp eq i64 %15, %0
  br i1 %exitcond31.not, label %._crit_edge, label %.lr.ph28, !llvm.loop !11
}

declare i64 @usearch_remove(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #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 = { 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 = { "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 = { 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 #5 = { 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/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