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

; 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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl17checknlcviolationEPNS_9ae_vectorEllPdPlPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  store double 0.000000e+00, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %16, align 8, !tbaa !9
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -1, ptr %18, align 8, !tbaa !9
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %56, %6
  %20 = load i64, ptr %13, align 8, !tbaa !9
  %21 = load i64, ptr %8, align 8, !tbaa !9
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = add nsw i64 %21, %22
  %24 = sub nsw i64 %23, 1
  %25 = icmp sle i64 %20, %24
  br i1 %25, label %26, label %59

26:                                               ; preds = %19
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load i64, ptr %13, align 8, !tbaa !9
  %31 = add nsw i64 %30, 1
  %32 = getelementptr inbounds double, ptr %29, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !11
  store double %33, ptr %14, align 8, !tbaa !11
  %34 = load i64, ptr %13, align 8, !tbaa !9
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = icmp slt i64 %34, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %26
  %38 = load double, ptr %14, align 8, !tbaa !11
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = call noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef %38, ptr noundef %39)
  store double %40, ptr %14, align 8, !tbaa !11
  br label %45

41:                                               ; preds = %26
  %42 = load double, ptr %14, align 8, !tbaa !11
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %42, double noundef 0.000000e+00, ptr noundef %43)
  store double %44, ptr %14, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %41, %37
  %46 = load double, ptr %14, align 8, !tbaa !11
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = fcmp ogt double %46, %48
  br i1 %49, label %50, label %55

50:                                               ; preds = %45
  %51 = load double, ptr %14, align 8, !tbaa !11
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  store double %51, ptr %52, align 8, !tbaa !11
  %53 = load i64, ptr %13, align 8, !tbaa !9
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 %53, ptr %54, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %50, %45
  br label %56

56:                                               ; preds = %55
  %57 = load i64, ptr %13, align 8, !tbaa !9
  %58 = add nsw i64 %57, 1
  store i64 %58, ptr %13, align 8, !tbaa !9
  br label %19, !llvm.loop !14

59:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl17checknlcviolationEPNS_9ae_vectorEllPdPlPNS_8ae_stateE(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, ptr nocapture noundef %3, ptr nocapture noundef writeonly %4, ptr noundef %5) local_unnamed_addr #1 {
  store double 0.000000e+00, ptr %3, align 8, !tbaa !5
  store i64 -1, ptr %4, align 8, !tbaa !9
  %7 = add nsw i64 %2, %1
  %.not.not22 = icmp sgt i64 %7, 0
  br i1 %.not.not22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  br label %9

9:                                                ; preds = %.lr.ph, %23
  %.02123 = phi i64 [ 0, %.lr.ph ], [ %11, %23 ]
  %10 = load ptr, ptr %8, align 8, !tbaa !11
  %11 = add nuw nsw i64 %.02123, 1
  %12 = getelementptr inbounds double, ptr %10, i64 %11
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = icmp slt i64 %.02123, %1
  br i1 %14, label %15, label %17

15:                                               ; preds = %9
  %16 = tail call noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef %13, ptr noundef %5)
  br label %19

17:                                               ; preds = %9
  %18 = tail call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %13, double noundef 0.000000e+00, ptr noundef %5)
  br label %19

19:                                               ; preds = %17, %15
  %.0 = phi double [ %16, %15 ], [ %18, %17 ]
  %20 = load double, ptr %3, align 8, !tbaa !5
  %21 = fcmp ogt double %.0, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store double %.0, ptr %3, align 8, !tbaa !5
  store i64 %.02123, ptr %4, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %19, %22
  %exitcond.not = icmp eq i64 %11, %7
  br i1 %exitcond.not, label %._crit_edge, label %9, !llvm.loop !12

._crit_edge:                                      ; preds = %23, %6
  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 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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