; 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_matrix_wrapper" = type <{ ptr, ptr, %"struct.alglib_impl::ae_matrix", i8, [7 x i8] }>
%"struct.alglib_impl::ae_matrix" = type { i64, i64, 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 }
%"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_matrix_wrapper9setlengthEll(ptr noundef nonnull align 8 dereferenceable(97), i64 noundef, i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6alglib16complex_2d_array10setcontentEllPKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(97) %0, i64 noundef %1, i64 noundef %2, ptr noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %13 = load i64, ptr %6, align 8, !tbaa !9
  %14 = load i64, ptr %7, align 8, !tbaa !9
  call void @_ZN6alglib17ae_matrix_wrapper9setlengthEll(ptr noundef nonnull align 8 dereferenceable(97) %12, i64 noundef %13, i64 noundef %14)
  %15 = getelementptr inbounds %"class.alglib::ae_matrix_wrapper", ptr %12, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp eq ptr %16, null
  br i1 %17, label %32, label %18

18:                                               ; preds = %4
  %19 = getelementptr inbounds %"class.alglib::ae_matrix_wrapper", ptr %12, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %20, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !16
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = icmp ne i64 %22, %23
  br i1 %24, label %32, label %25

25:                                               ; preds = %18
  %26 = getelementptr inbounds %"class.alglib::ae_matrix_wrapper", ptr %12, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = icmp ne i64 %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %25, %18, %4
  store i32 1, ptr %11, align 4
  br label %90

33:                                               ; preds = %25
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %86, %33
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = icmp slt i64 %35, %36
  br i1 %37, label %38, label %89

38:                                               ; preds = %34
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %82, %38
  %40 = load i64, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = icmp slt i64 %40, %41
  br i1 %42, label %43, label %85

43:                                               ; preds = %39
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = mul nsw i64 %45, %46
  %48 = load i64, ptr %10, align 8, !tbaa !9
  %49 = add nsw i64 %47, %48
  %50 = getelementptr inbounds %"class.alglib::complex", ptr %44, i64 %49
  %51 = getelementptr inbounds %"class.alglib::complex", ptr %50, i32 0, i32 0
  %52 = load double, ptr %51, align 8, !tbaa !18
  %53 = getelementptr inbounds %"class.alglib::ae_matrix_wrapper", ptr %12, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %54, i32 0, i32 6
  %56 = load ptr, ptr %55, align 8, !tbaa !21
  %57 = load i64, ptr %9, align 8, !tbaa !9
  %58 = getelementptr inbounds ptr, ptr %56, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = load i64, ptr %10, align 8, !tbaa !9
  %61 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %59, i64 %60
  %62 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %61, i32 0, i32 0
  store double %52, ptr %62, align 8, !tbaa !22
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = load i64, ptr %7, align 8, !tbaa !9
  %66 = mul nsw i64 %64, %65
  %67 = load i64, ptr %10, align 8, !tbaa !9
  %68 = add nsw i64 %66, %67
  %69 = getelementptr inbounds %"class.alglib::complex", ptr %63, i64 %68
  %70 = getelementptr inbounds %"class.alglib::complex", ptr %69, i32 0, i32 1
  %71 = load double, ptr %70, align 8, !tbaa !24
  %72 = getelementptr inbounds %"class.alglib::ae_matrix_wrapper", ptr %12, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  %74 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %73, i32 0, i32 6
  %75 = load ptr, ptr %74, align 8, !tbaa !21
  %76 = load i64, ptr %9, align 8, !tbaa !9
  %77 = getelementptr inbounds ptr, ptr %75, i64 %76
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  %79 = load i64, ptr %10, align 8, !tbaa !9
  %80 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %78, i64 %79
  %81 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %80, i32 0, i32 1
  store double %71, ptr %81, align 8, !tbaa !25
  br label %82

82:                                               ; preds = %43
  %83 = load i64, ptr %10, align 8, !tbaa !9
  %84 = add nsw i64 %83, 1
  store i64 %84, ptr %10, align 8, !tbaa !9
  br label %39, !llvm.loop !26

85:                                               ; preds = %39
  br label %86

86:                                               ; preds = %85
  %87 = load i64, ptr %9, align 8, !tbaa !9
  %88 = add nsw i64 %87, 1
  store i64 %88, ptr %9, align 8, !tbaa !9
  br label %34, !llvm.loop !28

