; LLVM IR from pdeljanov/Ayane :: src (Stage)

; 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.Ayane::Stage::Sink" = type <{ ptr, ptr, i32, [4 x i8], ptr, %"class.Ayane::BufferFormat", i8, [3 x i8] }>
%"class.Ayane::BufferFormat" = type { i32, i32, i32 }
%"class.Ayane::Stage::SourceSinkPrivate" = type { i32, %"class.Ayane::BufferQueue", %"class.std::mutex", %"class.std::condition_variable" }
%"class.Ayane::BufferQueue" = type { i32, %"struct.std::atomic", %"struct.std::atomic", %"class.std::vector" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>, std::allocator<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>, std::allocator<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>, std::allocator<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>, std::allocator<std::unique_ptr<Ayane::Buffer, Ayane::ManagedBufferDeallocator>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::condition_variable" = type { %"class.std::__condvar" }
%"class.std::__condvar" = type { %union.pthread_cond_t }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

; 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

declare noundef zeroext i1 @_ZN5Ayane11BufferQueue3popEPSt10unique_ptrINS_6BufferENS_24ManagedBufferDeallocatorEE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #1

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

declare noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68)) #1

declare noundef zeroext i1 @_ZNK5Ayane12BufferFormatneERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1

declare noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Ayane12BufferFormataSERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5Ayane5Stage7tryPullEPNS0_4SinkEPSt10unique_ptrINS_6BufferENS_24ManagedBufferDeallocatorEE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1, ptr noundef %2) #3 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.Ayane::Stage::Sink", ptr %11, i32 0, i32 4
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.Ayane::Stage::SourceSinkPrivate", ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %25

18:                                               ; preds = %3
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.Ayane::Stage::SourceSinkPrivate", ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call noundef zeroext i1 @_ZN5Ayane11BufferQueue3popEPSt10unique_ptrINS_6BufferENS_24ManagedBufferDeallocatorEE(ptr noundef nonnull align 8 dereferenceable(40) %20, ptr noundef %21)
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  store i32 3, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %51

24:                                               ; preds = %18
  br label %26

25:                                               ; preds = %3
  store i32 4, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %51

26:                                               ; preds = %24
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = call noundef ptr @_ZNKSt10unique_ptrIN5Ayane6BufferENS0_24ManagedBufferDeallocatorEEptEv(ptr noundef nonnull align 8 dereferenceable(24) %27) #4
  %29 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68) %28)
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.Ayane::Stage::Sink", ptr %30, i32 0, i32 5
  %32 = call noundef zeroext i1 @_ZNK5Ayane12BufferFormatneERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %29, ptr noundef nonnull align 4 dereferenceable(12) %31)
  br i1 %32, label %33, label %50

33:                                               ; preds = %26
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call noundef ptr @_ZNKSt10unique_ptrIN5Ayane6BufferENS0_24ManagedBufferDeallocatorEEptEv(ptr noundef nonnull align 8 dereferenceable(24) %35) #4
  %37 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68) %36)
  %38 = load ptr, ptr %10, align 8, !tbaa !29
  %39 = getelementptr inbounds ptr, ptr %38, i64 4
  %40 = load ptr, ptr %39, align 8
  %41 = call noundef zeroext i1 %40(ptr noundef nonnull align 8 dereferenceable(128) %10, ptr noundef nonnull align 8 dereferenceable(45) %34, ptr noundef nonnull align 4 dereferenceable(12) %37)
  br i1 %41, label %43, label %42

42:                                               ; preds = %33
  store i32 2, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %51

43:                                               ; preds = %33
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call noundef ptr @_ZNKSt10unique_ptrIN5Ayane6BufferENS0_24ManagedBufferDeallocatorEEptEv(ptr noundef nonnull align 8 dereferenceable(24) %44) #4
  %46 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68) %45)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.Ayane::Stage::Sink", ptr %47, i32 0, i32 5
  %49 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Ayane12BufferFormataSERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %48, ptr noundef nonnull align 4 dereferenceable(12) %46)
  br label %50

50:                                               ; preds = %43, %26
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %51

51:                                               ; preds = %50, %42, %25, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %52 = load i32, ptr %4, align 4
  ret i32 %52
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 24}
!10 = !{!"_ZTSN5Ayane5Stage4SinkE", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !14, i64 44}
!11 = !{!"_ZTSN5Ayane5Stage4Sink14SchedulingModeE", !7, i64 0}
!12 = !{!"_ZTSN5Ayane12BufferFormatE", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTSN5Ayane5Stage17SourceSinkPrivateE", !17, i64 0, !18, i64 8, !25, i64 48, !27, i64 88}
!17 = !{!"_ZTSN5Ayane5Stage17SynchronicityModeE", !7, i64 0}
!18 = !{!"_ZTSN5Ayane11BufferQueueE", !13, i64 0, !19, i64 4, !19, i64 8, !21, i64 16}
!19 = !{!"_ZTSSt6atomicIjE", !20, i64 0}
!20 = !{!"_ZTSSt13__atomic_baseIjE", !13, i64 0}
!21 = !{!"_ZTSSt6vectorISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"_ZTSSt5mutex", !26, i64 0}
!26 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!27 = !{!"_ZTSSt18condition_variable", !28, i64 0}
!28 = !{!"_ZTSSt9__condvar", !7, i64 0}
!29 = !{!30, !30, i64 0}
!30 = !{!"vtable pointer", !8, i64 0}


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

declare noundef zeroext i1 @_ZN5Ayane11BufferQueue3popEPSt10unique_ptrINS_6BufferENS_24ManagedBufferDeallocatorEE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #0

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

declare noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68)) local_unnamed_addr #0

declare noundef zeroext i1 @_ZNK5Ayane12BufferFormatneERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0

declare noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Ayane12BufferFormataSERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZN5Ayane5Stage7tryPullEPNS0_4SinkEPSt10unique_ptrINS_6BufferENS_24ManagedBufferDeallocatorEE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 align 2 {
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load i32, ptr %5, align 8, !tbaa !14
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %27

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  %10 = tail call noundef zeroext i1 @_ZN5Ayane11BufferQueue3popEPSt10unique_ptrINS_6BufferENS_24ManagedBufferDeallocatorEE(ptr noundef nonnull align 8 dereferenceable(40) %9, ptr noundef %2)
  br i1 %10, label %11, label %27

11:                                               ; preds = %8
  %12 = tail call noundef ptr @_ZNKSt10unique_ptrIN5Ayane6BufferENS0_24ManagedBufferDeallocatorEEptEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %13 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68) %12)
  %14 = getelementptr inbounds i8, ptr %1, i64 32
  %15 = tail call noundef zeroext i1 @_ZNK5Ayane12BufferFormatneERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %13, ptr noundef nonnull align 4 dereferenceable(12) %14)
  br i1 %15, label %16, label %27

16:                                               ; preds = %11
  %17 = tail call noundef ptr @_ZNKSt10unique_ptrIN5Ayane6BufferENS0_24ManagedBufferDeallocatorEEptEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %18 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68) %17)
  %19 = load ptr, ptr %0, align 8, !tbaa !28
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  %21 = load ptr, ptr %20, align 8
  %22 = tail call noundef zeroext i1 %21(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 8 dereferenceable(45) %1, ptr noundef nonnull align 4 dereferenceable(12) %18)
  br i1 %22, label %23, label %27

23:                                               ; preds = %16
  %24 = tail call noundef ptr @_ZNKSt10unique_ptrIN5Ayane6BufferENS0_24ManagedBufferDeallocatorEEptEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %25 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK5Ayane6Buffer6formatEv(ptr noundef nonnull align 8 dereferenceable(68) %24)
  %26 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Ayane12BufferFormataSERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %14, ptr noundef nonnull align 4 dereferenceable(12) %25)
  br label %27

27:                                               ; preds = %11, %23, %16, %3, %8
  %.0 = phi i32 [ 3, %8 ], [ 4, %3 ], [ 2, %16 ], [ 0, %23 ], [ 0, %11 ]
  ret i32 %.0
}

attributes #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 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, !7, i64 24}
!6 = !{!"_ZTSN5Ayane5Stage4SinkE", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !13, i64 44}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN5Ayane5Stage4Sink14SchedulingModeE", !8, i64 0}
!11 = !{!"_ZTSN5Ayane12BufferFormatE", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTSN5Ayane5Stage17SourceSinkPrivateE", !16, i64 0, !17, i64 8, !24, i64 48, !26, i64 88}
!16 = !{!"_ZTSN5Ayane5Stage17SynchronicityModeE", !8, i64 0}
!17 = !{!"_ZTSN5Ayane11BufferQueueE", !12, i64 0, !18, i64 4, !18, i64 8, !20, i64 16}
!18 = !{!"_ZTSSt6atomicIjE", !19, i64 0}
!19 = !{!"_ZTSSt13__atomic_baseIjE", !12, i64 0}
!20 = !{!"_ZTSSt6vectorISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrIN5Ayane6BufferENS1_24ManagedBufferDeallocatorEESaIS4_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!24 = !{!"_ZTSSt5mutex", !25, i64 0}
!25 = !{!"_ZTSSt12__mutex_base", !8, i64 0}
!26 = !{!"_ZTSSt18condition_variable", !27, i64 0}
!27 = !{!"_ZTSSt9__condvar", !8, i64 0}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !9, i64 0}


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