; LLVM IR from Aquatic-Games/mixr :: src/Impl/Impl.ll (ZN4mixr4Impl10SourceStopEm)

; 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.mixr::Impl" = type { i32, float, %"class.std::vector", %"class.std::vector.0", %"class.std::deque", %"class.std::deque" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<mixr::Buffer, std::allocator<mixr::Buffer>>::_Vector_impl" }
%"struct.std::_Vector_base<mixr::Buffer, std::allocator<mixr::Buffer>>::_Vector_impl" = type { %"struct.std::_Vector_base<mixr::Buffer, std::allocator<mixr::Buffer>>::_Vector_impl_data" }
%"struct.std::_Vector_base<mixr::Buffer, std::allocator<mixr::Buffer>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<mixr::Source, std::allocator<mixr::Source>>::_Vector_impl" }
%"struct.std::_Vector_base<mixr::Source, std::allocator<mixr::Source>>::_Vector_impl" = type { %"struct.std::_Vector_base<mixr::Source, std::allocator<mixr::Source>>::_Vector_impl_data" }
%"struct.std::_Vector_base<mixr::Source, std::allocator<mixr::Source>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<unsigned long, std::allocator<unsigned long>>::_Deque_impl" }
%"struct.std::_Deque_base<unsigned long, std::allocator<unsigned long>>::_Deque_impl" = type { %"struct.std::_Deque_base<unsigned long, std::allocator<unsigned long>>::_Deque_impl_data" }
%"struct.std::_Deque_base<unsigned long, std::allocator<unsigned long>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.mixr::Source" = type { i32, %"struct.mixr::AudioFormat", i32, i32, double, %"class.std::deque", ptr, i8, double, float, i8, i64, float, float, i64, double, ptr, ptr, ptr, ptr, i64, float, float, i64, i64, i64 }
%"struct.mixr::AudioFormat" = type { i32, i32, i8 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(248) ptr @_ZNSt6vectorIN4mixr6SourceESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4mixr4Impl10SourceStopEm(ptr noundef nonnull align 8 dereferenceable(216) %0, i64 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %8 = getelementptr inbounds %"class.mixr::Impl", ptr %7, i32 0, i32 3
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = call noundef nonnull align 8 dereferenceable(248) ptr @_ZNSt6vectorIN4mixr6SourceESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %9) #3
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = call noundef i32 @_ZN4mixr4Impl14SourceGetStateEm(ptr noundef nonnull align 8 dereferenceable(216) %7, i64 noundef %11)
  store i32 %12, ptr %6, align 4, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.mixr::Source", ptr %13, i32 0, i32 7
  store i8 0, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.mixr::Source", ptr %15, i32 0, i32 5
  call void @_ZNSt5dequeImSaImEE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %16) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.mixr::Source", ptr %17, i32 0, i32 14
  store i64 0, ptr %18, align 8, !tbaa !27
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.mixr::Source", ptr %19, i32 0, i32 20
  store i64 0, ptr %20, align 8, !tbaa !28
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.mixr::Source", ptr %21, i32 0, i32 21
  store float 0.000000e+00, ptr %22, align 8, !tbaa !29
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.mixr::Source", ptr %23, i32 0, i32 22
  store float 0.000000e+00, ptr %24, align 4, !tbaa !30
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.mixr::Source", ptr %25, i32 0, i32 15
  store double 0.000000e+00, ptr %26, align 8, !tbaa !31
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.mixr::Source", ptr %27, i32 0, i32 23
  store i64 -1, ptr %28, align 8, !tbaa !32
  %29 = load i32, ptr %6, align 4, !tbaa !11
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %43

31:                                               ; preds = %2
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.mixr::Source", ptr %32, i32 0, i32 18
  %34 = load ptr, ptr %33, align 8, !tbaa !33
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %43

36:                                               ; preds = %31
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.mixr::Source", ptr %37, i32 0, i32 18
  %39 = load ptr, ptr %38, align 8, !tbaa !33
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.mixr::Source", ptr %40, i32 0, i32 19
  %42 = load ptr, ptr %41, align 8, !tbaa !34
  call void %39(i32 noundef 0, ptr noundef %42)
  br label %43

43:                                               ; preds = %36, %31, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4mixr4Impl14SourceGetStateEm(ptr noundef nonnull align 8 dereferenceable(216), i64 noundef) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN4mixr11SourceStateE", !7, i64 0}
!13 = !{!14, !25, i64 120}
!14 = !{!"_ZTSN4mixr6SourceE", !15, i64 0, !16, i64 4, !18, i64 16, !18, i64 20, !19, i64 24, !20, i64 32, !6, i64 112, !25, i64 120, !19, i64 128, !26, i64 136, !25, i64 140, !10, i64 144, !26, i64 152, !26, i64 156, !10, i64 160, !19, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !10, i64 208, !26, i64 216, !26, i64 220, !10, i64 224, !10, i64 232, !10, i64 240}
!15 = !{!"_ZTSN4mixr10SourceTypeE", !7, i64 0}
!16 = !{!"_ZTSN4mixr11AudioFormatE", !17, i64 0, !18, i64 4, !7, i64 8}
!17 = !{!"_ZTSN4mixr8DataTypeE", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!"_ZTSSt5dequeImSaImEE", !21, i64 0}
!21 = !{!"_ZTSSt11_Deque_baseImSaImEE", !22, i64 0}
!22 = !{!"_ZTSNSt11_Deque_baseImSaImEE11_Deque_implE", !23, i64 0}
!23 = !{!"_ZTSNSt11_Deque_baseImSaImEE16_Deque_impl_dataE", !6, i64 0, !10, i64 8, !24, i64 16, !24, i64 48}
!24 = !{!"_ZTSSt15_Deque_iteratorImRmPmE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = !{!"bool", !7, i64 0}
!26 = !{!"float", !7, i64 0}
!27 = !{!14, !10, i64 160}
!28 = !{!14, !10, i64 208}
!29 = !{!14, !26, i64 216}
!30 = !{!14, !26, i64 220}
!31 = !{!14, !19, i64 168}
!32 = !{!14, !10, i64 224}
!33 = !{!14, !6, i64 192}
!34 = !{!14, !6, i64 200}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(248) ptr @_ZNSt6vectorIN4mixr6SourceESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4mixr4Impl10SourceStopEm(ptr noundef nonnull align 8 dereferenceable(216) %0, i64 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = tail call noundef nonnull align 8 dereferenceable(248) ptr @_ZNSt6vectorIN4mixr6SourceESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %1) #3
  %5 = tail call noundef i32 @_ZN4mixr4Impl14SourceGetStateEm(ptr noundef nonnull align 8 dereferenceable(216) %0, i64 noundef %1)
  %6 = getelementptr inbounds i8, ptr %4, i64 120
  store i8 0, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 32
  tail call void @_ZNSt5dequeImSaImEE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %7) #3
  %8 = getelementptr inbounds i8, ptr %4, i64 160
  %9 = getelementptr inbounds i8, ptr %4, i64 208
  %10 = getelementptr inbounds i8, ptr %4, i64 224
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %8, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  store i64 -1, ptr %10, align 8, !tbaa !23
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %17, label %11

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %4, i64 192
  %13 = load ptr, ptr %12, align 8, !tbaa !24
  %.not14 = icmp eq ptr %13, null
  br i1 %.not14, label %17, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %4, i64 200
  %16 = load ptr, ptr %15, align 8, !tbaa !25
  tail call void %13(i32 noundef 0, ptr noundef %16)
  br label %17

17:                                               ; preds = %14, %11, %2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4mixr4Impl14SourceGetStateEm(ptr noundef nonnull align 8 dereferenceable(216), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !21, i64 120}
!6 = !{!"_ZTSN4mixr6SourceE", !7, i64 0, !10, i64 4, !12, i64 16, !12, i64 20, !13, i64 24, !14, i64 32, !18, i64 112, !21, i64 120, !13, i64 128, !22, i64 136, !21, i64 140, !19, i64 144, !22, i64 152, !22, i64 156, !19, i64 160, !13, i64 168, !18, i64 176, !18, i64 184, !18, i64 192, !18, i64 200, !19, i64 208, !22, i64 216, !22, i64 220, !19, i64 224, !19, i64 232, !19, i64 240}
!7 = !{!"_ZTSN4mixr10SourceTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN4mixr11AudioFormatE", !11, i64 0, !12, i64 4, !8, i64 8}
!11 = !{!"_ZTSN4mixr8DataTypeE", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!"_ZTSSt5dequeImSaImEE", !15, i64 0}
!15 = !{!"_ZTSSt11_Deque_baseImSaImEE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseImSaImEE11_Deque_implE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseImSaImEE16_Deque_impl_dataE", !18, i64 0, !19, i64 8, !20, i64 16, !20, i64 48}
!18 = !{!"any pointer", !8, i64 0}
!19 = !{!"long", !8, i64 0}
!20 = !{!"_ZTSSt15_Deque_iteratorImRmPmE", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}
!21 = !{!"bool", !8, i64 0}
!22 = !{!"float", !8, i64 0}
!23 = !{!6, !19, i64 224}
!24 = !{!6, !18, i64 192}
!25 = !{!6, !18, i64 200}


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