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

; 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 }
%"struct.mixr::Buffer" = type { %"class.std::vector.8", i64 }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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(8) ptr @_ZNSt5dequeImSaImEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4mixr4Impl12UpdateSourceEPNS_6SourceE(ptr noundef nonnull align 8 dereferenceable(216) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %11 = getelementptr inbounds %"class.mixr::Impl", ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.mixr::Source", ptr %12, i32 0, i32 5
  %14 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeImSaImEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %13) #2
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorIN4mixr6BufferESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %15) #2
  %17 = getelementptr inbounds %"struct.mixr::Buffer", ptr %16, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %18, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.mixr::Source", ptr %19, i32 0, i32 2
  %21 = load i32, ptr %20, align 8, !tbaa !17
  store i32 %21, ptr %6, align 4, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.mixr::Source", ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds %"struct.mixr::AudioFormat", ptr %23, i32 0, i32 2
  %25 = load i8, ptr %24, align 4, !tbaa !32
  store i8 %25, ptr %7, align 1, !tbaa !33
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.mixr::Source", ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !34
  switch i32 %28, label %66 [
    i32 0, label %29
    i32 1, label %39
  ]

29:                                               ; preds = %2
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !31
  %32 = load i8, ptr %7, align 1, !tbaa !33
  %33 = zext i8 %32 to i32
  %34 = mul nsw i32 %31, %33
  %35 = sext i32 %34 to i64
  %36 = udiv i64 %30, %35
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.mixr::Source", ptr %37, i32 0, i32 11
  store i64 %36, ptr %38, align 8, !tbaa !35
  br label %66

39:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.mixr::Source", ptr %41, i32 0, i32 24
  %43 = load i64, ptr %42, align 8, !tbaa !36
  %44 = udiv i64 %40, %43
  store i64 %44, ptr %8, align 8, !tbaa !9
  %45 = load i64, ptr %8, align 8, !tbaa !9
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.mixr::Source", ptr %46, i32 0, i32 25
  store i64 %45, ptr %47, align 8, !tbaa !37
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %48 = load i8, ptr %7, align 1, !tbaa !33
  %49 = zext i8 %48 to i32
  %50 = mul nsw i32 %49, 4
  store i32 %50, ptr %9, align 4, !tbaa !31
  %51 = load i64, ptr %5, align 8, !tbaa !9
  %52 = mul i64 %51, 4
  %53 = load i32, ptr %9, align 4, !tbaa !31
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr %8, align 8, !tbaa !9
  %56 = mul i64 %54, %55
  %57 = sub i64 %52, %56
  %58 = load i32, ptr %6, align 4, !tbaa !31
  %59 = load i8, ptr %7, align 1, !tbaa !33
  %60 = zext i8 %59 to i32
  %61 = mul nsw i32 %58, %60
  %62 = sext i32 %61 to i64
  %63 = udiv i64 %57, %62
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.mixr::Source", ptr %64, i32 0, i32 11
  store i64 %63, ptr %65, align 8, !tbaa !35
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %66

66:                                               ; preds = %39, %29, %2
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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 = { 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, !10, i64 24}
!12 = !{!"_ZTSN4mixr6BufferE", !13, i64 0, !10, i64 24}
!13 = !{!"_ZTSSt6vectorIhSaIhEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!18, !22, i64 16}
!18 = !{!"_ZTSN4mixr6SourceE", !19, i64 0, !20, i64 4, !22, i64 16, !22, i64 20, !23, i64 24, !24, i64 32, !6, i64 112, !29, i64 120, !23, i64 128, !30, i64 136, !29, i64 140, !10, i64 144, !30, i64 152, !30, i64 156, !10, i64 160, !23, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !10, i64 208, !30, i64 216, !30, i64 220, !10, i64 224, !10, i64 232, !10, i64 240}
!19 = !{!"_ZTSN4mixr10SourceTypeE", !7, i64 0}
!20 = !{!"_ZTSN4mixr11AudioFormatE", !21, i64 0, !22, i64 4, !7, i64 8}
!21 = !{!"_ZTSN4mixr8DataTypeE", !7, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!"double", !7, i64 0}
!24 = !{!"_ZTSSt5dequeImSaImEE", !25, i64 0}
!25 = !{!"_ZTSSt11_Deque_baseImSaImEE", !26, i64 0}
!26 = !{!"_ZTSNSt11_Deque_baseImSaImEE11_Deque_implE", !27, i64 0}
!27 = !{!"_ZTSNSt11_Deque_baseImSaImEE16_Deque_impl_dataE", !6, i64 0, !10, i64 8, !28, i64 16, !28, i64 48}
!28 = !{!"_ZTSSt15_Deque_iteratorImRmPmE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!29 = !{!"bool", !7, i64 0}
!30 = !{!"float", !7, i64 0}
!31 = !{!22, !22, i64 0}
!32 = !{!18, !7, i64 12}
!33 = !{!7, !7, i64 0}
!34 = !{!18, !19, i64 0}
!35 = !{!18, !10, i64 144}
!36 = !{!18, !10, i64 232}
!37 = !{!18, !10, i64 240}


; 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(8) ptr @_ZNSt5dequeImSaImEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4mixr4Impl12UpdateSourceEPNS_6SourceE(ptr noundef nonnull align 8 dereferenceable(216) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = getelementptr inbounds i8, ptr %1, i64 32
  %5 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeImSaImEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %4) #1
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorIN4mixr6BufferESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %6) #1
  %8 = getelementptr inbounds i8, ptr %7, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %1, i64 12
  %13 = load i8, ptr %12, align 4, !tbaa !30
  %14 = load i32, ptr %1, align 8, !tbaa !31
  switch i32 %14, label %32 [
    i32 0, label %15
    i32 1, label %17
  ]

15:                                               ; preds = %2
  %16 = zext i8 %13 to i32
  br label %.sink.split

17:                                               ; preds = %2
  %18 = getelementptr inbounds i8, ptr %1, i64 232
  %19 = load i64, ptr %18, align 8, !tbaa !32
  %20 = udiv i64 %9, %19
  %21 = getelementptr inbounds i8, ptr %1, i64 240
  store i64 %20, ptr %21, align 8, !tbaa !33
  %22 = zext i8 %13 to i32
  %23 = shl nuw nsw i32 %22, 2
  %24 = shl i64 %9, 2
  %25 = zext nneg i32 %23 to i64
  %26 = mul i64 %20, %25
  %27 = sub i64 %24, %26
  br label %.sink.split

.sink.split:                                      ; preds = %15, %17
  %.sink22 = phi i32 [ %22, %17 ], [ %16, %15 ]
  %.sink20 = phi i64 [ %27, %17 ], [ %9, %15 ]
  %28 = mul nsw i32 %11, %.sink22
  %29 = sext i32 %28 to i64
  %30 = udiv i64 %.sink20, %29
  %31 = getelementptr inbounds i8, ptr %1, i64 144
  store i64 %30, ptr %31, align 8, !tbaa !34
  br label %32

32:                                               ; preds = %.sink.split, %2
  ret void
}

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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"_ZTSN4mixr6BufferE", !11, i64 0, !6, i64 24}
!11 = !{!"_ZTSSt6vectorIhSaIhEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!17, !21, i64 16}
!17 = !{!"_ZTSN4mixr6SourceE", !18, i64 0, !19, i64 4, !21, i64 16, !21, i64 20, !22, i64 24, !23, i64 32, !15, i64 112, !28, i64 120, !22, i64 128, !29, i64 136, !28, i64 140, !6, i64 144, !29, i64 152, !29, i64 156, !6, i64 160, !22, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !6, i64 208, !29, i64 216, !29, i64 220, !6, i64 224, !6, i64 232, !6, i64 240}
!18 = !{!"_ZTSN4mixr10SourceTypeE", !7, i64 0}
!19 = !{!"_ZTSN4mixr11AudioFormatE", !20, i64 0, !21, i64 4, !7, i64 8}
!20 = !{!"_ZTSN4mixr8DataTypeE", !7, i64 0}
!21 = !{!"int", !7, i64 0}
!22 = !{!"double", !7, i64 0}
!23 = !{!"_ZTSSt5dequeImSaImEE", !24, i64 0}
!24 = !{!"_ZTSSt11_Deque_baseImSaImEE", !25, i64 0}
!25 = !{!"_ZTSNSt11_Deque_baseImSaImEE11_Deque_implE", !26, i64 0}
!26 = !{!"_ZTSNSt11_Deque_baseImSaImEE16_Deque_impl_dataE", !15, i64 0, !6, i64 8, !27, i64 16, !27, i64 48}
!27 = !{!"_ZTSSt15_Deque_iteratorImRmPmE", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!28 = !{!"bool", !7, i64 0}
!29 = !{!"float", !7, i64 0}
!30 = !{!17, !7, i64 12}
!31 = !{!17, !18, i64 0}
!32 = !{!17, !6, i64 232}
!33 = !{!17, !6, i64 240}
!34 = !{!17, !6, i64 144}


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