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

; 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::MappedGltfFile" = type { %"class.fastgltf::GltfDataGetter", ptr, i64, i64, i64 }
%"class.fastgltf::GltfDataGetter" = type { ptr }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8fastgltf14MappedGltfFileC2EOS0_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @_ZN8fastgltf14GltfDataGetterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  store ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTVN8fastgltf14MappedGltfFileE, i32 0, i32 0, i32 2), ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 1
  store ptr null, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 2
  store i64 0, ptr %8, align 8, !tbaa !16
  %9 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 3
  store i64 0, ptr %9, align 8, !tbaa !17
  %10 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 4
  store i64 0, ptr %10, align 8, !tbaa !18
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %11, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr inttoptr (i64 -1 to ptr), ptr %5, align 8, !tbaa !5
  %13 = call noundef ptr @_ZSt8exchangeIPvS0_ET_RS1_OT0_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  %14 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 1
  store ptr %13, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %15, i32 0, i32 2
  %17 = load i64, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 2
  store i64 %17, ptr %18, align 8, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %19, i32 0, i32 3
  %21 = load i64, ptr %20, align 8, !tbaa !17
  %22 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 3
  store i64 %21, ptr %22, align 8, !tbaa !17
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %23, i32 0, i32 4
  %25 = load i64, ptr %24, align 8, !tbaa !18
  %26 = getelementptr inbounds %"class.fastgltf::MappedGltfFile", ptr %6, i32 0, i32 4
  store i64 %25, ptr %26, align 8, !tbaa !18
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZSt8exchangeIPvS0_ET_RS1_OT0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN8fastgltf14MappedGltfFileE", !13, i64 0, !6, i64 8, !14, i64 16, !14, i64 24, !15, i64 32}
!13 = !{!"_ZTSN8fastgltf14GltfDataGetterE"}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN8fastgltf5ErrorE", !7, i64 0}
!16 = !{!12, !14, i64 16}
!17 = !{!12, !14, i64 24}
!18 = !{!12, !15, i64 32}


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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8fastgltf14MappedGltfFileC2EOS0_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  tail call void @_ZN8fastgltf14GltfDataGetterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  store ptr getelementptr inbounds inrange(-16, 56) (i8, ptr @_ZTVN8fastgltf14MappedGltfFileE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %4, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store ptr inttoptr (i64 -1 to ptr), ptr %3, align 8, !tbaa !8
  %8 = call noundef ptr @_ZSt8exchangeIPvS0_ET_RS1_OT0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  store ptr %8, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load <2 x i64>, ptr %9, align 8, !tbaa !16
  store <2 x i64> %10, ptr %5, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %1, i64 32
  %12 = load i64, ptr %11, align 8, !tbaa !17
  store i64 %12, ptr %6, align 8, !tbaa !17
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZSt8exchangeIPvS0_ET_RS1_OT0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 8}
!12 = !{!"_ZTSN8fastgltf14MappedGltfFileE", !13, i64 0, !9, i64 8, !14, i64 16, !14, i64 24, !15, i64 32}
!13 = !{!"_ZTSN8fastgltf14GltfDataGetterE"}
!14 = !{!"long", !10, i64 0}
!15 = !{!"_ZTSN8fastgltf5ErrorE", !10, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!12, !15, i64 32}


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