; 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_complex" = type { double, double }
%"struct.alglib_impl::ae_matrix" = type { i64, i64, i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.1 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.1 = 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

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZN11alglib_impl11xdebugc2sumEPNS_9ae_matrixEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca %"struct.alglib_impl::ae_complex", align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca %"struct.alglib_impl::ae_complex", align 8
  %9 = alloca %"struct.alglib_impl::ae_complex", align 8
  %10 = alloca %"struct.alglib_impl::ae_complex", align 8
  %11 = alloca %"struct.alglib_impl::ae_complex", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %12 = call { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef 0)
  %13 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %14 = extractvalue { double, double } %12, 0
  store double %14, ptr %13, align 8
  %15 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %16 = extractvalue { double, double } %12, 1
  store double %16, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  store i64 0, ptr %6, align 8, !tbaa !12
  br label %17

17:                                               ; preds = %58, %2
  %18 = load i64, ptr %6, align 8, !tbaa !12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !14
  %22 = sub nsw i64 %21, 1
  %23 = icmp sle i64 %18, %22
  br i1 %23, label %24, label %61

24:                                               ; preds = %17
  store i64 0, ptr %7, align 8, !tbaa !12
  br label %25

25:                                               ; preds = %54, %24
  %26 = load i64, ptr %7, align 8, !tbaa !12
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !18
  %30 = sub nsw i64 %29, 1
  %31 = icmp sle i64 %26, %30
  br i1 %31, label %32, label %57

32:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %3, i64 16, i1 false), !tbaa.struct !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %33, i32 0, i32 6
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = load i64, ptr %6, align 8, !tbaa !12
  %37 = getelementptr inbounds ptr, ptr %35, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = load i64, ptr %7, align 8, !tbaa !12
  %40 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %38, i64 %39
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %40, i64 16, i1 false), !tbaa.struct !9
  %41 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  %42 = load double, ptr %41, align 8
  %43 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  %44 = load double, ptr %43, align 8
  %45 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  %46 = load double, ptr %45, align 8
  %47 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  %48 = load double, ptr %47, align 8
  %49 = call { double, double } @_ZN11alglib_impl8ae_c_addENS_10ae_complexES0_(double %42, double %44, double %46, double %48)
  %50 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  %51 = extractvalue { double, double } %49, 0
  store double %51, ptr %50, align 8
  %52 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  %53 = extractvalue { double, double } %49, 1
  store double %53, ptr %52, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %54

54:                                               ; preds = %32
  %55 = load i64, ptr %7, align 8, !tbaa !12
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %7, align 8, !tbaa !12
  br label %25, !llvm.loop !20

57:                                               ; preds = %25
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %6, align 8, !tbaa !12
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %6, align 8, !tbaa !12
  br label %17, !llvm.loop !22

61:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %62 = load { double, double }, ptr %3, align 8
  ret { double, double } %62
}

declare { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef) #2

; 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) #3

declare { double, double } @_ZN11alglib_impl8ae_c_addENS_10ae_complexES0_(double, double, double, double) #2

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


; 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_complex" = type { double, double }

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZN11alglib_impl11xdebugc2sumEPNS_9ae_matrixEPNS_8ae_stateE(ptr nocapture noundef readonly %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef 0)
  %4 = extractvalue { double, double } %3, 0
  %5 = extractvalue { double, double } %3, 1
  %6 = load i64, ptr %0, align 8, !tbaa !5
  %.not.not22 = icmp sgt i64 %6, 0
  br i1 %.not.not22, label %.preheader.lr.ph, label %._crit_edge26

.preheader.lr.ph:                                 ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  %9 = load i64, ptr %7, align 8, !tbaa !13
  %10 = icmp sgt i64 %9, 0
  br i1 %10, label %.preheader, label %._crit_edge26

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %11 = phi i64 [ %22, %._crit_edge ], [ %6, %.preheader.lr.ph ]
  %12 = phi i64 [ %23, %._crit_edge ], [ %9, %.preheader.lr.ph ]
  %.sroa.414.025 = phi double [ %.sroa.414.1.lcssa, %._crit_edge ], [ %5, %.preheader.lr.ph ]
  %.sroa.013.024 = phi double [ %.sroa.013.1.lcssa, %._crit_edge ], [ %4, %.preheader.lr.ph ]
  %.023 = phi i64 [ %24, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not.not1617 = icmp sgt i64 %12, 0
  br i1 %.not.not1617, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.sroa.414.120 = phi double [ %19, %.lr.ph ], [ %.sroa.414.025, %.preheader ]
  %.sroa.013.119 = phi double [ %18, %.lr.ph ], [ %.sroa.013.024, %.preheader ]
  %.01518 = phi i64 [ %20, %.lr.ph ], [ 0, %.preheader ]
  %13 = load ptr, ptr %8, align 8, !tbaa !14
  %14 = getelementptr inbounds ptr, ptr %13, i64 %.023
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %15, i64 %.01518
  %.sroa.0.0.copyload = load double, ptr %16, align 8, !tbaa !16
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %16, i64 8
  %.sroa.2.0.copyload = load double, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !16
  %17 = tail call { double, double } @_ZN11alglib_impl8ae_c_addENS_10ae_complexES0_(double %.sroa.013.119, double %.sroa.414.120, double %.sroa.0.0.copyload, double %.sroa.2.0.copyload)
  %18 = extractvalue { double, double } %17, 0
  %19 = extractvalue { double, double } %17, 1
  %20 = add nuw nsw i64 %.01518, 1
  %21 = load i64, ptr %7, align 8, !tbaa !13
  %.not.not16 = icmp slt i64 %20, %21
  br i1 %.not.not16, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %0, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %22 = phi i64 [ %11, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %23 = phi i64 [ %12, %.preheader ], [ %21, %._crit_edge.loopexit ]
  %.sroa.013.1.lcssa = phi double [ %.sroa.013.024, %.preheader ], [ %18, %._crit_edge.loopexit ]
  %.sroa.414.1.lcssa = phi double [ %.sroa.414.025, %.preheader ], [ %19, %._crit_edge.loopexit ]
  %24 = add nuw nsw i64 %.023, 1
  %.not.not = icmp slt i64 %24, %22
  br i1 %.not.not, label %.preheader, label %._crit_edge26, !llvm.loop !20

._crit_edge26:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %2
  %.sroa.013.0.lcssa = phi double [ %4, %2 ], [ %4, %.preheader.lr.ph ], [ %.sroa.013.1.lcssa, %._crit_edge ]
  %.sroa.414.0.lcssa = phi double [ %5, %2 ], [ %5, %.preheader.lr.ph ], [ %.sroa.414.1.lcssa, %._crit_edge ]
  %.fca.0.insert = insertvalue { double, double } poison, double %.sroa.013.0.lcssa, 0
  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %.sroa.414.0.lcssa, 1
  ret { double, double } %.fca.1.insert
}

declare { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef) local_unnamed_addr #1

declare { double, double } @_ZN11alglib_impl8ae_c_addENS_10ae_complexES0_(double, double, double, double) local_unnamed_addr #1

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

!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_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !8, i64 72}
!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 = !{!6, !7, i64 8}
!14 = !{!8, !8, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19, !21}
!21 = !{!"llvm.loop.unswitch.partial.disable"}


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