; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_audio_basics)

; 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::Array.16" = type { %"class.juce::ArrayAllocationBase.17", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.17" = type <{ %"class.juce::HeapBlock.18", i32, [4 x i8] }>
%"class.juce::HeapBlock.18" = type { ptr }
%"class.juce::AudioChannelSet" = type { %"class.juce::BigInteger" }
%"class.juce::BigInteger" = type <{ %"class.juce::HeapBlock.9", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock.9" = 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: 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 @_ZNK4juce15AudioChannelSet15getChannelTypesEv(ptr dead_on_unwind noalias writable sret(%"class.juce::Array.16") align 8 %0, ptr noundef nonnull align 8 dereferenceable(40) %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %11 = getelementptr inbounds %"class.juce::AudioChannelSet", ptr %10, i32 0, i32 0
  %12 = call noundef i32 @_ZNK4juce10BigInteger14findNextSetBitEi(ptr noundef nonnull align 8 dereferenceable(37) %11, i32 noundef 0) #4
  store i32 %12, ptr %6, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %20, %2
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %29

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %18 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %18, ptr %7, align 4, !tbaa !11
  invoke void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EE3addEOS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %19 unwind label %25

19:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %20

20:                                               ; preds = %19
  %21 = getelementptr inbounds %"class.juce::AudioChannelSet", ptr %10, i32 0, i32 0
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  %24 = call noundef i32 @_ZNK4juce10BigInteger14findNextSetBitEi(ptr noundef nonnull align 8 dereferenceable(37) %21, i32 noundef %23) #4
  store i32 %24, ptr %6, align 4, !tbaa !9
  br label %13, !llvm.loop !13

25:                                               ; preds = %17
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %8, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  br label %33

29:                                               ; preds = %16
  store i1 true, ptr %5, align 1
  %30 = load i1, ptr %5, align 1
  br i1 %30, label %32, label %31

31:                                               ; preds = %29
  call void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  br label %32

32:                                               ; preds = %31, %29
  ret void

33:                                               ; preds = %25
  %34 = load ptr, ptr %8, align 8
  %35 = load i32, ptr %9, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce10BigInteger14findNextSetBitEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EE3addEOS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN4juce15AudioChannelSet11ChannelTypeE", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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::Array.16" = type { %"class.juce::ArrayAllocationBase.17", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.17" = type <{ %"class.juce::HeapBlock.18", i32, [4 x i8] }>
%"class.juce::HeapBlock.18" = 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 uwtable
define dso_local void @_ZNK4juce15AudioChannelSet15getChannelTypesEv(ptr dead_on_unwind noalias nonnull writable sret(%"class.juce::Array.16") align 8 %0, ptr noundef nonnull align 8 dereferenceable(40) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  tail call void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  %4 = tail call noundef i32 @_ZNK4juce10BigInteger14findNextSetBitEi(ptr noundef nonnull align 8 dereferenceable(37) %1, i32 noundef 0) #4
  %5 = icmp sgt i32 %4, -1
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %6
  %.06 = phi i32 [ %8, %6 ], [ %4, %2 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 %.06, ptr %3, align 4, !tbaa !5
  invoke void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EE3addEOS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %6 unwind label %10

6:                                                ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %7 = add nuw nsw i32 %.06, 1
  %8 = call noundef i32 @_ZNK4juce10BigInteger14findNextSetBitEi(ptr noundef nonnull align 8 dereferenceable(37) %1, i32 noundef %7) #4
  %9 = icmp sgt i32 %8, -1
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !9

10:                                               ; preds = %.lr.ph
  %11 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  resume { ptr, i32 } %11

._crit_edge:                                      ; preds = %6, %2
  ret void
}

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce10BigInteger14findNextSetBitEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce5ArrayINS_15AudioChannelSet11ChannelTypeENS_20DummyCriticalSectionELi0EE3addEOS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 = { 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 = !{!"_ZTSN4juce15AudioChannelSet11ChannelTypeE", !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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass