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

; 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
define dso_local void @_ZN9UIElement11SetDisabledEb(ptr noundef nonnull align 8 dereferenceable(144) %0, i1 noundef zeroext %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %4, align 1, !tbaa !9
  %10 = load ptr, ptr %3, align 8
  %11 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  %13 = getelementptr inbounds %class.UIElement, ptr %10, i32 0, i32 14
  %14 = zext i1 %12 to i8
  store i8 %14, ptr %13, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %15 = getelementptr inbounds %class.UIElement, ptr %10, i32 0, i32 3
  store ptr %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  store ptr %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %18)
  store ptr %19, ptr %7, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %31, %2
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %34

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %30 = trunc i8 %29 to i1
  call void @_ZN9UIElement11SetDisabledEb(ptr noundef nonnull align 8 dereferenceable(144) %28, i1 noundef zeroext %30)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %31

31:                                               ; preds = %25
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %32, i32 1
  store ptr %33, ptr %6, align 8, !tbaa !5
  br label %20

34:                                               ; preds = %24
  ret void
}

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


; 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 nounwind uwtable
define dso_local void @_ZN9UIElement11SetDisabledEb(ptr noundef nonnull align 8 dereferenceable(144) %0, i1 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = zext i1 %1 to i8
  %4 = getelementptr inbounds i8, ptr %0, i64 108
  store i8 %3, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = tail call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %7 = tail call noundef ptr @_ZN3JPH5ArrayIP9UIElementNS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %.not9 = icmp eq ptr %6, %7
  br i1 %.not9, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.010 = phi ptr [ %9, %.lr.ph ], [ %6, %2 ]
  %8 = load ptr, ptr %.010, align 8, !tbaa !20
  tail call void @_ZN9UIElement11SetDisabledEb(ptr noundef nonnull align 8 dereferenceable(144) %8, i1 noundef zeroext %1)
  %9 = getelementptr inbounds i8, ptr %.010, i64 8
  %.not = icmp eq ptr %9, %7
  br i1 %.not, label %._crit_edge, label %.lr.ph
}

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


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