; LLVM IR from jrouwe/JoltPhysics :: TestFramework/UI/UIElement.ll (ZN9UIElement9MouseMoveEii)

; 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.UIElement = type { %class.UIEventListener, i32, ptr, %"class.JPH::Array", %"class.UIElement::Position", %"class.UIElement::Position", %"class.UIElement::Size", %"class.UIElement::Size", %"class.UIElement::Size", %"class.UIElement::Size", i8, i8, i8, i8, i8, i8, i8, %"class.JPH::Array.2", ptr }
%class.UIEventListener = type { ptr }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.UIElement::Position" = type { i32, %"class.UIElement::Size" }
%"class.UIElement::Size" = type { i32, i32 }
%"class.JPH::Array.2" = type { i64, i64, 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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK9UIElement8ContainsEii(ptr noundef nonnull align 8 dereferenceable(144), i32 noundef, i32 noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN9UIElement9MouseMoveEii(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = call noundef zeroext i1 @_ZNK9UIElement8ContainsEii(ptr noundef nonnull align 8 dereferenceable(144) %13, i32 noundef %14, i32 noundef %15)
  br i1 %16, label %17, label %19

17:                                               ; preds = %3
  %18 = getelementptr inbounds %class.UIElement, ptr %13, i32 0, i32 12
  store i8 1, ptr %18, align 2, !tbaa !11
  br label %21

19:                                               ; preds = %3
  %20 = getelementptr inbounds %class.UIElement, ptr %13, i32 0, i32 12
  store i8 0, ptr %20, align 2, !tbaa !11
  br label %21

21:                                               ; preds = %19, %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = getelementptr inbounds %class.UIElement, ptr %13, i32 0, i32 3
  store ptr %22, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %23)
  store ptr %24, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %25)
  store ptr %26, ptr %10, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %56, %21
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = icmp ne ptr %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 2, ptr %11, align 4
  br label %59

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  store ptr %34, ptr %12, align 8, !tbaa !5
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = call noundef zeroext i1 @_ZNK9UIElement9IsVisibleEv(ptr noundef nonnull align 8 dereferenceable(144) %35)
  br i1 %36, label %37, label %52

37:                                               ; preds = %32
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %class.UIElement, ptr %38, i32 0, i32 14
  %40 = load i8, ptr %39, align 4, !tbaa !22, !range !23, !noundef !24
  %41 = trunc i8 %40 to i1
  br i1 %41, label %52, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = load ptr, ptr %43, align 8, !tbaa !25
  %47 = getelementptr inbounds ptr, ptr %46, i64 13
  %48 = load ptr, ptr %47, align 8
  %49 = call noundef zeroext i1 %48(ptr noundef nonnull align 8 dereferenceable(144) %43, i32 noundef %44, i32 noundef %45)
  br i1 %49, label %50, label %51

50:                                               ; preds = %42
  store i1 true, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %53

51:                                               ; preds = %42
  br label %52

52:                                               ; preds = %51, %37, %32
  store i32 0, ptr %11, align 4
  br label %53

53:                                               ; preds = %52, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %54 = load i32, ptr %11, align 4
  switch i32 %54, label %59 [
    i32 0, label %55
  ]

55:                                               ; preds = %53
  br label %56

56:                                               ; preds = %55
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds ptr, ptr %57, i32 1
  store ptr %58, ptr %9, align 8, !tbaa !5
  br label %27

59:                                               ; preds = %53, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %60 = load i32, ptr %11, align 4
  switch i32 %60, label %64 [
    i32 2, label %61
    i32 1, label %62
  ]

61:                                               ; preds = %59
  store i1 false, ptr %4, align 1
  br label %62

62:                                               ; preds = %61, %59
  %63 = load i1, ptr %4, align 1
  ret i1 %63

64:                                               ; preds = %59
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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}
!11 = !{!12, !20, i64 106}
!12 = !{!"_ZTS9UIElement", !13, i64 0, !10, i64 8, !6, i64 16, !14, i64 24, !16, i64 48, !16, i64 60, !18, i64 72, !18, i64 80, !18, i64 88, !18, i64 96, !20, i64 104, !20, i64 105, !20, i64 106, !20, i64 107, !20, i64 108, !20, i64 109, !20, i64 110, !21, i64 112, !6, i64 136}
!13 = !{!"_ZTS15UIEventListener"}
!14 = !{!"_ZTSN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEEE", !15, i64 0, !15, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSN9UIElement8PositionE", !17, i64 0, !18, i64 4}
!17 = !{!"_ZTSN9UIElement10EAlignmentE", !7, i64 0}
!18 = !{!"_ZTSN9UIElement4SizeE", !10, i64 0, !19, i64 4}
!19 = !{!"_ZTSN9UIElement6EUnitsE", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTSN3JPH5ArrayIP11UIAnimationNS_12STLAllocatorIS2_EEEE", !15, i64 0, !15, i64 8, !6, i64 16}
!22 = !{!12, !20, i64 108}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !8, 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"

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK9UIElement8ContainsEii(ptr noundef nonnull align 8 dereferenceable(144), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9UIElement9IsVisibleEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN9UIElement9MouseMoveEii(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #1 align 2 {
  %4 = tail call noundef zeroext i1 @_ZNK9UIElement8ContainsEii(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1, i32 noundef %2)
  %spec.select = zext i1 %4 to i8
  %5 = getelementptr inbounds i8, ptr %0, i64 106
  store i8 %spec.select, ptr %5, align 2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = tail call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %8 = tail call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %.not19.not = icmp eq ptr %7, %8
  br i1 %.not19.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.critedge
  %.01820 = phi ptr [ %20, %.critedge ], [ %7, %3 ]
  %9 = load ptr, ptr %.01820, align 8, !tbaa !5
  %10 = tail call noundef zeroext i1 @_ZNK9UIElement9IsVisibleEv(ptr noundef nonnull align 8 dereferenceable(144) %9)
  br i1 %10, label %11, label %.critedge

11:                                               ; preds = %.lr.ph
  %12 = getelementptr inbounds i8, ptr %9, i64 108
  %13 = load i8, ptr %12, align 4, !tbaa !9, !range !21, !noundef !22
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %.critedge, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %9, align 8, !tbaa !23
  %17 = getelementptr inbounds i8, ptr %16, i64 104
  %18 = load ptr, ptr %17, align 8
  %19 = tail call noundef zeroext i1 %18(ptr noundef nonnull align 8 dereferenceable(144) %9, i32 noundef %1, i32 noundef %2)
  br i1 %19, label %._crit_edge, label %.critedge

.critedge:                                        ; preds = %15, %11, %.lr.ph
  %20 = getelementptr inbounds i8, ptr %.01820, i64 8
  %.not.not = icmp eq ptr %20, %8
  br i1 %.not.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.critedge, %15, %3
  %.not.lcssa = phi i1 [ false, %3 ], [ true, %15 ], [ false, %.critedge ]
  ret i1 %.not.lcssa
}

attributes #0 = { 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 #1 = { 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 #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" }

!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, !19, i64 108}
!10 = !{!"_ZTS9UIElement", !11, i64 0, !12, i64 8, !6, i64 16, !13, i64 24, !15, i64 48, !15, i64 60, !17, i64 72, !17, i64 80, !17, i64 88, !17, i64 96, !19, i64 104, !19, i64 105, !19, i64 106, !19, i64 107, !19, i64 108, !19, i64 109, !19, i64 110, !20, i64 112, !6, i64 136}
!11 = !{!"_ZTS15UIEventListener"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN9UIElement8PositionE", !16, i64 0, !17, i64 4}
!16 = !{!"_ZTSN9UIElement10EAlignmentE", !7, i64 0}
!17 = !{!"_ZTSN9UIElement4SizeE", !12, i64 0, !18, i64 4}
!18 = !{!"_ZTSN9UIElement6EUnitsE", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSN3JPH5ArrayIP11UIAnimationNS_12STLAllocatorIS2_EEEE", !14, i64 0, !14, i64 8, !6, i64 16}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!24, !24, i64 0}
!24 = !{!"vtable pointer", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass