; LLVM IR from modlfo/AudioEngine :: AudioEngine/Source/Server.ll (ZN6Server17broadCastResponseEv)

; 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::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%class.Server = type { %"class.juce::Thread.base", i32, %class.ServerConnections, %"class.juce::OwnedArray", %"class.juce::MemoryBlock", %"class.juce::MemoryBlock", ptr }
%"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::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 }
%class.ServerConnections = type { %"class.juce::Thread.base", ptr, ptr }
%"class.juce::OwnedArray" = type { %"class.juce::ArrayAllocationBase", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase" = type <{ %"class.juce::HeapBlock", i32, [4 x i8] }>
%"class.juce::HeapBlock" = type { ptr }
%"class.juce::MemoryBlock" = type { %"class.juce::HeapBlock.0", i64 }
%"class.juce::HeapBlock.0" = type { ptr }

; 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: nounwind
declare void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

; 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 void @_ZN6Server17broadCastResponseEv(ptr noundef nonnull align 8 dereferenceable(664) %0) #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.juce::String", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  %9 = getelementptr inbounds %class.Server, ptr %8, i32 0, i32 3
  %10 = call noundef i32 @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %9) #7
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %42

12:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %13 = getelementptr inbounds %class.Server, ptr %8, i32 0, i32 3
  %14 = call noundef ptr @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE5beginEv(ptr noundef nonnull align 8 dereferenceable(20) %13) #7
  store ptr %14, ptr %3, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %20, %12
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.Server, ptr %8, i32 0, i32 3
  %18 = call noundef ptr @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE3endEv(ptr noundef nonnull align 8 dereferenceable(20) %17) #7
  %19 = icmp ne ptr %16, %18
  br i1 %19, label %20, label %33

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %22, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.Server, ptr %8, i32 0, i32 5
  %25 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %24) #7
  %26 = getelementptr inbounds %class.Server, ptr %8, i32 0, i32 5
  %27 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %26) #7
  %28 = call i64 @strlen(ptr noundef %27) #8
  %29 = trunc i64 %28 to i32
  %30 = call noundef i32 @_ZN4juce15StreamingSocket5writeEPKvi(ptr noundef nonnull align 8 dereferenceable(64) %23, ptr noundef %25, i32 noundef %29)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds ptr, ptr %31, i32 1
  store ptr %32, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %15, !llvm.loop !9

33:                                               ; preds = %15
  %34 = getelementptr inbounds %class.Server, ptr %8, i32 0, i32 5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @_ZN6Server14makeStringSizeEi(ptr dead_on_unwind writable sret(%"class.juce::String") align 8 %5, ptr noundef nonnull align 8 dereferenceable(664) %8, i32 noundef 0)
  %35 = invoke noundef ptr @_ZNK4juce6String9toRawUTF8Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %36 unwind label %38

36:                                               ; preds = %33
  invoke void @_ZN4juce11MemoryBlock11replaceWithEPKvm(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef %35, i64 noundef 8)
          to label %37 unwind label %38

37:                                               ; preds = %36
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %42

38:                                               ; preds = %36, %33
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %6, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %7, align 4
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %43

42:                                               ; preds = %37, %1
  ret void

43:                                               ; preds = %38
  %44 = load ptr, ptr %6, align 8
  %45 = load i32, ptr %7, align 4
  %46 = insertvalue { ptr, i32 } poison, ptr %44, 0
  %47 = insertvalue { ptr, i32 } %46, i32 %45, 1
  resume { ptr, i32 } %47
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Server14makeStringSizeEi(ptr dead_on_unwind noalias writable sret(%"class.juce::String") align 8, ptr noundef nonnull align 8 dereferenceable(664), i32 noundef) #2 align 2

declare void @_ZN4juce11MemoryBlock11replaceWithEPKvm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) #4

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

declare noundef i32 @_ZN4juce15StreamingSocket5writeEPKvi(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef, i32 noundef) #4

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #6

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

!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 = distinct !{!9, !10}
!10 = !{!"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::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = 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: nounwind
declare void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

; 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 uwtable
define dso_local void @_ZN6Server17broadCastResponseEv(ptr noundef nonnull align 8 dereferenceable(664) %0) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.juce::String", align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 600
  %4 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #7
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %6, label %25

6:                                                ; preds = %1
  %7 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE5beginEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #7
  %8 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE3endEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #7
  %.not6 = icmp eq ptr %7, %8
  br i1 %.not6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 640
  br label %10

10:                                               ; preds = %.lr.ph, %10
  %.07 = phi ptr [ %7, %.lr.ph ], [ %17, %10 ]
  %11 = load ptr, ptr %.07, align 8, !tbaa !5
  %12 = tail call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %9) #7
  %13 = tail call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %9) #7
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %13) #8
  %15 = trunc i64 %14 to i32
  %16 = tail call noundef i32 @_ZN4juce15StreamingSocket5writeEPKvi(ptr noundef nonnull align 8 dereferenceable(64) %11, ptr noundef %12, i32 noundef %15)
  %17 = getelementptr inbounds i8, ptr %.07, i64 8
  %18 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_15StreamingSocketENS_20DummyCriticalSectionEE3endEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #7
  %.not = icmp eq ptr %17, %18
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !9

._crit_edge:                                      ; preds = %10, %6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @_ZN6Server14makeStringSizeEi(ptr dead_on_unwind nonnull writable sret(%"class.juce::String") align 8 %2, ptr noundef nonnull align 8 dereferenceable(664) %0, i32 noundef 0)
  %19 = invoke noundef ptr @_ZNK4juce6String9toRawUTF8Ev(ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %20 unwind label %23

20:                                               ; preds = %._crit_edge
  %21 = getelementptr inbounds i8, ptr %0, i64 640
  invoke void @_ZN4juce11MemoryBlock11replaceWithEPKvm(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef %19, i64 noundef 8)
          to label %22 unwind label %23

22:                                               ; preds = %20
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %25

23:                                               ; preds = %20, %._crit_edge
  %24 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  resume { ptr, i32 } %24

25:                                               ; preds = %22, %1
  ret void
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Server14makeStringSizeEi(ptr dead_on_unwind noalias writable sret(%"class.juce::String") align 8, ptr noundef nonnull align 8 dereferenceable(664), i32 noundef) local_unnamed_addr #2 align 2

declare void @_ZN4juce11MemoryBlock11replaceWithEPKvm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) local_unnamed_addr #4

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

declare noundef i32 @_ZN4juce15StreamingSocket5writeEPKvi(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #6

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

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


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