; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui (imgui_widgets)

; 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.ImGuiInputTextCallbackData = type { ptr, i32, i32, ptr, i16, i32, ptr, i32, i32, i8, i32, i32, i32 }

@.str.4 = external hidden unnamed_addr constant [125 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN26ImGuiInputTextCallbackData11DeleteCharsEii = external hidden unnamed_addr constant [55 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: mustprogress nounwind uwtable
define dso_local void @_ZN26ImGuiInputTextCallbackData11DeleteCharsEii(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = add nsw i32 %12, %13
  %15 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 7
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp sle i32 %14, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  br label %21

19:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.54, ptr noundef @.str.4, i32 noundef 3850, ptr noundef @__PRETTY_FUNCTION__._ZN26ImGuiInputTextCallbackData11DeleteCharsEii) #3
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %22 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  store ptr %26, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %27 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 6
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %31, i64 %33
  store ptr %34, ptr %8, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %48, %21
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i32 1
  store ptr %37, ptr %8, align 8, !tbaa !5
  %38 = load i8, ptr %36, align 1, !tbaa !17
  store i8 %38, ptr %9, align 1, !tbaa !17
  %39 = load i8, ptr %9, align 1, !tbaa !17
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  store i32 3, ptr %10, align 4
  br label %46

42:                                               ; preds = %35
  %43 = load i8, ptr %9, align 1, !tbaa !17
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %7, align 8, !tbaa !5
  store i8 %43, ptr %44, align 1, !tbaa !17
  store i32 0, ptr %10, align 4
  br label %46

46:                                               ; preds = %42, %41
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  %47 = load i32, ptr %10, align 4
  switch i32 %47, label %81 [
    i32 0, label %48
    i32 3, label %49
  ]

48:                                               ; preds = %46
  br label %35, !llvm.loop !18

49:                                               ; preds = %46
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %50, align 1, !tbaa !17
  %51 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 10
  %52 = load i32, ptr %51, align 4, !tbaa !20
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = add nsw i32 %53, %54
  %56 = icmp sge i32 %52, %55
  br i1 %56, label %57, label %62

57:                                               ; preds = %49
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 10
  %60 = load i32, ptr %59, align 4, !tbaa !20
  %61 = sub nsw i32 %60, %58
  store i32 %61, ptr %59, align 4, !tbaa !20
  br label %71

62:                                               ; preds = %49
  %63 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 10
  %64 = load i32, ptr %63, align 4, !tbaa !20
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = icmp sge i32 %64, %65
  br i1 %66, label %67, label %70

67:                                               ; preds = %62
  %68 = load i32, ptr %5, align 4, !tbaa !9
  %69 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 10
  store i32 %68, ptr %69, align 4, !tbaa !20
  br label %70

70:                                               ; preds = %67, %62
  br label %71

71:                                               ; preds = %70, %57
  %72 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 10
  %73 = load i32, ptr %72, align 4, !tbaa !20
  %74 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 12
  store i32 %73, ptr %74, align 4, !tbaa !21
  %75 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 11
  store i32 %73, ptr %75, align 8, !tbaa !22
  %76 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 9
  store i8 1, ptr %76, align 8, !tbaa !23
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = getelementptr inbounds %struct.ImGuiInputTextCallbackData, ptr %11, i32 0, i32 7
  %79 = load i32, ptr %78, align 8, !tbaa !11
  %80 = sub nsw i32 %79, %77
  store i32 %80, ptr %78, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void

81:                                               ; preds = %46
  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 = { 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 = { noreturn nounwind }
attributes #4 = { 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, !10, i64 40}
!12 = !{!"_ZTS26ImGuiInputTextCallbackData", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !13, i64 24, !14, i64 28, !6, i64 32, !10, i64 40, !10, i64 44, !15, i64 48, !10, i64 52, !10, i64 56, !10, i64 60}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTS8ImGuiKey", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!12, !6, i64 32}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !10, i64 52}
!21 = !{!12, !10, i64 60}
!22 = !{!12, !10, i64 56}
!23 = !{!12, !15, i64 48}


; 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.4 = external hidden unnamed_addr constant [125 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN26ImGuiInputTextCallbackData11DeleteCharsEii = external hidden unnamed_addr constant [55 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: mustprogress nounwind uwtable
define dso_local void @_ZN26ImGuiInputTextCallbackData11DeleteCharsEii(ptr nocapture noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = add nsw i32 %2, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp sgt i32 %4, %6
  br i1 %.not, label %7, label %8

7:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.54, ptr noundef nonnull @.str.4, i32 noundef 3850, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN26ImGuiInputTextCallbackData11DeleteCharsEii) #2
  unreachable

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = sext i32 %1 to i64
  %12 = getelementptr inbounds i8, ptr %10, i64 %11
  %13 = sext i32 %2 to i64
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !15
  %.not2431 = icmp eq i8 %15, 0
  br i1 %.not2431, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8, %.lr.ph
  %16 = phi i8 [ %19, %.lr.ph ], [ %15, %8 ]
  %.01733 = phi ptr [ %18, %.lr.ph ], [ %12, %8 ]
  %.01832 = phi ptr [ %17, %.lr.ph ], [ %14, %8 ]
  %17 = getelementptr inbounds i8, ptr %.01832, i64 1
  %18 = getelementptr inbounds i8, ptr %.01733, i64 1
  store i8 %16, ptr %.01733, align 1, !tbaa !15
  %19 = load i8, ptr %17, align 1, !tbaa !15
  %.not24 = icmp eq i8 %19, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %8
  %.017.lcssa = phi ptr [ %12, %8 ], [ %18, %.lr.ph ]
  store i8 0, ptr %.017.lcssa, align 1, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %0, i64 52
  %21 = load i32, ptr %20, align 4, !tbaa !16
  %.not25 = icmp slt i32 %21, %4
  br i1 %.not25, label %24, label %22

22:                                               ; preds = %._crit_edge
  %23 = sub nsw i32 %21, %2
  br label %.sink.split

24:                                               ; preds = %._crit_edge
  %.not26 = icmp slt i32 %21, %1
  br i1 %.not26, label %25, label %.sink.split

.sink.split:                                      ; preds = %24, %22
  %.sink = phi i32 [ %23, %22 ], [ %1, %24 ]
  store i32 %.sink, ptr %20, align 4, !tbaa !16
  br label %25

25:                                               ; preds = %.sink.split, %24
  %26 = phi i32 [ %21, %24 ], [ %.sink, %.sink.split ]
  %27 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %26, ptr %27, align 4, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %26, ptr %28, align 8, !tbaa !18
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  store i8 1, ptr %29, align 8, !tbaa !19
  %30 = load i32, ptr %5, align 8, !tbaa !5
  %31 = sub nsw i32 %30, %2
  store i32 %31, ptr %5, align 8, !tbaa !5
  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 = { 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 = { 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, !10, i64 40}
!6 = !{!"_ZTS26ImGuiInputTextCallbackData", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !11, i64 24, !12, i64 28, !7, i64 32, !10, i64 40, !10, i64 44, !13, i64 48, !10, i64 52, !10, i64 56, !10, i64 60}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"_ZTS8ImGuiKey", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!6, !7, i64 32}
!15 = !{!8, !8, i64 0}
!16 = !{!6, !10, i64 52}
!17 = !{!6, !10, i64 60}
!18 = !{!6, !10, i64 56}
!19 = !{!6, !13, i64 48}


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