; 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_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 }
%"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
define dso_local void @_ZN11alglib_impl17xdebugc2outsincosEllPNS_9ae_matrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %11 = load ptr, ptr %7, align 8, !tbaa !9
  call void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef %11)
  %12 = load ptr, ptr %7, align 8, !tbaa !9
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = load i64, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef %12, i64 noundef %13, i64 noundef %14, ptr noundef %15)
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %70, %4
  %17 = load i64, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !9
  %19 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %18, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = sub nsw i64 %20, 1
  %22 = icmp sle i64 %17, %21
  br i1 %22, label %23, label %73

23:                                               ; preds = %16
  store i64 0, ptr %10, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %66, %23
  %25 = load i64, ptr %10, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !15
  %29 = sub nsw i64 %28, 1
  %30 = icmp sle i64 %25, %29
  br i1 %30, label %31, label %69

31:                                               ; preds = %24
  %32 = load i64, ptr %9, align 8, !tbaa !5
  %33 = mul nsw i64 3, %32
  %34 = load i64, ptr %10, align 8, !tbaa !5
  %35 = mul nsw i64 5, %34
  %36 = add nsw i64 %33, %35
  %37 = sitofp i64 %36 to double
  %38 = load ptr, ptr %8, align 8, !tbaa !9
  %39 = call noundef double @_ZN11alglib_impl6ae_sinEdPNS_8ae_stateE(double noundef %37, ptr noundef %38)
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %40, i32 0, i32 6
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = load i64, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %42, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = load i64, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %45, i64 %46
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %47, i32 0, i32 0
  store double %39, ptr %48, align 8, !tbaa !17
  %49 = load i64, ptr %9, align 8, !tbaa !5
  %50 = mul nsw i64 3, %49
  %51 = load i64, ptr %10, align 8, !tbaa !5
  %52 = mul nsw i64 5, %51
  %53 = add nsw i64 %50, %52
  %54 = sitofp i64 %53 to double
  %55 = load ptr, ptr %8, align 8, !tbaa !9
  %56 = call noundef double @_ZN11alglib_impl6ae_cosEdPNS_8ae_stateE(double noundef %54, ptr noundef %55)
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  %58 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %57, i32 0, i32 6
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = load i64, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds ptr, ptr %59, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = load i64, ptr %10, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %62, i64 %63
  %65 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %64, i32 0, i32 1
  store double %56, ptr %65, align 8, !tbaa !20
  br label %66

66:                                               ; preds = %31
  %67 = load i64, ptr %10, align 8, !tbaa !5
  %68 = add nsw i64 %67, 1
  store i64 %68, ptr %10, align 8, !tbaa !5
  br label %24, !llvm.loop !21

69:                                               ; preds = %24
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %9, align 8, !tbaa !5
  %72 = add nsw i64 %71, 1
  store i64 %72, ptr %9, align 8, !tbaa !5
  br label %16, !llvm.loop !23

73:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

declare void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef) #2

declare noundef double @_ZN11alglib_impl6ae_sinEdPNS_8ae_stateE(double noundef, ptr noundef) #2

declare noundef double @_ZN11alglib_impl6ae_cosEdPNS_8ae_stateE(double noundef, ptr noundef) #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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN11alglib_impl9ae_matrixE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 40, !7, i64 72}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!15 = !{!12, !6, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !19, i64 0}
!18 = !{!"_ZTSN11alglib_impl10ae_complexE", !19, i64 0, !19, i64 8}
!19 = !{!"double", !7, i64 0}
!20 = !{!18, !19, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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 void @_ZN11alglib_impl17xdebugc2outsincosEllPNS_9ae_matrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  tail call void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef %2)
  tail call void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef %2, i64 noundef %0, i64 noundef %1, ptr noundef %3)
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %.not.not26 = icmp sgt i64 %5, 0
  br i1 %.not.not26, label %.preheader.lr.ph, label %._crit_edge28

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

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %10 = phi i64 [ %29, %._crit_edge ], [ %5, %.preheader.lr.ph ]
  %11 = phi i64 [ %30, %._crit_edge ], [ %8, %.preheader.lr.ph ]
  %.02227 = phi i64 [ %31, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not.not2324 = icmp sgt i64 %11, 0
  br i1 %.not.not2324, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %12 = mul nuw nsw i64 %.02227, 3
  br label %13

13:                                               ; preds = %.lr.ph, %13
  %.025 = phi i64 [ 0, %.lr.ph ], [ %27, %13 ]
  %14 = mul nuw nsw i64 %.025, 5
  %15 = add nuw nsw i64 %14, %12
  %16 = uitofp nneg i64 %15 to double
  %17 = tail call noundef double @_ZN11alglib_impl6ae_sinEdPNS_8ae_stateE(double noundef %16, ptr noundef %3)
  %18 = load ptr, ptr %7, align 8, !tbaa !14
  %19 = getelementptr inbounds ptr, ptr %18, i64 %.02227
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %20, i64 %.025
  store double %17, ptr %21, align 8, !tbaa !16
  %22 = tail call noundef double @_ZN11alglib_impl6ae_cosEdPNS_8ae_stateE(double noundef %16, ptr noundef %3)
  %23 = load ptr, ptr %7, align 8, !tbaa !14
  %24 = getelementptr inbounds ptr, ptr %23, i64 %.02227
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %25, i64 %.025, i32 1
  store double %22, ptr %26, align 8, !tbaa !19
  %27 = add nuw nsw i64 %.025, 1
  %28 = load i64, ptr %6, align 8, !tbaa !13
  %.not.not23 = icmp slt i64 %27, %28
  br i1 %.not.not23, label %13, label %._crit_edge.loopexit, !llvm.loop !20

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %29 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %10, %.preheader ]
  %30 = phi i64 [ %28, %._crit_edge.loopexit ], [ %11, %.preheader ]
  %31 = add nuw nsw i64 %.02227, 1
  %.not.not = icmp slt i64 %31, %29
  br i1 %.not.not, label %.preheader, label %._crit_edge28, !llvm.loop !22

._crit_edge28:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %4
  ret void
}

declare void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef) local_unnamed_addr #1

declare noundef double @_ZN11alglib_impl6ae_sinEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #1

declare noundef double @_ZN11alglib_impl6ae_cosEdPNS_8ae_stateE(double noundef, ptr noundef) 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, !18, i64 0}
!17 = !{!"_ZTSN11alglib_impl10ae_complexE", !18, i64 0, !18, i64 8}
!18 = !{!"double", !8, i64 0}
!19 = !{!17, !18, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21, !23}
!23 = !{!"llvm.loop.unswitch.partial.disable"}


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