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

%"struct.juce::MidiRPNDetector::ChannelState" = type { i8, i8, i8, i8, i8 }
%"struct.juce::MidiRPNMessage" = type { i32, i32, i32, i8, i8 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4juce15MidiRPNDetector12ChannelState11sendIfReadyEiRNS_14MidiRPNMessageE(ptr noundef nonnull align 1 dereferenceable(5) %0, i32 noundef %1, ptr noundef nonnull align 4 dereferenceable(16) %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8
  %9 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 0
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = zext i8 %10 to i32
  %12 = icmp slt i32 %11, 128
  br i1 %12, label %13, label %70

13:                                               ; preds = %3
  %14 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 1
  %15 = load i8, ptr %14, align 1, !tbaa !14
  %16 = zext i8 %15 to i32
  %17 = icmp slt i32 %16, 128
  br i1 %17, label %18, label %70

18:                                               ; preds = %13
  %19 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 2
  %20 = load i8, ptr %19, align 1, !tbaa !15
  %21 = zext i8 %20 to i32
  %22 = icmp slt i32 %21, 128
  br i1 %22, label %23, label %69

23:                                               ; preds = %18
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %25, i32 0, i32 0
  store i32 %24, ptr %26, align 4, !tbaa !16
  %27 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 0
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = zext i8 %28 to i32
  %30 = shl i32 %29, 7
  %31 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 1
  %32 = load i8, ptr %31, align 1, !tbaa !14
  %33 = zext i8 %32 to i32
  %34 = add nsw i32 %30, %33
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %35, i32 0, i32 1
  store i32 %34, ptr %36, align 4, !tbaa !18
  %37 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 4
  %38 = load i8, ptr %37, align 1, !tbaa !19, !range !20, !noundef !21
  %39 = trunc i8 %38 to i1
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %40, i32 0, i32 3
  %42 = zext i1 %39 to i8
  store i8 %42, ptr %41, align 4, !tbaa !22
  %43 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 3
  %44 = load i8, ptr %43, align 1, !tbaa !23
  %45 = zext i8 %44 to i32
  %46 = icmp slt i32 %45, 128
  br i1 %46, label %47, label %60

47:                                               ; preds = %23
  %48 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 2
  %49 = load i8, ptr %48, align 1, !tbaa !15
  %50 = zext i8 %49 to i32
  %51 = shl i32 %50, 7
  %52 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 3
  %53 = load i8, ptr %52, align 1, !tbaa !23
  %54 = zext i8 %53 to i32
  %55 = add nsw i32 %51, %54
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %56, i32 0, i32 2
  store i32 %55, ptr %57, align 4, !tbaa !24
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %58, i32 0, i32 4
  store i8 1, ptr %59, align 1, !tbaa !25
  br label %68

60:                                               ; preds = %23
  %61 = getelementptr inbounds %"struct.juce::MidiRPNDetector::ChannelState", ptr %8, i32 0, i32 2
  %62 = load i8, ptr %61, align 1, !tbaa !15
  %63 = zext i8 %62 to i32
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %64, i32 0, i32 2
  store i32 %63, ptr %65, align 4, !tbaa !24
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.juce::MidiRPNMessage", ptr %66, i32 0, i32 4
  store i8 0, ptr %67, align 1, !tbaa !25
  br label %68

68:                                               ; preds = %60, %47
  store i1 true, ptr %4, align 1
  br label %71

69:                                               ; preds = %18
  br label %70

70:                                               ; preds = %69, %13, %3
  store i1 false, ptr %4, align 1
  br label %71

71:                                               ; preds = %70, %68
  %72 = load i1, ptr %4, align 1
  ret i1 %72
}

attributes #0 = { 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" }

!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, !7, i64 0}
!12 = !{!"_ZTSN4juce15MidiRPNDetector12ChannelStateE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !13, i64 4}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !7, i64 1}
!15 = !{!12, !7, i64 2}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTSN4juce14MidiRPNMessageE", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 13}
!18 = !{!17, !10, i64 4}
!19 = !{!12, !13, i64 4}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!17, !13, i64 12}
!23 = !{!12, !7, i64 3}
!24 = !{!17, !10, i64 8}
!25 = !{!17, !13, i64 13}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef zeroext i1 @_ZN4juce15MidiRPNDetector12ChannelState11sendIfReadyEiRNS_14MidiRPNMessageE(ptr nocapture noundef nonnull readonly align 1 dereferenceable(5) %0, i32 noundef %1, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(16) %2) local_unnamed_addr #0 align 2 {
  %4 = load i8, ptr %0, align 1, !tbaa !5
  %5 = icmp sgt i8 %4, -1
  br i1 %5, label %6, label %32

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !10
  %9 = icmp sgt i8 %8, -1
  br i1 %9, label %10, label %32

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !11
  %13 = icmp sgt i8 %12, -1
  br i1 %13, label %.sink.split, label %32

.sink.split:                                      ; preds = %10
  store i32 %1, ptr %2, align 4, !tbaa !12
  %14 = zext nneg i8 %4 to i32
  %15 = shl nuw nsw i32 %14, 7
  %16 = zext nneg i8 %8 to i32
  %17 = or disjoint i32 %15, %16
  %18 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %17, ptr %18, align 4, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 4
  %20 = load i8, ptr %19, align 1, !tbaa !16, !range !17, !noundef !18
  %21 = getelementptr inbounds i8, ptr %2, i64 12
  store i8 %20, ptr %21, align 4, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %0, i64 3
  %23 = load i8, ptr %22, align 1, !tbaa !20
  %24 = icmp sgt i8 %23, -1
  %25 = zext nneg i8 %23 to i32
  %26 = zext nneg i8 %12 to i32
  %27 = shl nuw nsw i32 %26, 7
  %28 = or disjoint i32 %27, %25
  %29 = zext nneg i8 %12 to i32
  %.sink11 = select i1 %24, i32 %28, i32 %29
  %.sink = zext i1 %24 to i8
  %30 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %.sink11, ptr %30, align 4, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %2, i64 13
  store i8 %.sink, ptr %31, align 1, !tbaa !22
  br label %32

32:                                               ; preds = %.sink.split, %3, %6, %10
  %.0 = phi i1 [ false, %10 ], [ false, %6 ], [ false, %3 ], [ true, %.sink.split ]
  ret i1 %.0
}

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

!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, !7, i64 0}
!6 = !{!"_ZTSN4juce15MidiRPNDetector12ChannelStateE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !9, i64 4}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"bool", !7, i64 0}
!10 = !{!6, !7, i64 1}
!11 = !{!6, !7, i64 2}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSN4juce14MidiRPNMessageE", !14, i64 0, !14, i64 4, !14, i64 8, !9, i64 12, !9, i64 13}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !14, i64 4}
!16 = !{!6, !9, i64 4}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!13, !9, i64 12}
!20 = !{!6, !7, i64 3}
!21 = !{!13, !14, i64 8}
!22 = !{!13, !9, i64 13}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass