; LLVM IR from DarrenSweeney/3D-Physics-Engine :: Physics Engine/Imgui/imgui.ll (ZN11ImFontAtlas20AddFontFromMemoryTTFEPvmfPKti)

; 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.ImFontAtlas = type { ptr, ptr, ptr, i32, i32, %struct.ImVec2, %struct.ImVec2, %class.ImVector, %class.ImVector.0 }
%struct.ImVec2 = type { float, float }
%class.ImVector = type { i64, i64, ptr }
%class.ImVector.0 = type { i64, i64, ptr }
%"struct.ImFontAtlas::ImFontAtlasData" = type { ptr, ptr, i64, float, ptr, i32, %struct.stbtt_fontinfo, ptr, ptr, i32 }
%struct.stbtt_fontinfo = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5ImGui8MemAllocEm(i64 noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorIP6ImFontE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ImFontAtlas12ClearTexDataEv(ptr noundef nonnull align 8 dereferenceable(96)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvmfPKti(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef %1, i64 noundef %2, float noundef %3, ptr noundef %4, i32 noundef %5) #2 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store float %3, ptr %10, align 4, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !13
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %16 = call noundef ptr @_ZN5ImGui8MemAllocEm(i64 noundef 120)
  store ptr %16, ptr %13, align 8, !tbaa !5
  %17 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN6ImFontC1Ev(ptr noundef nonnull align 8 dereferenceable(120) %17)
  %18 = getelementptr inbounds %struct.ImFontAtlas, ptr %15, i32 0, i32 7
  call void @_ZN8ImVectorIP6ImFontE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef nonnull align 8 dereferenceable(8) %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %19 = call noundef ptr @_ZN5ImGui8MemAllocEm(i64 noundef 128)
  store ptr %19, ptr %14, align 8, !tbaa !5
  %20 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %20, i8 0, i64 128, i1 false)
  %21 = load ptr, ptr %13, align 8, !tbaa !5
  %22 = load ptr, ptr %14, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.ImFontAtlas::ImFontAtlasData", ptr %22, i32 0, i32 0
  store ptr %21, ptr %23, align 8, !tbaa !15
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %14, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.ImFontAtlas::ImFontAtlasData", ptr %25, i32 0, i32 1
  store ptr %24, ptr %26, align 8, !tbaa !18
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = load ptr, ptr %14, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.ImFontAtlas::ImFontAtlasData", ptr %28, i32 0, i32 2
  store i64 %27, ptr %29, align 8, !tbaa !19
  %30 = load float, ptr %10, align 4, !tbaa !11
  %31 = load ptr, ptr %14, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.ImFontAtlas::ImFontAtlasData", ptr %31, i32 0, i32 3
  store float %30, ptr %32, align 8, !tbaa !20
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = load ptr, ptr %14, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.ImFontAtlas::ImFontAtlasData", ptr %34, i32 0, i32 4
  store ptr %33, ptr %35, align 8, !tbaa !21
  %36 = load i32, ptr %12, align 4, !tbaa !13
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.ImFontAtlas::ImFontAtlasData", ptr %37, i32 0, i32 5
  store i32 %36, ptr %38, align 8, !tbaa !22
  %39 = getelementptr inbounds %struct.ImFontAtlas, ptr %15, i32 0, i32 8
  call void @_ZN8ImVectorIPN11ImFontAtlas15ImFontAtlasDataEE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %39, ptr noundef nonnull align 8 dereferenceable(8) %14)
  call void @_ZN11ImFontAtlas12ClearTexDataEv(ptr noundef nonnull align 8 dereferenceable(96) %15)
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret ptr %40
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorIPN11ImFontAtlas15ImFontAtlasDataEE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

declare void @_ZN6ImFontC1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { inlinehint 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 #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 = !{!"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 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTSN11ImFontAtlas15ImFontAtlasDataE", !6, i64 0, !6, i64 8, !10, i64 16, !12, i64 24, !6, i64 32, !14, i64 40, !17, i64 48, !6, i64 104, !6, i64 112, !14, i64 120}
!17 = !{!"_ZTS14stbtt_fontinfo", !6, i64 0, !6, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52}
!18 = !{!16, !6, i64 8}
!19 = !{!16, !10, i64 16}
!20 = !{!16, !12, i64 24}
!21 = !{!16, !6, i64 32}
!22 = !{!16, !14, 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"

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5ImGui8MemAllocEm(i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorIP6ImFontE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ImFontAtlas12ClearTexDataEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvmfPKti(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef %1, i64 noundef %2, float noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #2 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %9 = tail call noundef ptr @_ZN5ImGui8MemAllocEm(i64 noundef 120)
  store ptr %9, ptr %7, align 8, !tbaa !5
  tail call void @_ZN6ImFontC1Ev(ptr noundef nonnull align 8 dereferenceable(120) %9)
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  call void @_ZN8ImVectorIP6ImFontE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %11 = call noundef ptr @_ZN5ImGui8MemAllocEm(i64 noundef 128)
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %12, i8 0, i64 104, i1 false)
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %13, ptr %11, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr %1, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %11, i64 16
  store i64 %2, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %11, i64 24
  store float %3, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %11, i64 32
  store ptr %4, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %11, i64 40
  store i32 %5, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  call void @_ZN8ImVectorIPN11ImFontAtlas15ImFontAtlasDataEE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @_ZN11ImFontAtlas12ClearTexDataEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  ret ptr %20
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorIPN11ImFontAtlas15ImFontAtlasDataEE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

declare void @_ZN6ImFontC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN11ImFontAtlas15ImFontAtlasDataE", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !6, i64 32, !13, i64 40, !14, i64 48, !6, i64 104, !6, i64 112, !13, i64 120}
!11 = !{!"long", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS14stbtt_fontinfo", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !12, i64 24}
!18 = !{!10, !6, i64 32}
!19 = !{!10, !13, i64 40}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass