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

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

@.str.1 = external hidden unnamed_addr constant [122 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__._ZN6ImFont12AddRemapCharEttb = external hidden unnamed_addr constant [50 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 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) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6ImFont9GrowIndexEi(ptr noundef nonnull align 8 dereferenceable(118), i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN8ImVectorIfEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6ImFont12AddRemapCharEttb(ptr noundef nonnull align 8 dereferenceable(118) %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i1 noundef zeroext %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i16 %1, ptr %6, align 2, !tbaa !9
  store i16 %2, ptr %7, align 2, !tbaa !9
  %11 = zext i1 %3 to i8
  store i8 %11, ptr %8, align 1, !tbaa !11
  %12 = load ptr, ptr %5, align 8
  %13 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 3
  %14 = getelementptr inbounds %struct.ImVector.1, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %4
  br label %20

18:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.35, ptr noundef @.str.1, i32 noundef 3322, ptr noundef @__PRETTY_FUNCTION__._ZN6ImFont12AddRemapCharEttb) #4
  unreachable

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19, %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %21 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 3
  %22 = getelementptr inbounds %struct.ImVector.1, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !13
  store i32 %23, ptr %9, align 4, !tbaa !20
  %24 = load i16, ptr %6, align 2, !tbaa !9
  %25 = zext i16 %24 to i32
  %26 = load i32, ptr %9, align 4, !tbaa !20
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %28, label %42

28:                                               ; preds = %20
  %29 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 3
  %30 = getelementptr inbounds %struct.ImVector.1, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = load i16, ptr %6, align 2, !tbaa !9
  %33 = zext i16 %32 to i64
  %34 = getelementptr inbounds i16, ptr %31, i64 %33
  %35 = load i16, ptr %34, align 2, !tbaa !9
  %36 = zext i16 %35 to i32
  %37 = icmp eq i32 %36, 65535
  br i1 %37, label %38, label %42

38:                                               ; preds = %28
  %39 = load i8, ptr %8, align 1, !tbaa !11, !range !22, !noundef !23
  %40 = trunc i8 %39 to i1
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  store i32 1, ptr %10, align 4
  br label %95

42:                                               ; preds = %38, %28, %20
  %43 = load i16, ptr %7, align 2, !tbaa !9
  %44 = zext i16 %43 to i32
  %45 = load i32, ptr %9, align 4, !tbaa !20
  %46 = icmp uge i32 %44, %45
  br i1 %46, label %47, label %53

47:                                               ; preds = %42
  %48 = load i16, ptr %6, align 2, !tbaa !9
  %49 = zext i16 %48 to i32
  %50 = load i32, ptr %9, align 4, !tbaa !20
  %51 = icmp uge i32 %49, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  store i32 1, ptr %10, align 4
  br label %95

53:                                               ; preds = %47, %42
  %54 = load i16, ptr %6, align 2, !tbaa !9
  %55 = zext i16 %54 to i32
  %56 = add nsw i32 %55, 1
  call void @_ZN6ImFont9GrowIndexEi(ptr noundef nonnull align 8 dereferenceable(118) %12, i32 noundef %56)
  %57 = load i16, ptr %7, align 2, !tbaa !9
  %58 = zext i16 %57 to i32
  %59 = load i32, ptr %9, align 4, !tbaa !20
  %60 = icmp ult i32 %58, %59
  br i1 %60, label %61, label %69

61:                                               ; preds = %53
  %62 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 3
  %63 = getelementptr inbounds %struct.ImVector.1, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = load i16, ptr %7, align 2, !tbaa !9
  %66 = zext i16 %65 to i64
  %67 = getelementptr inbounds i16, ptr %64, i64 %66
  %68 = load i16, ptr %67, align 2, !tbaa !9
  br label %70

69:                                               ; preds = %53
  br label %70

70:                                               ; preds = %69, %61
  %71 = phi i16 [ %68, %61 ], [ -1, %69 ]
  %72 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 3
  %73 = load i16, ptr %6, align 2, !tbaa !9
  %74 = zext i16 %73 to i32
  %75 = call noundef nonnull align 2 dereferenceable(2) ptr @_ZN8ImVectorItEixEi(ptr noundef nonnull align 8 dereferenceable(16) %72, i32 noundef %74)
  store i16 %71, ptr %75, align 2, !tbaa !9
  %76 = load i16, ptr %7, align 2, !tbaa !9
  %77 = zext i16 %76 to i32
  %78 = load i32, ptr %9, align 4, !tbaa !20
  %79 = icmp ult i32 %77, %78
  br i1 %79, label %80, label %88

80:                                               ; preds = %70
  %81 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 0
  %82 = getelementptr inbounds %struct.ImVector.6, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !24
  %84 = load i16, ptr %7, align 2, !tbaa !9
  %85 = zext i16 %84 to i64
  %86 = getelementptr inbounds float, ptr %83, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !25
  br label %89

88:                                               ; preds = %70
  br label %89

89:                                               ; preds = %88, %80
  %90 = phi float [ %87, %80 ], [ 1.000000e+00, %88 ]
  %91 = getelementptr inbounds %struct.ImFont, ptr %12, i32 0, i32 0
  %92 = load i16, ptr %6, align 2, !tbaa !9
  %93 = zext i16 %92 to i32
  %94 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8ImVectorIfEixEi(ptr noundef nonnull align 8 dereferenceable(16) %91, i32 noundef %93)
  store float %90, ptr %94, align 4, !tbaa !25
  store i32 0, ptr %10, align 4
  br label %95

95:                                               ; preds = %89, %52, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %96 = load i32, ptr %10, align 4
  switch i32 %96, label %98 [
    i32 0, label %97
    i32 1, label %97
  ]

97:                                               ; preds = %95, %95
  ret void

98:                                               ; preds = %95
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !16, i64 24}
!14 = !{!"_ZTS6ImFont", !15, i64 0, !17, i64 16, !17, i64 20, !18, i64 24, !19, i64 40, !6, i64 56, !6, i64 64, !6, i64 72, !10, i64 80, !10, i64 82, !10, i64 84, !10, i64 86, !17, i64 88, !17, i64 92, !12, i64 96, !17, i64 100, !17, i64 104, !17, i64 108, !16, i64 112, !7, i64 116}
!15 = !{!"_ZTS8ImVectorIfE", !16, i64 0, !16, i64 4, !6, i64 8}
!16 = !{!"int", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!"_ZTS8ImVectorItE", !16, i64 0, !16, i64 4, !6, i64 8}
!19 = !{!"_ZTS8ImVectorI11ImFontGlyphE", !16, i64 0, !16, i64 4, !6, i64 8}
!20 = !{!16, !16, i64 0}
!21 = !{!14, !6, i64 32}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!14, !6, i64 8}
!25 = !{!17, !17, i64 0}


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

@.str.1 = external hidden unnamed_addr constant [122 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__._ZN6ImFont12AddRemapCharEttb = external hidden unnamed_addr constant [50 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6ImFont9GrowIndexEi(ptr noundef nonnull align 8 dereferenceable(118), i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6ImFont12AddRemapCharEttb(ptr noundef nonnull align 8 dereferenceable(118) %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i1 noundef zeroext %3) local_unnamed_addr #2 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %9, label %8

8:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.35, ptr noundef nonnull @.str.1, i32 noundef 3322, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6ImFont12AddRemapCharEttb) #3
  unreachable

9:                                                ; preds = %4
  %10 = zext i16 %1 to i32
  %11 = icmp ugt i32 %6, %10
  br i1 %11, label %12, label %21

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = zext i16 %1 to i64
  %16 = getelementptr inbounds i16, ptr %14, i64 %15
  %17 = load i16, ptr %16, align 2, !tbaa !18
  %18 = icmp ne i16 %17, -1
  %brmerge = or i1 %18, %3
  br i1 %brmerge, label %.thread, label %40

.thread:                                          ; preds = %12
  %19 = zext i16 %2 to i32
  %.not19 = icmp ugt i32 %6, %19
  %20 = add nuw nsw i32 %10, 1
  tail call void @_ZN6ImFont9GrowIndexEi(ptr noundef nonnull align 8 dereferenceable(118) %0, i32 noundef %20)
  br i1 %.not19, label %25, label %.critedge

21:                                               ; preds = %9
  %22 = zext i16 %2 to i32
  %.not = icmp ugt i32 %6, %22
  br i1 %.not, label %23, label %40

23:                                               ; preds = %21
  %24 = add nuw nsw i32 %10, 1
  tail call void @_ZN6ImFont9GrowIndexEi(ptr noundef nonnull align 8 dereferenceable(118) %0, i32 noundef %24)
  br label %25

25:                                               ; preds = %23, %.thread
  %26 = getelementptr inbounds i8, ptr %0, i64 32
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = zext i16 %2 to i64
  %29 = getelementptr inbounds i16, ptr %27, i64 %28
  %30 = load i16, ptr %29, align 2, !tbaa !18
  %31 = tail call noundef nonnull align 2 dereferenceable(2) ptr @_ZN8ImVectorItEixEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %10)
  store i16 %30, ptr %31, align 2, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  %34 = getelementptr inbounds float, ptr %33, i64 %28
  %35 = load float, ptr %34, align 4, !tbaa !20
  br label %37

.critedge:                                        ; preds = %.thread
  %36 = tail call noundef nonnull align 2 dereferenceable(2) ptr @_ZN8ImVectorItEixEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %10)
  store i16 -1, ptr %36, align 2, !tbaa !18
  br label %37

37:                                               ; preds = %.critedge, %25
  %38 = phi float [ %35, %25 ], [ 1.000000e+00, %.critedge ]
  %39 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8ImVectorIfEixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %10)
  store float %38, ptr %39, align 4, !tbaa !20
  br label %40

40:                                               ; preds = %21, %12, %37
  ret void
}

attributes #0 = { 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 #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 = { noreturn 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, !8, i64 24}
!6 = !{!"_ZTS6ImFont", !7, i64 0, !12, i64 16, !12, i64 20, !13, i64 24, !14, i64 40, !11, i64 56, !11, i64 64, !11, i64 72, !15, i64 80, !15, i64 82, !15, i64 84, !15, i64 86, !12, i64 88, !12, i64 92, !16, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !8, i64 112, !9, i64 116}
!7 = !{!"_ZTS8ImVectorIfE", !8, i64 0, !8, i64 4, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!"_ZTS8ImVectorItE", !8, i64 0, !8, i64 4, !11, i64 8}
!14 = !{!"_ZTS8ImVectorI11ImFontGlyphE", !8, i64 0, !8, i64 4, !11, i64 8}
!15 = !{!"short", !9, i64 0}
!16 = !{!"bool", !9, i64 0}
!17 = !{!6, !11, i64 32}
!18 = !{!15, !15, i64 0}
!19 = !{!6, !11, i64 8}
!20 = !{!12, !12, i64 0}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass