; LLVM IR from Try/Tempest :: Engine/thirdparty/openal-soft/core/mastering.ll (ZN10Compressor12peakDetectorEj)

; 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.al::span.0" = type { ptr, i64 }
%"class.al::span.1" = type { ptr }
%"class.al::ptr_wrapper.7" = type { ptr }
%"class.al::ptr_wrapper" = type { ptr }
%class.anon.8 = type { i8 }
%class.Compressor = type { i64, %"struct.Compressor::AutoFlags", i32, float, float, float, float, float, float, float, [4 x i8], %"struct.std::array", %"struct.std::array.2", %"class.std::unique_ptr", %"class.std::vector", float, float, float, float, float, float, float, float }
%"struct.Compressor::AutoFlags" = type { i8 }
%"struct.std::array" = type { [2048 x float] }
%"struct.std::array.2" = type { [1024 x float] }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.4" }
%"struct.std::_Head_base.4" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::array<float, 1024>, al::allocator<std::array<float, 1024>, 16>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<float, 1024>, al::allocator<std::array<float, 1024>, 16>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<float, 1024>, al::allocator<std::array<float, 1024>, 16>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<float, 1024>, al::allocator<std::array<float, 1024>, 16>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2al4spanIfLm2048EEC2ILm2048EEERSt5arrayIfXT_EE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8192)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZNK2al4spanIfLm2048EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIfLm18446744073709551615EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIfLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIfLm18446744073709551615EE4cendEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10Compressor12peakDetectorEj(ptr noundef nonnull align 16 dereferenceable(12400) %0, i32 noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.al::span.0", align 8
  %6 = alloca %"class.al::span.1", align 8
  %7 = alloca %"class.al::ptr_wrapper.7", align 8
  %8 = alloca %"class.al::ptr_wrapper.7", align 8
  %9 = alloca %"class.al::ptr_wrapper", align 8
  %10 = alloca %class.anon.8, align 1
  %11 = alloca %"class.al::ptr_wrapper", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp ugt i32 %13, 0
  call void @llvm.assume(i1 %14)
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = icmp ule i64 %16, 1024
  call void @llvm.assume(i1 %17)
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %18 = getelementptr inbounds %class.Compressor, ptr %12, i32 0, i32 11
  call void @_ZN2al4spanIfLm2048EEC2ILm2048EEERSt5arrayIfXT_EE(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8192) %18) #4
  %19 = getelementptr inbounds %class.Compressor, ptr %12, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = zext i32 %20 to i64
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = call { ptr, i64 } @_ZNK2al4spanIfLm2048EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(8) %6, i64 noundef %21, i64 noundef %23) #4
  %25 = getelementptr inbounds { ptr, i64 }, ptr %5, i32 0, i32 0
  %26 = extractvalue { ptr, i64 } %24, 0
  store ptr %26, ptr %25, align 8
  %27 = getelementptr inbounds { ptr, i64 }, ptr %5, i32 0, i32 1
  %28 = extractvalue { ptr, i64 } %24, 1
  store i64 %28, ptr %27, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %29 = call ptr @_ZNK2al4spanIfLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  %30 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %7, i32 0, i32 0
  store ptr %29, ptr %30, align 8
  %31 = call ptr @_ZNK2al4spanIfLm18446744073709551615EE4cendEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  %32 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %8, i32 0, i32 0
  store ptr %31, ptr %32, align 8
  %33 = call ptr @_ZNK2al4spanIfLm18446744073709551615EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  %34 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %9, i32 0, i32 0
  store ptr %33, ptr %34, align 8
  %35 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %7, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8
  %37 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %8, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8
  %39 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %9, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8
  %41 = call ptr @"_ZSt9transformIN2al11ptr_wrapperIPKfEENS1_IPfEEZN10Compressor12peakDetectorEjE3$_0ET0_T_SA_S9_T1_"(ptr %36, ptr %38, ptr %40)
  %42 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %11, i32 0, i32 0
  store ptr %41, ptr %42, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden ptr @"_ZSt9transformIN2al11ptr_wrapperIPKfEENS1_IPfEEZN10Compressor12peakDetectorEjE3$_0ET0_T_SA_S9_T1_"(ptr, ptr, ptr) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTS10Compressor", !13, i64 0, !14, i64 8, !10, i64 12, !16, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !16, i64 32, !16, i64 36, !16, i64 40, !17, i64 48, !18, i64 8240, !19, i64 12336, !25, i64 12344, !16, i64 12368, !16, i64 12372, !16, i64 12376, !16, i64 12380, !16, i64 12384, !16, i64 12388, !16, i64 12392, !16, i64 12396}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN10Compressor9AutoFlagsE", !15, i64 0, !15, i64 0, !15, i64 0, !15, i64 0, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_ZTSSt5arrayIfLm2048EE", !7, i64 0}
!18 = !{!"_ZTSSt5arrayIfLm1024EE", !7, i64 0}
!19 = !{!"_ZTSSt10unique_ptrI11SlidingHoldSt14default_deleteIS0_EE", !20, i64 0}
!20 = !{!"_ZTSSt15__uniq_ptr_dataI11SlidingHoldSt14default_deleteIS0_ELb1ELb1EE", !21, i64 0}
!21 = !{!"_ZTSSt15__uniq_ptr_implI11SlidingHoldSt14default_deleteIS0_EE", !22, i64 0}
!22 = !{!"_ZTSSt5tupleIJP11SlidingHoldSt14default_deleteIS0_EEE", !23, i64 0}
!23 = !{!"_ZTSSt11_Tuple_implILm0EJP11SlidingHoldSt14default_deleteIS0_EEE", !24, i64 0}
!24 = !{!"_ZTSSt10_Head_baseILm0EP11SlidingHoldLb0EE", !6, i64 0}
!25 = !{!"_ZTSSt6vectorISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE", !26, i64 0}
!26 = !{!"_ZTSSt12_Vector_baseISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE12_Vector_implE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


; 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.al::span.0" = type { ptr, i64 }
%"class.al::span.1" = type { ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2al4spanIfLm2048EEC2ILm2048EEERSt5arrayIfXT_EE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8192)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZNK2al4spanIfLm2048EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIfLm18446744073709551615EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIfLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIfLm18446744073709551615EE4cendEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10Compressor12peakDetectorEj(ptr noundef nonnull align 16 dereferenceable(12400) %0, i32 noundef %1) local_unnamed_addr #3 align 2 {
  %3 = alloca %"class.al::span.0", align 8
  %4 = alloca %"class.al::span.1", align 8
  %5 = icmp ne i32 %1, 0
  tail call void @llvm.assume(i1 %5)
  %6 = zext nneg i32 %1 to i64
  %7 = icmp ult i32 %1, 1025
  tail call void @llvm.assume(i1 %7)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  call void @_ZN2al4spanIfLm2048EEC2ILm2048EEERSt5arrayIfXT_EE(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8192) %8) #4
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = zext i32 %10 to i64
  %12 = call { ptr, i64 } @_ZNK2al4spanIfLm2048EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(8) %4, i64 noundef %11, i64 noundef %6) #4
  %13 = extractvalue { ptr, i64 } %12, 0
  store ptr %13, ptr %3, align 8
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  %15 = extractvalue { ptr, i64 } %12, 1
  store i64 %15, ptr %14, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %16 = call ptr @_ZNK2al4spanIfLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  %17 = call ptr @_ZNK2al4spanIfLm18446744073709551615EE4cendEv(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  %18 = call ptr @_ZNK2al4spanIfLm18446744073709551615EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  %19 = call ptr @"_ZSt9transformIN2al11ptr_wrapperIPKfEENS1_IPfEEZN10Compressor12peakDetectorEjE3$_0ET0_T_SA_S9_T1_"(ptr %16, ptr %17, ptr %18)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden ptr @"_ZSt9transformIN2al11ptr_wrapperIPKfEENS1_IPfEEZN10Compressor12peakDetectorEjE3$_0ET0_T_SA_S9_T1_"(ptr, ptr, ptr) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 12}
!6 = !{!"_ZTS10Compressor", !7, i64 0, !10, i64 8, !12, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !14, i64 48, !15, i64 8240, !16, i64 12336, !23, i64 12344, !13, i64 12368, !13, i64 12372, !13, i64 12376, !13, i64 12380, !13, i64 12384, !13, i64 12388, !13, i64 12392, !13, i64 12396}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN10Compressor9AutoFlagsE", !11, i64 0, !11, i64 0, !11, i64 0, !11, i64 0, !11, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTSSt5arrayIfLm2048EE", !8, i64 0}
!15 = !{!"_ZTSSt5arrayIfLm1024EE", !8, i64 0}
!16 = !{!"_ZTSSt10unique_ptrI11SlidingHoldSt14default_deleteIS0_EE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataI11SlidingHoldSt14default_deleteIS0_ELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implI11SlidingHoldSt14default_deleteIS0_EE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJP11SlidingHoldSt14default_deleteIS0_EEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJP11SlidingHoldSt14default_deleteIS0_EEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EP11SlidingHoldLb0EE", !22, i64 0}
!22 = !{!"any pointer", !8, i64 0}
!23 = !{!"_ZTSSt6vectorISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseISt5arrayIfLm1024EEN2al9allocatorIS1_Lm16EEEE17_Vector_impl_dataE", !22, i64 0, !22, i64 8, !22, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass