; LLVM IR from filipwasil/fillwave :: src/flf/loaders/textureloader (TextureFactory)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3flw3flf14TextureFactory9loadEmptyEiij(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 1112) #7
  invoke void @_ZN3flw3flc13TextureConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(1112) %10)
          to label %11 unwind label %49

11:                                               ; preds = %3
  store ptr %10, ptr %7, align 8, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = load ptr, ptr %7, align 8, !tbaa !9
  %14 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Header", ptr %14, i32 0, i32 4
  store i32 %12, ptr %15, align 8, !tbaa !11
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !9
  %18 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Header", ptr %18, i32 0, i32 0
  store i32 %16, ptr %19, align 8, !tbaa !30
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Header", ptr %22, i32 0, i32 2
  store i32 %20, ptr %23, align 8, !tbaa !31
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Header", ptr %26, i32 0, i32 1
  store i32 %24, ptr %27, align 4, !tbaa !32
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Header", ptr %29, i32 0, i32 3
  store i32 5121, ptr %30, align 4, !tbaa !33
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Content", ptr %32, i32 0, i32 1
  store i8 1, ptr %33, align 4, !tbaa !34
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Content", ptr %35, i32 0, i32 0
  store i32 0, ptr %36, align 8, !tbaa !35
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %37, i32 0, i32 1
  %39 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Content", ptr %38, i32 0, i32 2
  store i8 0, ptr %39, align 1, !tbaa !36
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds %"struct.flw::flc::TextureConfig::Content", ptr %41, i32 0, i32 3
  store i32 0, ptr %42, align 8, !tbaa !37
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %43, i32 0, i32 3
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10unique_ptrIhPFvPhEEaSEDn(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr null) #6
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = getelementptr inbounds %"struct.flw::flc::TextureConfig", ptr %46, i32 0, i32 2
  store i32 3, ptr %47, align 8, !tbaa !38
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret ptr %48

49:                                               ; preds = %3
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %8, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %9, align 4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 1112) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %53

53:                                               ; preds = %49
  %54 = load ptr, ptr %8, align 8
  %55 = load i32, ptr %9, align 4
  %56 = insertvalue { ptr, i32 } poison, ptr %54, 0
  %57 = insertvalue { ptr, i32 } %56, i32 %55, 1
  resume { ptr, i32 } %57
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

declare void @_ZN3flw3flc13TextureConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(1112)) unnamed_addr #3

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin allocsize(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 = { "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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTSN3flw3flc13TextureConfigE", !13, i64 0, !14, i64 24, !15, i64 40, !16, i64 48, !24, i64 64}
!13 = !{!"_ZTSN3flw3flc13TextureConfig6HeaderE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!14 = !{!"_ZTSN3flw3flc13TextureConfig7ContentE", !6, i64 0, !7, i64 4, !7, i64 5, !6, i64 8, !6, i64 12}
!15 = !{!"_ZTSN3flw3flc17EMemoryAllocationE", !7, i64 0}
!16 = !{!"_ZTSSt10unique_ptrIhPFvPhEE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataIhPFvPhELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implIhPFvPhEE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJPhPFvS0_EEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJPhPFvS0_EEE", !21, i64 0, !23, i64 8}
!21 = !{!"_ZTSSt11_Tuple_implILm1EJPFvPhEEE", !22, i64 0}
!22 = !{!"_ZTSSt10_Head_baseILm1EPFvPhELb0EE", !10, i64 0}
!23 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !10, i64 0}
!24 = !{!"_ZTSSt6vectorIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE12_Vector_implE", !27, i64 0, !29, i64 1024}
!27 = !{!"_ZTSN3flw14AllocatorStackINS_3flc13TextureConfig6MipmapEEE", !28, i64 0}
!28 = !{!"_ZTSSt5arrayIN3flw3flc13TextureConfig6MipmapELm32EE", !7, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIN3flw3flc13TextureConfig6MipmapENS0_14AllocatorStackIS3_EEE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!30 = !{!12, !6, i64 0}
!31 = !{!12, !6, i64 8}
!32 = !{!12, !6, i64 4}
!33 = !{!12, !6, i64 12}
!34 = !{!12, !7, i64 28}
!35 = !{!12, !6, i64 24}
!36 = !{!12, !7, i64 29}
!37 = !{!12, !6, i64 32}
!38 = !{!12, !15, i64 40}


; 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 i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN3flw3flf14TextureFactory9loadEmptyEiij(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = tail call noalias noundef nonnull dereferenceable(1112) ptr @_Znwm(i64 noundef 1112) #5
  invoke void @_ZN3flw3flc13TextureConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(1112) %4)
          to label %5 unwind label %17

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 %2, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %4, align 8, !tbaa !28
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %0, ptr %7, align 8, !tbaa !29
  %8 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %1, ptr %8, align 4, !tbaa !30
  %9 = getelementptr inbounds i8, ptr %4, i64 12
  store i32 5121, ptr %9, align 4, !tbaa !31
  %10 = getelementptr inbounds i8, ptr %4, i64 24
  %11 = getelementptr inbounds i8, ptr %4, i64 28
  store i8 1, ptr %11, align 4, !tbaa !32
  store i32 0, ptr %10, align 8, !tbaa !33
  %12 = getelementptr inbounds i8, ptr %4, i64 29
  store i8 0, ptr %12, align 1, !tbaa !34
  %13 = getelementptr inbounds i8, ptr %4, i64 32
  store i32 0, ptr %13, align 8, !tbaa !35
  %14 = getelementptr inbounds i8, ptr %4, i64 48
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10unique_ptrIhPFvPhEEaSEDn(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr null) #6
  %16 = getelementptr inbounds i8, ptr %4, i64 40
  store i32 3, ptr %16, align 8, !tbaa !36
  ret ptr %4

17:                                               ; preds = %3
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 1112) #7
  resume { ptr, i32 } %18
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

declare void @_ZN3flw3flc13TextureConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(1112)) unnamed_addr #2

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

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

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 = { "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 = { 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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { 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, !8, i64 16}
!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}
!28 = !{!6, !8, i64 0}
!29 = !{!6, !8, i64 8}
!30 = !{!6, !8, i64 4}
!31 = !{!6, !8, i64 12}
!32 = !{!6, !9, i64 28}
!33 = !{!6, !8, i64 24}
!34 = !{!6, !9, i64 29}
!35 = !{!6, !8, i64 32}
!36 = !{!6, !12, i64 40}


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