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

; 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.ImFont = type { float, float, %struct.ImVec2, i16, ptr, %class.ImVector.16, ptr, float, %class.ImVector.10, %class.ImVector.17 }
%struct.ImVec2 = type { float, float }
%class.ImVector.16 = type { i64, i64, ptr }
%class.ImVector.10 = type { i64, i64, ptr }
%class.ImVector.17 = type { i64, i64, 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: mustprogress uwtable
define dso_local noundef ptr @_ZNK6ImFont9FindGlyphEt(ptr noundef nonnull align 8 dereferenceable(120) %0, i16 noundef zeroext %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = load i16, ptr %5, align 2, !tbaa !9
  %10 = zext i16 %9 to i32
  %11 = getelementptr inbounds %struct.ImFont, ptr %8, i32 0, i32 9
  %12 = call noundef i64 @_ZNK8ImVectorIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = trunc i64 %12 to i32
  %14 = icmp slt i32 %10, %13
  br i1 %14, label %15, label %32

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %16 = getelementptr inbounds %struct.ImFont, ptr %8, i32 0, i32 9
  %17 = load i16, ptr %5, align 2, !tbaa !9
  %18 = zext i16 %17 to i64
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8ImVectorIiEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %18)
  %20 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %20, ptr %6, align 4, !tbaa !11
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = icmp ne i32 %21, -1
  br i1 %22, label %23, label %28

23:                                               ; preds = %15
  %24 = getelementptr inbounds %struct.ImFont, ptr %8, i32 0, i32 5
  %25 = load i32, ptr %6, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 4 dereferenceable(28) ptr @_ZNK8ImVectorIN6ImFont5GlyphEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %26)
  store ptr %27, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %29

28:                                               ; preds = %15
  store i32 0, ptr %7, align 4
  br label %29

29:                                               ; preds = %28, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %30 = load i32, ptr %7, align 4
  switch i32 %30, label %37 [
    i32 0, label %31
    i32 1, label %35
  ]

31:                                               ; preds = %29
  br label %32

32:                                               ; preds = %31, %2
  %33 = getelementptr inbounds %struct.ImFont, ptr %8, i32 0, i32 6
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  store ptr %34, ptr %3, align 8
  br label %35

35:                                               ; preds = %32, %29
  %36 = load ptr, ptr %3, align 8
  ret ptr %36

37:                                               ; preds = %29
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK8ImVectorIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8ImVectorIiEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(28) ptr @_ZNK8ImVectorIN6ImFont5GlyphEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 56}
!14 = !{!"_ZTS6ImFont", !15, i64 0, !15, i64 4, !16, i64 8, !10, i64 16, !6, i64 24, !17, i64 32, !6, i64 56, !15, i64 64, !19, i64 72, !20, i64 96}
!15 = !{!"float", !7, i64 0}
!16 = !{!"_ZTS6ImVec2", !15, i64 0, !15, i64 4}
!17 = !{!"_ZTS8ImVectorIN6ImFont5GlyphEE", !18, i64 0, !18, i64 8, !6, i64 16}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS8ImVectorIfE", !18, i64 0, !18, i64 8, !6, i64 16}
!20 = !{!"_ZTS8ImVectorIiE", !18, i64 0, !18, i64 8, !6, i64 16}


; 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 nounwind uwtable
define dso_local noundef ptr @_ZNK6ImFont9FindGlyphEt(ptr noundef nonnull align 8 dereferenceable(120) %0, i16 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = zext i16 %1 to i32
  %4 = getelementptr inbounds i8, ptr %0, i64 96
  %5 = tail call noundef i64 @_ZNK8ImVectorIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %6 = trunc i64 %5 to i32
  %7 = icmp slt i32 %3, %6
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %2
  %9 = zext i16 %1 to i64
  %10 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8ImVectorIiEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %9)
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %.not.not = icmp eq i32 %11, -1
  br i1 %.not.not, label %.thread, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = sext i32 %11 to i64
  %15 = tail call noundef nonnull align 4 dereferenceable(28) ptr @_ZNK8ImVectorIN6ImFont5GlyphEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %14)
  br label %18

.thread:                                          ; preds = %8, %2
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %12, %.thread
  %.1 = phi ptr [ %15, %12 ], [ %17, %.thread ]
  ret ptr %.1
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK8ImVectorIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8ImVectorIiEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(28) ptr @_ZNK8ImVectorIN6ImFont5GlyphEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !14, i64 56}
!10 = !{!"_ZTS6ImFont", !11, i64 0, !11, i64 4, !12, i64 8, !13, i64 16, !14, i64 24, !15, i64 32, !14, i64 56, !11, i64 64, !17, i64 72, !18, i64 96}
!11 = !{!"float", !7, i64 0}
!12 = !{!"_ZTS6ImVec2", !11, i64 0, !11, i64 4}
!13 = !{!"short", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"_ZTS8ImVectorIN6ImFont5GlyphEE", !16, i64 0, !16, i64 8, !14, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTS8ImVectorIfE", !16, i64 0, !16, i64 8, !14, i64 16}
!18 = !{!"_ZTS8ImVectorIiE", !16, i64 0, !16, i64 8, !14, i64 16}


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