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

%"class.alglib::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 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 double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16)) #2

declare void @_ZN6alglibmiERKNS_7complexES2_(ptr dead_on_unwind writable sret(%"class.alglib::complex") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z23doc_test_complex_vectorRKN6alglib16complex_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
  %12 = alloca %"class.alglib::complex", 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
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %13)
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %15)
  %17 = icmp ne i64 %14, %16
  br i1 %17, label %18, label %19

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

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

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

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

28:                                               ; preds = %25
  br label %34

29:                                               ; preds = %25
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i64, ptr %8, align 8, !tbaa !11
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %30, i64 noundef %31)
  %33 = call noundef double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16) %32)
  br label %34

34:                                               ; preds = %29, %28
  %35 = phi double [ 1.000000e+00, %28 ], [ %33, %29 ]
  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
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %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(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %38, i64 noundef %39)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i64, ptr %8, align 8, !tbaa !11
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %41, i64 noundef %42)
  call void @_ZN6alglibmiERKNS_7complexES2_(ptr dead_on_unwind writable sret(%"class.alglib::complex") align 8 %12, ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef nonnull align 8 dereferenceable(16) %43)
  %44 = call noundef double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %45 = load double, ptr %10, align 8, !tbaa !9
  %46 = fdiv double %44, %45
  %47 = load double, ptr %11, align 8, !tbaa !9
  %48 = fcmp ogt double %46, %47
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  br i1 %48, label %49, label %50

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

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

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

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53
  %55 = load i64, ptr %8, align 8, !tbaa !11
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %8, align 8, !tbaa !11
  br label %20, !llvm.loop !13

57:                                               ; preds = %20
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %58

58:                                               ; preds = %57, %51, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %59 = load i1, ptr %4, align 1
  ret i1 %59
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_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"

%"class.alglib::complex" = type { double, double }

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

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

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

declare noundef double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

declare void @_ZN6alglibmiERKNS_7complexES2_(ptr dead_on_unwind writable sret(%"class.alglib::complex") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z23doc_test_complex_vectorRKN6alglib16complex_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 #3 {
  %4 = alloca %"class.alglib::complex", align 8
  %5 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %0)
  %6 = tail call noundef i64 @_ZNK6alglib17ae_vector_wrapper6lengthEv(ptr noundef nonnull align 8 dereferenceable(81) %1)
  %.not = icmp eq i64 %5, %6
  br i1 %.not, label %.preheader, label %.loopexit

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

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

.lr.ph.split.us:                                  ; preds = %.lr.ph, %18
  %.01618.us = phi i64 [ %19, %18 ], [ 0, %.lr.ph ]
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %1, i64 noundef %.01618.us)
  %12 = call noundef double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16) %11)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %.01618.us)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %1, i64 noundef %.01618.us)
  call void @_ZN6alglibmiERKNS_7complexES2_(ptr dead_on_unwind nonnull writable sret(%"class.alglib::complex") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %14)
  %15 = call noundef double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %16 = fdiv double %15, %12
  %17 = fcmp ule double %16, %10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br i1 %17, label %18, label %.loopexit

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

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

.lr.ph.split:                                     ; preds = %.lr.ph, %22
  %.01618 = phi i64 [ %23, %22 ], [ 0, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %0, i64 noundef %.01618)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81) %1, i64 noundef %.01618)
  call void @_ZN6alglibmiERKNS_7complexES2_(ptr dead_on_unwind nonnull writable sret(%"class.alglib::complex") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(16) %27)
  %28 = call noundef double @_ZN6alglib10abscomplexERKNS_7complexE(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %29 = fcmp ule double %28, %10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br i1 %29, label %22, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.split, %22, %.lr.ph.split.us, %18, %.preheader, %3
  %.2 = phi i1 [ false, %3 ], [ true, %.preheader ], [ %17, %18 ], [ %17, %.lr.ph.split.us ], [ %29, %22 ], [ %29, %.lr.ph.split ]
  ret i1 %.2
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6alglib16complex_1d_arrayclEl(ptr noundef nonnull align 8 dereferenceable(81), i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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