; 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.18 = external hidden unnamed_addr constant [17 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 noundef zeroext i1 @_ZN11alglib_impl13ae_fp_less_eqEdd(double noundef, double noundef) #1

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

declare void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare noundef double @_ZN11alglib_impl7ae_sqrtEdPNS_8ae_stateE(double noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN11alglib_impl12randomnormalEPNS_8ae_stateE(ptr noundef) #3

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

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %19, i64 noundef %20, ptr noundef %21)
  br label %22

22:                                               ; preds = %18, %3
  br label %23

23:                                               ; preds = %46, %22
  store double 0.000000e+00, ptr %8, align 8, !tbaa !15
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %42, %23
  %25 = load i64, ptr %7, align 8, !tbaa !5
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = sub nsw i64 %26, 1
  %28 = icmp sle i64 %25, %27
  br i1 %28, label %29, label %45

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  %31 = call noundef double @_ZN11alglib_impl12randomnormalEPNS_8ae_stateE(ptr noundef %30)
  store double %31, ptr %9, align 8, !tbaa !15
  %32 = load double, ptr %9, align 8, !tbaa !15
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = load i64, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds double, ptr %35, i64 %36
  store double %32, ptr %37, align 8, !tbaa !15
  %38 = load double, ptr %8, align 8, !tbaa !15
  %39 = load double, ptr %9, align 8, !tbaa !15
  %40 = load double, ptr %9, align 8, !tbaa !15
  %41 = call double @llvm.fmuladd.f64(double %39, double %40, double %38)
  store double %41, ptr %8, align 8, !tbaa !15
  br label %42

42:                                               ; preds = %29
  %43 = load i64, ptr %7, align 8, !tbaa !5
  %44 = add nsw i64 %43, 1
  store i64 %44, ptr %7, align 8, !tbaa !5
  br label %24, !llvm.loop !18

45:                                               ; preds = %24
  br label %46

46:                                               ; preds = %45
  %47 = load double, ptr %8, align 8, !tbaa !15
  %48 = call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_less_eqEdd(double noundef %47, double noundef 0.000000e+00)
  br i1 %48, label %23, label %49, !llvm.loop !20

49:                                               ; preds = %46
  %50 = load double, ptr %8, align 8, !tbaa !15
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = call noundef double @_ZN11alglib_impl7ae_sqrtEdPNS_8ae_stateE(double noundef %50, ptr noundef %51)
  %53 = fdiv double 1.000000e+00, %52
  store double %53, ptr %8, align 8, !tbaa !15
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %73, %49
  %55 = load i64, ptr %7, align 8, !tbaa !5
  %56 = load i64, ptr %4, align 8, !tbaa !5
  %57 = sub nsw i64 %56, 1
  %58 = icmp sle i64 %55, %57
  br i1 %58, label %59, label %76

59:                                               ; preds = %54
  %60 = load ptr, ptr %5, align 8, !tbaa !9
  %61 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %60, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  %63 = load i64, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds double, ptr %62, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !15
  %66 = load double, ptr %8, align 8, !tbaa !15
  %67 = fmul double %65, %66
  %68 = load ptr, ptr %5, align 8, !tbaa !9
  %69 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %68, i32 0, i32 4
  %70 = load ptr, ptr %69, align 8, !tbaa !17
  %71 = load i64, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds double, ptr %70, i64 %71
  store double %67, ptr %72, align 8, !tbaa !15
  br label %73

73:                                               ; preds = %59
  %74 = load i64, ptr %7, align 8, !tbaa !5
  %75 = add nsw i64 %74, 1
  store i64 %75, ptr %7, align 8, !tbaa !5
  br label %54, !llvm.loop !21

76:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

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


; 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.18 = external hidden unnamed_addr constant [17 x i8], align 1

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

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

declare void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 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

declare noundef double @_ZN11alglib_impl7ae_sqrtEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN11alglib_impl12randomnormalEPNS_8ae_stateE(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl10randomunitElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = icmp sgt i64 %0, 0
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %4, ptr noundef nonnull @.str.18, ptr noundef %2)
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = icmp slt i64 %5, %0
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  tail call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %1, i64 noundef %0, ptr noundef %2)
  br label %8

8:                                                ; preds = %7, %3
  %9 = getelementptr inbounds i8, ptr %1, i64 56
  br i1 %4, label %.lr.ph.us, label %.split

.lr.ph.us:                                        ; preds = %8, %.lr.ph.us.backedge
  %.033.us = phi i64 [ %.033.us.be, %.lr.ph.us.backedge ], [ 0, %8 ]
  %.02732.us = phi double [ %.02732.us.be, %.lr.ph.us.backedge ], [ 0.000000e+00, %8 ]
  %10 = tail call noundef double @_ZN11alglib_impl12randomnormalEPNS_8ae_stateE(ptr noundef %2)
  %11 = load ptr, ptr %9, align 8, !tbaa !13
  %12 = getelementptr inbounds double, ptr %11, i64 %.033.us
  store double %10, ptr %12, align 8, !tbaa !14
  %13 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %.02732.us)
  %14 = add nuw nsw i64 %.033.us, 1
  %exitcond.not = icmp eq i64 %14, %0
  br i1 %exitcond.not, label %._crit_edge.us, label %.lr.ph.us.backedge

.lr.ph.us.backedge:                               ; preds = %.lr.ph.us, %._crit_edge.us
  %.033.us.be = phi i64 [ %14, %.lr.ph.us ], [ 0, %._crit_edge.us ]
  %.02732.us.be = phi double [ %13, %.lr.ph.us ], [ 0.000000e+00, %._crit_edge.us ]
  br label %.lr.ph.us, !llvm.loop !16

._crit_edge.us:                                   ; preds = %.lr.ph.us
  %15 = tail call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_less_eqEdd(double noundef %13, double noundef 0.000000e+00)
  br i1 %15, label %.lr.ph.us.backedge, label %.split35.us

.split:                                           ; preds = %8, %.split
  %16 = tail call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_less_eqEdd(double noundef 0.000000e+00, double noundef 0.000000e+00)
  br i1 %16, label %.split, label %.split35.us, !llvm.loop !16

.split35.us:                                      ; preds = %.split, %._crit_edge.us
  %.us-phi = phi double [ %13, %._crit_edge.us ], [ 0.000000e+00, %.split ]
  %17 = tail call noundef double @_ZN11alglib_impl7ae_sqrtEdPNS_8ae_stateE(double noundef %.us-phi, ptr noundef %2)
  %18 = fdiv double 1.000000e+00, %17
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.split35.us
  %xtraiter = and i64 %0, 3
  %19 = icmp ult i64 %0, 4
  br i1 %19, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

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

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.137 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %39, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %20 = load ptr, ptr %9, align 8, !tbaa !13
  %21 = getelementptr inbounds double, ptr %20, i64 %.137
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = fmul double %18, %22
  store double %23, ptr %21, align 8, !tbaa !14
  %24 = or disjoint i64 %.137, 1
  %25 = load ptr, ptr %9, align 8, !tbaa !13
  %26 = getelementptr inbounds double, ptr %25, i64 %24
  %27 = load double, ptr %26, align 8, !tbaa !14
  %28 = fmul double %18, %27
  store double %28, ptr %26, align 8, !tbaa !14
  %29 = or disjoint i64 %.137, 2
  %30 = load ptr, ptr %9, align 8, !tbaa !13
  %31 = getelementptr inbounds double, ptr %30, i64 %29
  %32 = load double, ptr %31, align 8, !tbaa !14
  %33 = fmul double %18, %32
  store double %33, ptr %31, align 8, !tbaa !14
  %34 = or disjoint i64 %.137, 3
  %35 = load ptr, ptr %9, align 8, !tbaa !13
  %36 = getelementptr inbounds double, ptr %35, i64 %34
  %37 = load double, ptr %36, align 8, !tbaa !14
  %38 = fmul double %18, %37
  store double %38, ptr %36, align 8, !tbaa !14
  %39 = add nuw nsw i64 %.137, 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 %.lr.ph, !llvm.loop !18

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

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.137.epil = phi i64 [ %44, %.lr.ph.epil ], [ %.137.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %40 = load ptr, ptr %9, align 8, !tbaa !13
  %41 = getelementptr inbounds double, ptr %40, i64 %.137.epil
  %42 = load double, ptr %41, align 8, !tbaa !14
  %43 = fmul double %18, %42
  store double %43, ptr %41, align 8, !tbaa !14
  %44 = add nuw nsw i64 %.137.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 %.lr.ph.epil, !llvm.loop !19

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.split35.us
  ret void
}

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, !17}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}


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