; 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::Point" = type { i32, i32 }
%"class.juce::Desktop::Displays" = type { %"class.juce::Array.54" }
%"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 }
%"struct.juce::Desktop::Displays::Display" = type <{ %"class.juce::Rectangle", %"class.juce::Rectangle", double, double, i8, [7 x i8] }>
%"class.juce::Rectangle" = type { %"class.juce::Point", i32, i32 }

; 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 nounwind uwtable
declare dso_local void @_ZN4juce5PointIiEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce7Desktop8Displays20getDisplayContainingENS_5PointIiEE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %"class.juce::Point", align 4
  %11 = alloca double, align 8
  %12 = alloca %"class.juce::Point", align 4
  %13 = alloca %"class.juce::Point", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8
  br label %15

15:                                               ; preds = %2
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %18 = getelementptr inbounds %"class.juce::Desktop::Displays", ptr %14, i32 0, i32 0
  %19 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE12getReferenceEi(ptr noundef nonnull align 8 dereferenceable(20) %18, i32 noundef 0) #3
  store ptr %19, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 1.000000e+10, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %20 = getelementptr inbounds %"class.juce::Desktop::Displays", ptr %14, i32 0, i32 0
  %21 = call noundef i32 @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %20) #3
  store i32 %21, ptr %7, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %50, %17
  %23 = load i32, ptr %7, align 4, !tbaa !11
  %24 = add nsw i32 %23, -1
  store i32 %24, ptr %7, align 4, !tbaa !11
  %25 = icmp sge i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 4, ptr %8, align 4
  br label %51

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %28 = getelementptr inbounds %"class.juce::Desktop::Displays", ptr %14, i32 0, i32 0
  %29 = load i32, ptr %7, align 4, !tbaa !11
  %30 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE12getReferenceEi(ptr noundef nonnull align 8 dereferenceable(20) %28, i32 noundef %29) #3
  store ptr %30, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.juce::Desktop::Displays::Display", ptr %31, i32 0, i32 1
  call void @_ZN4juce5PointIiEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(8) %1) #3
  %33 = call noundef zeroext i1 @_ZNK4juce9RectangleIiE8containsENS_5PointIiEE(ptr noundef nonnull align 4 dereferenceable(16) %32, ptr noundef %10) #3
  br i1 %33, label %34, label %36

34:                                               ; preds = %27
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %35, ptr %5, align 8, !tbaa !5
  store i32 4, ptr %8, align 4
  br label %48

36:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.juce::Desktop::Displays::Display", ptr %37, i32 0, i32 1
  call void @_ZNK4juce9RectangleIiE9getCentreEv(ptr dead_on_unwind writable sret(%"class.juce::Point") align 4 %12, ptr noundef nonnull align 4 dereferenceable(16) %38) #3
  call void @_ZN4juce5PointIiEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(8) %1) #3
  %39 = call noundef i32 @_ZNK4juce5PointIiE15getDistanceFromES1_(ptr noundef nonnull align 4 dereferenceable(8) %12, ptr noundef %13) #3
  %40 = sitofp i32 %39 to double
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  store double %40, ptr %11, align 8, !tbaa !9
  %41 = load double, ptr %11, align 8, !tbaa !9
  %42 = load double, ptr %6, align 8, !tbaa !9
  %43 = fcmp olt double %41, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %36
  %45 = load double, ptr %11, align 8, !tbaa !9
  store double %45, ptr %6, align 8, !tbaa !9
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %46, ptr %5, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %44, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  store i32 0, ptr %8, align 4
  br label %48

48:                                               ; preds = %47, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %49 = load i32, ptr %8, align 4
  switch i32 %49, label %51 [
    i32 0, label %50
  ]

50:                                               ; preds = %48
  br label %22, !llvm.loop !13

51:                                               ; preds = %48, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %53
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK4juce9RectangleIiE9getCentreEv(ptr dead_on_unwind noalias writable sret(%"class.juce::Point") align 4, ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE12getReferenceEi(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce9RectangleIiE8containsENS_5PointIiEE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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 = !{!"double", !7, 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::Point" = type { i32, i32 }

; 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 nounwind uwtable
declare dso_local void @_ZN4juce5PointIiEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce7Desktop8Displays20getDisplayContainingENS_5PointIiEE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.juce::Point", align 4
  %4 = alloca %"class.juce::Point", align 4
  %5 = alloca %"class.juce::Point", align 4
  %6 = tail call noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE12getReferenceEi(ptr noundef nonnull align 8 dereferenceable(20) %0, i32 noundef 0) #3
  %7 = tail call noundef i32 @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %0) #3
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %2, %13
  %.in = phi i32 [ %9, %13 ], [ %7, %2 ]
  %.021 = phi ptr [ %.1, %13 ], [ %6, %2 ]
  %.01120 = phi double [ %.112, %13 ], [ 1.000000e+10, %2 ]
  %9 = add nsw i32 %.in, -1
  %10 = call noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE12getReferenceEi(ptr noundef nonnull align 8 dereferenceable(20) %0, i32 noundef %9) #3
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  call void @_ZN4juce5PointIiEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %1) #3
  %12 = call noundef zeroext i1 @_ZNK4juce9RectangleIiE8containsENS_5PointIiEE(ptr noundef nonnull align 4 dereferenceable(16) %11, ptr noundef nonnull %3) #3
  br i1 %12, label %.thread, label %13

13:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @_ZNK4juce9RectangleIiE9getCentreEv(ptr dead_on_unwind nonnull writable sret(%"class.juce::Point") align 4 %4, ptr noundef nonnull align 4 dereferenceable(16) %11) #3
  call void @_ZN4juce5PointIiEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %1) #3
  %14 = call noundef i32 @_ZNK4juce5PointIiE15getDistanceFromES1_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull %5) #3
  %15 = sitofp i32 %14 to double
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  %16 = fcmp ogt double %.01120, %15
  %.112 = select i1 %16, double %15, double %.01120
  %.1 = select i1 %16, ptr %10, ptr %.021
  %17 = icmp ugt i32 %.in, 1
  br i1 %17, label %.lr.ph, label %.thread

.thread:                                          ; preds = %13, %.lr.ph, %2
  %.3 = phi ptr [ %6, %2 ], [ %10, %.lr.ph ], [ %.1, %13 ]
  ret ptr %.3
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK4juce9RectangleIiE9getCentreEv(ptr dead_on_unwind noalias writable sret(%"class.juce::Point") align 4, ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(49) ptr @_ZNK4juce5ArrayINS_7Desktop8Displays7DisplayENS_20DummyCriticalSectionELi0EE12getReferenceEi(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce9RectangleIiE8containsENS_5PointIiEE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) local_unnamed_addr #1 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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)"}


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