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

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

%"class.alglib::ae_vector_wrapper" = type <{ ptr, ptr, %"struct.alglib_impl::ae_vector", i8, [7 x i8] }>
%"struct.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.0 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.0 = type { ptr }
%"class.alglib::complex" = type { double, double }
%"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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6alglib17ae_vector_wrapper9setlengthEl(ptr noundef nonnull align 8 dereferenceable(81), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6alglib16complex_1d_array10setcontentElPKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = 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
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load i64, ptr %5, align 8, !tbaa !9
  call void @_ZN6alglib17ae_vector_wrapper9setlengthEl(ptr noundef nonnull align 8 dereferenceable(81) %9, i64 noundef %10)
  %11 = getelementptr inbounds %"class.alglib::ae_vector_wrapper", ptr %9, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp eq ptr %12, null
  br i1 %13, label %21, label %14

14:                                               ; preds = %3
  %15 = getelementptr inbounds %"class.alglib::ae_vector_wrapper", ptr %9, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !16
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = icmp ne i64 %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %14, %3
  store i32 1, ptr %8, align 4
  br label %56

22:                                               ; preds = %14
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %52, %22
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %27, label %55

27:                                               ; preds = %23
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !9
  %30 = getelementptr inbounds %"class.alglib::complex", ptr %28, i64 %29
  %31 = getelementptr inbounds %"class.alglib::complex", ptr %30, i32 0, i32 0
  %32 = load double, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds %"class.alglib::ae_vector_wrapper", ptr %9, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %36, i64 %37
  %39 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %38, i32 0, i32 0
  store double %32, ptr %39, align 8, !tbaa !21
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = getelementptr inbounds %"class.alglib::complex", ptr %40, i64 %41
  %43 = getelementptr inbounds %"class.alglib::complex", ptr %42, i32 0, i32 1
  %44 = load double, ptr %43, align 8, !tbaa !23
  %45 = getelementptr inbounds %"class.alglib::ae_vector_wrapper", ptr %9, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %46, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  %49 = load i64, ptr %7, align 8, !tbaa !9
  %50 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %48, i64 %49
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %50, i32 0, i32 1
  store double %44, ptr %51, align 8, !tbaa !24
  br label %52

52:                                               ; preds = %27
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %7, align 8, !tbaa !9
  br label %23, !llvm.loop !25

55:                                               ; preds = %23
  store i32 0, ptr %8, align 4
  br label %56

56:                                               ; preds = %55, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  %57 = load i32, ptr %8, align 4
  switch i32 %57, label %59 [
    i32 0, label %58
    i32 1, label %58
  ]

58:                                               ; preds = %56, %56
  ret void

59:                                               ; preds = %56
  unreachable
}

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 = { 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, !6, i64 8}
!12 = !{!"_ZTSN6alglib17ae_vector_wrapperE", !6, i64 8, !13, i64 16, !14, i64 80}
!13 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !14, i64 16, !15, i64 24, !7, i64 56}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!13, !10, i64 0}
!17 = !{!18, !19, i64 0}
!18 = !{!"_ZTSN6alglib7complexE", !19, i64 0, !19, i64 8}
!19 = !{!"double", !7, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !19, i64 0}
!22 = !{!"_ZTSN11alglib_impl10ae_complexE", !19, i64 0, !19, i64 8}
!23 = !{!18, !19, i64 8}
!24 = !{!22, !19, i64 8}
!25 = distinct !{!25, !26}
!26 = !{!"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"

%"class.alglib::complex" = type { double, double }
%"struct.alglib_impl::ae_complex" = type { double, double }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6alglib17ae_vector_wrapper9setlengthEl(ptr noundef nonnull align 8 dereferenceable(81), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6alglib16complex_1d_array10setcontentElPKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN6alglib17ae_vector_wrapper9setlengthEl(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %1)
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %3
  %8 = load i64, ptr %5, align 8, !tbaa !14
  %.not = icmp eq i64 %8, %1
  %9 = icmp sgt i64 %1, 0
  %or.cond = and i1 %.not, %9
  br i1 %or.cond, label %.lr.ph, label %.loopexit

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

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

12:                                               ; preds = %12, %.lr.ph.new
  %.013 = phi i64 [ 0, %.lr.ph.new ], [ %30, %12 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %12 ]
  %13 = getelementptr inbounds %"class.alglib::complex", ptr %2, i64 %.013
  %14 = load double, ptr %13, align 8, !tbaa !15
  %15 = load ptr, ptr %10, align 8, !tbaa !18
  %16 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %15, i64 %.013
  store double %14, ptr %16, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %13, i64 8
  %18 = load double, ptr %17, align 8, !tbaa !21
  %19 = load ptr, ptr %10, align 8, !tbaa !18
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %19, i64 %.013, i32 1
  store double %18, ptr %20, align 8, !tbaa !22
  %21 = or disjoint i64 %.013, 1
  %22 = getelementptr inbounds %"class.alglib::complex", ptr %2, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !15
  %24 = load ptr, ptr %10, align 8, !tbaa !18
  %25 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %24, i64 %21
  store double %23, ptr %25, align 8, !tbaa !19
  %26 = getelementptr inbounds i8, ptr %22, i64 8
  %27 = load double, ptr %26, align 8, !tbaa !21
  %28 = load ptr, ptr %10, align 8, !tbaa !18
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %28, i64 %21, i32 1
  store double %27, ptr %29, align 8, !tbaa !22
  %30 = add nuw nsw i64 %.013, 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 %.loopexit.loopexit.unr-lcssa, label %12, !llvm.loop !23

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

.loopexit.loopexit.epilog-lcssa:                  ; preds = %.loopexit.loopexit.unr-lcssa
  %31 = getelementptr inbounds %"class.alglib::complex", ptr %2, i64 %.013.unr
  %32 = load double, ptr %31, align 8, !tbaa !15
  %33 = load ptr, ptr %10, align 8, !tbaa !18
  %34 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %33, i64 %.013.unr
  store double %32, ptr %34, align 8, !tbaa !19
  %35 = getelementptr inbounds i8, ptr %31, i64 8
  %36 = load double, ptr %35, align 8, !tbaa !21
  %37 = load ptr, ptr %10, align 8, !tbaa !18
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %37, i64 %.013.unr, i32 1
  store double %36, ptr %38, align 8, !tbaa !22
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.epilog-lcssa, %.loopexit.loopexit.unr-lcssa, %3, %7
  ret void
}

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

!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 8}
!6 = !{!"_ZTSN6alglib17ae_vector_wrapperE", !7, i64 8, !10, i64 16, !12, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN11alglib_impl9ae_vectorE", !11, i64 0, !11, i64 8, !12, i64 16, !13, i64 24, !8, i64 56}
!11 = !{!"long", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!14 = !{!10, !11, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTSN6alglib7complexE", !17, i64 0, !17, i64 8}
!17 = !{!"double", !8, i64 0}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !17, i64 0}
!20 = !{!"_ZTSN11alglib_impl10ae_complexE", !17, i64 0, !17, i64 8}
!21 = !{!16, !17, i64 8}
!22 = !{!20, !17, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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