; LLVM IR from sp-nitech/SPTK :: src/conversion (autocorrelation_to_composite_sinusoidal_modeling)

; 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.sptk::AutocorrelationToCompositeSinusoidalModeling" = type <{ ptr, i32, i32, %"class.sptk::SymmetricSystemSolver", %"class.sptk::DurandKernerMethod", %"class.sptk::VandermondeSystemSolver", i8, [7 x i8] }>
%"class.sptk::SymmetricSystemSolver" = type <{ ptr, i32, i8, [3 x i8] }>
%"class.sptk::DurandKernerMethod" = type { ptr, i32, i32, double, i8, %"class.std::vector", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.sptk::VandermondeSystemSolver" = type <{ ptr, i32, i8, [3 x i8] }>

@_ZTVN4sptk44AutocorrelationToCompositeSinusoidalModelingE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk44AutocorrelationToCompositeSinusoidalModelingC2Eiid(ptr noundef nonnull align 8 dereferenceable(129) %0, i32 noundef %1, i32 noundef %2, double noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  %11 = load ptr, ptr %5, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk44AutocorrelationToCompositeSinusoidalModelingE, i32 0, i32 0, i32 2), ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %13, ptr %12, align 8, !tbaa !15
  %14 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 2
  %15 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = add nsw i32 %16, 1
  %18 = sdiv i32 %17, 2
  store i32 %18, ptr %14, align 4, !tbaa !25
  %19 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 3
  %20 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 2
  %21 = load i32, ptr %20, align 4, !tbaa !25
  %22 = sub nsw i32 %21, 1
  call void @_ZN4sptk21SymmetricSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13) %19, i32 noundef %22)
  %23 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 4
  %24 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !25
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load double, ptr %8, align 8, !tbaa !11
  invoke void @_ZN4sptk18DurandKernerMethodC1Eiid(ptr noundef nonnull align 8 dereferenceable(80) %23, i32 noundef %25, i32 noundef %26, double noundef %27)
          to label %28 unwind label %57

28:                                               ; preds = %4
  %29 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 5
  %30 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 2
  %31 = load i32, ptr %30, align 4, !tbaa !25
  %32 = sub nsw i32 %31, 1
  invoke void @_ZN4sptk23VandermondeSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13) %29, i32 noundef %32)
          to label %33 unwind label %61

33:                                               ; preds = %28
  %34 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 6
  store i8 1, ptr %34, align 8, !tbaa !26
  %35 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !15
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %55, label %38

38:                                               ; preds = %33
  %39 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !15
  %41 = srem i32 %40, 2
  %42 = icmp eq i32 0, %41
  br i1 %42, label %55, label %43

43:                                               ; preds = %38
  %44 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 3
  %45 = invoke noundef zeroext i1 @_ZNK4sptk21SymmetricSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13) %44)
          to label %46 unwind label %65

46:                                               ; preds = %43
  br i1 %45, label %47, label %55

47:                                               ; preds = %46
  %48 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 4
  %49 = invoke noundef zeroext i1 @_ZNK4sptk18DurandKernerMethod7IsValidEv(ptr noundef nonnull align 8 dereferenceable(80) %48)
          to label %50 unwind label %65

50:                                               ; preds = %47
  br i1 %49, label %51, label %55

51:                                               ; preds = %50
  %52 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 5
  %53 = invoke noundef zeroext i1 @_ZNK4sptk23VandermondeSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13) %52)
          to label %54 unwind label %65

54:                                               ; preds = %51
  br i1 %53, label %69, label %55

55:                                               ; preds = %54, %50, %46, %38, %33
  %56 = getelementptr inbounds %"class.sptk::AutocorrelationToCompositeSinusoidalModeling", ptr %11, i32 0, i32 6
  store i8 0, ptr %56, align 8, !tbaa !26
  br label %69

57:                                               ; preds = %4
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %9, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %10, align 4
  br label %71

61:                                               ; preds = %28
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %9, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %10, align 4
  br label %70

65:                                               ; preds = %51, %47, %43
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %9, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %10, align 4
  call void @_ZN4sptk23VandermondeSystemSolverD2Ev(ptr noundef nonnull align 8 dereferenceable(13) %29) #3
  br label %70

69:                                               ; preds = %55, %54
  ret void

70:                                               ; preds = %65, %61
  call void @_ZN4sptk18DurandKernerMethodD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %23) #3
  br label %71

71:                                               ; preds = %70, %57
  call void @_ZN4sptk21SymmetricSystemSolverD2Ev(ptr noundef nonnull align 8 dereferenceable(13) %19) #3
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %9, align 8
  %74 = load i32, ptr %10, align 4
  %75 = insertvalue { ptr, i32 } poison, ptr %73, 0
  %76 = insertvalue { ptr, i32 } %75, i32 %74, 1
  resume { ptr, i32 } %76
}

declare void @_ZN4sptk21SymmetricSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13), i32 noundef) unnamed_addr #1

declare void @_ZN4sptk18DurandKernerMethodC1Eiid(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, double noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @_ZN4sptk23VandermondeSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13), i32 noundef) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4sptk21SymmetricSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4sptk18DurandKernerMethod7IsValidEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4sptk23VandermondeSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk23VandermondeSystemSolverD2Ev(ptr noundef nonnull align 8 dereferenceable(13)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk18DurandKernerMethodD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk21SymmetricSystemSolverD2Ev(ptr noundef nonnull align 8 dereferenceable(13)) unnamed_addr #2 align 2

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" }
attributes #2 = { mustprogress nounwind 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !10, i64 8}
!16 = !{!"_ZTSN4sptk44AutocorrelationToCompositeSinusoidalModelingE", !10, i64 8, !10, i64 12, !17, i64 16, !19, i64 32, !24, i64 112, !18, i64 128}
!17 = !{!"_ZTSN4sptk21SymmetricSystemSolverE", !10, i64 8, !18, i64 12}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTSN4sptk18DurandKernerMethodE", !10, i64 8, !10, i64 12, !12, i64 16, !18, i64 24, !20, i64 32, !20, i64 56}
!20 = !{!"_ZTSSt6vectorIdSaIdEE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"_ZTSN4sptk23VandermondeSystemSolverE", !10, i64 8, !18, i64 12}
!25 = !{!16, !10, i64 12}
!26 = !{!16, !18, i64 128}


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

@_ZTVN4sptk44AutocorrelationToCompositeSinusoidalModelingE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk44AutocorrelationToCompositeSinusoidalModelingC2Eiid(ptr noundef nonnull align 8 dereferenceable(129) %0, i32 noundef %1, i32 noundef %2, double noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk44AutocorrelationToCompositeSinusoidalModelingE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %5, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = add nsw i32 %1, 1
  %8 = sdiv i32 %7, 2
  store i32 %8, ptr %6, align 4, !tbaa !22
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = add nsw i32 %8, -1
  tail call void @_ZN4sptk21SymmetricSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13) %9, i32 noundef %10)
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i32, ptr %6, align 4, !tbaa !22
  invoke void @_ZN4sptk18DurandKernerMethodC1Eiid(ptr noundef nonnull align 8 dereferenceable(80) %11, i32 noundef %12, i32 noundef %2, double noundef %3)
          to label %13 unwind label %28

13:                                               ; preds = %4
  %14 = getelementptr inbounds i8, ptr %0, i64 112
  %15 = load i32, ptr %6, align 4, !tbaa !22
  %16 = add nsw i32 %15, -1
  invoke void @_ZN4sptk23VandermondeSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13) %14, i32 noundef %16)
          to label %17 unwind label %30

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %0, i64 128
  store i8 1, ptr %18, align 8, !tbaa !23
  %19 = load i32, ptr %5, align 8, !tbaa !8
  %20 = and i32 %19, -2147483647
  %or.cond.not = icmp eq i32 %20, 1
  br i1 %or.cond.not, label %21, label %27

21:                                               ; preds = %17
  %22 = tail call noundef zeroext i1 @_ZNK4sptk21SymmetricSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13) %9)
  br i1 %22, label %23, label %27

23:                                               ; preds = %21
  %24 = tail call noundef zeroext i1 @_ZNK4sptk18DurandKernerMethod7IsValidEv(ptr noundef nonnull align 8 dereferenceable(80) %11)
  br i1 %24, label %25, label %27

25:                                               ; preds = %23
  %26 = tail call noundef zeroext i1 @_ZNK4sptk23VandermondeSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13) %14)
  br i1 %26, label %32, label %27

27:                                               ; preds = %25, %23, %21, %17
  store i8 0, ptr %18, align 8, !tbaa !23
  br label %32

28:                                               ; preds = %4
  %29 = landingpad { ptr, i32 }
          cleanup
  br label %33

30:                                               ; preds = %13
  %31 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN4sptk18DurandKernerMethodD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %11) #3
  br label %33

32:                                               ; preds = %27, %25
  ret void

33:                                               ; preds = %30, %28
  %.pn = phi { ptr, i32 } [ %31, %30 ], [ %29, %28 ]
  tail call void @_ZN4sptk21SymmetricSystemSolverD2Ev(ptr noundef nonnull align 8 dereferenceable(13) %9) #3
  resume { ptr, i32 } %.pn
}

declare void @_ZN4sptk21SymmetricSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13), i32 noundef) unnamed_addr #1

declare void @_ZN4sptk18DurandKernerMethodC1Eiid(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, double noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @_ZN4sptk23VandermondeSystemSolverC1Ei(ptr noundef nonnull align 8 dereferenceable(13), i32 noundef) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4sptk21SymmetricSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4sptk18DurandKernerMethod7IsValidEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4sptk23VandermondeSystemSolver7IsValidEv(ptr noundef nonnull align 8 dereferenceable(13)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk18DurandKernerMethodD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk21SymmetricSystemSolverD2Ev(ptr noundef nonnull align 8 dereferenceable(13)) unnamed_addr #2 align 2

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" }
attributes #2 = { mustprogress nounwind 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTSN4sptk44AutocorrelationToCompositeSinusoidalModelingE", !10, i64 8, !10, i64 12, !12, i64 16, !14, i64 32, !21, i64 112, !13, i64 128}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"_ZTSN4sptk21SymmetricSystemSolverE", !10, i64 8, !13, i64 12}
!13 = !{!"bool", !11, i64 0}
!14 = !{!"_ZTSN4sptk18DurandKernerMethodE", !10, i64 8, !10, i64 12, !15, i64 16, !13, i64 24, !16, i64 32, !16, i64 56}
!15 = !{!"double", !11, i64 0}
!16 = !{!"_ZTSSt6vectorIdSaIdEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !20, i64 0, !20, i64 8, !20, i64 16}
!20 = !{!"any pointer", !11, i64 0}
!21 = !{!"_ZTSN4sptk23VandermondeSystemSolverE", !10, i64 8, !13, i64 12}
!22 = !{!9, !10, i64 12}
!23 = !{!9, !13, i64 128}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass