; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui/imgui_draw.ll (ZN6ImFont18IsGlyphRangeUnusedEjj)

; 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 <{ %struct.ImVector.6, float, float, %struct.ImVector.1, %struct.ImVector.7, ptr, ptr, ptr, i16, i16, i16, i16, float, float, i8, [3 x i8], float, float, float, i32, [2 x i8], [2 x i8] }>
%struct.ImVector.6 = type { i32, i32, ptr }
%struct.ImVector.1 = type { i32, i32, ptr }
%struct.ImVector.7 = type { i32, i32, 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN6ImFont18IsGlyphRangeUnusedEjj(ptr noundef nonnull align 8 dereferenceable(118) %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = udiv i32 %13, 4096
  store i32 %14, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = udiv i32 %15, 4096
  store i32 %16, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %17 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %17, ptr %10, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %44, %3
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = icmp ule i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %11, align 4
  br label %47

23:                                               ; preds = %18
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = lshr i32 %24, 3
  %26 = zext i32 %25 to i64
  %27 = icmp ult i64 %26, 2
  br i1 %27, label %28, label %43

28:                                               ; preds = %23
  %29 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 20
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = lshr i32 %30, 3
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds [2 x i8], ptr %29, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = zext i8 %34 to i32
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = and i32 %36, 7
  %38 = shl i32 1, %37
  %39 = and i32 %35, %38
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %28
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %47

42:                                               ; preds = %28
  br label %43

43:                                               ; preds = %42, %23
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %10, align 4, !tbaa !9
  br label %18, !llvm.loop !12

47:                                               ; preds = %41, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %48 = load i32, ptr %11, align 4
  switch i32 %48, label %50 [
    i32 2, label %49
  ]

49:                                               ; preds = %47
  store i1 true, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %50

50:                                               ; preds = %49, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %51 = load i1, ptr %4, align 1
  ret i1 %51
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_ZN6ImFont18IsGlyphRangeUnusedEjj(ptr nocapture noundef nonnull readonly align 8 dereferenceable(118) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = lshr i32 %1, 12
  %5 = lshr i32 %2, 12
  %.not15 = icmp ugt i32 %4, %5
  br i1 %.not15, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 116
  br label %7

7:                                                ; preds = %.lr.ph, %18
  %.not17 = phi i1 [ false, %.lr.ph ], [ %.not, %18 ]
  %.01116 = phi i32 [ %4, %.lr.ph ], [ %19, %18 ]
  %8 = icmp ult i32 %.01116, 16
  br i1 %8, label %9, label %18

9:                                                ; preds = %7
  %10 = lshr i32 %.01116, 3
  %11 = zext nneg i32 %10 to i64
  %12 = getelementptr inbounds [2 x i8], ptr %6, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = and i32 %.01116, 7
  %16 = shl nuw nsw i32 1, %15
  %17 = and i32 %16, %14
  %.not14 = icmp eq i32 %17, 0
  br i1 %.not14, label %18, label %.critedge

18:                                               ; preds = %7, %9
  %19 = add nuw nsw i32 %.01116, 1
  %.not = icmp uge i32 %.01116, %5
  %exitcond = icmp eq i32 %.01116, %5
  br i1 %exitcond, label %.critedge, label %7, !llvm.loop !8

.critedge:                                        ; preds = %9, %18, %3
  %.not.lcssa = phi i1 [ true, %3 ], [ %.not, %18 ], [ %.not17, %9 ]
  ret i1 %.not.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass