; LLVM IR from Razakhel/RaZ :: extern/fastgltf/src/io.ll (ZN8fastgltf14GltfDataBufferC2EPKSt4bytem)

; 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.fastgltf::GltfDataBuffer" = type { %"class.fastgltf::GltfDataGetter", %"class.std::unique_ptr", i64, i64, i64, i64 }
%"class.fastgltf::GltfDataGetter" = type { ptr }
%"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::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }

@_ZTVN8fastgltf14GltfDataBufferE = external dso_local unnamed_addr constant { [9 x ptr] }, align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8fastgltf14GltfDataBufferC2EPKSt4bytem(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, i64 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  call void @_ZN8fastgltf14GltfDataGetterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #2
  store ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTVN8fastgltf14GltfDataBufferE, i32 0, i32 0, i32 2), ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds %"class.fastgltf::GltfDataBuffer", ptr %7, i32 0, i32 1
  call void @_ZNSt10unique_ptrIA_St4byteSt14default_deleteIS1_EEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #2
  %9 = getelementptr inbounds %"class.fastgltf::GltfDataBuffer", ptr %7, i32 0, i32 2
  store i64 0, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds %"class.fastgltf::GltfDataBuffer", ptr %7, i32 0, i32 3
  store i64 0, ptr %10, align 8, !tbaa !23
  %11 = getelementptr inbounds %"class.fastgltf::GltfDataBuffer", ptr %7, i32 0, i32 4
  store i64 0, ptr %11, align 8, !tbaa !24
  %12 = getelementptr inbounds %"class.fastgltf::GltfDataBuffer", ptr %7, i32 0, i32 5
  store i64 0, ptr %12, align 8, !tbaa !25
  %13 = load i64, ptr %6, align 8, !tbaa !9
  %14 = getelementptr inbounds %"class.fastgltf::GltfDataBuffer", ptr %7, i32 0, i32 3
  store i64 %13, ptr %14, align 8, !tbaa !23
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN8fastgltf14GltfDataBuffer15allocateAndCopyEPKSt4byte(ptr noundef nonnull align 8 dereferenceable(48) %7, ptr noundef %15) #2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8fastgltf14GltfDataBuffer15allocateAndCopyEPKSt4byte(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) #1 align 2

attributes #0 = { inlinehint 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 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, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTSN8fastgltf14GltfDataBufferE", !15, i64 0, !16, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !22, i64 40}
!15 = !{!"_ZTSN8fastgltf14GltfDataGetterE"}
!16 = !{!"_ZTSSt10unique_ptrIA_St4byteSt14default_deleteIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataISt4byteSt14default_deleteIA_S0_ELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implISt4byteSt14default_deleteIA_S0_EE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJPSt4byteSt14default_deleteIA_S0_EEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJPSt4byteSt14default_deleteIA_S0_EEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EPSt4byteLb0EE", !6, i64 0}
!22 = !{!"_ZTSN8fastgltf5ErrorE", !7, i64 0}
!23 = !{!14, !10, i64 24}
!24 = !{!14, !10, i64 32}
!25 = !{!14, !22, 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"

@_ZTVN8fastgltf14GltfDataBufferE = external dso_local unnamed_addr constant { [9 x ptr] }, align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8fastgltf14GltfDataBufferC2EPKSt4bytem(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, i64 noundef %2) unnamed_addr #1 align 2 {
  tail call void @_ZN8fastgltf14GltfDataGetterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #3
  store ptr getelementptr inbounds inrange(-16, 56) (i8, ptr @_ZTVN8fastgltf14GltfDataBufferE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt10unique_ptrIA_St4byteSt14default_deleteIS1_EEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %5, i8 0, i64 32, i1 false)
  store i64 %2, ptr %6, align 8, !tbaa !8
  tail call void @_ZN8fastgltf14GltfDataBuffer15allocateAndCopyEPKSt4byte(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8fastgltf14GltfDataBuffer15allocateAndCopyEPKSt4byte(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { inlinehint 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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !19, i64 24}
!9 = !{!"_ZTSN8fastgltf14GltfDataBufferE", !10, i64 0, !11, i64 8, !19, i64 16, !19, i64 24, !19, i64 32, !20, i64 40}
!10 = !{!"_ZTSN8fastgltf14GltfDataGetterE"}
!11 = !{!"_ZTSSt10unique_ptrIA_St4byteSt14default_deleteIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt15__uniq_ptr_dataISt4byteSt14default_deleteIA_S0_ELb1ELb1EE", !13, i64 0}
!13 = !{!"_ZTSSt15__uniq_ptr_implISt4byteSt14default_deleteIA_S0_EE", !14, i64 0}
!14 = !{!"_ZTSSt5tupleIJPSt4byteSt14default_deleteIA_S0_EEE", !15, i64 0}
!15 = !{!"_ZTSSt11_Tuple_implILm0EJPSt4byteSt14default_deleteIA_S0_EEE", !16, i64 0}
!16 = !{!"_ZTSSt10_Head_baseILm0EPSt4byteLb0EE", !17, i64 0}
!17 = !{!"any pointer", !18, i64 0}
!18 = !{!"omnipotent char", !7, i64 0}
!19 = !{!"long", !18, i64 0}
!20 = !{!"_ZTSN8fastgltf5ErrorE", !18, i64 0}


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