; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/tests (test_i)

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

; 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 speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z20doc_test_real_vectorRKN6alglib13real_1d_arrayES2_d(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(81) %1, double noundef %2) #3 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %12)
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %14)
  %16 = icmp ne i64 %13, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %61

18:                                               ; preds = %3
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %57, %18
  %20 = load i64, ptr %8, align 8, !tbaa !11
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %21)
  %23 = icmp slt i64 %20, %22
  br i1 %23, label %24, label %60

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %25 = load double, ptr %7, align 8, !tbaa !9
  %26 = fcmp oge double %25, 0.000000e+00
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  br label %34

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %8, align 8, !tbaa !11
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %29, i64 noundef %30)
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = call double @llvm.fabs.f64(double %32)
  br label %34

34:                                               ; preds = %28, %27
  %35 = phi double [ 1.000000e+00, %27 ], [ %33, %28 ]
  store double %35, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %36 = load double, ptr %7, align 8, !tbaa !9
  %37 = call double @llvm.fabs.f64(double %36)
  store double %37, ptr %11, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load i64, ptr %8, align 8, !tbaa !11
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %38, i64 noundef %39)
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i64, ptr %8, align 8, !tbaa !11
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %42, i64 noundef %43)
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = fsub double %41, %45
  %47 = call double @llvm.fabs.f64(double %46)
  %48 = load double, ptr %10, align 8, !tbaa !9
  %49 = fdiv double %47, %48
  %50 = load double, ptr %11, align 8, !tbaa !9
  %51 = fcmp ogt double %49, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %34
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %54

53:                                               ; preds = %34
  store i32 0, ptr %9, align 4
  br label %54

54:                                               ; preds = %53, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %55 = load i32, ptr %9, align 4
  switch i32 %55, label %61 [
    i32 0, label %56
  ]

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56
  %58 = load i64, ptr %8, align 8, !tbaa !11
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %8, align 8, !tbaa !11
  br label %19, !llvm.loop !13

60:                                               ; preds = %19
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %61

61:                                               ; preds = %60, %54, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %62 = load i1, ptr %4, align 1
  ret i1 %62
}

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81), i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

declare noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z20doc_test_real_vectorRKN6alglib13real_1d_arrayES2_d(ptr noundef nonnull align 8 dereferenceable(81) %0, ptr noundef nonnull align 8 dereferenceable(81) %1, double noundef %2) local_unnamed_addr #2 {
  %4 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %0)
  %5 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %1)
  %.not = icmp eq i64 %4, %5
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %3
  %6 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %0)
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %8 = fcmp ult double %2, 0.000000e+00
  %9 = tail call double @llvm.fabs.f64(double %2)
  br i1 %8, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %20
  %.01618.us = phi i64 [ %21, %20 ], [ 0, %.lr.ph ]
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %1, i64 noundef %.01618.us)
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %.01618.us)
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %1, i64 noundef %.01618.us)
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fsub double %13, %15
  %17 = fdiv double %16, %11
  %18 = tail call double @llvm.fabs.f64(double %17)
  %19 = fcmp ule double %18, %9
  br i1 %19, label %20, label %.loopexit

20:                                               ; preds = %.lr.ph.split.us
  %21 = add nuw nsw i64 %.01618.us, 1
  %22 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %0)
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %.lr.ph.split.us, label %.loopexit, !llvm.loop !9

24:                                               ; preds = %.lr.ph.split
  %25 = add nuw nsw i64 %.01618, 1
  %26 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %0)
  %27 = icmp slt i64 %25, %26
  br i1 %27, label %.lr.ph.split, label %.loopexit, !llvm.loop !9

.lr.ph.split:                                     ; preds = %.lr.ph, %24
  %.01618 = phi i64 [ %25, %24 ], [ 0, %.lr.ph ]
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %.01618)
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %1, i64 noundef %.01618)
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fsub double %29, %31
  %33 = tail call double @llvm.fabs.f64(double %32)
  %34 = fcmp ule double %33, %9
  br i1 %34, label %24, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.split, %24, %.lr.ph.split.us, %20, %.preheader, %3
  %.2 = phi i1 [ false, %3 ], [ true, %.preheader ], [ %19, %20 ], [ %19, %.lr.ph.split.us ], [ %34, %24 ], [ %34, %.lr.ph.split ]
  ret i1 %.2
}

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNK6alglib13real_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81), i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass