; LLVM IR from Dimandragon/non-parametric-dsp :: 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 zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef, ptr noundef) #1

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

22:                                               ; preds = %87, %7
  %23 = load i64, ptr %15, align 8, !tbaa !9
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = sub nsw i64 %24, 1
  %26 = icmp sle i64 %23, %25
  br i1 %26, label %27, label %90

27:                                               ; preds = %22
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = load i64, ptr %15, align 8, !tbaa !9
  %32 = add nsw i64 %31, 1
  %33 = getelementptr inbounds double, ptr %30, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  store double %34, ptr %16, align 8, !tbaa !11
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %35, i32 0, i32 4
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = load i64, ptr %15, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %14, align 8, !tbaa !5
  %42 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %40, ptr noundef %41)
  br i1 %42, label %43, label %55

43:                                               ; preds = %27
  %44 = load double, ptr %17, align 8, !tbaa !11
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i64, ptr %15, align 8, !tbaa !9
  %49 = getelementptr inbounds double, ptr %47, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load double, ptr %16, align 8, !tbaa !11
  %52 = fsub double %50, %51
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %44, double noundef %52, ptr noundef %53)
  store double %54, ptr %17, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %43, %27
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %56, i32 0, i32 4
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = load i64, ptr %15, align 8, !tbaa !9
  %60 = getelementptr inbounds double, ptr %58, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %14, align 8, !tbaa !5
  %63 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %61, ptr noundef %62)
  br i1 %63, label %64, label %76

64:                                               ; preds = %55
  %65 = load double, ptr %17, align 8, !tbaa !11
  %66 = load double, ptr %16, align 8, !tbaa !11
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = load i64, ptr %15, align 8, !tbaa !9
  %71 = getelementptr inbounds double, ptr %69, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !11
  %73 = fsub double %66, %72
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %65, double noundef %73, ptr noundef %74)
  store double %75, ptr %17, align 8, !tbaa !11
  br label %76

76:                                               ; preds = %64, %55
  %77 = load double, ptr %17, align 8, !tbaa !11
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = load double, ptr %78, align 8, !tbaa !11
  %80 = fcmp ogt double %77, %79
  br i1 %80, label %81, label %86

81:                                               ; preds = %76
  %82 = load double, ptr %17, align 8, !tbaa !11
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  store double %82, ptr %83, align 8, !tbaa !11
  %84 = load i64, ptr %15, align 8, !tbaa !9
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %84, ptr %85, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %81, %76
  br label %87

87:                                               ; preds = %86
  %88 = load i64, ptr %15, align 8, !tbaa !9
  %89 = add nsw i64 %88, 1
  store i64 %89, ptr %15, align 8, !tbaa !9
  br label %22, !llvm.loop !14

90:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #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 zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #0

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

.lr.ph:                                           ; preds = %7
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = getelementptr inbounds i8, ptr %1, i64 56
  %10 = getelementptr inbounds i8, ptr %2, i64 56
  br label %11

11:                                               ; preds = %.lr.ph, %41
  %.03032 = phi i64 [ 0, %.lr.ph ], [ %13, %41 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !11
  %13 = add nuw nsw i64 %.03032, 1
  %14 = getelementptr inbounds double, ptr %12, i64 %13
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !11
  %17 = getelementptr inbounds double, ptr %16, i64 %.03032
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %18, ptr noundef %6)
  br i1 %19, label %20, label %26

20:                                               ; preds = %11
  %21 = load ptr, ptr %9, align 8, !tbaa !11
  %22 = getelementptr inbounds double, ptr %21, i64 %.03032
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fsub double %23, %15
  %25 = tail call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef 0.000000e+00, double noundef %24, ptr noundef %6)
  br label %26

26:                                               ; preds = %20, %11
  %.0 = phi double [ %25, %20 ], [ 0.000000e+00, %11 ]
  %27 = load ptr, ptr %10, align 8, !tbaa !11
  %28 = getelementptr inbounds double, ptr %27, i64 %.03032
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %29, ptr noundef %6)
  br i1 %30, label %31, label %37

31:                                               ; preds = %26
  %32 = load ptr, ptr %10, align 8, !tbaa !11
  %33 = getelementptr inbounds double, ptr %32, i64 %.03032
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fsub double %15, %34
  %36 = tail call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %.0, double noundef %35, ptr noundef %6)
  br label %37

37:                                               ; preds = %31, %26
  %.1 = phi double [ %36, %31 ], [ %.0, %26 ]
  %38 = load double, ptr %4, align 8, !tbaa !5
  %39 = fcmp ogt double %.1, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  store double %.1, ptr %4, align 8, !tbaa !5
  store i64 %.03032, ptr %5, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %37, %40
  %exitcond.not = icmp eq i64 %13, %3
  br i1 %exitcond.not, label %._crit_edge, label %11, !llvm.loop !12

._crit_edge:                                      ; preds = %41, %7
  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,SROAPass,SimplifyCFGPass,TailCallElimPass