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

; 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_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl16copybooleanarrayEPNS_9ae_vectorES1_PNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef %8)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %9, i32 0, i32 0
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %13, label %44

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %15, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %14, i64 noundef %17, ptr noundef %18)
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %19

19:                                               ; preds = %40, %13
  %20 = load i64, ptr %7, align 8, !tbaa !14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %21, i32 0, i32 0
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = sub nsw i64 %23, 1
  %25 = icmp sle i64 %20, %24
  br i1 %25, label %26, label %43

26:                                               ; preds = %19
  %27 = load ptr, ptr %4, 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 !15
  %30 = load i64, ptr %7, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !16, !range !17, !noundef !18
  %33 = trunc i8 %32 to i1
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i64, ptr %7, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = zext i1 %33 to i8
  store i8 %39, ptr %38, align 1, !tbaa !16
  br label %40

40:                                               ; preds = %26
  %41 = load i64, ptr %7, align 8, !tbaa !14
  %42 = add nsw i64 %41, 1
  store i64 %42, ptr %7, align 8, !tbaa !14
  br label %19, !llvm.loop !19

43:                                               ; preds = %19
  br label %44

44:                                               ; preds = %43, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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 = { 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 = { 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 = !{!12, !12, 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"

declare void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl16copybooleanarrayEPNS_9ae_vectorES1_PNS_8ae_stateE(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  tail call void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef %1)
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = icmp sgt i64 %4, 0
  br i1 %5, label %6, label %.loopexit

6:                                                ; preds = %3
  tail call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %1, i64 noundef %4, ptr noundef %2)
  %7 = load i64, ptr %0, align 8, !tbaa !5
  %.not.not12 = icmp sgt i64 %7, 0
  br i1 %.not.not12, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = getelementptr inbounds i8, ptr %1, i64 56
  %xtraiter = and i64 %7, 3
  %10 = icmp ult i64 %7, 4
  br i1 %10, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.new

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

11:                                               ; preds = %11, %.lr.ph.new
  %.013 = phi i64 [ 0, %.lr.ph.new ], [ %35, %11 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %11 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %12, i64 %.013
  %14 = load i8, ptr %13, align 1, !tbaa !14, !range !15, !noundef !16
  %15 = load ptr, ptr %9, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %15, i64 %.013
  store i8 %14, ptr %16, align 1, !tbaa !14
  %17 = or disjoint i64 %.013, 1
  %18 = load ptr, ptr %8, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %18, i64 %17
  %20 = load i8, ptr %19, align 1, !tbaa !14, !range !15, !noundef !16
  %21 = load ptr, ptr %9, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %21, i64 %17
  store i8 %20, ptr %22, align 1, !tbaa !14
  %23 = or disjoint i64 %.013, 2
  %24 = load ptr, ptr %8, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %24, i64 %23
  %26 = load i8, ptr %25, align 1, !tbaa !14, !range !15, !noundef !16
  %27 = load ptr, ptr %9, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %27, i64 %23
  store i8 %26, ptr %28, align 1, !tbaa !14
  %29 = or disjoint i64 %.013, 3
  %30 = load ptr, ptr %8, align 8, !tbaa !13
  %31 = getelementptr inbounds i8, ptr %30, i64 %29
  %32 = load i8, ptr %31, align 1, !tbaa !14, !range !15, !noundef !16
  %33 = load ptr, ptr %9, align 8, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %33, i64 %29
  store i8 %32, ptr %34, align 1, !tbaa !14
  %35 = add nuw nsw i64 %.013, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit.loopexit.unr-lcssa, label %11, !llvm.loop !17

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

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader
  %.013.epil = phi i64 [ %41, %.epil.preheader ], [ %.013.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %36 = load ptr, ptr %8, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %36, i64 %.013.epil
  %38 = load i8, ptr %37, align 1, !tbaa !14, !range !15, !noundef !16
  %39 = load ptr, ptr %9, align 8, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %39, i64 %.013.epil
  store i8 %38, ptr %40, align 1, !tbaa !14
  %41 = add nuw nsw i64 %.013.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.epil.preheader, !llvm.loop !19

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %6, %3
  ret void
}

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

!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"}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}


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