; LLVM IR from sp-nitech/SPTK :: src/filter/inverse_mglsa_digital_filter.ll (ZN4sptk25InverseMglsaDigitalFilterC2Eiiidb)

; 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::InverseMglsaDigitalFilter" = type <{ ptr, i32, i32, double, i8, [7 x i8], %"class.sptk::MlsaDigitalFilter", i8, [7 x i8] }>
%"class.sptk::MlsaDigitalFilter" = type { ptr, i32, i32, double, i8, i8, %"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 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk25InverseMglsaDigitalFilterC2Eiiidb(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, i1 noundef zeroext %5) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca i8, align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store double %4, ptr %11, align 8, !tbaa !11
  %15 = zext i1 %5 to i8
  store i8 %15, ptr %12, align 1, !tbaa !13
  %16 = load ptr, ptr %7, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk25InverseMglsaDigitalFilterE, i32 0, i32 0, i32 2), ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 1
  %18 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %18, ptr %17, align 8, !tbaa !17
  %19 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 2
  %20 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %20, ptr %19, align 4, !tbaa !24
  %21 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 3
  %22 = load double, ptr %11, align 8, !tbaa !11
  store double %22, ptr %21, align 8, !tbaa !25
  %23 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 4
  %24 = load i8, ptr %12, align 1, !tbaa !13, !range !26, !noundef !27
  %25 = trunc i8 %24 to i1
  %26 = zext i1 %25 to i8
  store i8 %26, ptr %23, align 8, !tbaa !28
  %27 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 6
  %28 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 3
  %32 = load double, ptr %31, align 8, !tbaa !25
  %33 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 4
  %34 = load i8, ptr %33, align 8, !tbaa !28, !range !26, !noundef !27
  %35 = trunc i8 %34 to i1
  call void @_ZN4sptk17MlsaDigitalFilterC1Eiidb(ptr noundef nonnull align 8 dereferenceable(56) %27, i32 noundef %29, i32 noundef %30, double noundef %32, i1 noundef zeroext %35)
  %36 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 7
  store i8 1, ptr %36, align 8, !tbaa !29
  %37 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !17
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %49, label %40

40:                                               ; preds = %6
  %41 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !24
  %43 = icmp slt i32 %42, 0
  br i1 %43, label %49, label %44

44:                                               ; preds = %40
  %45 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 3
  %46 = load double, ptr %45, align 8, !tbaa !25
  %47 = invoke noundef zeroext i1 @_ZN4sptk12IsValidAlphaEd(double noundef %46)
          to label %48 unwind label %51

48:                                               ; preds = %44
  br i1 %47, label %55, label %49

49:                                               ; preds = %48, %40, %6
  %50 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 7
  store i8 0, ptr %50, align 8, !tbaa !29
  br label %64

51:                                               ; preds = %58, %44
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %13, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %14, align 4
  call void @_ZN4sptk17MlsaDigitalFilterD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %27) #3
  br label %65

55:                                               ; preds = %48
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = icmp eq i32 0, %56
  br i1 %57, label %58, label %64

58:                                               ; preds = %55
  %59 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 6
  %60 = invoke noundef zeroext i1 @_ZNK4sptk17MlsaDigitalFilter7IsValidEv(ptr noundef nonnull align 8 dereferenceable(56) %59)
          to label %61 unwind label %51

61:                                               ; preds = %58
  br i1 %60, label %64, label %62

62:                                               ; preds = %61
  %63 = getelementptr inbounds %"class.sptk::InverseMglsaDigitalFilter", ptr %16, i32 0, i32 7
  store i8 0, ptr %63, align 8, !tbaa !29
  br label %64

64:                                               ; preds = %62, %61, %55, %49
  ret void

65:                                               ; preds = %51
  %66 = load ptr, ptr %13, align 8
  %67 = load i32, ptr %14, align 4
  %68 = insertvalue { ptr, i32 } poison, ptr %66, 0
  %69 = insertvalue { ptr, i32 } %68, i32 %67, 1
  resume { ptr, i32 } %69
}

declare void @_ZN4sptk17MlsaDigitalFilterC1Eiidb(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef, double noundef, i1 noundef zeroext) unnamed_addr #1

declare noundef zeroext i1 @_ZN4sptk12IsValidAlphaEd(double noundef) #1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk17MlsaDigitalFilterD2Ev(ptr noundef nonnull align 8 dereferenceable(56)) 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 = !{!"bool", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !10, i64 8}
!18 = !{!"_ZTSN4sptk25InverseMglsaDigitalFilterE", !10, i64 8, !10, i64 12, !12, i64 16, !14, i64 24, !19, i64 32, !14, i64 88}
!19 = !{!"_ZTSN4sptk17MlsaDigitalFilterE", !10, i64 8, !10, i64 12, !12, i64 16, !14, i64 24, !14, i64 25, !20, i64 32}
!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 = !{!18, !10, i64 12}
!25 = !{!18, !12, i64 16}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!18, !14, i64 24}
!29 = !{!18, !14, i64 88}


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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk25InverseMglsaDigitalFilterC2Eiiidb(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, i1 noundef zeroext %5) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %7 = zext i1 %5 to i8
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk25InverseMglsaDigitalFilterE, i64 16), ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %8, align 8, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %3, ptr %9, align 4, !tbaa !20
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store double %4, ptr %10, align 8, !tbaa !21
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %7, ptr %11, align 8, !tbaa !22
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN4sptk17MlsaDigitalFilterC1Eiidb(ptr noundef nonnull align 8 dereferenceable(56) %12, i32 noundef %1, i32 noundef %2, double noundef %4, i1 noundef zeroext %5)
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  store i8 1, ptr %13, align 8, !tbaa !23
  %14 = load i32, ptr %8, align 8, !tbaa !8
  %15 = icmp slt i32 %14, 0
  %16 = load i32, ptr %9, align 4
  %17 = icmp slt i32 %16, 0
  %or.cond = select i1 %15, i1 true, i1 %17
  br i1 %or.cond, label %.sink.split, label %18

18:                                               ; preds = %6
  %19 = load double, ptr %10, align 8, !tbaa !21
  %20 = invoke noundef zeroext i1 @_ZN4sptk12IsValidAlphaEd(double noundef %19)
          to label %21 unwind label %22

21:                                               ; preds = %18
  br i1 %20, label %24, label %.sink.split

22:                                               ; preds = %18
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN4sptk17MlsaDigitalFilterD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %12) #3
  resume { ptr, i32 } %23

24:                                               ; preds = %21
  %25 = icmp eq i32 %3, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %24
  %27 = tail call noundef zeroext i1 @_ZNK4sptk17MlsaDigitalFilter7IsValidEv(ptr noundef nonnull align 8 dereferenceable(56) %12)
  br i1 %27, label %28, label %.sink.split

.sink.split:                                      ; preds = %26, %6, %21
  store i8 0, ptr %13, align 8, !tbaa !23
  br label %28

28:                                               ; preds = %.sink.split, %26, %24
  ret void
}

declare void @_ZN4sptk17MlsaDigitalFilterC1Eiidb(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef, double noundef, i1 noundef zeroext) unnamed_addr #1

declare noundef zeroext i1 @_ZN4sptk12IsValidAlphaEd(double noundef) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk17MlsaDigitalFilterD2Ev(ptr noundef nonnull align 8 dereferenceable(56)) 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 = !{!"_ZTSN4sptk25InverseMglsaDigitalFilterE", !10, i64 8, !10, i64 12, !12, i64 16, !13, i64 24, !14, i64 32, !13, i64 88}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"double", !11, i64 0}
!13 = !{!"bool", !11, i64 0}
!14 = !{!"_ZTSN4sptk17MlsaDigitalFilterE", !10, i64 8, !10, i64 12, !12, i64 16, !13, i64 24, !13, i64 25, !15, i64 32}
!15 = !{!"_ZTSSt6vectorIdSaIdEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"any pointer", !11, i64 0}
!20 = !{!9, !10, i64 12}
!21 = !{!9, !12, i64 16}
!22 = !{!9, !13, i64 24}
!23 = !{!9, !13, i64 88}


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