; LLVM IR from Devaniti/BoolkaEngine :: ThirdParty/imgui/imgui_draw.ll (ZN11ImFontAtlas18GetTexDataAsAlpha8EPPhPiS2_S2_)

; 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 { i8, i32, ptr, i32, i32, ptr, ptr, i32, i32, %struct.ImVec2, %struct.ImVec2, %struct.ImVector.8, %struct.ImVector.9, %struct.ImVector.10, [64 x %struct.ImVec4], i32, i32 }
%struct.ImVec2 = type { float, float }
%struct.ImVector.8 = type { i32, i32, ptr }
%struct.ImVector.9 = type { i32, i32, ptr }
%struct.ImVector.10 = type { i32, i32, ptr }
%struct.ImVec4 = type { float, float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11ImFontAtlas18GetTexDataAsAlpha8EPPhPiS2_S2_(ptr noundef nonnull align 8 dereferenceable(1144) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8
  %12 = getelementptr inbounds %struct.ImFontAtlas, ptr %11, i32 0, i32 5
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %22

15:                                               ; preds = %5
  %16 = getelementptr inbounds %struct.ImFontAtlas, ptr %11, i32 0, i32 13
  %17 = call noundef zeroext i1 @_ZNK8ImVectorI12ImFontConfigE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  %19 = call noundef ptr @_ZN11ImFontAtlas14AddFontDefaultEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1144) %11, ptr noundef null)
  br label %20

20:                                               ; preds = %18, %15
  %21 = call noundef zeroext i1 @_ZN11ImFontAtlas5BuildEv(ptr noundef nonnull align 8 dereferenceable(1144) %11)
  br label %22

22:                                               ; preds = %20, %5
  %23 = getelementptr inbounds %struct.ImFontAtlas, ptr %11, i32 0, i32 5
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %24, ptr %25, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %32

28:                                               ; preds = %22
  %29 = getelementptr inbounds %struct.ImFontAtlas, ptr %11, i32 0, i32 7
  %30 = load i32, ptr %29, align 8, !tbaa !18
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %30, ptr %31, align 4, !tbaa !19
  br label %32

32:                                               ; preds = %28, %22
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %39

35:                                               ; preds = %32
  %36 = getelementptr inbounds %struct.ImFontAtlas, ptr %11, i32 0, i32 8
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %37, ptr %38, align 4, !tbaa !19
  br label %39

39:                                               ; preds = %35, %32
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %44

42:                                               ; preds = %39
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 1, ptr %43, align 4, !tbaa !19
  br label %44

44:                                               ; preds = %42, %39
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8ImVectorI12ImFontConfigE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11ImFontAtlas14AddFontDefaultEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1144), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN11ImFontAtlas5BuildEv(ptr noundef nonnull align 8 dereferenceable(1144)) #0 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 = { 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" }

!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 24}
!10 = !{!"_ZTS11ImFontAtlas", !11, i64 0, !12, i64 4, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !13, i64 48, !13, i64 56, !15, i64 64, !16, i64 80, !17, i64 96, !7, i64 112, !12, i64 1136, !12, i64 1140}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_ZTS8ImVectorIP6ImFontE", !12, i64 0, !12, i64 4, !6, i64 8}
!16 = !{!"_ZTS8ImVectorI21ImFontAtlasCustomRectE", !12, i64 0, !12, i64 4, !6, i64 8}
!17 = !{!"_ZTS8ImVectorI12ImFontConfigE", !12, i64 0, !12, i64 4, !6, i64 8}
!18 = !{!10, !12, i64 40}
!19 = !{!12, !12, i64 0}
!20 = !{!10, !12, i64 44}


; 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 uwtable
define dso_local void @_ZN11ImFontAtlas18GetTexDataAsAlpha8EPPhPiS2_S2_(ptr noundef nonnull align 8 dereferenceable(1144) %0, ptr nocapture noundef writeonly %1, ptr noundef writeonly %2, ptr noundef writeonly %3, ptr noundef writeonly %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %16

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = tail call noundef zeroext i1 @_ZNK8ImVectorI12ImFontConfigE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  br i1 %11, label %12, label %14

12:                                               ; preds = %9
  %13 = tail call noundef ptr @_ZN11ImFontAtlas14AddFontDefaultEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1144) %0, ptr noundef null)
  br label %14

14:                                               ; preds = %12, %9
  %15 = tail call noundef zeroext i1 @_ZN11ImFontAtlas5BuildEv(ptr noundef nonnull align 8 dereferenceable(1144) %0)
  %.pre = load ptr, ptr %6, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %14, %5
  %17 = phi ptr [ %.pre, %14 ], [ %7, %5 ]
  store ptr %17, ptr %1, align 8, !tbaa !17
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %21, label %18

18:                                               ; preds = %16
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load i32, ptr %19, align 8, !tbaa !18
  store i32 %20, ptr %2, align 4, !tbaa !19
  br label %21

21:                                               ; preds = %18, %16
  %.not10 = icmp eq ptr %3, null
  br i1 %.not10, label %25, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %0, i64 44
  %24 = load i32, ptr %23, align 4, !tbaa !20
  store i32 %24, ptr %3, align 4, !tbaa !19
  br label %25

25:                                               ; preds = %22, %21
  %.not11 = icmp eq ptr %4, null
  br i1 %.not11, label %27, label %26

26:                                               ; preds = %25
  store i32 1, ptr %4, align 4, !tbaa !19
  br label %27

27:                                               ; preds = %26, %25
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8ImVectorI12ImFontConfigE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11ImFontAtlas14AddFontDefaultEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1144), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN11ImFontAtlas5BuildEv(ptr noundef nonnull align 8 dereferenceable(1144)) local_unnamed_addr #0 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 = { 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" }

!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, !11, i64 24}
!6 = !{!"_ZTS11ImFontAtlas", !7, i64 0, !10, i64 4, !11, i64 8, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 32, !10, i64 40, !10, i64 44, !12, i64 48, !12, i64 56, !14, i64 64, !15, i64 80, !16, i64 96, !8, i64 112, !10, i64 1136, !10, i64 1140}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTS6ImVec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTS8ImVectorIP6ImFontE", !10, i64 0, !10, i64 4, !11, i64 8}
!15 = !{!"_ZTS8ImVectorI21ImFontAtlasCustomRectE", !10, i64 0, !10, i64 4, !11, i64 8}
!16 = !{!"_ZTS8ImVectorI12ImFontConfigE", !10, i64 0, !10, i64 4, !11, i64 8}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !10, i64 40}
!19 = !{!10, !10, i64 0}
!20 = !{!6, !10, i64 44}


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