; LLVM IR from hadryansalles/Luz :: deps/imgui/imgui_draw.ll (ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt)

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

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt = external hidden unnamed_addr constant [101 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [62 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11ImFontAtlas7AddFontEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1180), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(1180) %0, ptr noundef %1, i32 noundef %2, float noundef %3, ptr noundef %4, ptr noundef %5) #3 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.ImFontConfig, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store float %3, ptr %10, align 4, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8
  %15 = getelementptr inbounds %struct.ImFontAtlas, ptr %14, i32 0, i32 5
  %16 = load i8, ptr %15, align 8, !tbaa !13, !range !20, !noundef !21
  %17 = trunc i8 %16 to i1
  br i1 %17, label %19, label %18

18:                                               ; preds = %6
  br label %19

19:                                               ; preds = %18, %6
  %20 = phi i1 [ false, %6 ], [ true, %18 ]
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  br label %24

22:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.1, i32 noundef 2271, ptr noundef @__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt) #4
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  call void @llvm.lifetime.start.p0(i64 144, ptr %13) #5
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %29

27:                                               ; preds = %24
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %28, i64 144, i1 false), !tbaa.struct !22
  br label %30

29:                                               ; preds = %24
  call void @_ZN12ImFontConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(144) %13)
  br label %30

30:                                               ; preds = %29, %27
  %31 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !27
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  br label %37

35:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 2273, ptr noundef @__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt) #4
  unreachable

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36, %34
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = icmp sgt i32 %38, 100
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  br label %41

41:                                               ; preds = %40, %37
  %42 = phi i1 [ false, %37 ], [ true, %40 ]
  br i1 %42, label %43, label %44

43:                                               ; preds = %41
  br label %46

44:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.1, i32 noundef 2274, ptr noundef @__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt) #4
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 0
  store ptr %47, ptr %48, align 8, !tbaa !27
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 1
  store i32 %49, ptr %50, align 8, !tbaa !29
  %51 = load float, ptr %10, align 4, !tbaa !11
  %52 = fcmp ogt float %51, 0.000000e+00
  br i1 %52, label %53, label %55

53:                                               ; preds = %46
  %54 = load float, ptr %10, align 4, !tbaa !11
  br label %58

55:                                               ; preds = %46
  %56 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 4
  %57 = load float, ptr %56, align 4, !tbaa !30
  br label %58

58:                                               ; preds = %55, %53
  %59 = phi float [ %54, %53 ], [ %57, %55 ]
  %60 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 4
  store float %59, ptr %60, align 4, !tbaa !30
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %66

63:                                               ; preds = %58
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 10
  store ptr %64, ptr %65, align 8, !tbaa !31
  br label %66

66:                                               ; preds = %63, %58
  %67 = call noundef ptr @_ZN11ImFontAtlas7AddFontEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1180) %14, ptr noundef %13)
  call void @llvm.lifetime.end.p0(i64 144, ptr %13) #5
  ret ptr %67
}

declare void @_ZN12ImFontConfigC1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 #3 = { 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 = { noreturn nounwind }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !15, i64 24}
!14 = !{!"_ZTS11ImFontAtlas", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !15, i64 24, !6, i64 32, !15, i64 40, !15, i64 41, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !16, i64 72, !16, i64 80, !17, i64 88, !18, i64 104, !19, i64 120, !7, i64 136, !6, i64 1160, !10, i64 1168, !10, i64 1172, !10, i64 1176}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!17 = !{!"_ZTS8ImVectorIP6ImFontE", !10, i64 0, !10, i64 4, !6, i64 8}
!18 = !{!"_ZTS8ImVectorI21ImFontAtlasCustomRectE", !10, i64 0, !10, i64 4, !6, i64 8}
!19 = !{!"_ZTS8ImVectorI12ImFontConfigE", !10, i64 0, !10, i64 4, !6, i64 8}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{i64 0, i64 8, !5, i64 8, i64 4, !9, i64 12, i64 1, !23, i64 16, i64 4, !9, i64 20, i64 4, !11, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 1, !23, i64 36, i64 4, !11, i64 40, i64 4, !11, i64 44, i64 4, !11, i64 48, i64 4, !11, i64 56, i64 8, !5, i64 64, i64 4, !11, i64 68, i64 4, !11, i64 72, i64 1, !23, i64 76, i64 4, !9, i64 80, i64 4, !11, i64 84, i64 4, !11, i64 88, i64 2, !24, i64 90, i64 40, !26, i64 136, i64 8, !5}
!23 = !{!15, !15, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"short", !7, i64 0}
!26 = !{!7, !7, i64 0}
!27 = !{!28, !6, i64 0}
!28 = !{!"_ZTS12ImFontConfig", !6, i64 0, !10, i64 8, !15, i64 12, !10, i64 16, !12, i64 20, !10, i64 24, !10, i64 28, !15, i64 32, !16, i64 36, !16, i64 44, !6, i64 56, !12, i64 64, !12, i64 68, !15, i64 72, !10, i64 76, !12, i64 80, !12, i64 84, !25, i64 88, !7, i64 90, !6, i64 136}
!29 = !{!28, !10, i64 8}
!30 = !{!28, !12, i64 20}
!31 = !{!28, !6, i64 56}


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

%struct.ImFontConfig = type { ptr, i32, i8, i32, float, i32, i32, i8, %struct.ImVec2, %struct.ImVec2, ptr, float, float, i8, i32, float, float, i16, [40 x i8], ptr }
%struct.ImVec2 = type { float, float }

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt = external hidden unnamed_addr constant [101 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [62 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11ImFontAtlas7AddFontEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1180), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(1180) %0, ptr noundef %1, i32 noundef %2, float noundef %3, ptr noundef readonly %4, ptr noundef %5) local_unnamed_addr #3 align 2 {
  %7 = alloca %struct.ImFontConfig, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i8, ptr %8, align 8, !tbaa !5, !range !17, !noundef !18
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.1, i32 noundef 2271, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt) #4
  unreachable

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %7) #5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %14, label %13

13:                                               ; preds = %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(144) %7, ptr noundef nonnull align 8 dereferenceable(144) %4, i64 144, i1 false), !tbaa.struct !19
  br label %15

14:                                               ; preds = %12
  call void @_ZN12ImFontConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(144) %7)
  br label %15

15:                                               ; preds = %14, %13
  %16 = load ptr, ptr %7, align 8, !tbaa !27
  %17 = icmp eq ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 2273, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt) #4
  unreachable

19:                                               ; preds = %15
  %20 = icmp sgt i32 %2, 100
  br i1 %20, label %22, label %21

21:                                               ; preds = %19
  call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.1, i32 noundef 2274, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt) #4
  unreachable

22:                                               ; preds = %19
  store ptr %1, ptr %7, align 8, !tbaa !27
  %23 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %2, ptr %23, align 8, !tbaa !29
  %24 = fcmp ogt float %3, 0.000000e+00
  %25 = getelementptr inbounds i8, ptr %7, i64 20
  %26 = load float, ptr %25, align 4
  %27 = select i1 %24, float %3, float %26
  store float %27, ptr %25, align 4, !tbaa !30
  %.not12 = icmp eq ptr %5, null
  br i1 %.not12, label %30, label %28

28:                                               ; preds = %22
  %29 = getelementptr inbounds i8, ptr %7, i64 56
  store ptr %5, ptr %29, align 8, !tbaa !31
  br label %30

30:                                               ; preds = %28, %22
  %31 = call noundef ptr @_ZN11ImFontAtlas7AddFontEPK12ImFontConfig(ptr noundef nonnull align 8 dereferenceable(1180) %0, ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %7) #5
  ret ptr %31
}

declare void @_ZN12ImFontConfigC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 #3 = { 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 = { noreturn nounwind }
attributes #5 = { 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, !11, i64 24}
!6 = !{!"_ZTS11ImFontAtlas", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !11, i64 24, !10, i64 32, !11, i64 40, !11, i64 41, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 68, !12, i64 72, !12, i64 80, !14, i64 88, !15, i64 104, !16, i64 120, !8, i64 136, !10, i64 1160, !7, i64 1168, !7, i64 1172, !7, i64 1176}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTS6ImVec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTS8ImVectorIP6ImFontE", !7, i64 0, !7, i64 4, !10, i64 8}
!15 = !{!"_ZTS8ImVectorI21ImFontAtlasCustomRectE", !7, i64 0, !7, i64 4, !10, i64 8}
!16 = !{!"_ZTS8ImVectorI12ImFontConfigE", !7, i64 0, !7, i64 4, !10, i64 8}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{i64 0, i64 8, !20, i64 8, i64 4, !21, i64 12, i64 1, !22, i64 16, i64 4, !21, i64 20, i64 4, !23, i64 24, i64 4, !21, i64 28, i64 4, !21, i64 32, i64 1, !22, i64 36, i64 4, !23, i64 40, i64 4, !23, i64 44, i64 4, !23, i64 48, i64 4, !23, i64 56, i64 8, !20, i64 64, i64 4, !23, i64 68, i64 4, !23, i64 72, i64 1, !22, i64 76, i64 4, !21, i64 80, i64 4, !23, i64 84, i64 4, !23, i64 88, i64 2, !24, i64 90, i64 40, !26, i64 136, i64 8, !20}
!20 = !{!10, !10, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!11, !11, i64 0}
!23 = !{!13, !13, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"short", !8, i64 0}
!26 = !{!8, !8, i64 0}
!27 = !{!28, !10, i64 0}
!28 = !{!"_ZTS12ImFontConfig", !10, i64 0, !7, i64 8, !11, i64 12, !7, i64 16, !13, i64 20, !7, i64 24, !7, i64 28, !11, i64 32, !12, i64 36, !12, i64 44, !10, i64 56, !13, i64 64, !13, i64 68, !11, i64 72, !7, i64 76, !13, i64 80, !13, i64 84, !25, i64 88, !8, i64 90, !10, i64 136}
!29 = !{!28, !7, i64 8}
!30 = !{!28, !13, i64 20}
!31 = !{!28, !10, i64 56}


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