; 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"

@_ZN4juce18LinuxErrorHandlingL13errorOccurredE = external hidden global i8, align 1
@_ZN4juce18LinuxErrorHandlingL21keyboardBreakOccurredE = external hidden global i8, align 1

; 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 noundef zeroext i1 @_ZN4juce19JUCEApplicationBase15isStandaloneAppEv() #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext %0) #2 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = zext i1 %0 to i8
  store i8 %6, ptr %3, align 1, !tbaa !5
  br label %7

7:                                                ; preds = %36, %1
  %8 = load i8, ptr @_ZN4juce18LinuxErrorHandlingL13errorOccurredE, align 1, !tbaa !5, !range !9, !noundef !10
  %9 = trunc i8 %8 to i1
  %10 = xor i1 %9, true
  br i1 %10, label %11, label %37

11:                                               ; preds = %7
  %12 = load i8, ptr @_ZN4juce18LinuxErrorHandlingL21keyboardBreakOccurredE, align 1, !tbaa !5, !range !9, !noundef !10
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %18

14:                                               ; preds = %11
  store i8 1, ptr @_ZN4juce18LinuxErrorHandlingL13errorOccurredE, align 1, !tbaa !5
  %15 = call noundef zeroext i1 @_ZN4juce19JUCEApplicationBase15isStandaloneAppEv() #5
  br i1 %15, label %16, label %17

16:                                               ; preds = %14
  call void @_ZN4juce7Process9terminateEv()
  br label %17

17:                                               ; preds = %16, %14
  br label %37

18:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %19 = call noundef ptr @_ZN4juce20InternalMessageQueue26getInstanceWithoutCreatingEv() #5
  store ptr %19, ptr %4, align 8, !tbaa !11
  %20 = load ptr, ptr %4, align 8, !tbaa !11
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %33

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !11
  %24 = call noundef zeroext i1 @_ZN4juce20InternalMessageQueue17dispatchNextEventEv(ptr noundef nonnull align 8 dereferenceable(80) %23)
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %34

26:                                               ; preds = %22
  %27 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 3, ptr %5, align 4
  br label %34

30:                                               ; preds = %26
  %31 = load ptr, ptr %4, align 8, !tbaa !11
  %32 = call noundef zeroext i1 @_ZN4juce20InternalMessageQueue15sleepUntilEventEi(ptr noundef nonnull align 8 dereferenceable(80) %31, i32 noundef 2000)
  br label %33

33:                                               ; preds = %30, %18
  store i32 0, ptr %5, align 4
  br label %34

34:                                               ; preds = %33, %29, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %35 = load i32, ptr %5, align 4
  switch i32 %35, label %40 [
    i32 0, label %36
    i32 1, label %38
    i32 3, label %37
  ]

36:                                               ; preds = %34
  br label %7, !llvm.loop !13

37:                                               ; preds = %34, %17, %7
  store i1 false, ptr %2, align 1
  br label %38

38:                                               ; preds = %37, %34
  %39 = load i1, ptr %2, align 1
  ret i1 %39

40:                                               ; preds = %34
  unreachable
}

declare void @_ZN4juce7Process9terminateEv() #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce20InternalMessageQueue26getInstanceWithoutCreatingEv() #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4juce20InternalMessageQueue17dispatchNextEventEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4juce20InternalMessageQueue15sleepUntilEventEi(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef) #2 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 = { 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 = { "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 = { 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 #5 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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"

@_ZN4juce18LinuxErrorHandlingL13errorOccurredE = external hidden local_unnamed_addr global i8, align 1
@_ZN4juce18LinuxErrorHandlingL21keyboardBreakOccurredE = external hidden local_unnamed_addr global i8, align 1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce14MessageManager32dispatchNextMessageOnSystemQueueEb(i1 noundef zeroext %0) local_unnamed_addr #1 align 2 {
  br i1 %0, label %.split.us, label %.split

.split.us:                                        ; preds = %1, %7
  %2 = load i8, ptr @_ZN4juce18LinuxErrorHandlingL13errorOccurredE, align 1, !tbaa !5, !range !9, !noundef !10
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %.split.us
  %5 = load i8, ptr @_ZN4juce18LinuxErrorHandlingL21keyboardBreakOccurredE, align 1, !tbaa !5, !range !9, !noundef !10
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %.split9.us, label %7

7:                                                ; preds = %4
  %8 = tail call noundef ptr @_ZN4juce20InternalMessageQueue26getInstanceWithoutCreatingEv() #4
  %.not.us = icmp eq ptr %8, null
  br i1 %.not.us, label %.split.us, label %9

9:                                                ; preds = %7
  %10 = tail call noundef zeroext i1 @_ZN4juce20InternalMessageQueue17dispatchNextEventEv(ptr noundef nonnull align 8 dereferenceable(80) %8)
  br label %.loopexit

.split:                                           ; preds = %1, %.split.backedge
  %11 = load i8, ptr @_ZN4juce18LinuxErrorHandlingL13errorOccurredE, align 1, !tbaa !5, !range !9, !noundef !10
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %.loopexit.loopexit21, label %13

13:                                               ; preds = %.split
  %14 = load i8, ptr @_ZN4juce18LinuxErrorHandlingL21keyboardBreakOccurredE, align 1, !tbaa !5, !range !9, !noundef !10
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %.split9.us, label %18

.split9.us:                                       ; preds = %13, %4
  store i8 1, ptr @_ZN4juce18LinuxErrorHandlingL13errorOccurredE, align 1, !tbaa !5
  %16 = tail call noundef zeroext i1 @_ZN4juce19JUCEApplicationBase15isStandaloneAppEv() #4
  br i1 %16, label %17, label %.loopexit

17:                                               ; preds = %.split9.us
  tail call void @_ZN4juce7Process9terminateEv()
  br label %.loopexit

18:                                               ; preds = %13
  %19 = tail call noundef ptr @_ZN4juce20InternalMessageQueue26getInstanceWithoutCreatingEv() #4
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %.split.backedge, label %20

.split.backedge:                                  ; preds = %18, %22
  br label %.split

20:                                               ; preds = %18
  %21 = tail call noundef zeroext i1 @_ZN4juce20InternalMessageQueue17dispatchNextEventEv(ptr noundef nonnull align 8 dereferenceable(80) %19)
  br i1 %21, label %.loopexit.loopexit21, label %22

22:                                               ; preds = %20
  %23 = tail call noundef zeroext i1 @_ZN4juce20InternalMessageQueue15sleepUntilEventEi(ptr noundef nonnull align 8 dereferenceable(80) %19, i32 noundef 2000)
  br label %.split.backedge

.loopexit.loopexit21:                             ; preds = %20, %.split
  %.2.ph = xor i1 %12, true
  br label %.loopexit

.loopexit:                                        ; preds = %.split.us, %.loopexit.loopexit21, %9, %17, %.split9.us
  %.2 = phi i1 [ false, %.split9.us ], [ false, %17 ], [ %10, %9 ], [ %.2.ph, %.loopexit.loopexit21 ], [ false, %.split.us ]
  ret i1 %.2
}

declare void @_ZN4juce7Process9terminateEv() local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce20InternalMessageQueue26getInstanceWithoutCreatingEv() local_unnamed_addr #3 align 2

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

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

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 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 = { "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 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopInstSimplifyPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass