; 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::GenericScopedLock" = type { ptr }
%"class.juce::Synthesiser" = type { ptr, %"class.juce::CriticalSection", %"class.juce::OwnedArray", %"class.juce::ReferenceCountedArray", [16 x i32], double, i32, i32, i8, i8, [6 x i8], %"class.juce::BigInteger" }
%"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.3", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.3" = type <{ %"class.juce::HeapBlock.4", i32, [4 x i8] }>
%"class.juce::HeapBlock.4" = type { ptr }
%"class.juce::ReferenceCountedArray" = type { %"class.juce::ArrayAllocationBase.6", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.6" = type <{ %"class.juce::HeapBlock.7", i32, [4 x i8] }>
%"class.juce::HeapBlock.7" = type { ptr }
%"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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce11Synthesiser16handleControllerEiii(ptr noundef nonnull align 8 dereferenceable(224) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"class.juce::GenericScopedLock", align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8
  %15 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %15, label %37 [
    i32 64, label %16
    i32 66, label %23
    i32 67, label %30
  ]

16:                                               ; preds = %4
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = icmp sge i32 %18, 64
  %20 = load ptr, ptr %14, align 8, !tbaa !11
  %21 = getelementptr inbounds ptr, ptr %20, i64 9
  %22 = load ptr, ptr %21, align 8
  call void %22(ptr noundef nonnull align 8 dereferenceable(224) %14, i32 noundef %17, i1 noundef zeroext %19)
  br label %38

23:                                               ; preds = %4
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp sge i32 %25, 64
  %27 = load ptr, ptr %14, align 8, !tbaa !11
  %28 = getelementptr inbounds ptr, ptr %27, i64 10
  %29 = load ptr, ptr %28, align 8
  call void %29(ptr noundef nonnull align 8 dereferenceable(224) %14, i32 noundef %24, i1 noundef zeroext %26)
  br label %38

30:                                               ; preds = %4
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = icmp sge i32 %32, 64
  %34 = load ptr, ptr %14, align 8, !tbaa !11
  %35 = getelementptr inbounds ptr, ptr %34, i64 11
  %36 = load ptr, ptr %35, align 8
  call void %36(ptr noundef nonnull align 8 dereferenceable(224) %14, i32 noundef %31, i1 noundef zeroext %33)
  br label %38

37:                                               ; preds = %4
  br label %38

38:                                               ; preds = %37, %30, %23, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %39 = getelementptr inbounds %"class.juce::Synthesiser", ptr %14, i32 0, i32 1
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(40) %39) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %40 = getelementptr inbounds %"class.juce::Synthesiser", ptr %14, i32 0, i32 2
  %41 = call noundef i32 @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %40) #3
  store i32 %41, ptr %10, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %73, %38
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %10, align 4, !tbaa !9
  %45 = icmp sge i32 %44, 0
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %74

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %48 = getelementptr inbounds %"class.juce::Synthesiser", ptr %14, i32 0, i32 2
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %48, i32 noundef %49) #3
  store ptr %50, ptr %11, align 8, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = icmp sle i32 %51, 0
  br i1 %52, label %61, label %53

53:                                               ; preds = %47
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = load ptr, ptr %54, align 8, !tbaa !11
  %57 = getelementptr inbounds ptr, ptr %56, i64 13
  %58 = load ptr, ptr %57, align 8
  %59 = invoke noundef zeroext i1 %58(ptr noundef nonnull align 8 dereferenceable(344) %54, i32 noundef %55)
          to label %60 unwind label %69

60:                                               ; preds = %53
  br i1 %59, label %61, label %73

61:                                               ; preds = %60, %47
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = load ptr, ptr %62, align 8, !tbaa !11
  %66 = getelementptr inbounds ptr, ptr %65, i64 7
  %67 = load ptr, ptr %66, align 8
  invoke void %67(ptr noundef nonnull align 8 dereferenceable(344) %62, i32 noundef %63, i32 noundef %64)
          to label %68 unwind label %69

68:                                               ; preds = %61
  br label %73

69:                                               ; preds = %61, %53
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %12, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %75

73:                                               ; preds = %68, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %42, !llvm.loop !13

74:                                               ; preds = %46
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void

75:                                               ; preds = %69
  %76 = load ptr, ptr %12, align 8
  %77 = load i32, ptr %13, align 4
  %78 = insertvalue { ptr, i32 } poison, ptr %76, 0
  %79 = insertvalue { ptr, i32 } %78, i32 %77, 1
  resume { ptr, i32 } %79
}

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 = { 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 = !{!"vtable pointer", !8, 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::GenericScopedLock" = 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce11Synthesiser16handleControllerEiii(ptr noundef nonnull align 8 dereferenceable(224) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.juce::GenericScopedLock", align 8
  switch i32 %2, label %12 [
    i32 64, label %.sink.split
    i32 66, label %6
    i32 67, label %7
  ]

6:                                                ; preds = %4
  br label %.sink.split

7:                                                ; preds = %4
  br label %.sink.split

.sink.split:                                      ; preds = %4, %6, %7
  %.sink24 = phi i64 [ 88, %7 ], [ 80, %6 ], [ 72, %4 ]
  %8 = icmp sgt i32 %3, 63
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 %.sink24
  %11 = load ptr, ptr %10, align 8
  tail call void %11(ptr noundef nonnull align 8 dereferenceable(224) %0, i32 noundef %1, i1 noundef zeroext %8)
  br label %12

12:                                               ; preds = %.sink.split, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(40) %13) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = call noundef i32 @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %14) #3
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %12
  %17 = add nsw i32 %15, -1
  %18 = icmp slt i32 %1, 1
  br i1 %18, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %24
  %19 = phi i32 [ %25, %24 ], [ %17, %.lr.ph ]
  %20 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %14, i32 noundef %19) #3
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 56
  %23 = load ptr, ptr %22, align 8
  invoke void %23(ptr noundef nonnull align 8 dereferenceable(344) %20, i32 noundef %2, i32 noundef %3)
          to label %24 unwind label %.split.us

24:                                               ; preds = %.lr.ph.split.us
  %25 = add nsw i32 %19, -1
  %26 = icmp sgt i32 %19, 0
  br i1 %26, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !8

.split.us:                                        ; preds = %.lr.ph.split.us
  %27 = landingpad { ptr, i32 }
          cleanup
  br label %40

._crit_edge:                                      ; preds = %41, %24, %12
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret void

.lr.ph.split:                                     ; preds = %.lr.ph, %41
  %28 = phi i32 [ %42, %41 ], [ %17, %.lr.ph ]
  %29 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %14, i32 noundef %28) #3
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 104
  %32 = load ptr, ptr %31, align 8
  %33 = invoke noundef zeroext i1 %32(ptr noundef nonnull align 8 dereferenceable(344) %29, i32 noundef %1)
          to label %34 unwind label %.split

34:                                               ; preds = %.lr.ph.split
  br i1 %33, label %35, label %41

35:                                               ; preds = %34
  %36 = load ptr, ptr %29, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 56
  %38 = load ptr, ptr %37, align 8
  invoke void %38(ptr noundef nonnull align 8 dereferenceable(344) %29, i32 noundef %2, i32 noundef %3)
          to label %41 unwind label %.split

.split:                                           ; preds = %35, %.lr.ph.split
  %39 = landingpad { ptr, i32 }
          cleanup
  br label %40

40:                                               ; preds = %.split.us, %.split
  %.us-phi = phi { ptr, i32 } [ %39, %.split ], [ %27, %.split.us ]
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  resume { ptr, i32 } %.us-phi

41:                                               ; preds = %35, %34
  %42 = add nsw i32 %28, -1
  %43 = icmp sgt i32 %28, 0
  br i1 %43, label %.lr.ph.split, label %._crit_edge, !llvm.loop !8
}

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 = { 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,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass