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

; 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::Array.54" = type { %"class.juce::ArrayAllocationBase.55", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.55" = type <{ %"class.juce::HeapBlock.56", i32, [4 x i8] }>
%"class.juce::HeapBlock.56" = type { ptr }
%"class.juce::Desktop::Displays" = type { %"class.juce::Array.54" }

declare i32 @__gxx_personality_v0(...)

; 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: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(360) ptr @_ZN4juce7Desktop11getInstanceEv() #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce7Desktop8Displays4initERS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(360)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce7Desktop8Displays7refreshEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.juce::Array.54", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %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 24, ptr %3) #3
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %3) #3
  %9 = getelementptr inbounds %"class.juce::Desktop::Displays", ptr %8, i32 0, i32 0
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE8swapWithIS5_EEvRT_(ptr noundef nonnull align 8 dereferenceable(20) %3, ptr noundef nonnull align 8 dereferenceable(20) %9) #3
  %10 = invoke noundef nonnull align 8 dereferenceable(360) ptr @_ZN4juce7Desktop11getInstanceEv()
          to label %11 unwind label %23

11:                                               ; preds = %1
  invoke void @_ZN4juce7Desktop8Displays4initERS0_(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(360) %10)
          to label %12 unwind label %23

12:                                               ; preds = %11
  %13 = getelementptr inbounds %"class.juce::Desktop::Displays", ptr %8, i32 0, i32 0
  %14 = invoke noundef zeroext i1 @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EEneIS5_EEbRKT_(ptr noundef nonnull align 8 dereferenceable(20) %3, ptr noundef nonnull align 8 dereferenceable(20) %13)
          to label %15 unwind label %23

15:                                               ; preds = %12
  br i1 %14, label %16, label %44

16:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %17 = call noundef i32 @_ZN4juce13ComponentPeer11getNumPeersEv() #3
  store i32 %17, ptr %6, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %42, %16
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = add nsw i32 %19, -1
  store i32 %20, ptr %6, align 4, !tbaa !9
  %21 = icmp sge i32 %20, 0
  br i1 %21, label %27, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %43

23:                                               ; preds = %12, %11, %1
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %4, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %5, align 4
  br label %45

27:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = call noundef ptr @_ZN4juce13ComponentPeer7getPeerEi(i32 noundef %28) #3
  store ptr %29, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %42

32:                                               ; preds = %27
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds ptr, ptr %34, i64 21
  %36 = load ptr, ptr %35, align 8
  invoke void %36(ptr noundef nonnull align 8 dereferenceable(77) %33)
          to label %37 unwind label %38

37:                                               ; preds = %32
  br label %42

38:                                               ; preds = %32
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %4, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %45

42:                                               ; preds = %37, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %18, !llvm.loop !13

43:                                               ; preds = %22
  br label %44

44:                                               ; preds = %43, %15
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %3) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #3
  ret void

45:                                               ; preds = %38, %23
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %3) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #3
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %4, align 8
  %48 = load i32, ptr %5, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EEneIS5_EEbRKT_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(20)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4juce13ComponentPeer11getNumPeersEv() #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, 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::Array.54" = type { %"class.juce::ArrayAllocationBase.55", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.55" = type <{ %"class.juce::HeapBlock.56", i32, [4 x i8] }>
%"class.juce::HeapBlock.56" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; 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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(360) ptr @_ZN4juce7Desktop11getInstanceEv() local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce7Desktop8Displays4initERS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(360)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce7Desktop8Displays7refreshEv(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.juce::Array.54", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #3
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %2) #3
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE8swapWithIS5_EEvRT_(ptr noundef nonnull align 8 dereferenceable(20) %2, ptr noundef nonnull align 8 dereferenceable(20) %0) #3
  %3 = invoke noundef nonnull align 8 dereferenceable(360) ptr @_ZN4juce7Desktop11getInstanceEv()
          to label %4 unwind label %11

4:                                                ; preds = %1
  invoke void @_ZN4juce7Desktop8Displays4initERS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(360) %3)
          to label %5 unwind label %11

5:                                                ; preds = %4
  %6 = invoke noundef zeroext i1 @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EEneIS5_EEbRKT_(ptr noundef nonnull align 8 dereferenceable(20) %2, ptr noundef nonnull align 8 dereferenceable(20) %0)
          to label %7 unwind label %11

7:                                                ; preds = %5
  br i1 %6, label %8, label %.loopexit

8:                                                ; preds = %7
  %9 = call noundef i32 @_ZN4juce13ComponentPeer11getNumPeersEv() #3
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.loopexit

11:                                               ; preds = %5, %4, %1
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %23

.lr.ph:                                           ; preds = %8, %21
  %.in = phi i32 [ %13, %21 ], [ %9, %8 ]
  %13 = add nsw i32 %.in, -1
  %14 = call noundef ptr @_ZN4juce13ComponentPeer7getPeerEi(i32 noundef %13) #3
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %21, label %15

15:                                               ; preds = %.lr.ph
  %16 = load ptr, ptr %14, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 168
  %18 = load ptr, ptr %17, align 8
  invoke void %18(ptr noundef nonnull align 8 dereferenceable(77) %14)
          to label %21 unwind label %19

19:                                               ; preds = %15
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %23

21:                                               ; preds = %15, %.lr.ph
  %22 = icmp ugt i32 %.in, 1
  br i1 %22, label %.lr.ph, label %.loopexit, !llvm.loop !8

.loopexit:                                        ; preds = %21, %8, %7
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %2) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  ret void

23:                                               ; preds = %19, %11
  %.pn = phi { ptr, i32 } [ %20, %19 ], [ %12, %11 ]
  call void @_ZN4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %2) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  resume { ptr, i32 } %.pn
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4juce13ComponentPeer11getNumPeersEv() local_unnamed_addr #2 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass