; 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.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [21 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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_view(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
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, i64 noundef %11, i64 noundef %12)
  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
  %14 = 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 %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %15 = call ptr @usearch_init(ptr noundef %6, ptr noundef %5)
  store ptr %15, ptr %7, align 8, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !9
  %17 = load i64, ptr %3, align 8, !tbaa !5
  call void @usearch_reserve(ptr noundef %16, i64 noundef %17, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = call ptr @create_vectors(i64 noundef %18, i64 noundef %19)
  store ptr %20, 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 %21

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

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

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

39:                                               ; preds = %26
  %40 = load i64, ptr %9, align 8, !tbaa !5
  %41 = add i64 %40, 1
  store i64 %41, ptr %9, align 8, !tbaa !5
  br label %21, !llvm.loop !11

42:                                               ; preds = %25
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_save(ptr noundef %43, ptr noundef @.str.16, ptr noundef %5)
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = icmp ne ptr %44, null
  %46 = xor i1 %45, true
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %46, ptr noundef %47)
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_free(ptr noundef %48, ptr noundef %5)
  %49 = load ptr, ptr %5, align 8, !tbaa !9
  %50 = icmp ne ptr %49, null
  %51 = xor i1 %50, true
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %51, ptr noundef %52)
  %53 = call ptr @usearch_init(ptr noundef %6, ptr noundef %5)
  store ptr %53, ptr %7, align 8, !tbaa !9
  %54 = load ptr, ptr %5, align 8, !tbaa !9
  %55 = icmp ne ptr %54, null
  %56 = xor i1 %55, true
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %56, ptr noundef %57)
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_view(ptr noundef %58, ptr noundef @.str.16, ptr noundef %5)
  %59 = load ptr, ptr %5, align 8, !tbaa !9
  %60 = icmp ne ptr %59, null
  %61 = xor i1 %60, true
  %62 = load ptr, ptr %5, align 8, !tbaa !9
  call void @expect(i1 noundef zeroext %61, ptr noundef %62)
  %63 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %63) #4
  %64 = load ptr, ptr %7, align 8, !tbaa !9
  call void @usearch_free(ptr noundef %64, ptr noundef %5)
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  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 void @usearch_view(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 "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"}


; 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.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [21 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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_view(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.18, 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)
  %.not25 = icmp eq i64 %0, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  call void @usearch_save(ptr noundef %6, ptr noundef nonnull @.str.16, ptr noundef nonnull %3) #5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  call void @expect(i1 noundef zeroext %.not, ptr noundef %8)
  call void @usearch_free(ptr noundef %6, ptr noundef nonnull %3) #5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %.not20 = icmp eq ptr %9, null
  call void @expect(i1 noundef zeroext %.not20, ptr noundef %9)
  %10 = call ptr @usearch_init(ptr noundef nonnull %4, ptr noundef nonnull %3) #5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %.not21 = icmp eq ptr %11, null
  call void @expect(i1 noundef zeroext %.not21, ptr noundef %11)
  call void @usearch_view(ptr noundef %10, ptr noundef nonnull @.str.16, ptr noundef nonnull %3) #5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %.not22 = icmp eq ptr %12, null
  call void @expect(i1 noundef zeroext %.not22, ptr noundef %12)
  call void @free(ptr noundef %7) #5
  call void @usearch_free(ptr noundef %10, ptr noundef nonnull %3) #5
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19)
  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.ph:                                           ; preds = %2, %.lr.ph
  %.024 = phi i64 [ %17, %.lr.ph ], [ 0, %2 ]
  %14 = mul i64 %.024, %1
  %15 = getelementptr inbounds float, ptr %7, i64 %14
  call void @usearch_add(ptr noundef %6, i64 noundef %.024, ptr noundef %15, i32 noundef 1, ptr noundef nonnull %3) #5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %.not23 = icmp eq ptr %16, null
  call void @expect(i1 noundef zeroext %.not23, ptr noundef %16)
  %17 = add nuw i64 %.024, 1
  %exitcond.not = icmp eq i64 %17, %0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

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


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