; LLVM IR from awawa-dev/HyperHDR :: sources/image/VideoMemoryManager.ll (ZN18VideoMemoryManagerC2Ei)

; 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.VideoMemoryManager = type { %"class.std::__cxx11::list", i64, i64, i32, i8, i8, i64, %"class.std::mutex" }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<std::unique_ptr<MemoryBuffer<unsigned char>>, std::allocator<std::unique_ptr<MemoryBuffer<unsigned char>>>>::_List_impl" }
%"struct.std::__cxx11::_List_base<std::unique_ptr<MemoryBuffer<unsigned char>>, std::allocator<std::unique_ptr<MemoryBuffer<unsigned char>>>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { 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 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN18VideoMemoryManagerC2Ei(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 0
  call void @_ZNSt7__cxx114listISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #1
  %7 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 1
  store i64 0, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 2
  store i64 0, ptr %8, align 8, !tbaa !22
  %9 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 3
  store i32 0, ptr %9, align 8, !tbaa !23
  %10 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 4
  store i8 0, ptr %10, align 4, !tbaa !24
  %11 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 5
  store i8 1, ptr %11, align 1, !tbaa !25
  %12 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 6
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  store i64 %14, ptr %12, align 8, !tbaa !26
  %15 = getelementptr inbounds %class.VideoMemoryManager, ptr %5, i32 0, i32 7
  call void @_ZNSt5mutexC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %15) #1
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5mutexC2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #0 align 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 = { 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, !18, i64 24}
!12 = !{!"_ZTS18VideoMemoryManager", !13, i64 0, !18, i64 24, !18, i64 32, !10, i64 40, !19, i64 44, !19, i64 45, !18, i64 48, !20, i64 56}
!13 = !{!"_ZTSNSt7__cxx114listISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EEE", !14, i64 0}
!14 = !{!"_ZTSNSt7__cxx1110_List_baseISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EEE", !15, i64 0}
!15 = !{!"_ZTSNSt7__cxx1110_List_baseISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EE10_List_implE", !16, i64 0}
!16 = !{!"_ZTSNSt8__detail17_List_node_headerE", !17, i64 0, !18, i64 16}
!17 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSSt5mutex", !21, i64 0}
!21 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!22 = !{!12, !18, i64 32}
!23 = !{!12, !10, i64 40}
!24 = !{!12, !19, i64 44}
!25 = !{!12, !19, i64 45}
!26 = !{!12, !18, i64 48}


; 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
define dso_local void @_ZN18VideoMemoryManagerC2Ei(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  tail call void @_ZNSt7__cxx114listISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = getelementptr inbounds i8, ptr %0, i64 45
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(21) %3, i8 0, i64 21, i1 false)
  store i8 1, ptr %4, align 1, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = sext i32 %1 to i64
  store i64 %6, ptr %5, align 8, !tbaa !20
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @_ZNSt5mutexC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %7) #2
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5mutexC2Ev(ptr noundef nonnull align 8 dereferenceable(40)) 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) #1

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: write) }
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, !17, i64 45}
!6 = !{!"_ZTS18VideoMemoryManager", !7, i64 0, !15, i64 24, !15, i64 32, !16, i64 40, !17, i64 44, !17, i64 45, !15, i64 48, !18, i64 56}
!7 = !{!"_ZTSNSt7__cxx114listISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EEE", !8, i64 0}
!8 = !{!"_ZTSNSt7__cxx1110_List_baseISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EEE", !9, i64 0}
!9 = !{!"_ZTSNSt7__cxx1110_List_baseISt10unique_ptrI12MemoryBufferIhESt14default_deleteIS3_EESaIS6_EE10_List_implE", !10, i64 0}
!10 = !{!"_ZTSNSt8__detail17_List_node_headerE", !11, i64 0, !15, i64 16}
!11 = !{!"_ZTSNSt8__detail15_List_node_baseE", !12, i64 0, !12, i64 8}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"long", !13, i64 0}
!16 = !{!"int", !13, i64 0}
!17 = !{!"bool", !13, i64 0}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !13, i64 0}
!20 = !{!6, !15, i64 48}


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