; LLVM IR from xhub/reshop :: gui/external/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.ImGuiInputTextState = type <{ ptr, ptr, i32, i32, i32, [4 x i8], ptr, %struct.ImVector.34, %struct.ImVector.34, %struct.ImVector.34, i32, %struct.ImVec2, float, i8, i8, i8, i8, i32, i32, [4 x i8] }>
%struct.ImVector.34 = type { i32, i32, ptr }
%struct.ImVec2 = type { float, float }
%"struct.ImStb::STB_TexteditState" = type { i32, i32, i32, i8, i32, i8, i8, i8, i8, i8, i8, i8, float, %"struct.ImStb::StbUndoState" }
%"struct.ImStb::StbUndoState" = type { [99 x %"struct.ImStb::StbUndoRecord"], [999 x i8], i16, i16, i32, i32 }
%"struct.ImStb::StbUndoRecord" = type { i32, i32, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN19ImGuiInputTextState29ReloadUserBufAndKeepSelectionEv(ptr noundef nonnull align 8 dereferenceable(116) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %struct.ImGuiInputTextState, ptr %3, i32 0, i32 16
  store i8 1, ptr %4, align 1, !tbaa !9
  %5 = getelementptr inbounds %struct.ImGuiInputTextState, ptr %3, i32 0, i32 1
  %6 = load ptr, ptr %5, align 8, !tbaa !16
  %7 = getelementptr inbounds %"struct.ImStb::STB_TexteditState", ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 4, !tbaa !17
  %9 = getelementptr inbounds %struct.ImGuiInputTextState, ptr %3, i32 0, i32 17
  store i32 %8, ptr %9, align 4, !tbaa !21
  %10 = getelementptr inbounds %struct.ImGuiInputTextState, ptr %3, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = getelementptr inbounds %"struct.ImStb::STB_TexteditState", ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 4, !tbaa !22
  %14 = getelementptr inbounds %struct.ImGuiInputTextState, ptr %3, i32 0, i32 18
  store i32 %13, ptr %14, align 8, !tbaa !23
  ret void
}

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

!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, !15, i64 107}
!10 = !{!"_ZTS19ImGuiInputTextState", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !12, i64 40, !12, i64 56, !12, i64 72, !11, i64 88, !13, i64 92, !14, i64 100, !15, i64 104, !15, i64 105, !15, i64 106, !15, i64 107, !11, i64 108, !11, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS8ImVectorIcE", !11, i64 0, !11, i64 4, !6, i64 8}
!13 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!10, !6, i64 8}
!17 = !{!18, !11, i64 4}
!18 = !{!"_ZTSN5ImStb17STB_TexteditStateE", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !11, i64 16, !7, i64 20, !7, i64 21, !7, i64 22, !7, i64 23, !7, i64 24, !7, i64 25, !7, i64 26, !14, i64 28, !19, i64 32}
!19 = !{!"_ZTSN5ImStb12StbUndoStateE", !7, i64 0, !7, i64 1584, !20, i64 2584, !20, i64 2586, !11, i64 2588, !11, i64 2592}
!20 = !{!"short", !7, i64 0}
!21 = !{!10, !11, i64 108}
!22 = !{!18, !11, i64 8}
!23 = !{!10, !11, i64 112}


; 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(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN19ImGuiInputTextState29ReloadUserBufAndKeepSelectionEv(ptr nocapture noundef nonnull align 8 dereferenceable(116) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 107
  store i8 1, ptr %2, align 1, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !15
  %5 = getelementptr inbounds i8, ptr %4, i64 4
  %6 = getelementptr inbounds i8, ptr %0, i64 108
  %7 = load <2 x i32>, ptr %5, align 4, !tbaa !16
  store <2 x i32> %7, ptr %6, align 4, !tbaa !16
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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, !14, i64 107}
!6 = !{!"_ZTS19ImGuiInputTextState", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !11, i64 40, !11, i64 56, !11, i64 72, !10, i64 88, !12, i64 92, !13, i64 100, !14, i64 104, !14, i64 105, !14, i64 106, !14, i64 107, !10, i64 108, !10, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS8ImVectorIcE", !10, i64 0, !10, i64 4, !7, i64 8}
!12 = !{!"_ZTS6ImVec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass