; LLVM IR from cieslarmichal/rpg :: src/Menu.ll (ZN4Menu6eventsEv)

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

%class.Menu = type { ptr, %"class.sf::Event", %"class.sf::Font", [3 x %"class.sf::Text"], i32, i32 }
%"class.sf::Event" = type { i32, %union.anon }
%union.anon = type { %"struct.sf::Event::MouseWheelScrollEvent" }
%"struct.sf::Event::MouseWheelScrollEvent" = type { i32, float, i32, i32 }
%"class.sf::Font" = type { ptr, ptr, ptr, ptr, ptr, %"struct.sf::Font::Info", %"class.std::map", %"class.std::vector" }
%"struct.sf::Font::Info" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.0 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.0 = type { i64, [8 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned int, std::pair<const unsigned int, sf::Font::Page>, std::_Select1st<std::pair<const unsigned int, sf::Font::Page>>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, std::pair<const unsigned int, sf::Font::Page>, std::_Select1st<std::pair<const unsigned int, sf::Font::Page>>, std::less<unsigned int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.sf::Text" = type { %"class.sf::Drawable", %"class.sf::Transformable.base", %"class.sf::String", ptr, i32, float, float, i32, %"class.sf::Color", %"class.sf::Color", float, [4 x i8], %"class.sf::VertexArray", %"class.sf::VertexArray", %"class.sf::Rect", i8, i64 }
%"class.sf::Drawable" = type { ptr }
%"class.sf::Transformable.base" = type <{ ptr, %"class.sf::Vector2", %"class.sf::Vector2", float, %"class.sf::Vector2", %"class.sf::Transform", i8, [3 x i8], %"class.sf::Transform", i8 }>
%"class.sf::Vector2" = type { float, float }
%"class.sf::Transform" = type { [16 x float] }
%"class.sf::String" = type { %"class.std::__cxx11::basic_string.7" }
%"class.std::__cxx11::basic_string.7" = type { %"struct.std::__cxx11::basic_string<unsigned int>::_Alloc_hider", i64, %union.anon.11 }
%"struct.std::__cxx11::basic_string<unsigned int>::_Alloc_hider" = type { ptr }
%union.anon.11 = type { i64, [8 x i8] }
%"class.sf::Color" = type { i8, i8, i8, i8 }
%"class.sf::VertexArray" = type <{ %"class.sf::Drawable", %"class.std::vector.12", i32, [4 x i8] }>
%"class.std::vector.12" = type { %"struct.std::_Vector_base.13" }
%"struct.std::_Vector_base.13" = type { %"struct.std::_Vector_base<sf::Vertex, std::allocator<sf::Vertex>>::_Vector_impl" }
%"struct.std::_Vector_base<sf::Vertex, std::allocator<sf::Vertex>>::_Vector_impl" = type { %"struct.std::_Vector_base<sf::Vertex, std::allocator<sf::Vertex>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sf::Vertex, std::allocator<sf::Vertex>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.sf::Rect" = type { float, float, float, float }
%"struct.sf::Event::KeyEvent" = type { i32, i8, i8, i8, i8 }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4Menu6eventsEv(ptr noundef nonnull align 8 dereferenceable(1288) %0) #0 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  br label %5

5:                                                ; preds = %29, %1
  %6 = getelementptr inbounds %class.Menu, ptr %4, i32 0, i32 0
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %class.Menu, ptr %4, i32 0, i32 1
  %9 = call noundef zeroext i1 @_ZN2sf6Window9pollEventERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(48) %7, ptr noundef nonnull align 4 dereferenceable(20) %8)
  br i1 %9, label %10, label %30

10:                                               ; preds = %5
  %11 = getelementptr inbounds %class.Menu, ptr %4, i32 0, i32 1
  %12 = getelementptr inbounds %"class.sf::Event", ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !31
  switch i32 %13, label %29 [
    i32 6, label %14
    i32 0, label %26
  ]

14:                                               ; preds = %10
  %15 = getelementptr inbounds %class.Menu, ptr %4, i32 0, i32 1
  %16 = getelementptr inbounds %"class.sf::Event", ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds %"struct.sf::Event::KeyEvent", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !32
  switch i32 %18, label %25 [
    i32 73, label %19
    i32 74, label %20
    i32 36, label %21
    i32 58, label %24
  ]

19:                                               ; preds = %14
  call void @_ZN4Menu13currentItemUpEv(ptr noundef nonnull align 8 dereferenceable(1288) %4)
  br label %25

20:                                               ; preds = %14
  call void @_ZN4Menu15currentItemDownEv(ptr noundef nonnull align 8 dereferenceable(1288) %4)
  br label %25

21:                                               ; preds = %14
  %22 = getelementptr inbounds %class.Menu, ptr %4, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  call void @_ZN2sf6Window5closeEv(ptr noundef nonnull align 8 dereferenceable(48) %23)
  store i32 0, ptr %2, align 4
  br label %31

24:                                               ; preds = %14
  store i32 1, ptr %2, align 4
  br label %31

25:                                               ; preds = %20, %19, %14
  br label %29

26:                                               ; preds = %10
  %27 = getelementptr inbounds %class.Menu, ptr %4, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  call void @_ZN2sf6Window5closeEv(ptr noundef nonnull align 8 dereferenceable(48) %28)
  store i32 0, ptr %2, align 4
  br label %31

29:                                               ; preds = %25, %10
  br label %5, !llvm.loop !33

30:                                               ; preds = %5
  store i32 -1, ptr %2, align 4
  br label %31

31:                                               ; preds = %30, %26, %24, %21
  %32 = load i32, ptr %2, align 4
  ret i32 %32
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Menu13currentItemUpEv(ptr noundef nonnull align 8 dereferenceable(1288)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Menu15currentItemDownEv(ptr noundef nonnull align 8 dereferenceable(1288)) #1 align 2

declare noundef zeroext i1 @_ZN2sf6Window9pollEventERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(20)) #2

declare void @_ZN2sf6Window5closeEv(ptr noundef nonnull align 8 dereferenceable(48)) #2

attributes #0 = { 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 #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 = { "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, !6, i64 0}
!10 = !{!"_ZTS4Menu", !6, i64 0, !11, i64 8, !13, i64 32, !7, i64 176, !30, i64 1280, !30, i64 1284}
!11 = !{!"_ZTSN2sf5EventE", !12, i64 0, !7, i64 4}
!12 = !{!"_ZTSN2sf5Event9EventTypeE", !7, i64 0}
!13 = !{!"_ZTSN2sf4FontE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !18, i64 72, !26, i64 120}
!14 = !{!"_ZTSN2sf4Font4InfoE", !15, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSSt3mapIjN2sf4Font4PageESt4lessIjESaISt4pairIKjS2_EEE", !19, i64 0}
!19 = !{!"_ZTSSt8_Rb_treeIjSt4pairIKjN2sf4Font4PageEESt10_Select1stIS5_ESt4lessIjESaIS5_EE", !20, i64 0}
!20 = !{!"_ZTSNSt8_Rb_treeIjSt4pairIKjN2sf4Font4PageEESt10_Select1stIS5_ESt4lessIjESaIS5_EE13_Rb_tree_implIS9_Lb1EEE", !21, i64 0, !23, i64 8}
!21 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIjEE", !22, i64 0}
!22 = !{!"_ZTSSt4lessIjE"}
!23 = !{!"_ZTSSt15_Rb_tree_header", !24, i64 0, !17, i64 32}
!24 = !{!"_ZTSSt18_Rb_tree_node_base", !25, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!26 = !{!"_ZTSSt6vectorIhSaIhEE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!30 = !{!"int", !7, i64 0}
!31 = !{!10, !12, i64 8}
!32 = !{!7, !7, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"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 uwtable
define dso_local noundef range(i32 -1, 2) i32 @_ZN4Menu6eventsEv(ptr noundef nonnull align 8 dereferenceable(1288) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = tail call noundef zeroext i1 @_ZN2sf6Window9pollEventERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 4 dereferenceable(20) %2)
  br i1 %4, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  br label %6

6:                                                ; preds = %.lr.ph, %12
  %7 = load i32, ptr %2, align 8, !tbaa !30
  switch i32 %7, label %12 [
    i32 6, label %8
    i32 0, label %.loopexit.sink.split
  ]

8:                                                ; preds = %6
  %9 = load i32, ptr %5, align 4, !tbaa !31
  switch i32 %9, label %12 [
    i32 73, label %10
    i32 74, label %11
    i32 36, label %.loopexit.sink.split
    i32 58, label %.loopexit
  ]

10:                                               ; preds = %8
  tail call void @_ZN4Menu13currentItemUpEv(ptr noundef nonnull align 8 dereferenceable(1288) %0)
  br label %12

11:                                               ; preds = %8
  tail call void @_ZN4Menu15currentItemDownEv(ptr noundef nonnull align 8 dereferenceable(1288) %0)
  br label %12

12:                                               ; preds = %8, %10, %11, %6
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = tail call noundef zeroext i1 @_ZN2sf6Window9pollEventERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(48) %13, ptr noundef nonnull align 4 dereferenceable(20) %2)
  br i1 %14, label %6, label %.loopexit, !llvm.loop !32

.loopexit.sink.split:                             ; preds = %6, %8
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @_ZN2sf6Window5closeEv(ptr noundef nonnull align 8 dereferenceable(48) %15)
  br label %.loopexit

.loopexit:                                        ; preds = %8, %12, %.loopexit.sink.split, %1
  %.0 = phi i32 [ -1, %1 ], [ 0, %.loopexit.sink.split ], [ 1, %8 ], [ -1, %12 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Menu13currentItemUpEv(ptr noundef nonnull align 8 dereferenceable(1288)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Menu15currentItemDownEv(ptr noundef nonnull align 8 dereferenceable(1288)) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZN2sf6Window9pollEventERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(20)) local_unnamed_addr #2

declare void @_ZN2sf6Window5closeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2

attributes #0 = { 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 #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 = { "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, !7, i64 0}
!6 = !{!"_ZTS4Menu", !7, i64 0, !10, i64 8, !12, i64 32, !8, i64 176, !29, i64 1280, !29, i64 1284}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN2sf5EventE", !11, i64 0, !8, i64 4}
!11 = !{!"_ZTSN2sf5Event9EventTypeE", !8, i64 0}
!12 = !{!"_ZTSN2sf4FontE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !13, i64 40, !17, i64 72, !25, i64 120}
!13 = !{!"_ZTSN2sf4Font4InfoE", !14, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !8, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !7, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!"_ZTSSt3mapIjN2sf4Font4PageESt4lessIjESaISt4pairIKjS2_EEE", !18, i64 0}
!18 = !{!"_ZTSSt8_Rb_treeIjSt4pairIKjN2sf4Font4PageEESt10_Select1stIS5_ESt4lessIjESaIS5_EE", !19, i64 0}
!19 = !{!"_ZTSNSt8_Rb_treeIjSt4pairIKjN2sf4Font4PageEESt10_Select1stIS5_ESt4lessIjESaIS5_EE13_Rb_tree_implIS9_Lb1EEE", !20, i64 0, !22, i64 8}
!20 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIjEE", !21, i64 0}
!21 = !{!"_ZTSSt4lessIjE"}
!22 = !{!"_ZTSSt15_Rb_tree_header", !23, i64 0, !16, i64 32}
!23 = !{!"_ZTSSt18_Rb_tree_node_base", !24, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!24 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!25 = !{!"_ZTSSt6vectorIhSaIhEE", !26, i64 0}
!26 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!29 = !{!"int", !8, i64 0}
!30 = !{!6, !11, i64 8}
!31 = !{!8, !8, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass