; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (interpolation)

; 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.alglib_impl::idwbuilder" = type { i64, %"struct.alglib_impl::ae_vector", i64, i64, double, double, double, double, double, double, %"struct.alglib_impl::ae_vector", i64, i64, i64, %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::kdtree", %"struct.alglib_impl::ae_vector" }
%"struct.alglib_impl::ae_matrix" = type { i64, i64, i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.1 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.1 = type { ptr }
%"struct.alglib_impl::kdtree" = type { i64, i64, i64, i64, %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::kdtreerequestbuffer", i64 }
%"struct.alglib_impl::kdtreerequestbuffer" = type { %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", i64, double, i8, double, i64, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", double }
%"struct.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.0 }
%union.anon.0 = type { ptr }

@.str.111 = external hidden unnamed_addr constant [49 x i8], align 1

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

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

declare void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl21idwbuildersetusertermEPNS_10idwbuilderEdPNS_8ae_stateE(ptr noundef %0, double noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load double, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %8, ptr noundef %9)
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %10, ptr noundef @.str.111, ptr noundef %11)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.alglib_impl::idwbuilder", ptr %12, i32 0, i32 0
  store i64 0, ptr %13, align 8, !tbaa !11
  store i64 0, ptr %7, align 8, !tbaa !20
  br label %14

14:                                               ; preds = %29, %3
  %15 = load i64, ptr %7, align 8, !tbaa !20
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.alglib_impl::idwbuilder", ptr %16, i32 0, i32 13
  %18 = load i64, ptr %17, align 8, !tbaa !21
  %19 = sub nsw i64 %18, 1
  %20 = icmp sle i64 %15, %19
  br i1 %20, label %21, label %32

21:                                               ; preds = %14
  %22 = load double, ptr %5, align 8, !tbaa !9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::idwbuilder", ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %27 = load i64, ptr %7, align 8, !tbaa !20
  %28 = getelementptr inbounds double, ptr %26, i64 %27
  store double %22, ptr %28, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %21
  %30 = load i64, ptr %7, align 8, !tbaa !20
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %7, align 8, !tbaa !20
  br label %14, !llvm.loop !23

32:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

declare noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN11alglib_impl10idwbuilderE", !13, i64 0, !14, i64 8, !13, i64 72, !13, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !14, i64 136, !13, i64 200, !13, i64 208, !13, i64 216, !17, i64 224, !17, i64 304, !14, i64 384, !14, i64 448, !14, i64 512, !14, i64 576, !14, i64 640, !18, i64 704, !14, i64 1704}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl9ae_vectorE", !13, i64 0, !13, i64 8, !15, i64 16, !16, i64 24, !7, i64 56}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"_ZTSN11alglib_impl9ae_matrixE", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !15, i64 32, !16, i64 40, !7, i64 72}
!18 = !{!"_ZTSN11alglib_impl6kdtreeE", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !17, i64 32, !14, i64 112, !14, i64 176, !14, i64 240, !14, i64 304, !14, i64 368, !19, i64 432, !13, i64 992}
!19 = !{!"_ZTSN11alglib_impl19kdtreerequestbufferE", !14, i64 0, !14, i64 64, !14, i64 128, !13, i64 192, !10, i64 200, !15, i64 208, !10, i64 216, !13, i64 224, !14, i64 232, !14, i64 296, !14, i64 360, !14, i64 424, !14, i64 488, !10, i64 552}
!20 = !{!13, !13, i64 0}
!21 = !{!12, !13, i64 216}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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"

@.str.111 = external hidden unnamed_addr constant [49 x i8], align 1

declare void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl21idwbuildersetusertermEPNS_10idwbuilderEdPNS_8ae_stateE(ptr nocapture noundef %0, double noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %1, ptr noundef %2)
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %4, ptr noundef nonnull @.str.111, ptr noundef %2)
  store i64 0, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 216
  %6 = load i64, ptr %5, align 8, !tbaa !18
  %.not.not9 = icmp sgt i64 %6, 0
  br i1 %.not.not9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 64
  %xtraiter = and i64 %6, 3
  %8 = icmp ult i64 %6, 4
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %6, 9223372036854775804
  br label %9

9:                                                ; preds = %9, %.lr.ph.new
  %.010 = phi i64 [ 0, %.lr.ph.new ], [ %21, %9 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %9 ]
  %10 = load ptr, ptr %7, align 8, !tbaa !19
  %11 = getelementptr inbounds double, ptr %10, i64 %.010
  store double %1, ptr %11, align 8, !tbaa !20
  %12 = or disjoint i64 %.010, 1
  %13 = load ptr, ptr %7, align 8, !tbaa !19
  %14 = getelementptr inbounds double, ptr %13, i64 %12
  store double %1, ptr %14, align 8, !tbaa !20
  %15 = or disjoint i64 %.010, 2
  %16 = load ptr, ptr %7, align 8, !tbaa !19
  %17 = getelementptr inbounds double, ptr %16, i64 %15
  store double %1, ptr %17, align 8, !tbaa !20
  %18 = or disjoint i64 %.010, 3
  %19 = load ptr, ptr %7, align 8, !tbaa !19
  %20 = getelementptr inbounds double, ptr %19, i64 %18
  store double %1, ptr %20, align 8, !tbaa !20
  %21 = add nuw nsw i64 %.010, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %9, !llvm.loop !21

._crit_edge.loopexit.unr-lcssa:                   ; preds = %9, %.lr.ph
  %.010.unr = phi i64 [ 0, %.lr.ph ], [ %21, %9 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.010.epil = phi i64 [ %24, %.epil.preheader ], [ %.010.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %22 = load ptr, ptr %7, align 8, !tbaa !19
  %23 = getelementptr inbounds double, ptr %22, i64 %.010.epil
  store double %1, ptr %23, align 8, !tbaa !20
  %24 = add nuw nsw i64 %.010.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !23

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %3
  ret void
}

declare noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #0

attributes #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 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" }

!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, !7, i64 0}
!6 = !{!"_ZTSN11alglib_impl10idwbuilderE", !7, i64 0, !10, i64 8, !7, i64 72, !7, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !10, i64 136, !7, i64 200, !7, i64 208, !7, i64 216, !15, i64 224, !15, i64 304, !10, i64 384, !10, i64 448, !10, i64 512, !10, i64 576, !10, i64 640, !16, i64 704, !10, i64 1704}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN11alglib_impl9ae_vectorE", !7, i64 0, !7, i64 8, !11, i64 16, !12, i64 24, !8, i64 56}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"double", !8, i64 0}
!15 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !12, i64 40, !8, i64 72}
!16 = !{!"_ZTSN11alglib_impl6kdtreeE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !15, i64 32, !10, i64 112, !10, i64 176, !10, i64 240, !10, i64 304, !10, i64 368, !17, i64 432, !7, i64 992}
!17 = !{!"_ZTSN11alglib_impl19kdtreerequestbufferE", !10, i64 0, !10, i64 64, !10, i64 128, !7, i64 192, !14, i64 200, !11, i64 208, !14, i64 216, !7, i64 224, !10, i64 232, !10, i64 296, !10, i64 360, !10, i64 424, !10, i64 488, !14, i64 552}
!18 = !{!6, !7, i64 216}
!19 = !{!8, !8, i64 0}
!20 = !{!14, !14, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass