; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_gui_basics)

; 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.juce::ComponentPeer" = type <{ ptr, ptr, i32, %"class.juce::Rectangle", [4 x i8], ptr, %"class.juce::WeakReference", %"class.juce::WeakReference", ptr, i32, i8, [3 x i8] }>
%"class.juce::Rectangle" = type { %"class.juce::Point", i32, i32 }
%"class.juce::Point" = type { i32, i32 }
%"class.juce::WeakReference" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }

@_ZTIN4juce9ComponentE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN4juce15TextInputTargetE = external dso_local constant { ptr, ptr }, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce9Component10isParentOfEPKS0_(ptr noundef nonnull align 8 dereferenceable(197), ptr noundef) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce9Component28getCurrentlyFocusedComponentEv() #0 align 2

; Function Attrs: nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4juce13ComponentPeer26findCurrentTextInputTargetEv(ptr noundef nonnull align 8 dereferenceable(77) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = call noundef ptr @_ZN4juce9Component28getCurrentlyFocusedComponentEv() #4
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %"class.juce::ComponentPeer", ptr %7, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = icmp eq ptr %9, %11
  br i1 %12, label %18, label %13

13:                                               ; preds = %1
  %14 = getelementptr inbounds %"class.juce::ComponentPeer", ptr %7, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_ZNK4juce9Component10isParentOfEPKS0_(ptr noundef nonnull align 8 dereferenceable(197) %15, ptr noundef %16) #4
  br i1 %17, label %18, label %41

18:                                               ; preds = %13, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %23, label %21

21:                                               ; preds = %18
  %22 = call ptr @__dynamic_cast(ptr %19, ptr @_ZTIN4juce9ComponentE, ptr @_ZTIN4juce15TextInputTargetE, i64 -2) #4
  br label %24

23:                                               ; preds = %18
  br label %24

24:                                               ; preds = %23, %21
  %25 = phi ptr [ %22, %21 ], [ null, %23 ]
  store ptr %25, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %37

28:                                               ; preds = %24
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = getelementptr inbounds ptr, ptr %30, i64 2
  %32 = load ptr, ptr %31, align 8
  %33 = call noundef zeroext i1 %32(ptr noundef nonnull align 8 dereferenceable(8) %29)
  br i1 %33, label %34, label %36

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %35, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %38

36:                                               ; preds = %28
  br label %37

37:                                               ; preds = %36, %24
  store i32 0, ptr %6, align 4
  br label %38

38:                                               ; preds = %37, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %39 = load i32, ptr %6, align 4
  switch i32 %39, label %42 [
    i32 0, label %40
  ]

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40, %13
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %42

42:                                               ; preds = %41, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %43 = load ptr, ptr %2, align 8
  ret ptr %43
}

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) }
attributes #3 = { 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 #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, !6, i64 8}
!10 = !{!"_ZTSN4juce13ComponentPeerE", !6, i64 8, !11, i64 16, !12, i64 20, !6, i64 40, !14, i64 48, !14, i64 56, !6, i64 64, !11, i64 72, !16, i64 76}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN4juce9RectangleIiEE", !13, i64 0, !11, i64 8, !11, i64 12}
!13 = !{!"_ZTSN4juce5PointIiEE", !11, i64 0, !11, i64 4}
!14 = !{!"_ZTSN4juce13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEEE", !15, i64 0}
!15 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE13SharedPointerEEE", !6, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"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"

@_ZTIN4juce9ComponentE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN4juce15TextInputTargetE = external dso_local constant { ptr, ptr }, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce9Component10isParentOfEPKS0_(ptr noundef nonnull align 8 dereferenceable(197), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce9Component28getCurrentlyFocusedComponentEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4juce13ComponentPeer26findCurrentTextInputTargetEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(77) %0) local_unnamed_addr #2 align 2 {
  %2 = tail call noundef ptr @_ZN4juce9Component28getCurrentlyFocusedComponentEv() #3
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %2, %4
  br i1 %5, label %8, label %6

6:                                                ; preds = %1
  %7 = tail call noundef zeroext i1 @_ZNK4juce9Component10isParentOfEPKS0_(ptr noundef nonnull align 8 dereferenceable(197) %4, ptr noundef %2) #3
  br i1 %7, label %8, label %17

8:                                                ; preds = %6, %1
  %9 = icmp eq ptr %2, null
  br i1 %9, label %.critedge, label %10

10:                                               ; preds = %8
  %11 = tail call ptr @__dynamic_cast(ptr nonnull %2, ptr nonnull @_ZTIN4juce9ComponentE, ptr nonnull @_ZTIN4juce15TextInputTargetE, i64 -2) #3
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %.critedge, label %12

12:                                               ; preds = %10
  %13 = load ptr, ptr %11, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8
  %16 = tail call noundef zeroext i1 %15(ptr noundef nonnull align 8 dereferenceable(8) %11)
  br i1 %16, label %17, label %.critedge

.critedge:                                        ; preds = %8, %12, %10
  br label %17

17:                                               ; preds = %6, %.critedge, %12
  %.1 = phi ptr [ %11, %12 ], [ null, %.critedge ], [ null, %6 ]
  ret ptr %.1
}

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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(read) }
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, !7, i64 8}
!6 = !{!"_ZTSN4juce13ComponentPeerE", !7, i64 8, !10, i64 16, !11, i64 20, !7, i64 40, !13, i64 48, !13, i64 56, !7, i64 64, !10, i64 72, !15, i64 76}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSN4juce9RectangleIiEE", !12, i64 0, !10, i64 8, !10, i64 12}
!12 = !{!"_ZTSN4juce5PointIiEE", !10, i64 0, !10, i64 4}
!13 = !{!"_ZTSN4juce13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEEE", !14, i64 0}
!14 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE13SharedPointerEEE", !7, i64 0}
!15 = !{!"bool", !8, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !9, i64 0}


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