; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (alglibmisc)

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

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; 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_impl18xdebugc1appendcopyEPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.alglib_impl::ae_frame", align 8
  %6 = alloca i64, align 8
  %7 = alloca %"struct.alglib_impl::ae_vector", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef %8, ptr noundef %5)
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 64, i1 false)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_vector_initEPNS_9ae_vectorEllPNS_8ae_stateEb(ptr noundef %7, i64 noundef 0, i64 noundef 4, ptr noundef %9, i1 noundef zeroext true)
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %10, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %7, i64 noundef %12, ptr noundef %13)
  store i64 0, ptr %6, align 8, !tbaa !14
  br label %14

14:                                               ; preds = %30, %2
  %15 = load i64, ptr %6, align 8, !tbaa !14
  %16 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = sub nsw i64 %17, 1
  %19 = icmp sle i64 %15, %18
  br i1 %19, label %20, label %33

20:                                               ; preds = %14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %21, i32 0, i32 4
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load i64, ptr %6, align 8, !tbaa !14
  %25 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %23, i64 %24
  %26 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 4
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = load i64, ptr %6, align 8, !tbaa !14
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %27, i64 %28
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 8 %25, i64 16, i1 false), !tbaa.struct !16
  br label %30

30:                                               ; preds = %20
  %31 = load i64, ptr %6, align 8, !tbaa !14
  %32 = add nsw i64 %31, 1
  store i64 %32, ptr %6, align 8, !tbaa !14
  br label %14, !llvm.loop !19

33:                                               ; preds = %14
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = mul nsw i64 2, %36
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %34, i64 noundef %37, ptr noundef %38)
  store i64 0, ptr %6, align 8, !tbaa !14
  br label %39

39:                                               ; preds = %59, %33
  %40 = load i64, ptr %6, align 8, !tbaa !14
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %41, i32 0, i32 0
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = sub nsw i64 %43, 1
  %45 = icmp sle i64 %40, %44
  br i1 %45, label %46, label %62

46:                                               ; preds = %39
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load i64, ptr %6, align 8, !tbaa !14
  %50 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 0
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = srem i64 %49, %51
  %53 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %48, i64 %52
  %54 = load ptr, ptr %3, 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 !15
  %57 = load i64, ptr %6, align 8, !tbaa !14
  %58 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %56, i64 %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %58, ptr align 8 %53, i64 16, i1 false), !tbaa.struct !16
  br label %59

59:                                               ; preds = %46
  %60 = load i64, ptr %6, align 8, !tbaa !14
  %61 = add nsw i64 %60, 1
  store i64 %61, ptr %6, align 8, !tbaa !14
  br label %39, !llvm.loop !21

62:                                               ; preds = %39
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %63)
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  ret void
}

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

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

declare void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #3

declare void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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: readwrite) }
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, !11, i64 0}
!10 = !{!"_ZTSN11alglib_impl9ae_vectorE", !11, i64 0, !11, i64 8, !12, i64 16, !13, i64 24, !7, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!11, !11, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{i64 0, i64 8, !17, i64 8, i64 8, !17}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress 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_impl18xdebugc1appendcopyEPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %"struct.alglib_impl::ae_frame", align 8
  %4 = alloca %"struct.alglib_impl::ae_vector", align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #5
  call void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef %1, ptr noundef nonnull %3)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %4, i8 0, i64 64, i1 false)
  call void @_ZN11alglib_impl14ae_vector_initEPNS_9ae_vectorEllPNS_8ae_stateEb(ptr noundef nonnull %4, i64 noundef 0, i64 noundef 4, ptr noundef %1, i1 noundef zeroext true)
  %5 = load i64, ptr %0, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %4, i64 noundef %5, ptr noundef %1)
  %6 = load i64, ptr %4, align 8, !tbaa !5
  %.not.not18 = icmp sgt i64 %6, 0
  br i1 %.not.not18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = getelementptr inbounds i8, ptr %4, i64 56
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %.019 = phi i64 [ 0, %.lr.ph ], [ %14, %9 ]
  %10 = load ptr, ptr %7, align 8, !tbaa !13
  %11 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %10, i64 %.019
  %12 = load ptr, ptr %8, align 8, !tbaa !13
  %13 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %12, i64 %.019
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %11, i64 16, i1 false), !tbaa.struct !14
  %14 = add nuw nsw i64 %.019, 1
  %15 = load i64, ptr %4, align 8, !tbaa !5
  %.not.not = icmp slt i64 %14, %15
  br i1 %.not.not, label %9, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %9, %2
  %.lcssa = phi i64 [ %6, %2 ], [ %15, %9 ]
  %16 = shl nsw i64 %.lcssa, 1
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %0, i64 noundef %16, ptr noundef %1)
  %17 = load i64, ptr %0, align 8, !tbaa !5
  %.not.not1720 = icmp sgt i64 %17, 0
  br i1 %.not.not1720, label %.lr.ph23, label %._crit_edge24

.lr.ph23:                                         ; preds = %._crit_edge
  %18 = getelementptr inbounds i8, ptr %4, i64 56
  %19 = getelementptr inbounds i8, ptr %0, i64 56
  br label %20

20:                                               ; preds = %.lr.ph23, %20
  %.121 = phi i64 [ 0, %.lr.ph23 ], [ %27, %20 ]
  %21 = load ptr, ptr %18, align 8, !tbaa !13
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = srem i64 %.121, %22
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %21, i64 %23
  %25 = load ptr, ptr %19, align 8, !tbaa !13
  %26 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %25, i64 %.121
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(16) %24, i64 16, i1 false), !tbaa.struct !14
  %27 = add nuw nsw i64 %.121, 1
  %28 = load i64, ptr %0, align 8, !tbaa !5
  %.not.not17 = icmp slt i64 %27, %28
  br i1 %.not.not17, label %20, label %._crit_edge24, !llvm.loop !19

._crit_edge24:                                    ; preds = %20, %._crit_edge
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %1)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  ret void
}

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

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

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

declare void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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: readwrite) }
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 = !{i64 0, i64 8, !15, i64 8, i64 8, !15}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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