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

; 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::MessageManager" = type { %"class.juce::ScopedPointer.1", i8, i8, ptr, ptr, %"class.juce::CriticalSection" }
%"class.juce::ScopedPointer.1" = type { ptr }
%"class.juce::CriticalSection" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce14MessageManager20runDispatchLoopUntilEi(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  br label %7

7:                                                ; preds = %2
  br label %8

8:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = call noundef i64 @_ZN4juce4Time17currentTimeMillisEv() #4
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = add nsw i64 %9, %11
  store i64 %12, ptr %5, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %31, %8
  %14 = getelementptr inbounds %"class.juce::MessageManager", ptr %6, i32 0, i32 2
  %15 = load i8, ptr %14, align 1, !tbaa !13, !range !18, !noundef !19
  %16 = trunc i8 %15 to i1
  %17 = xor i1 %16, true
  br i1 %17, label %18, label %32

18:                                               ; preds = %13
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = icmp sge i32 %19, 0
  %21 = call noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext %20)
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @_ZN4juce6Thread5sleepEi(i32 noundef 1)
  br label %23

23:                                               ; preds = %22, %18
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = icmp sge i32 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %23
  %27 = call noundef i64 @_ZN4juce4Time17currentTimeMillisEv() #4
  %28 = load i64, ptr %5, align 8, !tbaa !11
  %29 = icmp sge i64 %27, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  br label %32

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

32:                                               ; preds = %30, %13
  %33 = getelementptr inbounds %"class.juce::MessageManager", ptr %6, i32 0, i32 2
  %34 = load i8, ptr %33, align 1, !tbaa !13, !range !18, !noundef !19
  %35 = trunc i8 %34 to i1
  %36 = xor i1 %35, true
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i1 %36
}

; Function Attrs: nounwind
declare noundef i64 @_ZN4juce4Time17currentTimeMillisEv() #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext) #1 align 2

declare void @_ZN4juce6Thread5sleepEi(i32 noundef) #3

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 = { 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 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !16, i64 9}
!14 = !{!"_ZTSN4juce14MessageManagerE", !15, i64 0, !16, i64 8, !16, i64 9, !6, i64 16, !6, i64 24, !17, i64 32}
!15 = !{!"_ZTSN4juce13ScopedPointerINS_17ActionBroadcasterEEE", !6, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSN4juce15CriticalSectionE", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce14MessageManager20runDispatchLoopUntilEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i64 @_ZN4juce4Time17currentTimeMillisEv() #3
  %4 = sext i32 %1 to i64
  %5 = add nsw i64 %3, %4
  %6 = getelementptr inbounds i8, ptr %0, i64 9
  %7 = load i8, ptr %6, align 1, !tbaa !5, !range !13, !noundef !14
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = icmp sgt i32 %1, -1
  br i1 %9, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %16
  %10 = tail call noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext true)
  br i1 %10, label %12, label %11

11:                                               ; preds = %.lr.ph.split.us
  tail call void @_ZN4juce6Thread5sleepEi(i32 noundef 1)
  br label %12

12:                                               ; preds = %11, %.lr.ph.split.us
  %13 = tail call noundef i64 @_ZN4juce4Time17currentTimeMillisEv() #3
  %.not.us = icmp slt i64 %13, %5
  %.pre.pre = load i8, ptr %6, align 1, !tbaa !5, !range !13
  %14 = trunc nuw i8 %.pre.pre to i1
  br i1 %.not.us, label %16, label %.._crit_edge.loopexit_crit_edge

.._crit_edge.loopexit_crit_edge:                  ; preds = %12
  %15 = xor i1 %14, true
  br label %._crit_edge

16:                                               ; preds = %12
  br i1 %14, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !15

.lr.ph.split:                                     ; preds = %.lr.ph, %19
  %17 = tail call noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext false)
  br i1 %17, label %19, label %18

18:                                               ; preds = %.lr.ph.split
  tail call void @_ZN4juce6Thread5sleepEi(i32 noundef 1)
  br label %19

19:                                               ; preds = %18, %.lr.ph.split
  %20 = load i8, ptr %6, align 1, !tbaa !5, !range !13, !noundef !14
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %._crit_edge, label %.lr.ph.split, !llvm.loop !15

._crit_edge:                                      ; preds = %19, %16, %.._crit_edge.loopexit_crit_edge, %2
  %.pre-phi = phi i1 [ false, %2 ], [ %15, %.._crit_edge.loopexit_crit_edge ], [ false, %16 ], [ false, %19 ]
  ret i1 %.pre-phi
}

; Function Attrs: nounwind
declare noundef i64 @_ZN4juce4Time17currentTimeMillisEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext) local_unnamed_addr #0 align 2

declare void @_ZN4juce6Thread5sleepEi(i32 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #2 = { "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, !11, i64 9}
!6 = !{!"_ZTSN4juce14MessageManagerE", !7, i64 0, !11, i64 8, !11, i64 9, !8, i64 16, !8, i64 24, !12, i64 32}
!7 = !{!"_ZTSN4juce13ScopedPointerINS_17ActionBroadcasterEEE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"_ZTSN4juce15CriticalSectionE", !9, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass