; LLVM IR from venumb/ZSPACE :: cpp/depends/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_frame" = type { %"struct.alglib_impl::ae_dyn_block" }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%"struct.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon }
%union.anon = 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 void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl13bvectorgrowtoEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.alglib_impl::ae_frame", align 8
  %8 = alloca %"struct.alglib_impl::ae_vector", align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef %12, ptr noundef %7)
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 64, i1 false)
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_vector_initEPNS_9ae_vectorEllPNS_8ae_stateEb(ptr noundef %8, i64 noundef 0, i64 noundef 1, ptr noundef %13, i1 noundef zeroext true)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %14, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = icmp sge i64 %16, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %20)
  store i32 1, ptr %11, align 4
  br label %73

21:                                               ; preds = %3
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %23, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = sitofp i64 %25 to double
  %27 = call double @llvm.fmuladd.f64(double 1.800000e+00, double %26, double 1.000000e+00)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call noundef i64 @_ZN11alglib_impl8ae_roundEdPNS_8ae_stateE(double noundef %27, ptr noundef %28)
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call noundef i64 @_ZN11alglib_impl9ae_maxintEllPNS_8ae_stateE(i64 noundef %22, i64 noundef %29, ptr noundef %30)
  store i64 %31, ptr %5, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %32, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !11
  store i64 %34, ptr %10, align 8, !tbaa !9
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl15ae_swap_vectorsEPNS_9ae_vectorES1_(ptr noundef %35, ptr noundef %8)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i64, ptr %5, align 8, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %36, i64 noundef %37, ptr noundef %38)
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %68, %21
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = sub nsw i64 %41, 1
  %43 = icmp sle i64 %40, %42
  br i1 %43, label %44, label %71

44:                                               ; preds = %39
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = load i64, ptr %10, align 8, !tbaa !9
  %47 = icmp slt i64 %45, %46
  br i1 %47, label %48, label %61

48:                                               ; preds = %44
  %49 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %8, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !16, !range !17, !noundef !18
  %54 = trunc i8 %53 to i1
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = load i64, ptr %9, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  %60 = zext i1 %54 to i8
  store i8 %60, ptr %59, align 1, !tbaa !16
  br label %67

61:                                               ; preds = %44
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  %65 = load i64, ptr %9, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  store i8 0, ptr %66, align 1, !tbaa !16
  br label %67

67:                                               ; preds = %61, %48
  br label %68

68:                                               ; preds = %67
  %69 = load i64, ptr %9, align 8, !tbaa !9
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %9, align 8, !tbaa !9
  br label %39, !llvm.loop !19

71:                                               ; preds = %39
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %72)
  store i32 0, ptr %11, align 4
  br label %73

73:                                               ; preds = %71, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  %74 = load i32, ptr %11, align 4
  switch i32 %74, label %76 [
    i32 0, label %75
    i32 1, label %75
  ]

75:                                               ; preds = %73, %73
  ret void

76:                                               ; preds = %73
  unreachable
}

declare void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @_ZN11alglib_impl14ae_vector_initEPNS_9ae_vectorEllPNS_8ae_stateEb(ptr noundef, i64 noundef, i64 noundef, ptr noundef, i1 noundef zeroext) #1

declare void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef) #1

declare noundef i64 @_ZN11alglib_impl9ae_maxintEllPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef) #1

declare noundef i64 @_ZN11alglib_impl8ae_roundEdPNS_8ae_stateE(double noundef, ptr noundef) #1

declare void @_ZN11alglib_impl15ae_swap_vectorsEPNS_9ae_vectorES1_(ptr noundef, ptr noundef) #1

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !10, i64 0}
!12 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !13, i64 16, !14, i64 24, !7, i64 56}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!7, !7, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%"struct.alglib_impl::ae_frame" = type { %"struct.alglib_impl::ae_dyn_block" }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%"struct.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon }
%union.anon = type { ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl13bvectorgrowtoEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca %"struct.alglib_impl::ae_frame", align 8
  %5 = alloca %"struct.alglib_impl::ae_vector", align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #5
  call void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef %2, ptr noundef nonnull %4)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %5, i8 0, i64 64, i1 false)
  call void @_ZN11alglib_impl14ae_vector_initEPNS_9ae_vectorEllPNS_8ae_stateEb(ptr noundef nonnull %5, i64 noundef 0, i64 noundef 1, ptr noundef %2, i1 noundef zeroext true)
  %6 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp slt i64 %6, %1
  br i1 %.not, label %7, label %._crit_edge

7:                                                ; preds = %3
  %8 = sitofp i64 %6 to double
  %9 = call double @llvm.fmuladd.f64(double %8, double 1.800000e+00, double 1.000000e+00)
  %10 = call noundef i64 @_ZN11alglib_impl8ae_roundEdPNS_8ae_stateE(double noundef %9, ptr noundef %2)
  %11 = call noundef i64 @_ZN11alglib_impl9ae_maxintEllPNS_8ae_stateE(i64 noundef %1, i64 noundef %10, ptr noundef %2)
  %12 = load i64, ptr %0, align 8, !tbaa !5
  call void @_ZN11alglib_impl15ae_swap_vectorsEPNS_9ae_vectorES1_(ptr noundef nonnull %0, ptr noundef nonnull %5)
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %0, i64 noundef %11, ptr noundef %2)
  %.not26.not27 = icmp sgt i64 %11, 0
  br i1 %.not26.not27, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  %14 = getelementptr inbounds i8, ptr %5, i64 56
  %xtraiter = and i64 %11, 1
  %15 = icmp eq i64 %11, 1
  br i1 %15, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %11, 9223372036854775806
  br label %16

16:                                               ; preds = %31, %.lr.ph.new
  %.028 = phi i64 [ 0, %.lr.ph.new ], [ %34, %31 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %31 ]
  %17 = icmp slt i64 %.028, %12
  br i1 %17, label %18, label %22

18:                                               ; preds = %16
  %19 = load ptr, ptr %14, align 8, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %19, i64 %.028
  %21 = load i8, ptr %20, align 1, !tbaa !14, !range !15, !noundef !16
  br label %22

22:                                               ; preds = %16, %18
  %.sink = phi i8 [ %21, %18 ], [ 0, %16 ]
  %23 = load ptr, ptr %13, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %23, i64 %.028
  store i8 %.sink, ptr %24, align 1, !tbaa !14
  %25 = or disjoint i64 %.028, 1
  %26 = icmp slt i64 %25, %12
  br i1 %26, label %27, label %31

27:                                               ; preds = %22
  %28 = load ptr, ptr %14, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %28, i64 %25
  %30 = load i8, ptr %29, align 1, !tbaa !14, !range !15, !noundef !16
  br label %31

31:                                               ; preds = %27, %22
  %.sink.1 = phi i8 [ %30, %27 ], [ 0, %22 ]
  %32 = load ptr, ptr %13, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %32, i64 %25
  store i8 %.sink.1, ptr %33, align 1, !tbaa !14
  %34 = add nuw nsw i64 %.028, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %16, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %31, %.lr.ph
  %.028.unr = phi i64 [ 0, %.lr.ph ], [ %34, %31 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %35 = icmp slt i64 %.028.unr, %12
  br i1 %35, label %36, label %._crit_edge.loopexit.epilog-lcssa

36:                                               ; preds = %.epil.preheader
  %37 = load ptr, ptr %14, align 8, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %37, i64 %.028.unr
  %39 = load i8, ptr %38, align 1, !tbaa !14, !range !15, !noundef !16
  br label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %36, %.epil.preheader
  %.sink.epil = phi i8 [ %39, %36 ], [ 0, %.epil.preheader ]
  %40 = load ptr, ptr %13, align 8, !tbaa !13
  %41 = getelementptr inbounds i8, ptr %40, i64 %.028.unr
  store i8 %.sink.epil, ptr %41, align 1, !tbaa !14
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %7, %3
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  ret void
}

declare void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @_ZN11alglib_impl14ae_vector_initEPNS_9ae_vectorEllPNS_8ae_stateEb(ptr noundef, i64 noundef, i64 noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef) local_unnamed_addr #1

declare noundef i64 @_ZN11alglib_impl9ae_maxintEllPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare noundef i64 @_ZN11alglib_impl8ae_roundEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN11alglib_impl15ae_swap_vectorsEPNS_9ae_vectorES1_(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !7, i64 0}
!6 = !{!"_ZTSN11alglib_impl9ae_vectorE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !8, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass