; 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 }

; 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_impl18xdebugi1appendcopyEPNS_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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #4
  %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 2, 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 = %31, %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 %34

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 i64, ptr %23, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = load i64, ptr %6, align 8, !tbaa !14
  %30 = getelementptr inbounds i64, ptr %28, i64 %29
  store i64 %26, ptr %30, align 8, !tbaa !14
  br label %31

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

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

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

47:                                               ; preds = %40
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = load i64, ptr %6, align 8, !tbaa !14
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %7, i32 0, i32 0
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = srem i64 %50, %52
  %54 = getelementptr inbounds i64, ptr %49, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !14
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %56, i32 0, i32 4
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = load i64, ptr %6, align 8, !tbaa !14
  %60 = getelementptr inbounds i64, ptr %58, i64 %59
  store i64 %55, ptr %60, align 8, !tbaa !14
  br label %61

61:                                               ; preds = %47
  %62 = load i64, ptr %6, align 8, !tbaa !14
  %63 = add nsw i64 %62, 1
  store i64 %63, ptr %6, align 8, !tbaa !14
  br label %40, !llvm.loop !18

64:                                               ; preds = %40
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %65)
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  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

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 = { 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 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 }

; 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_impl18xdebugi1appendcopyEPNS_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) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #4
  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 2, 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 ], [ %15, %9 ]
  %10 = load ptr, ptr %7, align 8, !tbaa !13
  %11 = getelementptr inbounds i64, ptr %10, i64 %.019
  %12 = load i64, ptr %11, align 8, !tbaa !14
  %13 = load ptr, ptr %8, align 8, !tbaa !13
  %14 = getelementptr inbounds i64, ptr %13, i64 %.019
  store i64 %12, ptr %14, align 8, !tbaa !14
  %15 = add nuw nsw i64 %.019, 1
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %.not.not = icmp slt i64 %15, %16
  br i1 %.not.not, label %9, label %._crit_edge, !llvm.loop !15

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

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

21:                                               ; preds = %.lr.ph23, %21
  %.121 = phi i64 [ 0, %.lr.ph23 ], [ %29, %21 ]
  %22 = load ptr, ptr %19, align 8, !tbaa !13
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = srem i64 %.121, %23
  %25 = getelementptr inbounds i64, ptr %22, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = load ptr, ptr %20, align 8, !tbaa !13
  %28 = getelementptr inbounds i64, ptr %27, i64 %.121
  store i64 %26, ptr %28, align 8, !tbaa !14
  %29 = add nuw nsw i64 %.121, 1
  %30 = load i64, ptr %0, align 8, !tbaa !5
  %.not.not17 = icmp slt i64 %29, %30
  br i1 %.not.not17, label %21, label %._crit_edge24, !llvm.loop !17

._crit_edge24:                                    ; preds = %21, %._crit_edge
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %1)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  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

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 = { 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 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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