; 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 }

@.str.183 = external hidden unnamed_addr constant [53 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

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

declare noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef, double noundef) #1

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

24:                                               ; preds = %106, %8
  %25 = load i64, ptr %17, align 8, !tbaa !9
  %26 = load i64, ptr %13, align 8, !tbaa !9
  %27 = sub nsw i64 %26, 1
  %28 = icmp sle i64 %25, %27
  br i1 %28, label %29, label %109

29:                                               ; preds = %24
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load i64, ptr %17, align 8, !tbaa !9
  %34 = add nsw i64 %33, 1
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef %36, double noundef 0.000000e+00)
  %38 = load ptr, ptr %16, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %37, ptr noundef @.str.183, ptr noundef %38)
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load i64, ptr %17, align 8, !tbaa !9
  %43 = add nsw i64 %42, 1
  %44 = getelementptr inbounds double, ptr %41, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %46, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i64, ptr %17, align 8, !tbaa !9
  %50 = add nsw i64 %49, 1
  %51 = getelementptr inbounds double, ptr %48, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = fmul double %45, %52
  store double %53, ptr %18, align 8, !tbaa !11
  store double 0.000000e+00, ptr %19, align 8, !tbaa !11
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = load i64, ptr %17, align 8, !tbaa !9
  %58 = getelementptr inbounds double, ptr %56, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !11
  %60 = load ptr, ptr %16, align 8, !tbaa !5
  %61 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %59, ptr noundef %60)
  br i1 %61, label %62, label %74

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

74:                                               ; preds = %62, %29
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !13
  %78 = load i64, ptr %17, align 8, !tbaa !9
  %79 = getelementptr inbounds double, ptr %77, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !11
  %81 = load ptr, ptr %16, align 8, !tbaa !5
  %82 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %80, ptr noundef %81)
  br i1 %82, label %83, label %95

83:                                               ; preds = %74
  %84 = load double, ptr %19, align 8, !tbaa !11
  %85 = load double, ptr %18, align 8, !tbaa !11
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %86, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !13
  %89 = load i64, ptr %17, align 8, !tbaa !9
  %90 = getelementptr inbounds double, ptr %88, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !11
  %92 = fsub double %85, %91
  %93 = load ptr, ptr %16, align 8, !tbaa !5
  %94 = call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %84, double noundef %92, ptr noundef %93)
  store double %94, ptr %19, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %83, %74
  %96 = load double, ptr %19, align 8, !tbaa !11
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = load double, ptr %97, align 8, !tbaa !11
  %99 = fcmp ogt double %96, %98
  br i1 %99, label %100, label %105

100:                                              ; preds = %95
  %101 = load double, ptr %19, align 8, !tbaa !11
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  store double %101, ptr %102, align 8, !tbaa !11
  %103 = load i64, ptr %17, align 8, !tbaa !9
  %104 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 %103, ptr %104, align 8, !tbaa !9
  br label %105

105:                                              ; preds = %100, %95
  br label %106

106:                                              ; preds = %105
  %107 = load i64, ptr %17, align 8, !tbaa !9
  %108 = add nsw i64 %107, 1
  store i64 %108, ptr %17, align 8, !tbaa !9
  br label %24, !llvm.loop !14

109:                                              ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #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"

@.str.183 = external hidden unnamed_addr constant [53 x i8], align 1

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

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

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

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

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

13:                                               ; preds = %.lr.ph, %51
  %.03537 = phi i64 [ 0, %.lr.ph ], [ %15, %51 ]
  %14 = load ptr, ptr %9, align 8, !tbaa !11
  %15 = add nuw nsw i64 %.03537, 1
  %16 = getelementptr inbounds double, ptr %14, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = tail call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef %17, double noundef 0.000000e+00)
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %18, ptr noundef nonnull @.str.183, ptr noundef %7)
  %19 = load ptr, ptr %10, align 8, !tbaa !11
  %20 = getelementptr inbounds double, ptr %19, i64 %15
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !11
  %23 = getelementptr inbounds double, ptr %22, i64 %15
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fmul double %21, %24
  %26 = load ptr, ptr %11, align 8, !tbaa !11
  %27 = getelementptr inbounds double, ptr %26, i64 %.03537
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %28, ptr noundef %7)
  br i1 %29, label %30, label %36

30:                                               ; preds = %13
  %31 = load ptr, ptr %11, align 8, !tbaa !11
  %32 = getelementptr inbounds double, ptr %31, i64 %.03537
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = fsub double %33, %25
  %35 = tail call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef 0.000000e+00, double noundef %34, ptr noundef %7)
  br label %36

36:                                               ; preds = %30, %13
  %.0 = phi double [ %35, %30 ], [ 0.000000e+00, %13 ]
  %37 = load ptr, ptr %12, align 8, !tbaa !11
  %38 = getelementptr inbounds double, ptr %37, i64 %.03537
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %39, ptr noundef %7)
  br i1 %40, label %41, label %47

41:                                               ; preds = %36
  %42 = load ptr, ptr %12, align 8, !tbaa !11
  %43 = getelementptr inbounds double, ptr %42, i64 %.03537
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = fsub double %25, %44
  %46 = tail call noundef double @_ZN11alglib_impl10ae_maxrealEddPNS_8ae_stateE(double noundef %.0, double noundef %45, ptr noundef %7)
  br label %47

47:                                               ; preds = %41, %36
  %.1 = phi double [ %46, %41 ], [ %.0, %36 ]
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = fcmp ogt double %.1, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  store double %.1, ptr %5, align 8, !tbaa !5
  store i64 %.03537, ptr %6, align 8, !tbaa !9
  br label %51

51:                                               ; preds = %47, %50
  %exitcond.not = icmp eq i64 %15, %4
  br i1 %exitcond.not, label %._crit_edge, label %13, !llvm.loop !12

._crit_edge:                                      ; preds = %51, %8
  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