; 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_complex" = type { double, double }
%"struct.alglib_impl::ae_vector" = type { 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl15xdebugc1outevenElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca %"struct.alglib_impl::ae_complex", align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr %5, align 8, !tbaa !9
  call void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef %9)
  %10 = load ptr, ptr %5, align 8, !tbaa !9
  %11 = load i64, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !9
  call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %10, i64 noundef %11, ptr noundef %12)
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %55, %3
  %14 = load i64, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %15, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = sub nsw i64 %17, 1
  %19 = icmp sle i64 %14, %18
  br i1 %19, label %20, label %58

20:                                               ; preds = %13
  %21 = load i64, ptr %7, align 8, !tbaa !5
  %22 = srem i64 %21, 2
  %23 = icmp eq i64 %22, 0
  br i1 %23, label %24, label %43

24:                                               ; preds = %20
  %25 = load i64, ptr %7, align 8, !tbaa !5
  %26 = sitofp i64 %25 to double
  %27 = fmul double %26, 2.500000e-01
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = load i64, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %30, i64 %31
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %32, i32 0, i32 0
  store double %27, ptr %33, align 8, !tbaa !16
  %34 = load i64, ptr %7, align 8, !tbaa !5
  %35 = sitofp i64 %34 to double
  %36 = fmul double %35, 1.250000e-01
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i64, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %39, i64 %40
  %42 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %41, i32 0, i32 1
  store double %36, ptr %42, align 8, !tbaa !19
  br label %54

43:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %44 = call { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef 0)
  %45 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %46 = extractvalue { double, double } %44, 0
  store double %46, ptr %45, align 8
  %47 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %48 = extractvalue { double, double } %44, 1
  store double %48, ptr %47, align 8
  %49 = load ptr, ptr %5, align 8, !tbaa !9
  %50 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %49, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = load i64, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %51, i64 %52
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %53, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  br label %54

54:                                               ; preds = %43, %24
  br label %55

55:                                               ; preds = %54
  %56 = load i64, ptr %7, align 8, !tbaa !5
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %7, align 8, !tbaa !5
  br label %13, !llvm.loop !22

58:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

declare void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #2

declare void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef) #2

declare { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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_vectorE", !6, i64 0, !6, i64 8, !13, i64 16, !14, i64 24, !7, i64 56}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTSN11alglib_impl10ae_complexE", !18, i64 0, !18, i64 8}
!18 = !{!"double", !7, i64 0}
!19 = !{!17, !18, i64 8}
!20 = !{i64 0, i64 8, !21, i64 8, i64 8, !21}
!21 = !{!18, !18, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

%"struct.alglib_impl::ae_complex" = type { double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl15xdebugc1outevenElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  tail call void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef %1)
  tail call void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %1, i64 noundef %0, ptr noundef %2)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %.not.not15 = icmp sgt i64 %4, 0
  br i1 %.not.not15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %5 = getelementptr inbounds i8, ptr %1, i64 56
  br label %6

6:                                                ; preds = %.lr.ph, %24
  %7 = phi i64 [ %4, %.lr.ph ], [ %25, %24 ]
  %.016 = phi i64 [ 0, %.lr.ph ], [ %26, %24 ]
  %8 = and i64 %.016, 1
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %10, label %18

10:                                               ; preds = %6
  %11 = uitofp nneg i64 %.016 to double
  %12 = fmul double %11, 2.500000e-01
  %13 = load ptr, ptr %5, align 8, !tbaa !13
  %14 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %13, i64 %.016
  store double %12, ptr %14, align 8, !tbaa !14
  %15 = fmul double %11, 1.250000e-01
  %16 = load ptr, ptr %5, align 8, !tbaa !13
  %17 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %16, i64 %.016, i32 1
  store double %15, ptr %17, align 8, !tbaa !17
  br label %24

18:                                               ; preds = %6
  %19 = tail call { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 noundef 0)
  %20 = extractvalue { double, double } %19, 0
  %21 = extractvalue { double, double } %19, 1
  %22 = load ptr, ptr %5, align 8, !tbaa !13
  %23 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %22, i64 %.016
  store double %20, ptr %23, align 8, !tbaa !18
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %23, i64 8
  store double %21, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !18
  %.pre = load i64, ptr %1, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %10, %18
  %25 = phi i64 [ %7, %10 ], [ %.pre, %18 ]
  %26 = add nuw nsw i64 %.016, 1
  %.not.not = icmp slt i64 %26, %25
  br i1 %.not.not, label %6, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %24, %3
  ret void
}

declare void @_ZN11alglib_impl20ae_vector_set_lengthEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN11alglib_impl15ae_vector_clearEPNS_9ae_vectorE(ptr noundef) local_unnamed_addr #1

declare { double, double } @_ZN11alglib_impl17ae_complex_from_iEl(i64 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_vectorE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !8, i64 56}
!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 = !{!8, !8, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTSN11alglib_impl10ae_complexE", !16, i64 0, !16, i64 8}
!16 = !{!"double", !8, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!16, !16, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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