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

; 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_impl14xdebugr2outsinEllPNS_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 = %52, %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 %55

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

24:                                               ; preds = %48, %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 %51

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 double, ptr %45, i64 %46
  store double %39, ptr %47, align 8, !tbaa !17
  br label %48

48:                                               ; preds = %31
  %49 = load i64, ptr %10, align 8, !tbaa !5
  %50 = add nsw i64 %49, 1
  store i64 %50, ptr %10, align 8, !tbaa !5
  br label %24, !llvm.loop !19

51:                                               ; preds = %24
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr %9, align 8, !tbaa !5
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %9, align 8, !tbaa !5
  br label %16, !llvm.loop !21

55:                                               ; 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

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, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl14xdebugr2outsinEllPNS_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.not20 = icmp sgt i64 %5, 0
  br i1 %.not.not20, label %.preheader.lr.ph, label %._crit_edge22

.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_edge22

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %10 = phi i64 [ %24, %._crit_edge ], [ %5, %.preheader.lr.ph ]
  %11 = phi i64 [ %25, %._crit_edge ], [ %8, %.preheader.lr.ph ]
  %.01621 = phi i64 [ %26, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not.not1718 = icmp sgt i64 %11, 0
  br i1 %.not.not1718, label %.lr.ph, label %._crit_edge

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

13:                                               ; preds = %.lr.ph, %13
  %.019 = phi i64 [ 0, %.lr.ph ], [ %22, %13 ]
  %14 = mul nuw nsw i64 %.019, 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 %.01621
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds double, ptr %20, i64 %.019
  store double %17, ptr %21, align 8, !tbaa !16
  %22 = add nuw nsw i64 %.019, 1
  %23 = load i64, ptr %6, align 8, !tbaa !13
  %.not.not17 = icmp slt i64 %22, %23
  br i1 %.not.not17, label %13, label %._crit_edge.loopexit, !llvm.loop !18

._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
  %24 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %10, %.preheader ]
  %25 = phi i64 [ %23, %._crit_edge.loopexit ], [ %11, %.preheader ]
  %26 = add nuw nsw i64 %.01621, 1
  %.not.not = icmp slt i64 %26, %24
  br i1 %.not.not, label %.preheader, label %._crit_edge22, !llvm.loop !20

._crit_edge22:                                    ; 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

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,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass