; LLVM IR from filipwasil/fillwave :: src/cmn/TextureConfig.ll (ZN3flw3flc13TextureConfigD2Ev)

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

%"struct.flw::flc::TextureConfig" = type { %"struct.flw::flc::TextureConfig::Header", %"struct.flw::flc::TextureConfig::Content", i32, %"class.std::unique_ptr", %"class.std::vector" }
%"struct.flw::flc::TextureConfig::Header" = type { i32, i32, i32, i32, i32, i32 }
%"struct.flw::flc::TextureConfig::Content" = type { i32, i8, i8, i32, i32 }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { ptr }
%"struct.std::_Head_base.1" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<flw::flc::TextureConfig::Mipmap, flw::AllocatorStack<flw::flc::TextureConfig::Mipmap>>::_Vector_impl" }
%"struct.std::_Vector_base<flw::flc::TextureConfig::Mipmap, flw::AllocatorStack<flw::flc::TextureConfig::Mipmap>>::_Vector_impl" = type { %"class.flw::AllocatorStack", %"struct.std::_Vector_base<flw::flc::TextureConfig::Mipmap, flw::AllocatorStack<flw::flc::TextureConfig::Mipmap>>::_Vector_impl_data" }
%"class.flw::AllocatorStack" = type { %"struct.std::array" }
%"struct.std::array" = type { [32 x %"struct.flw::flc::TextureConfig::Mipmap"] }
%"struct.flw::flc::TextureConfig::Mipmap" = type { i32, i32, i32, i32, %"class.std::unique_ptr" }
%"struct.std::_Vector_base<flw::flc::TextureConfig::Mipmap, flw::AllocatorStack<flw::flc::TextureConfig::Mipmap>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3flw3flc13TextureConfigD2Ev(ptr noundef nonnull align 8 dereferenceable(1112) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %3, i32 0, i32 2
  %5 = load i32, ptr %4, align 8, !tbaa !9
  switch i32 %5, label %21 [
    i32 0, label %6
    i32 1, label %9
    i32 2, label %15
    i32 3, label %21
  ]

6:                                                ; preds = %1
  %7 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %3, i32 0, i32 3
  %8 = call noundef ptr @_ZNKSt10unique_ptrIhPFvPhEE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  call void @free(ptr noundef %8) #3
  br label %21

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %3, i32 0, i32 3
  %11 = call noundef ptr @_ZNKSt10unique_ptrIhPFvPhEE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #3
  %12 = icmp eq ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @_ZdlPvm(ptr noundef %11, i64 noundef 1) #4
  br label %14

14:                                               ; preds = %13, %9
  br label %21

15:                                               ; preds = %1
  %16 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %3, i32 0, i32 3
  %17 = call noundef ptr @_ZNKSt10unique_ptrIhPFvPhEE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %16) #3
  %18 = icmp eq ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @_ZdaPv(ptr noundef %17) #4
  br label %20

20:                                               ; preds = %19, %15
  br label %21

21:                                               ; preds = %20, %14, %6, %1, %1
  %22 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %3, i32 0, i32 4
  call void @_ZNSt6vectorIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(1048) %22) #3
  %23 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %3, i32 0, i32 3
  call void @_ZNSt10unique_ptrIhPFvPhEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %23) #3
  ret void
}

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10unique_ptrIhPFvPhEED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) 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 "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 = { nobuiltin nounwind "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 }
attributes #4 = { builtin 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, !14, i64 40}
!10 = !{!"_ZTSN3flw3flc13TextureConfigE", !11, i64 0, !13, i64 24, !14, i64 40, !15, i64 48, !23, i64 64}
!11 = !{!"_ZTSN3flw3flc13TextureConfig6HeaderE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3flw3flc13TextureConfig7ContentE", !12, i64 0, !7, i64 4, !7, i64 5, !12, i64 8, !12, i64 12}
!14 = !{!"_ZTSN3flw3flc17EMemoryAllocationE", !7, i64 0}
!15 = !{!"_ZTSSt10unique_ptrIhPFvPhEE", !16, i64 0}
!16 = !{!"_ZTSSt15__uniq_ptr_dataIhPFvPhELb1ELb1EE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_implIhPFvPhEE", !18, i64 0}
!18 = !{!"_ZTSSt5tupleIJPhPFvS0_EEE", !19, i64 0}
!19 = !{!"_ZTSSt11_Tuple_implILm0EJPhPFvS0_EEE", !20, i64 0, !22, i64 8}
!20 = !{!"_ZTSSt11_Tuple_implILm1EJPFvPhEEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm1EPFvPhELb0EE", !6, i64 0}
!22 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !6, i64 0}
!23 = !{!"_ZTSSt6vectorIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE12_Vector_implE", !26, i64 0, !28, i64 1024}
!26 = !{!"_ZTSN3flw14AllocatorStackINS_3flc13TextureConfig6MipmapEEE", !27, i64 0}
!27 = !{!"_ZTSSt5arrayIN3flw3flc13TextureConfig6MipmapELm32EE", !7, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


; 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 @_ZN3flw3flc13TextureConfigD2Ev(ptr noundef nonnull align 8 dereferenceable(1112) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i32, ptr %2, align 8, !tbaa !5
  switch i32 %3, label %17 [
    i32 0, label %4
    i32 1, label %7
    i32 2, label %12
  ]

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = tail call noundef ptr @_ZNKSt10unique_ptrIhPFvPhEE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  tail call void @free(ptr noundef %6) #3
  br label %17

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = tail call noundef ptr @_ZNKSt10unique_ptrIhPFvPhEE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %8) #3
  %10 = icmp eq ptr %9, null
  br i1 %10, label %17, label %11

11:                                               ; preds = %7
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 1) #4
  br label %17

12:                                               ; preds = %1
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = tail call noundef ptr @_ZNKSt10unique_ptrIhPFvPhEE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %13) #3
  %15 = icmp eq ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  tail call void @_ZdaPv(ptr noundef nonnull %14) #4
  br label %17

17:                                               ; preds = %12, %16, %7, %11, %4, %1
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @_ZNSt6vectorIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(1048) %18) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @_ZNSt10unique_ptrIhPFvPhEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #3
  ret void
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10unique_ptrIhPFvPhEED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) 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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nobuiltin nounwind "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 }
attributes #4 = { builtin 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, !12, i64 40}
!6 = !{!"_ZTSN3flw3flc13TextureConfigE", !7, i64 0, !11, i64 24, !12, i64 40, !13, i64 48, !22, i64 64}
!7 = !{!"_ZTSN3flw3flc13TextureConfig6HeaderE", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN3flw3flc13TextureConfig7ContentE", !8, i64 0, !9, i64 4, !9, i64 5, !8, i64 8, !8, i64 12}
!12 = !{!"_ZTSN3flw3flc17EMemoryAllocationE", !9, i64 0}
!13 = !{!"_ZTSSt10unique_ptrIhPFvPhEE", !14, i64 0}
!14 = !{!"_ZTSSt15__uniq_ptr_dataIhPFvPhELb1ELb1EE", !15, i64 0}
!15 = !{!"_ZTSSt15__uniq_ptr_implIhPFvPhEE", !16, i64 0}
!16 = !{!"_ZTSSt5tupleIJPhPFvS0_EEE", !17, i64 0}
!17 = !{!"_ZTSSt11_Tuple_implILm0EJPhPFvS0_EEE", !18, i64 0, !21, i64 8}
!18 = !{!"_ZTSSt11_Tuple_implILm1EJPFvPhEEE", !19, i64 0}
!19 = !{!"_ZTSSt10_Head_baseILm1EPFvPhELb0EE", !20, i64 0}
!20 = !{!"any pointer", !9, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !20, i64 0}
!22 = !{!"_ZTSSt6vectorIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE12_Vector_implE", !25, i64 0, !27, i64 1024}
!25 = !{!"_ZTSN3flw14AllocatorStackINS_3flc13TextureConfig6MipmapEEE", !26, i64 0}
!26 = !{!"_ZTSSt5arrayIN3flw3flc13TextureConfig6MipmapELm32EE", !9, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE17_Vector_impl_dataE", !20, i64 0, !20, i64 8, !20, i64 16}


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