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

; 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::ScopedPointer.29" = type { ptr }
%"class.juce::InterprocessConnectionServer" = type { %"class.juce::Thread.base", %"class.juce::ScopedPointer.29" }
%"class.juce::Thread.base" = type <{ ptr, %"class.juce::String", ptr, ptr, %"class.juce::CriticalSection", %"class.juce::WaitableEvent", %"class.juce::WaitableEvent", i32, [4 x i8], i64, i32, i8 }>
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = 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::WaitableEvent" = type <{ %union.pthread_cond_t, %union.pthread_mutex_t, i8, i8, [6 x i8] }>
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN4juce13ScopedPointerINS_15StreamingSocketEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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_15StreamingSocketEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce28InterprocessConnectionServer3runEv(ptr noundef nonnull align 8 dereferenceable(296) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.juce::ScopedPointer.29", align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  br label %8

8:                                                ; preds = %39, %1
  %9 = call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %7)
  br i1 %9, label %14, label %10

10:                                               ; preds = %8
  %11 = getelementptr inbounds %"class.juce::InterprocessConnectionServer", ptr %7, i32 0, i32 1
  %12 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %13 = icmp ne ptr %12, null
  br label %14

14:                                               ; preds = %10, %8
  %15 = phi i1 [ false, %8 ], [ %13, %10 ]
  br i1 %15, label %16, label %40

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %17 = getelementptr inbounds %"class.juce::InterprocessConnectionServer", ptr %7, i32 0, i32 1
  %18 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %17) #5
  %19 = call noundef ptr @_ZNK4juce15StreamingSocket21waitForNextConnectionEv(ptr noundef nonnull align 8 dereferenceable(64) %18)
  call void @_ZN4juce13ScopedPointerINS_15StreamingSocketEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef %19) #5
  %20 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %39

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %23 = load ptr, ptr %7, align 8, !tbaa !9
  %24 = getelementptr inbounds ptr, ptr %23, i64 3
  %25 = load ptr, ptr %24, align 8
  %26 = invoke noundef ptr %25(ptr noundef nonnull align 8 dereferenceable(296) %7)
          to label %27 unwind label %34

27:                                               ; preds = %22
  store ptr %26, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %38

30:                                               ; preds = %27
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call noundef ptr @_ZN4juce13ScopedPointerINS_15StreamingSocketEE7releaseEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  invoke void @_ZN4juce22InterprocessConnection20initialiseWithSocketEPNS_15StreamingSocketE(ptr noundef nonnull align 8 dereferenceable(96) %31, ptr noundef %32)
          to label %33 unwind label %34

33:                                               ; preds = %30
  br label %38

34:                                               ; preds = %30, %22
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %5, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @_ZN4juce13ScopedPointerINS_15StreamingSocketEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %41

38:                                               ; preds = %33, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %39

39:                                               ; preds = %38, %16
  call void @_ZN4juce13ScopedPointerINS_15StreamingSocketEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %8, !llvm.loop !11

40:                                               ; preds = %14
  ret void

41:                                               ; preds = %34
  %42 = load ptr, ptr %5, align 8
  %43 = load i32, ptr %6, align 4
  %44 = insertvalue { ptr, i32 } poison, ptr %42, 0
  %45 = insertvalue { ptr, i32 } %44, i32 %43, 1
  resume { ptr, i32 } %45
}

declare noundef ptr @_ZNK4juce15StreamingSocket21waitForNextConnectionEv(ptr noundef nonnull align 8 dereferenceable(64)) #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce13ScopedPointerINS_15StreamingSocketEE7releaseEv(ptr noundef nonnull align 8 dereferenceable(8)) #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 = { 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 = !{!"vtable pointer", !8, 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"

%"class.juce::ScopedPointer.29" = type { ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; 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 noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce13ScopedPointerINS_15StreamingSocketEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 #2 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 #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce28InterprocessConnectionServer3runEv(ptr noundef nonnull align 8 dereferenceable(296) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.juce::ScopedPointer.29", align 8
  %3 = tail call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %0)
  br i1 %3, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 288
  br label %5

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

7:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %8 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %9 = call noundef ptr @_ZNK4juce15StreamingSocket21waitForNextConnectionEv(ptr noundef nonnull align 8 dereferenceable(64) %8)
  call void @_ZN4juce13ScopedPointerINS_15StreamingSocketEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef %9) #5
  %10 = call noundef ptr @_ZNK4juce13ScopedPointerINS_15StreamingSocketEEcvPS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %.not4 = icmp eq ptr %10, null
  br i1 %.not4, label %21, label %11

11:                                               ; preds = %7
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 24
  %14 = load ptr, ptr %13, align 8
  %15 = invoke noundef ptr %14(ptr noundef nonnull align 8 dereferenceable(296) %0)
          to label %16 unwind label %19

16:                                               ; preds = %11
  %.not5 = icmp eq ptr %15, null
  br i1 %.not5, label %21, label %17

17:                                               ; preds = %16
  %18 = call noundef ptr @_ZN4juce13ScopedPointerINS_15StreamingSocketEE7releaseEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  invoke void @_ZN4juce22InterprocessConnection20initialiseWithSocketEPNS_15StreamingSocketE(ptr noundef nonnull align 8 dereferenceable(96) %15, ptr noundef %18)
          to label %21 unwind label %19

19:                                               ; preds = %17, %11
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce13ScopedPointerINS_15StreamingSocketEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  resume { ptr, i32 } %20

21:                                               ; preds = %16, %17, %7
  call void @_ZN4juce13ScopedPointerINS_15StreamingSocketEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %22 = call noundef zeroext i1 @_ZNK4juce6Thread16threadShouldExitEv(ptr noundef nonnull align 8 dereferenceable(285) %0)
  br i1 %22, label %.critedge, label %5, !llvm.loop !8

.critedge:                                        ; preds = %5, %21, %1
  ret void
}

declare noundef ptr @_ZNK4juce15StreamingSocket21waitForNextConnectionEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce13ScopedPointerINS_15StreamingSocketEE7releaseEv(ptr noundef nonnull align 8 dereferenceable(8)) 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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