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

; 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::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon = type { ptr }

@.str.7 = external hidden unnamed_addr constant [43 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11alglib_impl14isfinitevectorEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, ptr noundef %2) #3 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = icmp sge i64 %12, 0
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %13, ptr noundef @.str.7, ptr noundef %14)
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  store i8 1, ptr %10, align 1, !tbaa !11
  %18 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %19 = trunc i8 %18 to i1
  store i1 %19, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %54

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %21, i32 0, i32 0
  %23 = load i64, ptr %22, align 8, !tbaa !15
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = icmp slt i64 %23, %24
  br i1 %25, label %26, label %29

26:                                               ; preds = %20
  store i8 0, ptr %10, align 1, !tbaa !11
  %27 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %28 = trunc i8 %27 to i1
  store i1 %28, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %54

29:                                               ; preds = %20
  store double 0.000000e+00, ptr %9, align 8, !tbaa !18
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %44, %29
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = load i64, ptr %6, align 8, !tbaa !9
  %33 = sub nsw i64 %32, 1
  %34 = icmp sle i64 %31, %33
  br i1 %34, label %35, label %47

35:                                               ; preds = %30
  %36 = load double, ptr %9, align 8, !tbaa !18
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !18
  %43 = call double @llvm.fmuladd.f64(double 1.000000e-02, double %36, double %42)
  store double %43, ptr %9, align 8, !tbaa !18
  br label %44

44:                                               ; preds = %35
  %45 = load i64, ptr %8, align 8, !tbaa !9
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %8, align 8, !tbaa !9
  br label %30, !llvm.loop !21

47:                                               ; preds = %30
  %48 = load double, ptr %9, align 8, !tbaa !18
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %48, ptr noundef %49)
  %51 = zext i1 %50 to i8
  store i8 %51, ptr %10, align 1, !tbaa !11
  %52 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %53 = trunc i8 %52 to i1
  store i1 %53, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %54

54:                                               ; preds = %47, %26, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %55 = load i1, ptr %4, align 1
  ret i1 %55
}

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !12, i64 16, !17, i64 24, !7, i64 56}
!17 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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.7 = external hidden unnamed_addr constant [43 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11alglib_impl14isfinitevectorEPNS_9ae_vectorElPNS_8ae_stateE(ptr nocapture noundef readonly %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = icmp sgt i64 %1, -1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %4, ptr noundef nonnull @.str.7, ptr noundef %2)
  %5 = icmp eq i64 %1, 0
  br i1 %5, label %34, label %6

6:                                                ; preds = %3
  %7 = load i64, ptr %0, align 8, !tbaa !5
  %8 = icmp slt i64 %7, %1
  br i1 %8, label %34, label %.preheader

.preheader:                                       ; preds = %6
  %.not.not19 = icmp sgt i64 %1, 0
  br i1 %.not.not19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %xtraiter = and i64 %1, 3
  %11 = icmp ult i64 %1, 4
  br i1 %11, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

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

12:                                               ; preds = %12, %.lr.ph.new
  %.021 = phi double [ 0.000000e+00, %.lr.ph.new ], [ %27, %12 ]
  %.01620 = phi i64 [ 0, %.lr.ph.new ], [ %28, %12 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %12 ]
  %13 = getelementptr inbounds double, ptr %10, i64 %.01620
  %14 = load double, ptr %13, align 8, !tbaa !14
  %15 = tail call double @llvm.fmuladd.f64(double %.021, double 1.000000e-02, double %14)
  %16 = or disjoint i64 %.01620, 1
  %17 = getelementptr inbounds double, ptr %10, i64 %16
  %18 = load double, ptr %17, align 8, !tbaa !14
  %19 = tail call double @llvm.fmuladd.f64(double %15, double 1.000000e-02, double %18)
  %20 = or disjoint i64 %.01620, 2
  %21 = getelementptr inbounds double, ptr %10, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = tail call double @llvm.fmuladd.f64(double %19, double 1.000000e-02, double %22)
  %24 = or disjoint i64 %.01620, 3
  %25 = getelementptr inbounds double, ptr %10, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !14
  %27 = tail call double @llvm.fmuladd.f64(double %23, double 1.000000e-02, double %26)
  %28 = add nuw nsw i64 %.01620, 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 %12, !llvm.loop !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %12, %.lr.ph
  %.lcssa.ph = phi double [ poison, %.lr.ph ], [ %27, %12 ]
  %.021.unr = phi double [ 0.000000e+00, %.lr.ph ], [ %27, %12 ]
  %.01620.unr = phi i64 [ 0, %.lr.ph ], [ %28, %12 ]
  %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
  %.021.epil = phi double [ %31, %.epil.preheader ], [ %.021.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01620.epil = phi i64 [ %32, %.epil.preheader ], [ %.01620.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %29 = getelementptr inbounds double, ptr %10, i64 %.01620.epil
  %30 = load double, ptr %29, align 8, !tbaa !14
  %31 = tail call double @llvm.fmuladd.f64(double %.021.epil, double 1.000000e-02, double %30)
  %32 = add nuw nsw i64 %.01620.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 !18

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %.preheader
  %.0.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %31, %.epil.preheader ]
  %33 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %.0.lcssa, ptr noundef %2)
  br label %34

34:                                               ; preds = %6, %3, %._crit_edge
  %.017 = phi i1 [ %33, %._crit_edge ], [ true, %3 ], [ false, %6 ]
  ret i1 %.017
}

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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_impl9ae_vectorE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !8, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}


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