89:                                               ; preds = %34
  store i32 0, ptr %11, align 4
  br label %90

90:                                               ; preds = %89, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %91 = load i32, ptr %11, align 4
  switch i32 %91, label %93 [
    i32 0, label %92
    i32 1, label %92
  ]

92:                                               ; preds = %90, %90
  ret void

93:                                               ; preds = %90
  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_matrix_wrapperE", !6, i64 8, !13, i64 16, !14, i64 96}
!13 = !{!"_ZTSN11alglib_impl9ae_matrixE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !14, i64 32, !15, i64 40, !7, i64 72}
!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 = !{!13, !10, i64 8}
!18 = !{!19, !20, i64 0}
!19 = !{!"_ZTSN6alglib7complexE", !20, i64 0, !20, i64 8}
!20 = !{!"double", !7, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !20, i64 0}
!23 = !{!"_ZTSN11alglib_impl10ae_complexE", !20, i64 0, !20, i64 8}
!24 = !{!19, !20, i64 8}
!25 = !{!23, !20, i64 8}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


; 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_matrix_wrapper9setlengthEll(ptr noundef nonnull align 8 dereferenceable(97), i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

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

8:                                                ; preds = %4
  %9 = load i64, ptr %6, align 8, !tbaa !14
  %.not = icmp eq i64 %9, %1
  br i1 %.not, label %10, label %.loopexit

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %6, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !15
  %.not26 = icmp eq i64 %12, %2
  %13 = icmp sgt i64 %1, 0
  %or.cond = and i1 %.not26, %13
  br i1 %or.cond, label %.preheader.lr.ph, label %.loopexit

.preheader.lr.ph:                                 ; preds = %10
  %14 = icmp sgt i64 %2, 0
  %15 = getelementptr inbounds i8, ptr %6, i64 72
  br i1 %14, label %.preheader.us, label %.loopexit

.preheader.us:                                    ; preds = %.preheader.lr.ph, %._crit_edge.us
  %.02229.us = phi i64 [ %32, %._crit_edge.us ], [ 0, %.preheader.lr.ph ]
  %16 = mul nuw nsw i64 %.02229.us, %2
  %17 = getelementptr %"class.alglib::complex", ptr %3, i64 %16
  br label %18

18:                                               ; preds = %.preheader.us, %18
  %.028.us = phi i64 [ 0, %.preheader.us ], [ %31, %18 ]
  %19 = getelementptr %"class.alglib::complex", ptr %17, i64 %.028.us
  %20 = load double, ptr %19, align 8, !tbaa !16
  %21 = load ptr, ptr %15, align 8, !tbaa !19
  %22 = getelementptr inbounds ptr, ptr %21, i64 %.02229.us
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %23, i64 %.028.us
  store double %20, ptr %24, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %19, i64 8
  %26 = load double, ptr %25, align 8, !tbaa !23
  %27 = load ptr, ptr %15, align 8, !tbaa !19
  %28 = getelementptr inbounds ptr, ptr %27, i64 %.02229.us
  %29 = load ptr, ptr %28, align 8, !tbaa !20
  %30 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %29, i64 %.028.us, i32 1
  store double %26, ptr %30, align 8, !tbaa !24
  %31 = add nuw nsw i64 %.028.us, 1
  %exitcond.not = icmp eq i64 %31, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %18, !llvm.loop !25

._crit_edge.us:                                   ; preds = %18
  %32 = add nuw nsw i64 %.02229.us, 1
  %exitcond31.not = icmp eq i64 %32, %1
  br i1 %exitcond31.not, label %.loopexit, label %.preheader.us, !llvm.loop !27

.loopexit:                                        ; preds = %._crit_edge.us, %.preheader.lr.ph, %4, %8, %10
  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_matrix_wrapperE", !7, i64 8, !10, i64 16, !12, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN11alglib_impl9ae_matrixE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !8, i64 72}
!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 = !{!10, !11, i64 8}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTSN6alglib7complexE", !18, i64 0, !18, i64 8}
!18 = !{!"double", !8, i64 0}
!19 = !{!8, !8, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !18, i64 0}
!22 = !{!"_ZTSN11alglib_impl10ae_complexE", !18, i64 0, !18, i64 8}
!23 = !{!17, !18, i64 8}
!24 = !{!22, !18, i64 8}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


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