; LLVM IR from VTIvanov20/eight-ball-pool :: src/settings_menu.ll (ZN12SettingsMenu6UpdateEv)

; 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.std::_List_iterator" = type { ptr }
%class.SettingsMenu = type { %"class.DrawableManager::Drawable.base", %"class.std::__cxx11::list" }
%"class.DrawableManager::Drawable.base" = type <{ ptr, i32 }>
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<UIElement *, std::allocator<UIElement *>>::_List_impl" }
%"struct.std::__cxx11::_List_base<UIElement *, std::allocator<UIElement *>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, 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

declare zeroext i1 @IsWindowFullscreen() #1

declare noundef zeroext i1 @_ZN11GameManager9IsAudioOnEv() #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12SettingsMenu6UpdateEv(ptr noundef nonnull align 8 dereferenceable(40) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.std::_List_iterator", align 8
  %6 = alloca %"struct.std::_List_iterator", align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %9 = getelementptr inbounds %class.SettingsMenu, ptr %8, i32 0, i32 1
  store ptr %9, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  %12 = getelementptr inbounds %"struct.std::_List_iterator", ptr %5, i32 0, i32 0
  store ptr %11, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #4
  %15 = getelementptr inbounds %"struct.std::_List_iterator", ptr %6, i32 0, i32 0
  store ptr %14, ptr %15, align 8
  br label %16

16:                                               ; preds = %63, %1
  %17 = call noundef zeroext i1 @_ZStneRKSt14_List_iteratorIP9UIElementES4_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  br i1 %17, label %19, label %18

18:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %65

19:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14_List_iteratorIP9UIElementEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load i32, ptr %3, align 4, !tbaa !9
  switch i32 %21, label %60 [
    i32 0, label %22
    i32 1, label %28
    i32 2, label %44
  ]

22:                                               ; preds = %19
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = call noundef zeroext i1 @_ZN6Button9IsClickedEv(ptr noundef nonnull align 8 dereferenceable(112) %24)
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  call void @_ZN11GameManager11ChangeSceneENS_5SceneE(i32 noundef 0)
  br label %27

27:                                               ; preds = %26, %22
  br label %60

28:                                               ; preds = %19
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %30)
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  %33 = call zeroext i1 @IsWindowFullscreen()
  br i1 %33, label %35, label %34

34:                                               ; preds = %32
  call void @ToggleFullscreen()
  br label %43

35:                                               ; preds = %32, %28
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %37)
  br i1 %38, label %42, label %39

39:                                               ; preds = %35
  %40 = call zeroext i1 @IsWindowFullscreen()
  br i1 %40, label %41, label %42

41:                                               ; preds = %39
  call void @ToggleFullscreen()
  br label %42

42:                                               ; preds = %41, %39, %35
  br label %43

43:                                               ; preds = %42, %34
  br label %60

44:                                               ; preds = %19
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %46)
  br i1 %47, label %48, label %51

48:                                               ; preds = %44
  %49 = call noundef zeroext i1 @_ZN11GameManager9IsAudioOnEv()
  br i1 %49, label %51, label %50

50:                                               ; preds = %48
  call void @_ZN11GameManager11ToggleAudioEv()
  br label %59

51:                                               ; preds = %48, %44
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %53)
  br i1 %54, label %58, label %55

55:                                               ; preds = %51
  %56 = call noundef zeroext i1 @_ZN11GameManager9IsAudioOnEv()
  br i1 %56, label %57, label %58

57:                                               ; preds = %55
  call void @_ZN11GameManager11ToggleAudioEv()
  br label %58

58:                                               ; preds = %57, %55, %51
  br label %59

59:                                               ; preds = %58, %50
  br label %60

60:                                               ; preds = %59, %43, %27, %19
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %63

63:                                               ; preds = %60
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt14_List_iteratorIP9UIElementEppEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  br label %16

65:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt14_List_iteratorIP9UIElementES4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14_List_iteratorIP9UIElementEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

declare noundef zeroext i1 @_ZN6Button9IsClickedEv(ptr noundef nonnull align 8 dereferenceable(112)) #1

declare void @_ZN11GameManager11ChangeSceneENS_5SceneE(i32 noundef) #1

declare noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48)) #1

declare void @ToggleFullscreen() #1

declare void @_ZN11GameManager11ToggleAudioEv() #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt14_List_iteratorIP9UIElementEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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}


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

%"struct.std::_List_iterator" = type { ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare zeroext i1 @IsWindowFullscreen() local_unnamed_addr #1

declare noundef zeroext i1 @_ZN11GameManager9IsAudioOnEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12SettingsMenu6UpdateEv(ptr noundef nonnull align 8 dereferenceable(40) %0) unnamed_addr #2 align 2 {
  %2 = alloca %"struct.std::_List_iterator", align 8
  %3 = alloca %"struct.std::_List_iterator", align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %5 = tail call ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  store ptr %5, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %6 = tail call ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  store ptr %6, ptr %3, align 8
  %7 = call noundef zeroext i1 @_ZStneRKSt14_List_iteratorIP9UIElementES4_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %37, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret void

.lr.ph:                                           ; preds = %1, %37
  %.09 = phi i32 [ %38, %37 ], [ 0, %1 ]
  %8 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14_List_iteratorIP9UIElementEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  switch i32 %.09, label %37 [
    i32 0, label %9
    i32 1, label %13
    i32 2, label %25
  ]

9:                                                ; preds = %.lr.ph
  %10 = load ptr, ptr %8, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZN6Button9IsClickedEv(ptr noundef nonnull align 8 dereferenceable(112) %10)
  br i1 %11, label %12, label %37

12:                                               ; preds = %9
  call void @_ZN11GameManager11ChangeSceneENS_5SceneE(i32 noundef 0)
  br label %37

13:                                               ; preds = %.lr.ph
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %14)
  br i1 %15, label %16, label %19

16:                                               ; preds = %13
  %17 = call zeroext i1 @IsWindowFullscreen()
  br i1 %17, label %19, label %18

18:                                               ; preds = %16
  call void @ToggleFullscreen()
  br label %37

19:                                               ; preds = %16, %13
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %20)
  br i1 %21, label %37, label %22

22:                                               ; preds = %19
  %23 = call zeroext i1 @IsWindowFullscreen()
  br i1 %23, label %24, label %37

24:                                               ; preds = %22
  call void @ToggleFullscreen()
  br label %37

25:                                               ; preds = %.lr.ph
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %26)
  br i1 %27, label %28, label %31

28:                                               ; preds = %25
  %29 = call noundef zeroext i1 @_ZN11GameManager9IsAudioOnEv()
  br i1 %29, label %31, label %30

30:                                               ; preds = %28
  call void @_ZN11GameManager11ToggleAudioEv()
  br label %37

31:                                               ; preds = %28, %25
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = call noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48) %32)
  br i1 %33, label %37, label %34

34:                                               ; preds = %31
  %35 = call noundef zeroext i1 @_ZN11GameManager9IsAudioOnEv()
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  call void @_ZN11GameManager11ToggleAudioEv()
  br label %37

37:                                               ; preds = %30, %36, %34, %31, %18, %24, %22, %19, %9, %12, %.lr.ph
  %38 = add nuw nsw i32 %.09, 1
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt14_List_iteratorIP9UIElementEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  %40 = call noundef zeroext i1 @_ZStneRKSt14_List_iteratorIP9UIElementES4_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  br i1 %40, label %.lr.ph, label %._crit_edge
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listIP9UIElementSaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt14_List_iteratorIP9UIElementES4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14_List_iteratorIP9UIElementEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

declare noundef zeroext i1 @_ZN6Button9IsClickedEv(ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #1

declare void @_ZN11GameManager11ChangeSceneENS_5SceneE(i32 noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN8CheckBox9IsCheckedEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1

declare void @ToggleFullscreen() local_unnamed_addr #1

declare void @_ZN11GameManager11ToggleAudioEv() local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt14_List_iteratorIP9UIElementEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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"}


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