; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src (alglibinternal)

; 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 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon = type { ptr }

@.str.34 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [3 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl19tracevectorautoprecEPKNS_9ae_vectorEllPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  %11 = call noundef zeroext i1 @_ZN11alglib_impl19ae_is_trace_enabledEPKc(ptr noundef @.str.34)
  br i1 %11, label %12, label %13

12:                                               ; preds = %4
  store i64 1, ptr %10, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %12, %4
  %14 = call noundef zeroext i1 @_ZN11alglib_impl19ae_is_trace_enabledEPKc(ptr noundef @.str.35)
  br i1 %14, label %15, label %16

15:                                               ; preds = %13
  store i64 2, ptr %10, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %15, %13
  call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef @.str.36)
  %17 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %17, ptr %9, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %60, %16
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = sub nsw i64 %20, 1
  %22 = icmp sle i64 %19, %21
  br i1 %22, label %23, label %63

23:                                               ; preds = %18
  %24 = load i64, ptr %10, align 8, !tbaa !9
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %33

26:                                               ; preds = %23
  %27 = load ptr, ptr %5, 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 !11
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds double, ptr %29, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !12
  call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef @.str.37, double noundef %32)
  br label %33

33:                                               ; preds = %26, %23
  %34 = load i64, ptr %10, align 8, !tbaa !9
  %35 = icmp eq i64 %34, 1
  br i1 %35, label %36, label %43

36:                                               ; preds = %33
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !12
  call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef @.str.38, double noundef %42)
  br label %43

43:                                               ; preds = %36, %33
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = icmp eq i64 %44, 2
  br i1 %45, label %46, label %53

46:                                               ; preds = %43
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load i64, ptr %9, align 8, !tbaa !9
  %51 = getelementptr inbounds double, ptr %49, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !12
  call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef @.str.39, double noundef %52)
  br label %53

53:                                               ; preds = %46, %43
  %54 = load i64, ptr %9, align 8, !tbaa !9
  %55 = load i64, ptr %7, align 8, !tbaa !9
  %56 = sub nsw i64 %55, 1
  %57 = icmp slt i64 %54, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef @.str.40)
  br label %59

59:                                               ; preds = %58, %53
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %9, align 8, !tbaa !9
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %9, align 8, !tbaa !9
  br label %18, !llvm.loop !14

63:                                               ; preds = %18
  call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef @.str.41)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

declare noundef zeroext i1 @_ZN11alglib_impl19ae_is_trace_enabledEPKc(ptr noundef) #2

declare void @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { "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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !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.34 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl19tracevectorautoprecEPKNS_9ae_vectorEllPNS_8ae_stateE(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, ptr nocapture noundef readnone %3) local_unnamed_addr #0 {
  %5 = tail call noundef zeroext i1 @_ZN11alglib_impl19ae_is_trace_enabledEPKc(ptr noundef nonnull @.str.34)
  %6 = tail call noundef zeroext i1 @_ZN11alglib_impl19ae_is_trace_enabledEPKc(ptr noundef nonnull @.str.35)
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.36)
  %7 = add nsw i64 %2, -1
  %.not.not16 = icmp slt i64 %1, %2
  br i1 %.not.not16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %spec.select = zext i1 %5 to i64
  %.1 = select i1 %6, i64 2, i64 %spec.select
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  switch i64 %.1, label %default.unreachable [
    i64 0, label %.lr.ph.split.us
    i64 1, label %.lr.ph.split.us18
    i64 2, label %.lr.ph.split.us21
  ]

.lr.ph.split.us:                                  ; preds = %.lr.ph, %14
  %.01417.us = phi i64 [ %15, %14 ], [ %1, %.lr.ph ]
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds double, ptr %9, i64 %.01417.us
  %11 = load double, ptr %10, align 8, !tbaa !8
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.37, double noundef %11)
  %12 = icmp slt i64 %.01417.us, %7
  br i1 %12, label %13, label %14

13:                                               ; preds = %.lr.ph.split.us
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.40)
  br label %14

14:                                               ; preds = %13, %.lr.ph.split.us
  %15 = add i64 %.01417.us, 1
  %exitcond32.not = icmp eq i64 %15, %2
  br i1 %exitcond32.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !10

.lr.ph.split.us18:                                ; preds = %.lr.ph, %21
  %.01417.us19 = phi i64 [ %22, %21 ], [ %1, %.lr.ph ]
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 %.01417.us19
  %18 = load double, ptr %17, align 8, !tbaa !8
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.38, double noundef %18)
  %19 = icmp slt i64 %.01417.us19, %7
  br i1 %19, label %20, label %21

20:                                               ; preds = %.lr.ph.split.us18
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.40)
  br label %21

21:                                               ; preds = %20, %.lr.ph.split.us18
  %22 = add i64 %.01417.us19, 1
  %exitcond31.not = icmp eq i64 %22, %2
  br i1 %exitcond31.not, label %._crit_edge, label %.lr.ph.split.us18, !llvm.loop !10

.lr.ph.split.us21:                                ; preds = %.lr.ph, %28
  %.01417.us22 = phi i64 [ %29, %28 ], [ %1, %.lr.ph ]
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 %.01417.us22
  %25 = load double, ptr %24, align 8, !tbaa !8
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.39, double noundef %25)
  %26 = icmp slt i64 %.01417.us22, %7
  br i1 %26, label %27, label %28

27:                                               ; preds = %.lr.ph.split.us21
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.40)
  br label %28

28:                                               ; preds = %27, %.lr.ph.split.us21
  %29 = add i64 %.01417.us22, 1
  %exitcond30.not = icmp eq i64 %29, %2
  br i1 %exitcond30.not, label %._crit_edge, label %.lr.ph.split.us21, !llvm.loop !10

default.unreachable:                              ; preds = %.lr.ph
  unreachable

._crit_edge:                                      ; preds = %28, %21, %14, %4
  tail call void (ptr, ...) @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef nonnull @.str.41)
  ret void
}

declare noundef zeroext i1 @_ZN11alglib_impl19ae_is_trace_enabledEPKc(ptr noundef) local_unnamed_addr #1

declare void @_ZN11alglib_impl8ae_traceEPKcz(ptr noundef, ...) local_unnamed_addr #1

attributes #0 = { 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 #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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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