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

; 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 <{ 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.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 }
%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 }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN8ImVectorI12ImFontConfigE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z20ImFontAtlasBuildInitP11ImFontAtlas(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ImFontAtlas, ptr %7, i32 0, i32 19
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef ptr @_ZN8ImVectorI12ImFontConfigE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  store ptr %10, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call noundef ptr @_ZN8ImVectorI12ImFontConfigE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  store ptr %12, ptr %5, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %26, %1
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %29

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImFontConfig, ptr %20, i32 0, i32 4
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = call noundef float @_ZL7ImTruncf(float noundef %22)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ImFontConfig, ptr %24, i32 0, i32 4
  store float %23, ptr %25, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %26

26:                                               ; preds = %18
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ImFontConfig, ptr %27, i32 1
  store ptr %28, ptr %4, align 8, !tbaa !5
  br label %13

29:                                               ; preds = %17
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ImFontAtlas, ptr %30, i32 0, i32 23
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %51

34:                                               ; preds = %29
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ImFontAtlas, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !21
  %38 = and i32 %37, 2
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %45, label %40

40:                                               ; preds = %34
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = call noundef i32 @_ZN11ImFontAtlas20AddCustomRectRegularEii(ptr noundef nonnull align 8 dereferenceable(1180) %41, i32 noundef 245, i32 noundef 27)
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ImFontAtlas, ptr %43, i32 0, i32 23
  store i32 %42, ptr %44, align 4, !tbaa !16
  br label %50

45:                                               ; preds = %34
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = call noundef i32 @_ZN11ImFontAtlas20AddCustomRectRegularEii(ptr noundef nonnull align 8 dereferenceable(1180) %46, i32 noundef 2, i32 noundef 2)
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ImFontAtlas, ptr %48, i32 0, i32 23
  store i32 %47, ptr %49, align 4, !tbaa !16
  br label %50

50:                                               ; preds = %45, %40
  br label %51

51:                                               ; preds = %50, %29
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ImFontAtlas, ptr %52, i32 0, i32 24
  %54 = load i32, ptr %53, align 8, !tbaa !22
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %56, label %68

56:                                               ; preds = %51
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ImFontAtlas, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !21
  %60 = and i32 %59, 4
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %67, label %62

62:                                               ; preds = %56
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = call noundef i32 @_ZN11ImFontAtlas20AddCustomRectRegularEii(ptr noundef nonnull align 8 dereferenceable(1180) %63, i32 noundef 65, i32 noundef 64)
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ImFontAtlas, ptr %65, i32 0, i32 24
  store i32 %64, ptr %66, align 8, !tbaa !22
  br label %67

67:                                               ; preds = %62, %56
  br label %68

68:                                               ; preds = %67, %51
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL7ImTruncf(float noundef) #1

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


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN8ImVectorI12ImFontConfigE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z20ImFontAtlasBuildInitP11ImFontAtlas(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 120
  %3 = tail call noundef ptr @_ZN8ImVectorI12ImFontConfigE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %4 = tail call noundef ptr @_ZN8ImVectorI12ImFontConfigE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %.not21 = icmp eq ptr %3, %4
  br i1 %.not21, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 1172
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %12, label %19

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.022 = phi ptr [ %11, %.lr.ph ], [ %3, %1 ]
  %8 = getelementptr inbounds i8, ptr %.022, i64 20
  %9 = load float, ptr %8, align 4, !tbaa !17
  %10 = tail call noundef float @_ZL7ImTruncf(float noundef %9)
  store float %10, ptr %8, align 4, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %.022, i64 144
  %.not = icmp eq ptr %11, %4
  br i1 %.not, label %._crit_edge, label %.lr.ph

12:                                               ; preds = %._crit_edge
  %13 = load i32, ptr %0, align 8, !tbaa !20
  %14 = and i32 %13, 2
  %.not19 = icmp eq i32 %14, 0
  br i1 %.not19, label %15, label %17

15:                                               ; preds = %12
  %16 = tail call noundef i32 @_ZN11ImFontAtlas20AddCustomRectRegularEii(ptr noundef nonnull align 8 dereferenceable(1180) %0, i32 noundef 245, i32 noundef 27)
  br label %.sink.split

17:                                               ; preds = %12
  %18 = tail call noundef i32 @_ZN11ImFontAtlas20AddCustomRectRegularEii(ptr noundef nonnull align 8 dereferenceable(1180) %0, i32 noundef 2, i32 noundef 2)
  br label %.sink.split

.sink.split:                                      ; preds = %17, %15
  %.sink = phi i32 [ %16, %15 ], [ %18, %17 ]
  store i32 %.sink, ptr %5, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %.sink.split, %._crit_edge
  %20 = getelementptr inbounds i8, ptr %0, i64 1176
  %21 = load i32, ptr %20, align 8, !tbaa !21
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = load i32, ptr %0, align 8, !tbaa !20
  %25 = and i32 %24, 4
  %.not20 = icmp eq i32 %25, 0
  br i1 %.not20, label %26, label %28

26:                                               ; preds = %23
  %27 = tail call noundef i32 @_ZN11ImFontAtlas20AddCustomRectRegularEii(ptr noundef nonnull align 8 dereferenceable(1180) %0, i32 noundef 65, i32 noundef 64)
  store i32 %27, ptr %20, align 8, !tbaa !21
  br label %28

28:                                               ; preds = %23, %26, %19
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL7ImTruncf(float noundef) local_unnamed_addr #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 = { 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" }

!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, !7, i64 1172}
!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 = !{!18, !13, i64 20}
!18 = !{!"_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, !19, i64 88, !8, i64 90, !10, i64 136}
!19 = !{!"short", !8, i64 0}
!20 = !{!6, !7, i64 0}
!21 = !{!6, !7, i64 1176}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass