; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/juce_audio_processors.ll (ZN4juce14AudioProcessor9removeBusEb)

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

%"struct.juce::AudioProcessor::BusProperties" = type <{ %"class.juce::String", %"class.juce::AudioChannelSet", i8, [7 x i8] }>
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::AudioChannelSet" = type { %"class.juce::BigInteger" }
%"class.juce::BigInteger" = type <{ %"class.juce::HeapBlock.50", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock.50" = type { ptr }
%"class.juce::AudioProcessor" = type { ptr, i32, ptr, %"class.juce::Array", %"class.juce::Component::SafePointer", double, i32, i32, i8, i8, i32, %"class.juce::CriticalSection", %"class.juce::CriticalSection", %"class.juce::OwnedArray", %"class.juce::OwnedArray", %"class.juce::String", %"class.juce::String", i32, i32, %"class.juce::OwnedArray.3" }
%"class.juce::Array" = 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::Component::SafePointer" = type { %"class.juce::WeakReference" }
%"class.juce::WeakReference" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = 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::OwnedArray" = type { %"class.juce::ArrayAllocationBase.0", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.0" = type <{ %"class.juce::HeapBlock.1", i32, [4 x i8] }>
%"class.juce::HeapBlock.1" = type { ptr }
%"class.juce::OwnedArray.3" = type { %"class.juce::ArrayAllocationBase.4", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.4" = type <{ %"class.juce::HeapBlock.5", i32, [4 x i8] }>
%"class.juce::HeapBlock.5" = 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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce14AudioProcessor9removeBusEb(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.juce::AudioProcessor::BusProperties", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %13 = zext i1 %1 to i8
  store i8 %13, ptr %5, align 1, !tbaa !9
  %14 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %15 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %16 = trunc i8 %15 to i1
  %17 = call noundef i32 @_ZNK4juce14AudioProcessor11getBusCountEb(ptr noundef nonnull align 8 dereferenceable(256) %14, i1 noundef zeroext %16) #4
  store i32 %17, ptr %6, align 4, !tbaa !13
  %18 = load i32, ptr %6, align 4, !tbaa !13
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %68

21:                                               ; preds = %2
  %22 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %23 = trunc i8 %22 to i1
  %24 = load ptr, ptr %14, align 8, !tbaa !15
  %25 = getelementptr inbounds ptr, ptr %24, i64 10
  %26 = load ptr, ptr %25, align 8
  %27 = call noundef zeroext i1 %26(ptr noundef nonnull align 8 dereferenceable(256) %14, i1 noundef zeroext %23)
  br i1 %27, label %29, label %28

28:                                               ; preds = %21
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %68

29:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 56, ptr %8) #4
  call void @_ZN4juce14AudioProcessor13BusPropertiesC2Ev(ptr noundef nonnull align 8 dereferenceable(49) %8) #4
  %30 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %31 = trunc i8 %30 to i1
  %32 = load ptr, ptr %14, align 8, !tbaa !15
  %33 = getelementptr inbounds ptr, ptr %32, i64 57
  %34 = load ptr, ptr %33, align 8
  %35 = invoke noundef zeroext i1 %34(ptr noundef nonnull align 8 dereferenceable(256) %14, i1 noundef zeroext %31, i1 noundef zeroext false, ptr noundef nonnull align 8 dereferenceable(49) %8)
          to label %36 unwind label %38

36:                                               ; preds = %29
  br i1 %35, label %42, label %37

37:                                               ; preds = %36
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %66

38:                                               ; preds = %29
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %9, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %10, align 4
  br label %67

42:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %43 = load i32, ptr %6, align 4, !tbaa !13
  %44 = sub nsw i32 %43, 1
  store i32 %44, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %45 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %46 = trunc i8 %45 to i1
  %47 = load i32, ptr %11, align 4, !tbaa !13
  %48 = call noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256) %14, i1 noundef zeroext %46, i32 noundef %47) #4
  store i32 %48, ptr %12, align 4, !tbaa !13
  %49 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %50 = trunc i8 %49 to i1
  br i1 %50, label %51, label %53

51:                                               ; preds = %42
  %52 = getelementptr inbounds %"class.juce::AudioProcessor", ptr %14, i32 0, i32 13
  br label %55

53:                                               ; preds = %42
  %54 = getelementptr inbounds %"class.juce::AudioProcessor", ptr %14, i32 0, i32 14
  br label %55

55:                                               ; preds = %53, %51
  %56 = phi ptr [ %52, %51 ], [ %54, %53 ]
  %57 = load i32, ptr %11, align 4, !tbaa !13
  invoke void @_ZN4juce10OwnedArrayINS_14AudioProcessor3BusENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20) %56, i32 noundef %57, i1 noundef zeroext true)
          to label %58 unwind label %62

58:                                               ; preds = %55
  %59 = load i32, ptr %12, align 4, !tbaa !13
  %60 = icmp sgt i32 %59, 0
  invoke void @_ZN4juce14AudioProcessor14audioIOChangedEbb(ptr noundef nonnull align 8 dereferenceable(256) %14, i1 noundef zeroext true, i1 noundef zeroext %60)
          to label %61 unwind label %62

61:                                               ; preds = %58
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %66

62:                                               ; preds = %58, %55
  %63 = landingpad { ptr, i32 }
          cleanup
  %64 = extractvalue { ptr, i32 } %63, 0
  store ptr %64, ptr %9, align 8
  %65 = extractvalue { ptr, i32 } %63, 1
  store i32 %65, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %67

66:                                               ; preds = %61, %37
  call void @_ZN4juce14AudioProcessor13BusPropertiesD2Ev(ptr noundef nonnull align 8 dereferenceable(49) %8) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr %8) #4
  br label %68

67:                                               ; preds = %62, %38
  call void @_ZN4juce14AudioProcessor13BusPropertiesD2Ev(ptr noundef nonnull align 8 dereferenceable(49) %8) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %70

68:                                               ; preds = %66, %28, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %69 = load i1, ptr %3, align 1
  ret i1 %69

70:                                               ; preds = %67
  %71 = load ptr, ptr %9, align 8
  %72 = load i32, ptr %10, align 4
  %73 = insertvalue { ptr, i32 } poison, ptr %71, 0
  %74 = insertvalue { ptr, i32 } %73, i32 %72, 1
  resume { ptr, i32 } %74
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce14AudioProcessor11getBusCountEb(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce10OwnedArrayINS_14AudioProcessor3BusENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef, i1 noundef zeroext) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce14AudioProcessor14audioIOChangedEbb(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i1 noundef zeroext) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, 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"

%"struct.juce::AudioProcessor::BusProperties" = type <{ %"class.juce::String", %"class.juce::AudioChannelSet", i8, [7 x i8] }>
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::AudioChannelSet" = type { %"class.juce::BigInteger" }
%"class.juce::BigInteger" = type <{ %"class.juce::HeapBlock.50", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock.50" = type { ptr }

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

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce14AudioProcessor9removeBusEb(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.juce::AudioProcessor::BusProperties", align 8
  %4 = tail call noundef i32 @_ZNK4juce14AudioProcessor11getBusCountEb(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1) #4
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %29, label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 80
  %9 = load ptr, ptr %8, align 8
  %10 = tail call noundef zeroext i1 %9(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1)
  br i1 %10, label %11, label %29

11:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %3) #4
  call void @_ZN4juce14AudioProcessor13BusPropertiesC2Ev(ptr noundef nonnull align 8 dereferenceable(49) %3) #4
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 456
  %14 = load ptr, ptr %13, align 8
  %15 = invoke noundef zeroext i1 %14(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i1 noundef zeroext false, ptr noundef nonnull align 8 dereferenceable(49) %3)
          to label %16 unwind label %17

16:                                               ; preds = %11
  br i1 %15, label %19, label %27

17:                                               ; preds = %11
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %28

19:                                               ; preds = %16
  %20 = add nsw i32 %4, -1
  %21 = call noundef i32 @_ZNK4juce14AudioProcessor20getChannelCountOfBusEbi(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext %1, i32 noundef %20) #4
  %.v = select i1 %1, i64 160, i64 184
  %22 = getelementptr inbounds i8, ptr %0, i64 %.v
  invoke void @_ZN4juce10OwnedArrayINS_14AudioProcessor3BusENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20) %22, i32 noundef %20, i1 noundef zeroext true)
          to label %23 unwind label %25

23:                                               ; preds = %19
  %24 = icmp sgt i32 %21, 0
  invoke void @_ZN4juce14AudioProcessor14audioIOChangedEbb(ptr noundef nonnull align 8 dereferenceable(256) %0, i1 noundef zeroext true, i1 noundef zeroext %24)
          to label %27 unwind label %25

25:                                               ; preds = %23, %19
  %26 = landingpad { ptr, i32 }
          cleanup
  br label %28

27:                                               ; preds = %23, %16
  call void @_ZN4juce14AudioProcessor13BusPropertiesD2Ev(ptr noundef nonnull align 8 dereferenceable(49) %3) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #4
  br label %29

28:                                               ; preds = %25, %17
  %.pn = phi { ptr, i32 } [ %26, %25 ], [ %18, %17 ]
  call void @_ZN4juce14AudioProcessor13BusPropertiesD2Ev(ptr noundef nonnull align 8 dereferenceable(49) %3) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #4
  resume { ptr, i32 } %.pn

29:                                               ; preds = %6, %2, %27
  %.1 = phi i1 [ %15, %27 ], [ false, %2 ], [ false, %6 ]
  ret i1 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce14AudioProcessor11getBusCountEb(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce14AudioProcessor14audioIOChangedEbb(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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