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

; 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::LinearPredictiveCoefficientsToLineSpectralPairs" = type <{ ptr, i32, i32, i32, i32, i32, [4 x i8], double, i8, [7 x i8] }>

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk47LinearPredictiveCoefficientsToLineSpectralPairsC2Eiiid(ptr noundef nonnull align 8 dereferenceable(41) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4) unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store double %4, ptr %10, align 8, !tbaa !11
  %11 = load ptr, ptr %6, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk47LinearPredictiveCoefficientsToLineSpectralPairsE, i32 0, i32 0, i32 2), ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %13, ptr %12, align 8, !tbaa !15
  %14 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 2
  %15 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = sitofp i32 %16 to double
  %18 = fmul double %17, 5.000000e-01
  %19 = call double @llvm.ceil.f64(double %18)
  %20 = fptosi double %19 to i32
  store i32 %20, ptr %14, align 4, !tbaa !18
  %21 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 3
  %22 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = sitofp i32 %23 to double
  %25 = fmul double %24, 5.000000e-01
  %26 = call double @llvm.floor.f64(double %25)
  %27 = fptosi double %26 to i32
  store i32 %27, ptr %21, align 8, !tbaa !19
  %28 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 4
  %29 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %29, ptr %28, align 4, !tbaa !20
  %30 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 5
  %31 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %31, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 7
  %33 = load double, ptr %10, align 8, !tbaa !11
  store double %33, ptr %32, align 8, !tbaa !22
  %34 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 8
  store i8 1, ptr %34, align 8, !tbaa !23
  %35 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", 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 %50, label %38

38:                                               ; preds = %5
  %39 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 4
  %40 = load i32, ptr %39, align 4, !tbaa !20
  %41 = icmp sle i32 %40, 0
  br i1 %41, label %50, label %42

42:                                               ; preds = %38
  %43 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 5
  %44 = load i32, ptr %43, align 8, !tbaa !21
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %50, label %46

46:                                               ; preds = %42
  %47 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 7
  %48 = load double, ptr %47, align 8, !tbaa !22
  %49 = fcmp olt double %48, 0.000000e+00
  br i1 %49, label %50, label %52

50:                                               ; preds = %46, %42, %38, %5
  %51 = getelementptr inbounds %"class.sptk::LinearPredictiveCoefficientsToLineSpectralPairs", ptr %11, i32 0, i32 8
  store i8 0, ptr %51, align 8, !tbaa !23
  br label %52

52:                                               ; preds = %50, %46
  ret void
}

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

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

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

!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 = !{!"_ZTSN4sptk47LinearPredictiveCoefficientsToLineSpectralPairsE", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !12, i64 32, !17, i64 40}
!17 = !{!"bool", !7, i64 0}
!18 = !{!16, !10, i64 12}
!19 = !{!16, !10, i64 16}
!20 = !{!16, !10, i64 20}
!21 = !{!16, !10, i64 24}
!22 = !{!16, !12, i64 32}
!23 = !{!16, !17, i64 40}


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

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN4sptk47LinearPredictiveCoefficientsToLineSpectralPairsC2Eiiid(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(41) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4) unnamed_addr #0 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk47LinearPredictiveCoefficientsToLineSpectralPairsE, i64 16), ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %6, align 8, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = sitofp i32 %1 to double
  %9 = fmul double %8, 5.000000e-01
  %10 = tail call double @llvm.ceil.f64(double %9)
  %11 = tail call double @llvm.floor.f64(double %9)
  %12 = insertelement <2 x double> poison, double %10, i64 0
  %13 = insertelement <2 x double> %12, double %11, i64 1
  %14 = fptosi <2 x double> %13 to <2 x i32>
  store <2 x i32> %14, ptr %7, align 4, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %2, ptr %15, align 4, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %3, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  store double %4, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = icmp sgt i32 %2, 0
  %20 = or i32 %3, %1
  %21 = icmp sgt i32 %20, -1
  %or.cond6.not11 = and i1 %19, %21
  %22 = fcmp uge double %4, 0.000000e+00
  %or.cond8.not = and i1 %22, %or.cond6.not11
  %spec.store.select = zext i1 %or.cond8.not to i8
  store i8 %spec.store.select, ptr %18, align 8
  ret void
}

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

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

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

!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 = !{!"_ZTSN4sptk47LinearPredictiveCoefficientsToLineSpectralPairsE", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !12, i64 32, !13, i64 40}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"double", !11, i64 0}
!13 = !{!"bool", !11, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!9, !10, i64 20}
!16 = !{!9, !10, i64 24}
!17 = !{!9, !12, i64 32}


; Effective O3 passes: DSEPass,EarlyCSEPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass