; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (alglibinternal)

; 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.0 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.0 = 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

declare noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef, double noundef) #1

declare noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN11alglib_impl12rowidxabsmaxEPNS_9ae_matrixElllPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %13 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %13, ptr %12, align 8, !tbaa !9
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = add nsw i64 %14, 1
  store i64 %15, ptr %11, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %47, %5
  %17 = load i64, ptr %11, align 8, !tbaa !9
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = icmp sle i64 %17, %18
  br i1 %19, label %20, label %50

20:                                               ; preds = %16
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %21, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = getelementptr inbounds ptr, ptr %23, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = getelementptr inbounds double, ptr %26, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !12
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = call noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef %29, ptr noundef %30)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %32, i32 0, i32 6
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %34, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr %12, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !12
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = call noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef %40, ptr noundef %41)
  %43 = call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef %31, double noundef %42)
  br i1 %43, label %44, label %46

44:                                               ; preds = %20
  %45 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %45, ptr %12, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %44, %20
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = add nsw i64 %48, 1
  store i64 %49, ptr %11, align 8, !tbaa !9
  br label %16, !llvm.loop !14

50:                                               ; preds = %16
  %51 = load i64, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret i64 %51
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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

declare noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef, double noundef) local_unnamed_addr #0

declare noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN11alglib_impl12rowidxabsmaxEPNS_9ae_matrixElllPNS_8ae_stateE(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %.not.not15 = icmp slt i64 %1, %2
  br i1 %.not.not15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %6 = getelementptr inbounds i8, ptr %0, i64 72
  br label %7

7:                                                ; preds = %.lr.ph, %7
  %.017 = phi i64 [ %1, %.lr.ph ], [ %spec.select, %7 ]
  %.014.in16 = phi i64 [ %1, %.lr.ph ], [ %.014, %7 ]
  %.014 = add nsw i64 %.014.in16, 1
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  %9 = getelementptr inbounds ptr, ptr %8, i64 %3
  %10 = load ptr, ptr %9, align 8, !tbaa !8
  %11 = getelementptr inbounds double, ptr %10, i64 %.014
  %12 = load double, ptr %11, align 8, !tbaa !10
  %13 = tail call noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef %12, ptr noundef %4)
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds ptr, ptr %14, i64 %3
  %16 = load ptr, ptr %15, align 8, !tbaa !8
  %17 = getelementptr inbounds double, ptr %16, i64 %.017
  %18 = load double, ptr %17, align 8, !tbaa !10
  %19 = tail call noundef double @_ZN11alglib_impl7ae_fabsEdPNS_8ae_stateE(double noundef %18, ptr noundef %4)
  %20 = tail call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef %13, double noundef %19)
  %spec.select = select i1 %20, i64 %.014, i64 %.017
  %exitcond.not = icmp eq i64 %.014, %2
  br i1 %exitcond.not, label %._crit_edge, label %7, !llvm.loop !12

._crit_edge:                                      ; preds = %7, %5
  %.0.lcssa = phi i64 [ %1, %5 ], [ %spec.select, %7 ]
  ret i64 %.0.lcssa
}

attributes #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 = { 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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