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

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

@.str.4 = external hidden unnamed_addr constant [13 x 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: 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

declare void @_ZN4juce11MemoryBlock10ensureSizeEmb(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext) #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6Server14receiveMessageEPN4juce15StreamingSocketEi(ptr noundef nonnull align 8 dereferenceable(664) %0, ptr noundef %1, i32 noundef %2) #3 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.juce::String", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call noundef zeroext i1 @_ZNK4juce15StreamingSocket11isConnectedEv(ptr noundef nonnull align 8 dereferenceable(64) %14) #5
  br i1 %15, label %16, label %65

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = call noundef i32 @_ZNK4juce15StreamingSocket14waitUntilReadyEbi(ptr noundef nonnull align 8 dereferenceable(64) %17, i1 noundef zeroext true, i32 noundef %18)
  store i32 %19, ptr %8, align 4, !tbaa !9
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %22, label %59

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  %25 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %24) #5
  %26 = call noundef i32 @_ZN4juce15StreamingSocket4readEPvib(ptr noundef nonnull align 8 dereferenceable(64) %23, ptr noundef %25, i32 noundef 8, i1 noundef zeroext true)
  store i32 %26, ptr %9, align 4, !tbaa !9
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %22
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %58

30:                                               ; preds = %22
  %31 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  %32 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK4juce11MemoryBlockixIiEERcT_(ptr noundef nonnull align 8 dereferenceable(16) %31, i32 noundef 8) #5
  store i8 0, ptr %32, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %33 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  call void @_ZNK4juce11MemoryBlock8toStringEv(ptr dead_on_unwind writable sret(%"class.juce::String") align 8 %12, ptr noundef nonnull align 8 dereferenceable(16) %33)
  %34 = call noundef i32 @_ZNK4juce6String13getHexValue32Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  store i32 %34, ptr %11, align 4, !tbaa !9
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %37, label %56

37:                                               ; preds = %30
  %38 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  call void @_ZN4juce11MemoryBlock10ensureSizeEmb(ptr noundef nonnull align 8 dereferenceable(16) %38, i64 noundef %40, i1 noundef zeroext true)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  %43 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %42) #5
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = call noundef i32 @_ZN4juce15StreamingSocket4readEPvib(ptr noundef nonnull align 8 dereferenceable(64) %41, ptr noundef %43, i32 noundef %44, i1 noundef zeroext true)
  store i32 %45, ptr %9, align 4, !tbaa !9
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = icmp slt i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %37
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %57

49:                                               ; preds = %37
  %50 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK4juce11MemoryBlockixIiEERcT_(ptr noundef nonnull align 8 dereferenceable(16) %50, i32 noundef %51) #5
  store i8 0, ptr %52, align 1, !tbaa !11
  %53 = getelementptr inbounds %class.Server, ptr %13, i32 0, i32 4
  %54 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %53) #5
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %54)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %57

56:                                               ; preds = %30
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %57

57:                                               ; preds = %56, %49, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %58

58:                                               ; preds = %57, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %64

59:                                               ; preds = %16
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i32 2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %64

63:                                               ; preds = %59
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %64

64:                                               ; preds = %63, %62, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %66

65:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  br label %66

66:                                               ; preds = %65, %64
  %67 = load i32, ptr %4, align 4
  ret i32 %67
}

declare void @_ZNK4juce11MemoryBlock8toStringEv(ptr dead_on_unwind writable sret(%"class.juce::String") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNK4juce11MemoryBlockixIiEERcT_(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce15StreamingSocket11isConnectedEv(ptr noundef nonnull align 8 dereferenceable(64)) #4 align 2

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

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce6String13getHexValue32Ev(ptr noundef nonnull align 8 dereferenceable(8)) #1

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 = { "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 = { 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 = !{!"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 = !{!7, !7, i64 0}


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

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1

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

; 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

declare void @_ZN4juce11MemoryBlock10ensureSizeEmb(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZN6Server14receiveMessageEPN4juce15StreamingSocketEi(ptr noundef nonnull align 8 dereferenceable(664) %0, ptr noundef nonnull %1, i32 noundef %2) local_unnamed_addr #4 align 2 {
  %4 = alloca %"class.juce::String", align 8
  %5 = tail call noundef zeroext i1 @_ZNK4juce15StreamingSocket11isConnectedEv(ptr noundef nonnull align 8 dereferenceable(64) %1) #6
  br i1 %5, label %6, label %29

6:                                                ; preds = %3
  %7 = tail call noundef i32 @_ZNK4juce15StreamingSocket14waitUntilReadyEbi(ptr noundef nonnull align 8 dereferenceable(64) %1, i1 noundef zeroext true, i32 noundef %2)
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %9, label %27

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 624
  %11 = tail call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  %12 = tail call noundef i32 @_ZN4juce15StreamingSocket4readEPvib(ptr noundef nonnull align 8 dereferenceable(64) %1, ptr noundef %11, i32 noundef 8, i1 noundef zeroext true)
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %29, label %14

14:                                               ; preds = %9
  %15 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK4juce11MemoryBlockixIiEERcT_(ptr noundef nonnull align 8 dereferenceable(16) %10, i32 noundef 8) #6
  store i8 0, ptr %15, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @_ZNK4juce11MemoryBlock8toStringEv(ptr dead_on_unwind nonnull writable sret(%"class.juce::String") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %10)
  %16 = call noundef i32 @_ZNK4juce6String13getHexValue32Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %18, label %29

18:                                               ; preds = %14
  %19 = zext nneg i32 %16 to i64
  call void @_ZN4juce11MemoryBlock10ensureSizeEmb(ptr noundef nonnull align 8 dereferenceable(16) %10, i64 noundef %19, i1 noundef zeroext true)
  %20 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  %21 = call noundef i32 @_ZN4juce15StreamingSocket4readEPvib(ptr noundef nonnull align 8 dereferenceable(64) %1, ptr noundef %20, i32 noundef %16, i1 noundef zeroext true)
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %29, label %23

23:                                               ; preds = %18
  %24 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK4juce11MemoryBlockixIiEERcT_(ptr noundef nonnull align 8 dereferenceable(16) %10, i32 noundef %16) #6
  store i8 0, ptr %24, align 1, !tbaa !5
  %25 = call noundef ptr @_ZNK4juce11MemoryBlock7getDataEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef %25)
  br label %29

27:                                               ; preds = %6
  %28 = icmp eq i32 %7, 0
  %. = select i1 %28, i32 2, i32 1
  br label %29

29:                                               ; preds = %3, %23, %18, %14, %9, %27
  %.3 = phi i32 [ 1, %9 ], [ 0, %23 ], [ 1, %18 ], [ 0, %14 ], [ %., %27 ], [ 1, %3 ]
  ret i32 %.3
}

declare void @_ZNK4juce11MemoryBlock8toStringEv(ptr dead_on_unwind writable sret(%"class.juce::String") align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

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

; 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce15StreamingSocket11isConnectedEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #5 align 2

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

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce6String13getHexValue32Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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 = { "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 = { nofree 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 #4 = { 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 #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 }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass