; 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_impl16nlpfisacceptableEPNS_9nlpfilterEddddPNS_8ae_stateE(ptr noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, ptr noundef %5) #2 {
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store double %2, ptr %10, align 8, !tbaa !9
  store double %3, ptr %11, align 8, !tbaa !9
  store double %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  %17 = load double, ptr %12, align 8, !tbaa !9
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %18, i32 0, i32 0
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = fcmp oge double %17, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %6
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %23, i32 0, i32 4
  store i8 1, ptr %24, align 8, !tbaa !17
  store i8 0, ptr %15, align 1, !tbaa !18
  %25 = load i8, ptr %15, align 1, !tbaa !18, !range !19, !noundef !20
  %26 = trunc i8 %25 to i1
  store i1 %26, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %98

27:                                               ; preds = %6
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %28, i32 0, i32 4
  store i8 0, ptr %29, align 8, !tbaa !17
  %30 = load double, ptr %11, align 8, !tbaa !9
  %31 = load double, ptr %9, align 8, !tbaa !9
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %32, i32 0, i32 2
  %34 = load double, ptr %33, align 8, !tbaa !21
  %35 = load double, ptr %10, align 8, !tbaa !9
  %36 = fneg double %34
  %37 = call double @llvm.fmuladd.f64(double %36, double %35, double %31)
  %38 = fcmp oge double %30, %37
  br i1 %38, label %39, label %50

39:                                               ; preds = %27
  %40 = load double, ptr %12, align 8, !tbaa !9
  %41 = load double, ptr %10, align 8, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %42, i32 0, i32 3
  %44 = load double, ptr %43, align 8, !tbaa !22
  %45 = fmul double %41, %44
  %46 = fcmp oge double %40, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %39
  store i8 0, ptr %15, align 1, !tbaa !18
  %48 = load i8, ptr %15, align 1, !tbaa !18, !range !19, !noundef !20
  %49 = trunc i8 %48 to i1
  store i1 %49, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %98

50:                                               ; preds = %39, %27
  store i64 0, ptr %14, align 8, !tbaa !23
  br label %51

51:                                               ; preds = %92, %50
  %52 = load i64, ptr %14, align 8, !tbaa !23
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %53, i32 0, i32 1
  %55 = load i64, ptr %54, align 8, !tbaa !24
  %56 = sub nsw i64 %55, 1
  %57 = icmp sle i64 %52, %56
  br i1 %57, label %58, label %95

58:                                               ; preds = %51
  %59 = load double, ptr %11, align 8, !tbaa !9
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %60, i32 0, i32 5
  %62 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %61, i32 0, i32 4
  %63 = load ptr, ptr %62, align 8, !tbaa !25
  %64 = load i64, ptr %14, align 8, !tbaa !23
  %65 = getelementptr inbounds double, ptr %63, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %67, i32 0, i32 2
  %69 = load double, ptr %68, align 8, !tbaa !21
  %70 = load double, ptr %12, align 8, !tbaa !9
  %71 = fneg double %69
  %72 = call double @llvm.fmuladd.f64(double %71, double %70, double %66)
  %73 = fcmp oge double %59, %72
  br i1 %73, label %74, label %91

74:                                               ; preds = %58
  %75 = load double, ptr %12, align 8, !tbaa !9
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %76, i32 0, i32 6
  %78 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %77, i32 0, i32 4
  %79 = load ptr, ptr %78, align 8, !tbaa !25
  %80 = load i64, ptr %14, align 8, !tbaa !23
  %81 = getelementptr inbounds double, ptr %79, i64 %80
  %82 = load double, ptr %81, align 8, !tbaa !9
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.alglib_impl::nlpfilter", ptr %83, i32 0, i32 3
  %85 = load double, ptr %84, align 8, !tbaa !22
  %86 = fmul double %82, %85
  %87 = fcmp oge double %75, %86
  br i1 %87, label %88, label %91

88:                                               ; preds = %74
  store i8 0, ptr %15, align 1, !tbaa !18
  %89 = load i8, ptr %15, align 1, !tbaa !18, !range !19, !noundef !20
  %90 = trunc i8 %89 to i1
  store i1 %90, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %98

91:                                               ; preds = %74, %58
  br label %92

92:                                               ; preds = %91
  %93 = load i64, ptr %14, align 8, !tbaa !23
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr %14, align 8, !tbaa !23
  br label %51, !llvm.loop !26

95:                                               ; preds = %51
  store i8 1, ptr %15, align 1, !tbaa !18
  %96 = load i8, ptr %15, align 1, !tbaa !18, !range !19, !noundef !20
  %97 = trunc i8 %96 to i1
  store i1 %97, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %98

98:                                               ; preds = %95, %88, %47, %22
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %99 = load i1, ptr %7, align 1
  ret i1 %99
}

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 = !{!12, !10, i64 16}
!22 = !{!12, !10, i64 24}
!23 = !{!13, !13, i64 0}
!24 = !{!12, !13, i64 8}
!25 = !{!7, !7, i64 0}
!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_impl16nlpfisacceptableEPNS_9nlpfilterEddddPNS_8ae_stateE(ptr nocapture noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, ptr nocapture noundef readnone %5) local_unnamed_addr #1 {
  %7 = load double, ptr %0, align 8, !tbaa !5
  %8 = fcmp ugt double %7, %4
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %8, label %11, label %10

10:                                               ; preds = %6
  store i8 1, ptr %9, align 8, !tbaa !15
  br label %.loopexit

11:                                               ; preds = %6
  store i8 0, ptr %9, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !16
  %14 = fneg double %13
  %15 = tail call double @llvm.fmuladd.f64(double %14, double %2, double %1)
  %16 = fcmp ugt double %15, %3
  br i1 %16, label %22, label %17

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load double, ptr %18, align 8, !tbaa !17
  %20 = fmul double %19, %2
  %21 = fcmp ugt double %20, %4
  br i1 %21, label %22, label %.loopexit

22:                                               ; preds = %17, %11
  %23 = getelementptr inbounds i8, ptr %0, i64 160
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load i64, ptr %24, align 8, !tbaa !18
  %.not.not29 = icmp sgt i64 %25, 0
  br i1 %.not.not29, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %22
  %26 = getelementptr inbounds i8, ptr %0, i64 96
  %27 = load ptr, ptr %26, align 8, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  br label %29

29:                                               ; preds = %.lr.ph, %41
  %.030 = phi i64 [ 0, %.lr.ph ], [ %42, %41 ]
  %30 = getelementptr inbounds double, ptr %27, i64 %.030
  %31 = load double, ptr %30, align 8, !tbaa !20
  %32 = tail call double @llvm.fmuladd.f64(double %14, double %4, double %31)
  %33 = fcmp ugt double %32, %3
  br i1 %33, label %41, label %34

34:                                               ; preds = %29
  %35 = load ptr, ptr %23, align 8, !tbaa !19
  %36 = getelementptr inbounds double, ptr %35, i64 %.030
  %37 = load double, ptr %36, align 8, !tbaa !20
  %38 = load double, ptr %28, align 8, !tbaa !17
  %39 = fmul double %37, %38
  %40 = fcmp ugt double %39, %4
  br i1 %40, label %41, label %.loopexit

41:                                               ; preds = %29, %34
  %42 = add nuw nsw i64 %.030, 1
  %exitcond.not = icmp eq i64 %42, %25
  br i1 %exitcond.not, label %.loopexit, label %29, !llvm.loop !21

.loopexit:                                        ; preds = %34, %41, %22, %17, %10
  %.027 = phi i1 [ false, %10 ], [ false, %17 ], [ true, %22 ], [ false, %34 ], [ true, %41 ]
  ret i1 %.027
}

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, !7, i64 16}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !10, i64 8}
!19 = !{!8, !8, i64 0}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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