; 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_impl14xdebugi2outsinEllPNS_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 = %54, %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 %57

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

24:                                               ; preds = %50, %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 %53

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 %8, align 8, !tbaa !9
  %41 = call noundef i64 @_ZN11alglib_impl7ae_signEdPNS_8ae_stateE(double noundef %39, ptr noundef %40)
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = load i64, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds ptr, ptr %44, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = load i64, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds i64, ptr %47, i64 %48
  store i64 %41, ptr %49, align 8, !tbaa !5
  br label %50

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

53:                                               ; preds = %24
  br label %54

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

57:                                               ; 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 i64 @_ZN11alglib_impl7ae_signEdPNS_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 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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_impl14xdebugi2outsinEllPNS_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.not21 = icmp sgt i64 %5, 0
  br i1 %.not.not21, label %.preheader.lr.ph, label %._crit_edge23

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

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

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

13:                                               ; preds = %.lr.ph, %13
  %.020 = phi i64 [ 0, %.lr.ph ], [ %23, %13 ]
  %14 = mul nuw nsw i64 %.020, 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 = tail call noundef i64 @_ZN11alglib_impl7ae_signEdPNS_8ae_stateE(double noundef %17, ptr noundef %3)
  %19 = load ptr, ptr %7, align 8, !tbaa !14
  %20 = getelementptr inbounds ptr, ptr %19, i64 %.01722
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds i64, ptr %21, i64 %.020
  store i64 %18, ptr %22, align 8, !tbaa !16
  %23 = add nuw nsw i64 %.020, 1
  %24 = load i64, ptr %6, align 8, !tbaa !13
  %.not.not18 = icmp slt i64 %23, %24
  br i1 %.not.not18, label %13, label %._crit_edge.loopexit, !llvm.loop !17

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

._crit_edge23:                                    ; 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 i64 @_ZN11alglib_impl7ae_signEdPNS_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 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18, !20}
!20 = !{!"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