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

; 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::DocumentWindow" = type { %"class.juce::ResizableWindow", i32, i32, i32, i8, i8, [3 x %"class.juce::ScopedPointer.282"], %"class.juce::Image", %"class.juce::ScopedPointer.159", ptr, %"class.juce::ScopedPointer.360" }
%"class.juce::ResizableWindow" = type { %"class.juce::TopLevelWindow", %"class.juce::ScopedPointer.294", %"class.juce::ScopedPointer.295", %"class.juce::Component::SafePointer", i8, i8, i8, i8, i8, %"class.juce::ComponentDragger", %"class.juce::Rectangle", %"class.juce::ComponentBoundsConstrainer", ptr }
%"class.juce::TopLevelWindow" = type { %"class.juce::Component.base", i8, i8, i8, %"class.juce::ScopedPointer.293" }
%"class.juce::Component.base" = type <{ %"class.juce::MouseListener", %"class.juce::String", %"class.juce::String", ptr, %"class.juce::Rectangle", %"class.juce::ScopedPointer", %"class.juce::ScopedPointer.0", %"class.juce::Array", ptr, %"class.juce::MouseCursor", ptr, %"class.juce::ScopedPointer.1", %"class.juce::ScopedPointer.2", %"class.juce::ScopedPointer.3", %"class.juce::ListenerList", %"class.juce::NamedValueSet", %"class.juce::WeakReference<juce::Component>::Master", %union.anon, i8 }>
%"class.juce::MouseListener" = type { ptr }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::ScopedPointer" = type { ptr }
%"class.juce::ScopedPointer.0" = type { ptr }
%"class.juce::Array" = type { %"class.juce::ArrayAllocationBase", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase" = type <{ %"class.juce::HeapBlock", i32, [4 x i8] }>
%"class.juce::HeapBlock" = type { ptr }
%"class.juce::MouseCursor" = type { ptr }
%"class.juce::ScopedPointer.1" = type { ptr }
%"class.juce::ScopedPointer.2" = type { ptr }
%"class.juce::ScopedPointer.3" = type { ptr }
%"class.juce::ListenerList" = type { %"class.juce::Array.4" }
%"class.juce::Array.4" = type { %"class.juce::ArrayAllocationBase.5", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.5" = type <{ %"class.juce::HeapBlock.6", i32, [4 x i8] }>
%"class.juce::HeapBlock.6" = type { ptr }
%"class.juce::NamedValueSet" = type { %"class.juce::Array.9" }
%"class.juce::Array.9" = type { %"class.juce::ArrayAllocationBase.10", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.10" = type <{ %"class.juce::HeapBlock.11", i32, [4 x i8] }>
%"class.juce::HeapBlock.11" = type { ptr }
%"class.juce::WeakReference<juce::Component>::Master" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%union.anon = type { i32 }
%"class.juce::ScopedPointer.293" = type { ptr }
%"class.juce::ScopedPointer.294" = type { ptr }
%"class.juce::ScopedPointer.295" = type { ptr }
%"class.juce::Component::SafePointer" = type { %"class.juce::WeakReference" }
%"class.juce::WeakReference" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ComponentDragger" = type { ptr, %"class.juce::Point" }
%"class.juce::Point" = type { i32, i32 }
%"class.juce::Rectangle" = type { %"class.juce::Point", i32, i32 }
%"class.juce::ComponentBoundsConstrainer" = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, double }
%"class.juce::ScopedPointer.282" = type { ptr }
%"class.juce::Image" = type { %"class.juce::ReferenceCountedObjectPtr.48" }
%"class.juce::ReferenceCountedObjectPtr.48" = type { ptr }
%"class.juce::ScopedPointer.159" = type { ptr }
%"class.juce::ScopedPointer.360" = type { ptr }

@_ZTVN4juce14DocumentWindowE = external dso_local unnamed_addr constant { [54 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #0

; 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: nounwind
declare void @_ZN4juce5ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce15ResizableWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(328)) unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce14DocumentWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(400) %0) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 416) ({ [54 x ptr] }, ptr @_ZTVN4juce14DocumentWindowE, i32 0, i32 0, i32 2), ptr %4, align 8, !tbaa !9
  br label %5

5:                                                ; preds = %1
  br label %6

6:                                                ; preds = %5
  br label %7

7:                                                ; preds = %6
  br label %8

8:                                                ; preds = %7
  br label %9

9:                                                ; preds = %8
  br label %10

10:                                               ; preds = %9
  br label %11

11:                                               ; preds = %10
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %17 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 6
  %18 = invoke noundef i32 @_ZN4juce18numElementsInArrayINS_13ScopedPointerINS_6ButtonEEELi3EEEiRAT0__T_(ptr noundef nonnull align 8 dereferenceable(24) %17)
          to label %19 unwind label %47

19:                                               ; preds = %16
  store i32 %18, ptr %3, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %31, %19
  %21 = load i32, ptr %3, align 4, !tbaa !11
  %22 = add nsw i32 %21, -1
  store i32 %22, ptr %3, align 4, !tbaa !11
  %23 = icmp sge i32 %22, 0
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  %26 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 6
  %27 = load i32, ptr %3, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [3 x %"class.juce::ScopedPointer.282"], ptr %26, i64 0, i64 %28
  %30 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce13ScopedPointerINS_6ButtonEEaSEPS1_(ptr noundef nonnull align 8 dereferenceable(8) %29, ptr noundef null)
          to label %31 unwind label %47

31:                                               ; preds = %25
  br label %20, !llvm.loop !13

32:                                               ; preds = %24
  %33 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 8
  %34 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce13ScopedPointerINS_9ComponentEEaSEPS1_(ptr noundef nonnull align 8 dereferenceable(8) %33, ptr noundef null)
          to label %35 unwind label %47

35:                                               ; preds = %32
  %36 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 10
  call void @_ZN4juce13ScopedPointerINS_14DocumentWindow19ButtonListenerProxyEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %36) #5
  %37 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 8
  call void @_ZN4juce13ScopedPointerINS_9ComponentEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %37) #5
  %38 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 7
  call void @_ZN4juce5ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %38) #5
  %39 = getelementptr inbounds %"class.juce::DocumentWindow", ptr %4, i32 0, i32 6
  %40 = getelementptr inbounds [3 x %"class.juce::ScopedPointer.282"], ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %"class.juce::ScopedPointer.282", ptr %40, i64 3
  br label %42

42:                                               ; preds = %42, %35
  %43 = phi ptr [ %41, %35 ], [ %44, %42 ]
  %44 = getelementptr inbounds %"class.juce::ScopedPointer.282", ptr %43, i64 -1
  call void @_ZN4juce13ScopedPointerINS_6ButtonEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %44) #5
  %45 = icmp eq ptr %44, %40
  br i1 %45, label %46, label %42

46:                                               ; preds = %42
  call void @_ZN4juce15ResizableWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(328) %4) #5
  ret void

47:                                               ; preds = %32, %25, %16
  %48 = landingpad { ptr, i32 }
          catch ptr null
  %49 = extractvalue { ptr, i32 } %48, 0
  call void @__clang_call_terminate(ptr %49) #6
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4juce18numElementsInArrayINS_13ScopedPointerINS_6ButtonEEELi3EEEiRAT0__T_(ptr noundef nonnull align 8 dereferenceable(24)) #4

attributes #0 = { noinline noreturn nounwind uwtable "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 "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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"class.juce::ScopedPointer.282" = type { ptr }

@_ZTVN4juce14DocumentWindowE = external dso_local unnamed_addr constant { [54 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN4juce5ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce15ResizableWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(328)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce14DocumentWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(400) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 416) (i8, ptr @_ZTVN4juce14DocumentWindowE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 344
  %3 = tail call noundef i32 @_ZN4juce18numElementsInArrayINS_13ScopedPointerINS_6ButtonEEELi3EEEiRAT0__T_(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %1
  %5 = zext nneg i32 %3 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %6 = getelementptr inbounds i8, ptr %0, i64 376
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce13ScopedPointerINS_9ComponentEEaSEPS1_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef null)
  %8 = getelementptr inbounds i8, ptr %0, i64 392
  tail call void @_ZN4juce13ScopedPointerINS_14DocumentWindow19ButtonListenerProxyEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #3
  tail call void @_ZN4juce13ScopedPointerINS_9ComponentEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 368
  tail call void @_ZN4juce5ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #3
  %.ptr3 = getelementptr inbounds i8, ptr %0, i64 360
  tail call void @_ZN4juce13ScopedPointerINS_6ButtonEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr3) #3
  %.ptr3.1 = getelementptr inbounds i8, ptr %0, i64 352
  tail call void @_ZN4juce13ScopedPointerINS_6ButtonEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr3.1) #3
  tail call void @_ZN4juce13ScopedPointerINS_6ButtonEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #3
  tail call void @_ZN4juce15ResizableWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(328) %0) #3
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %5, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %10 = getelementptr inbounds [3 x %"class.juce::ScopedPointer.282"], ptr %2, i64 0, i64 %indvars.iv.next
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce13ScopedPointerINS_6ButtonEEaSEPS1_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef null)
  %12 = icmp ugt i64 %indvars.iv, 1
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !8
}

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

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

attributes #0 = { nounwind "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 = { 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 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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