; LLVM IR from Try/Tempest :: Engine/thirdparty/openal-soft/core/mixer (mixer_c)

; 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" = type { ptr, i64 }
%struct.BsincState = type { float, i32, i32, %"class.al::span" }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZNK2al4spanIKfLm18446744073709551615EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i64 noundef) #0 align 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) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9Resample_I12FastBSincTag4CTagEvPKSt7variantIJSt9monostate10CubicState10BsincStateEEN2al4spanIKfLm18446744073709551615EEEjjNSA_IfLm18446744073709551615EEE(ptr noundef %0, ptr %1, i64 %2, i32 noundef %3, i32 noundef %4, ptr noundef byval(%"class.al::span.0") align 8 %5) #2 {
  %7 = alloca %"class.al::span", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.BsincState, align 8
  %12 = alloca %struct.BsincState, align 8
  %13 = alloca %"class.al::span", align 8
  %14 = alloca %"class.al::span.0", align 8
  %15 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 0
  store ptr %1, ptr %15, align 8
  %16 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 1
  store i64 %2, ptr %16, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZSt3getI10BsincStateJSt9monostate10CubicStateS0_EERKT_RKSt7variantIJDpT0_EE(ptr noundef nonnull align 8 dereferenceable(33) %17)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %18, i64 32, i1 false), !tbaa.struct !11
  %19 = getelementptr inbounds %struct.BsincState, ptr %11, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %21 = icmp ule i32 %20, 24
  call void @llvm.assume(i1 %21)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %11, i64 32, i1 false), !tbaa.struct !11
  %22 = getelementptr inbounds %struct.BsincState, ptr %11, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !16
  %24 = sub i32 24, %23
  %25 = zext i32 %24 to i64
  %26 = call { ptr, i64 } @_ZNK2al4spanIKfLm18446744073709551615EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(16) %7, i64 noundef %25, i64 noundef -1) #5
  %27 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 0
  %28 = extractvalue { ptr, i64 } %26, 0
  store ptr %28, ptr %27, align 8
  %29 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 1
  %30 = extractvalue { ptr, i64 } %26, 1
  store i64 %30, ptr %29, align 8
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !19
  %33 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8
  %35 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 1
  %36 = load i64, ptr %35, align 8
  %37 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8
  %39 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 1
  %40 = load i64, ptr %39, align 8
  call void @_ZN12_GLOBAL__N_110DoResampleI10BsincStateTnPDoFfRKT_N2al4spanIKfLm18446744073709551615EEEmjEXadL_ZNS_12do_fastbsincERKS1_S8_mjEEEEvS2_S8_jjNS6_IfLm18446744073709551615EEE(ptr noundef byval(%struct.BsincState) align 8 %12, ptr %34, i64 %36, i32 noundef %31, i32 noundef %32, ptr %38, i64 %40)
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #5
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZSt3getI10BsincStateJSt9monostate10CubicStateS0_EERKT_RKSt7variantIJDpT0_EE(ptr noundef nonnull align 8 dereferenceable(33)) #2

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_110DoResampleI10BsincStateTnPDoFfRKT_N2al4spanIKfLm18446744073709551615EEEmjEXadL_ZNS_12do_fastbsincERKS1_S8_mjEEEEvS2_S8_jjNS6_IfLm18446744073709551615EEE(ptr noundef byval(%struct.BsincState) align 8, ptr, i64, i32 noundef, i32 noundef, ptr, i64) #2

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

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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #5 = { 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 = !{i64 0, i64 4, !12, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 16, i64 8, !5, i64 24, i64 8, !14}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !10, i64 8}
!17 = !{!"_ZTS10BsincState", !13, i64 0, !10, i64 4, !10, i64 8, !18, i64 16}
!18 = !{!"_ZTSN2al4spanIKfLm18446744073709551615EEE", !6, i64 0, !15, i64 8}
!19 = !{i64 0, i64 8, !5, i64 8, i64 8, !14}


; 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" = type { ptr, i64 }
%struct.BsincState = type { float, i32, i32, %"class.al::span" }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9Resample_I12FastBSincTag4CTagEvPKSt7variantIJSt9monostate10CubicState10BsincStateEEN2al4spanIKfLm18446744073709551615EEEjjNSA_IfLm18446744073709551615EEE(ptr noundef nonnull %0, ptr %1, i64 %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef readonly byval(%"class.al::span.0") align 8 %5) local_unnamed_addr #1 {
  %7 = alloca %"class.al::span", align 8
  %8 = alloca %struct.BsincState, align 8
  store ptr %1, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store i64 %2, ptr %9, align 8
  %10 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZSt3getI10BsincStateJSt9monostate10CubicStateS0_EERKT_RKSt7variantIJDpT0_EE(ptr noundef nonnull align 8 dereferenceable(33) %0)
  %11 = load i64, ptr %10, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 12
  %12 = icmp ult i32 %.sroa.4.0.copyload, 25
  tail call void @llvm.assume(i1 %12)
  store i64 %11, ptr %8, align 8
  %.sroa.4.0..sroa_idx4 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %.sroa.4.0.copyload, ptr %.sroa.4.0..sroa_idx4, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx7 = getelementptr inbounds i8, ptr %8, i64 12
  call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %.sroa.6.0..sroa_idx7, ptr noundef nonnull align 4 dereferenceable(20) %.sroa.6.0..sroa_idx, i64 20, i1 false)
  %13 = sub nuw nsw i32 24, %.sroa.4.0.copyload
  %14 = zext nneg i32 %13 to i64
  %15 = call { ptr, i64 } @_ZNK2al4spanIKfLm18446744073709551615EE7subspanEmm(ptr noundef nonnull align 8 dereferenceable(16) %7, i64 noundef %14, i64 noundef -1) #4
  %16 = extractvalue { ptr, i64 } %15, 0
  %17 = extractvalue { ptr, i64 } %15, 1
  %.sroa.0.0.copyload = load ptr, ptr %5, align 8, !tbaa !9
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  %.sroa.2.0.copyload = load i64, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !11
  call void @_ZN12_GLOBAL__N_110DoResampleI10BsincStateTnPDoFfRKT_N2al4spanIKfLm18446744073709551615EEEmjEXadL_ZNS_12do_fastbsincERKS1_S8_mjEEEEvS2_S8_jjNS6_IfLm18446744073709551615EEE(ptr noundef nonnull byval(%struct.BsincState) align 8 %8, ptr %16, i64 %17, i32 noundef %3, i32 noundef %4, ptr %.sroa.0.0.copyload, i64 %.sroa.2.0.copyload)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZSt3getI10BsincStateJSt9monostate10CubicStateS0_EERKT_RKSt7variantIJDpT0_EE(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_110DoResampleI10BsincStateTnPDoFfRKT_N2al4spanIKfLm18446744073709551615EEEmjEXadL_ZNS_12do_fastbsincERKS1_S8_mjEEEEvS2_S8_jjNS6_IfLm18446744073709551615EEE(ptr noundef byval(%struct.BsincState) align 8, ptr, i64, i32 noundef, i32 noundef, ptr, i64) local_unnamed_addr #1

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

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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
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 = !{!"int", !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, !12, i64 0}
!12 = !{!"long", !7, i64 0}


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