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

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

; 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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl11rmatrixsymvEldPNS_9ae_matrixEllbPNS_9ae_vectorEldS3_lPNS_8ae_stateE(i64 noundef, double noundef, ptr noundef, i64 noundef, i64 noundef, i1 noundef zeroext, ptr noundef, i64 noundef, double noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11alglib_impl12rmatrixsyvmvElPNS_9ae_matrixEllbPNS_9ae_vectorElS3_PNS_8ae_stateE(i64 noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i1 noundef zeroext %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, ptr noundef %8) #1 {
  %10 = alloca double, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i8, align 1
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca double, align 8
  %22 = alloca i32, align 4
  store i64 %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !9
  store i64 %2, ptr %13, align 8, !tbaa !5
  store i64 %3, ptr %14, align 8, !tbaa !5
  %23 = zext i1 %4 to i8
  store i8 %23, ptr %15, align 1, !tbaa !11
  store ptr %5, ptr %16, align 8, !tbaa !9
  store i64 %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !9
  store ptr %8, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %24 = load i64, ptr %11, align 8, !tbaa !5
  %25 = icmp sle i64 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %9
  store double 0.000000e+00, ptr %21, align 8, !tbaa !13
  %27 = load double, ptr %21, align 8, !tbaa !13
  store double %27, ptr %10, align 8
  store i32 1, ptr %22, align 4
  br label %66

28:                                               ; preds = %9
  %29 = load i64, ptr %11, align 8, !tbaa !5
  %30 = load ptr, ptr %12, align 8, !tbaa !9
  %31 = load i64, ptr %13, align 8, !tbaa !5
  %32 = load i64, ptr %14, align 8, !tbaa !5
  %33 = load i8, ptr %15, align 1, !tbaa !11, !range !15, !noundef !16
  %34 = trunc i8 %33 to i1
  %35 = load ptr, ptr %16, align 8, !tbaa !9
  %36 = load i64, ptr %17, align 8, !tbaa !5
  %37 = load ptr, ptr %18, align 8, !tbaa !9
  %38 = load ptr, ptr %19, align 8, !tbaa !9
  call void @_ZN11alglib_impl11rmatrixsymvEldPNS_9ae_matrixEllbPNS_9ae_vectorEldS3_lPNS_8ae_stateE(i64 noundef %29, double noundef 1.000000e+00, ptr noundef %30, i64 noundef %31, i64 noundef %32, i1 noundef zeroext %34, ptr noundef %35, i64 noundef %36, double noundef 0.000000e+00, ptr noundef %37, i64 noundef 0, ptr noundef %38)
  store double 0.000000e+00, ptr %21, align 8, !tbaa !13
  store i64 0, ptr %20, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %61, %28
  %40 = load i64, ptr %20, align 8, !tbaa !5
  %41 = load i64, ptr %11, align 8, !tbaa !5
  %42 = sub nsw i64 %41, 1
  %43 = icmp sle i64 %40, %42
  br i1 %43, label %44, label %64

44:                                               ; preds = %39
  %45 = load double, ptr %21, align 8, !tbaa !13
  %46 = load ptr, ptr %16, align 8, !tbaa !9
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %46, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = load i64, ptr %17, align 8, !tbaa !5
  %50 = load i64, ptr %20, align 8, !tbaa !5
  %51 = add nsw i64 %49, %50
  %52 = getelementptr inbounds double, ptr %48, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !13
  %54 = load ptr, ptr %18, align 8, !tbaa !9
  %55 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = load i64, ptr %20, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %56, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !13
  %60 = call double @llvm.fmuladd.f64(double %53, double %59, double %45)
  store double %60, ptr %21, align 8, !tbaa !13
  br label %61

61:                                               ; preds = %44
  %62 = load i64, ptr %20, align 8, !tbaa !5
  %63 = add nsw i64 %62, 1
  store i64 %63, ptr %20, align 8, !tbaa !5
  br label %39, !llvm.loop !18

64:                                               ; preds = %39
  %65 = load double, ptr %21, align 8, !tbaa !13
  store double %65, ptr %10, align 8
  store i32 1, ptr %22, align 4
  br label %66

66:                                               ; preds = %64, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  %67 = load double, ptr %10, align 8
  ret double %67
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl11rmatrixsymvEldPNS_9ae_matrixEllbPNS_9ae_vectorEldS3_lPNS_8ae_stateE(i64 noundef, double noundef, ptr noundef, i64 noundef, i64 noundef, i1 noundef zeroext, ptr noundef, i64 noundef, double noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11alglib_impl12rmatrixsyvmvElPNS_9ae_matrixEllbPNS_9ae_vectorElS3_PNS_8ae_stateE(i64 noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i1 noundef zeroext %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, ptr noundef %8) local_unnamed_addr #0 {
  %10 = icmp slt i64 %0, 1
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %9
  tail call void @_ZN11alglib_impl11rmatrixsymvEldPNS_9ae_matrixEllbPNS_9ae_vectorEldS3_lPNS_8ae_stateE(i64 noundef %0, double noundef 1.000000e+00, ptr noundef %1, i64 noundef %2, i64 noundef %3, i1 noundef zeroext %4, ptr noundef %5, i64 noundef %6, double noundef 0.000000e+00, ptr noundef %7, i64 noundef 0, ptr noundef %8)
  %12 = getelementptr inbounds i8, ptr %5, i64 56
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %invariant.gep = getelementptr double, ptr %13, i64 %6
  %14 = getelementptr inbounds i8, ptr %7, i64 56
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %xtraiter = and i64 %0, 3
  %16 = icmp ult i64 %0, 4
  br i1 %16, label %.loopexit.loopexit.unr-lcssa, label %.new

.new:                                             ; preds = %11
  %unroll_iter = and i64 %0, 9223372036854775804
  br label %17

17:                                               ; preds = %17, %.new
  %.025 = phi double [ 0.000000e+00, %.new ], [ %36, %17 ]
  %.02124 = phi i64 [ 0, %.new ], [ %37, %17 ]
  %niter = phi i64 [ 0, %.new ], [ %niter.next.3, %17 ]
  %gep = getelementptr double, ptr %invariant.gep, i64 %.02124
  %18 = load double, ptr %gep, align 8, !tbaa !8
  %19 = getelementptr inbounds double, ptr %15, i64 %.02124
  %20 = load double, ptr %19, align 8, !tbaa !8
  %21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %.025)
  %22 = or disjoint i64 %.02124, 1
  %gep.1 = getelementptr double, ptr %invariant.gep, i64 %22
  %23 = load double, ptr %gep.1, align 8, !tbaa !8
  %24 = getelementptr inbounds double, ptr %15, i64 %22
  %25 = load double, ptr %24, align 8, !tbaa !8
  %26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %21)
  %27 = or disjoint i64 %.02124, 2
  %gep.2 = getelementptr double, ptr %invariant.gep, i64 %27
  %28 = load double, ptr %gep.2, align 8, !tbaa !8
  %29 = getelementptr inbounds double, ptr %15, i64 %27
  %30 = load double, ptr %29, align 8, !tbaa !8
  %31 = tail call double @llvm.fmuladd.f64(double %28, double %30, double %26)
  %32 = or disjoint i64 %.02124, 3
  %gep.3 = getelementptr double, ptr %invariant.gep, i64 %32
  %33 = load double, ptr %gep.3, align 8, !tbaa !8
  %34 = getelementptr inbounds double, ptr %15, i64 %32
  %35 = load double, ptr %34, align 8, !tbaa !8
  %36 = tail call double @llvm.fmuladd.f64(double %33, double %35, double %31)
  %37 = add nuw nsw i64 %.02124, 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 %.loopexit.loopexit.unr-lcssa, label %17, !llvm.loop !10

.loopexit.loopexit.unr-lcssa:                     ; preds = %17, %11
  %.lcssa.ph = phi double [ poison, %11 ], [ %36, %17 ]
  %.025.unr = phi double [ 0.000000e+00, %11 ], [ %36, %17 ]
  %.02124.unr = phi i64 [ 0, %11 ], [ %37, %17 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader
  %.025.epil = phi double [ %41, %.epil.preheader ], [ %.025.unr, %.loopexit.loopexit.unr-lcssa ]
  %.02124.epil = phi i64 [ %42, %.epil.preheader ], [ %.02124.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %gep.epil = getelementptr double, ptr %invariant.gep, i64 %.02124.epil
  %38 = load double, ptr %gep.epil, align 8, !tbaa !8
  %39 = getelementptr inbounds double, ptr %15, i64 %.02124.epil
  %40 = load double, ptr %39, align 8, !tbaa !8
  %41 = tail call double @llvm.fmuladd.f64(double %38, double %40, double %.025.epil)
  %42 = add nuw nsw i64 %.02124.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 %.loopexit, label %.epil.preheader, !llvm.loop !12

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %9
  %.022 = phi double [ 0.000000e+00, %9 ], [ %.lcssa.ph, %.loopexit.loopexit.unr-lcssa ], [ %41, %.epil.preheader ]
  ret double %.022
}

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}


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