; 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::nlpfilter" = type { double, i64, double, double, i8, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector" }
%"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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

18:                                               ; preds = %4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %19, i32 0, i32 4
  store i8 1, ptr %20, align 8, !tbaa !17
  store i8 0, ptr %11, align 1, !tbaa !18
  %21 = load i8, ptr %11, align 1, !tbaa !18, !range !19, !noundef !20
  %22 = trunc i8 %21 to i1
  store i1 %22, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %73

23:                                               ; preds = %4
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %24, i32 0, i32 4
  store i8 0, ptr %25, align 8, !tbaa !17
  store i64 0, ptr %10, align 8, !tbaa !21
  br label %26

26:                                               ; preds = %67, %23
  %27 = load i64, ptr %10, align 8, !tbaa !21
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %28, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !22
  %31 = sub nsw i64 %30, 1
  %32 = icmp sle i64 %27, %31
  br i1 %32, label %33, label %70

33:                                               ; preds = %26
  %34 = load double, ptr %7, align 8, !tbaa !9
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %35, i32 0, i32 5
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %36, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !23
  %39 = load i64, ptr %10, align 8, !tbaa !21
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %42, i32 0, i32 2
  %44 = load double, ptr %43, align 8, !tbaa !24
  %45 = load double, ptr %8, align 8, !tbaa !9
  %46 = fneg double %44
  %47 = call double @llvm.fmuladd.f64(double %46, double %45, double %41)
  %48 = fcmp oge double %34, %47
  br i1 %48, label %49, label %66

49:                                               ; preds = %33
  %50 = load double, ptr %8, align 8, !tbaa !9
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !23
  %55 = load i64, ptr %10, align 8, !tbaa !21
  %56 = getelementptr inbounds double, ptr %54, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %58, i32 0, i32 3
  %60 = load double, ptr %59, align 8, !tbaa !25
  %61 = fmul double %57, %60
  %62 = fcmp oge double %50, %61
  br i1 %62, label %63, label %66

63:                                               ; preds = %49
  store i8 0, ptr %11, align 1, !tbaa !18
  %64 = load i8, ptr %11, align 1, !tbaa !18, !range !19, !noundef !20
  %65 = trunc i8 %64 to i1
  store i1 %65, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %73

66:                                               ; preds = %49, %33
  br label %67

67:                                               ; preds = %66
  %68 = load i64, ptr %10, align 8, !tbaa !21
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %10, align 8, !tbaa !21
  br label %26, !llvm.loop !26

70:                                               ; preds = %26
  store i8 1, ptr %11, align 1, !tbaa !18
  %71 = load i8, ptr %11, align 1, !tbaa !18, !range !19, !noundef !20
  %72 = trunc i8 %71 to i1
  store i1 %72, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %73

73:                                               ; preds = %70, %63, %18
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %74 = load i1, ptr %5, align 1
  ret i1 %74
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nounwind 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 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN11alglib_impl9nlpfilterE", !10, i64 0, !13, i64 8, !10, i64 16, !10, i64 24, !14, i64 32, !15, i64 40, !15, i64 104}
!13 = !{!"long", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN11alglib_impl9ae_vectorE", !13, i64 0, !13, i64 8, !14, i64 16, !16, i64 24, !7, i64 56}
!16 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!12, !14, i64 32}
!18 = !{!14, !14, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!13, !13, i64 0}
!22 = !{!12, !13, i64 8}
!23 = !{!7, !7, i64 0}
!24 = !{!12, !10, i64 16}
!25 = !{!12, !10, i64 24}
!26 = distinct !{!26, !27}
!27 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_ZN11alglib_impl17nlpfisacceptable1EPNS_9nlpfilterEddPNS_8ae_stateE(ptr nocapture noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef readnone %3) local_unnamed_addr #1 {
  %5 = load double, ptr %0, align 8, !tbaa !5
  %6 = fcmp ugt double %5, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %6, label %9, label %8

8:                                                ; preds = %4
  store i8 1, ptr %7, align 8, !tbaa !15
  br label %.loopexit

9:                                                ; preds = %4
  store i8 0, ptr %7, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 160
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %.not.not21 = icmp sgt i64 %12, 0
  br i1 %.not.not21, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 96
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !18
  %17 = fneg double %16
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  br label %19

19:                                               ; preds = %.lr.ph, %31
  %.022 = phi i64 [ 0, %.lr.ph ], [ %32, %31 ]
  %20 = getelementptr inbounds double, ptr %14, i64 %.022
  %21 = load double, ptr %20, align 8, !tbaa !19
  %22 = tail call double @llvm.fmuladd.f64(double %17, double %2, double %21)
  %23 = fcmp ugt double %22, %1
  br i1 %23, label %31, label %24

24:                                               ; preds = %19
  %25 = load ptr, ptr %10, align 8, !tbaa !17
  %26 = getelementptr inbounds double, ptr %25, i64 %.022
  %27 = load double, ptr %26, align 8, !tbaa !19
  %28 = load double, ptr %18, align 8, !tbaa !20
  %29 = fmul double %27, %28
  %30 = fcmp ugt double %29, %2
  br i1 %30, label %31, label %.loopexit

31:                                               ; preds = %19, %24
  %32 = add nuw nsw i64 %.022, 1
  %exitcond.not = icmp eq i64 %32, %12
  br i1 %exitcond.not, label %.loopexit, label %19, !llvm.loop !21

.loopexit:                                        ; preds = %24, %31, %9, %8
  %.019 = phi i1 [ false, %8 ], [ true, %9 ], [ false, %24 ], [ true, %31 ]
  ret i1 %.019
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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_impl9nlpfilterE", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !12, i64 40, !12, i64 104}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !11, i64 16, !13, i64 24, !8, i64 56}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !11, i64 32}
!16 = !{!6, !10, i64 8}
!17 = !{!8, !8, i64 0}
!18 = !{!6, !7, i64 16}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !7, i64 24}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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