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

; 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::InterprocessConnection" = type { ptr, %"class.juce::WeakReference<juce::InterprocessConnection>::Master", %"class.juce::CriticalSection", %"class.juce::ScopedPointer.29", %"class.juce::ScopedPointer.30", i8, i8, i32, i32, %"class.juce::ScopedPointer.31" }
%"class.juce::WeakReference<juce::InterprocessConnection>::Master" = type { %"class.juce::ReferenceCountedObjectPtr.28" }
%"class.juce::ReferenceCountedObjectPtr.28" = 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 }
%"class.juce::ScopedPointer.29" = type { ptr }
%"class.juce::ScopedPointer.30" = type { ptr }
%"class.juce::ScopedPointer.31" = type { 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285)) #1 align 2

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce22InterprocessConnection19deletePipeAndSocketEv(ptr noundef nonnull align 8 dereferenceable(96)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce22InterprocessConnection17connectionLostIntEv(ptr noundef nonnull align 8 dereferenceable(96)) #3 align 2

declare noundef zeroext i1 @_ZNK4juce9NamedPipe6isOpenEv(ptr noundef nonnull align 8 dereferenceable(160)) #4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce22InterprocessConnection9runThreadEv(ptr noundef nonnull align 8 dereferenceable(96) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  br label %6

6:                                                ; preds = %52, %30, %1
  %7 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 9
  %8 = call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  %9 = call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %8)
  %10 = xor i1 %9, true
  br i1 %10, label %11, label %53

11:                                               ; preds = %6
  %12 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 3
  %13 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %33

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %16 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 3
  %17 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %16) #5
  %18 = call noundef i32 @_ZNK4juce15StreamingSocket14waitUntilReadyEbi(ptr noundef nonnull align 8 dereferenceable(64) %17, i1 noundef zeroext true, i32 noundef 0)
  store i32 %18, ptr %3, align 4, !tbaa !9
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %15
  call void @_ZN4juce22InterprocessConnection19deletePipeAndSocketEv(ptr noundef nonnull align 8 dereferenceable(96) %5)
  call void @_ZN4juce22InterprocessConnection17connectionLostIntEv(ptr noundef nonnull align 8 dereferenceable(96) %5)
  store i32 3, ptr %4, align 4
  br label %30

22:                                               ; preds = %15
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %22
  %26 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 9
  %27 = call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %26) #5
  %28 = call noundef zeroext i1 @_ZNK4juce6Thread4waitEi(ptr noundef nonnull align 8 dereferenceable(285) %27, i32 noundef 1)
  store i32 2, ptr %4, align 4
  br label %30, !llvm.loop !11

29:                                               ; preds = %22
  store i32 0, ptr %4, align 4
  br label %30

30:                                               ; preds = %29, %25, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %31 = load i32, ptr %4, align 4
  switch i32 %31, label %54 [
    i32 0, label %32
    i32 3, label %53
    i32 2, label %6
  ]

32:                                               ; preds = %30
  br label %45

33:                                               ; preds = %11
  %34 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 4
  %35 = call noundef ptr @_ZNK4juce13ScopedPointerINS_9NamedPipeEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %34) #5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %43

37:                                               ; preds = %33
  %38 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 4
  %39 = call noundef ptr @_ZNK4juce13ScopedPointerINS_9NamedPipeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %38) #5
  %40 = call noundef zeroext i1 @_ZNK4juce9NamedPipe6isOpenEv(ptr noundef nonnull align 8 dereferenceable(160) %39)
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  call void @_ZN4juce22InterprocessConnection19deletePipeAndSocketEv(ptr noundef nonnull align 8 dereferenceable(96) %5)
  call void @_ZN4juce22InterprocessConnection17connectionLostIntEv(ptr noundef nonnull align 8 dereferenceable(96) %5)
  br label %53

42:                                               ; preds = %37
  br label %44

43:                                               ; preds = %33
  br label %53

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44, %32
  %46 = getelementptr inbounds %"class.juce::InterprocessConnection", ptr %5, i32 0, i32 9
  %47 = call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %46) #5
  %48 = call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %47)
  br i1 %48, label %51, label %49

49:                                               ; preds = %45
  %50 = call noundef zeroext i1 @_ZN4juce22InterprocessConnection18readNextMessageIntEv(ptr noundef nonnull align 8 dereferenceable(96) %5)
  br i1 %50, label %52, label %51

51:                                               ; preds = %49, %45
  br label %53

52:                                               ; preds = %49
  br label %6, !llvm.loop !11

53:                                               ; preds = %51, %43, %41, %30, %6
  ret void

54:                                               ; preds = %30
  unreachable
}

declare noundef i32 @_ZNK4juce15StreamingSocket14waitUntilReadyEbi(ptr noundef nonnull align 8 dereferenceable(64), i1 noundef zeroext, i32 noundef) #4

declare noundef zeroext i1 @_ZNK4juce6Thread4waitEi(ptr noundef nonnull align 8 dereferenceable(285), i32 noundef) #4

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 = { 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 #4 = { "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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285)) local_unnamed_addr #0 align 2

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce22InterprocessConnection19deletePipeAndSocketEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce22InterprocessConnection17connectionLostIntEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #2 align 2

declare noundef zeroext i1 @_ZNK4juce9NamedPipe6isOpenEv(ptr noundef nonnull align 8 dereferenceable(160)) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce22InterprocessConnection9runThreadEv(ptr noundef nonnull align 8 dereferenceable(96) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 88
  %3 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  %4 = tail call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %3)
  br i1 %4, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  br label %7

7:                                                ; preds = %.lr.ph, %.backedge
  %8 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %18, label %9

9:                                                ; preds = %7
  %10 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  %11 = tail call noundef i32 @_ZNK4juce15StreamingSocket14waitUntilReadyEbi(ptr noundef nonnull align 8 dereferenceable(64) %10, i1 noundef zeroext true, i32 noundef 0)
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %.loopexit.sink.split, label %13

13:                                               ; preds = %9
  %14 = icmp eq i32 %11, 0
  br i1 %14, label %15, label %.thread

15:                                               ; preds = %13
  %16 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  %17 = tail call noundef zeroext i1 @_ZNK4juce6Thread4waitEi(ptr noundef nonnull align 8 dereferenceable(285) %16, i32 noundef 1)
  br label %.backedge

18:                                               ; preds = %7
  %19 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_9NamedPipeEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  %.not4 = icmp eq ptr %19, null
  br i1 %.not4, label %.loopexit, label %20

20:                                               ; preds = %18
  %21 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_9NamedPipeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  %22 = tail call noundef zeroext i1 @_ZNK4juce9NamedPipe6isOpenEv(ptr noundef nonnull align 8 dereferenceable(160) %21)
  br i1 %22, label %.thread, label %.loopexit.sink.split

.thread:                                          ; preds = %13, %20
  %23 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  %24 = tail call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %23)
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %.thread
  %26 = tail call noundef zeroext i1 @_ZN4juce22InterprocessConnection18readNextMessageIntEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  br i1 %26, label %.backedge, label %.loopexit

.backedge:                                        ; preds = %25, %15
  %27 = tail call noundef ptr @_ZNK4juce13ScopedPointerINS_22InterprocessConnection16ConnectionThreadEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  %28 = tail call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %27)
  br i1 %28, label %.loopexit, label %7, !llvm.loop !5

.loopexit.sink.split:                             ; preds = %20, %9
  tail call void @_ZN4juce22InterprocessConnection19deletePipeAndSocketEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  tail call void @_ZN4juce22InterprocessConnection17connectionLostIntEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  br label %.loopexit

.loopexit:                                        ; preds = %.backedge, %18, %25, %.thread, %.loopexit.sink.split, %1
  ret void
}

declare noundef i32 @_ZNK4juce15StreamingSocket14waitUntilReadyEbi(ptr noundef nonnull align 8 dereferenceable(64), i1 noundef zeroext, i32 noundef) local_unnamed_addr #3

declare noundef zeroext i1 @_ZNK4juce6Thread4waitEi(ptr noundef nonnull align 8 dereferenceable(285), i32 noundef) local_unnamed_addr #3

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 = { 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 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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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