; 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::MidiMessage" = type <{ %"union.juce::MidiMessage::PackedData", double, i32, [4 x i8] }>
%"union.juce::MidiMessage::PackedData" = type { ptr }
%"class.juce::StringRef" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce11MidiMessage13textMetaEventEiNS_9StringRefE(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiMessage") align 8 %0, i32 noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca i64, align 8
  %9 = alloca [8 x i8], align 1
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %3
  br label %16

16:                                               ; preds = %15
  store i1 false, ptr %7, align 1
  call void @_ZN4juce11MidiMessageC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %17 = getelementptr inbounds %"class.juce::StringRef", ptr %2, i32 0, i32 0
  %18 = call noundef i64 @_ZNK4juce16CharPointer_UTF811sizeInBytesEv(ptr noundef nonnull align 8 dereferenceable(8) %17) #4
  %19 = sub i64 %18, 1
  store i64 %19, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 8, ptr %10, align 8, !tbaa !11
  %20 = load i64, ptr %8, align 8, !tbaa !11
  %21 = and i64 %20, 127
  %22 = trunc i64 %21 to i8
  %23 = load i64, ptr %10, align 8, !tbaa !11
  %24 = add i64 %23, -1
  store i64 %24, ptr %10, align 8, !tbaa !11
  %25 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 %24
  store i8 %22, ptr %25, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %26 = load i64, ptr %8, align 8, !tbaa !11
  store i64 %26, ptr %11, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %32, %16
  %28 = load i64, ptr %11, align 8, !tbaa !11
  %29 = lshr i64 %28, 7
  store i64 %29, ptr %11, align 8, !tbaa !11
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %40

32:                                               ; preds = %27
  %33 = load i64, ptr %11, align 8, !tbaa !11
  %34 = and i64 %33, 127
  %35 = or i64 %34, 128
  %36 = trunc i64 %35 to i8
  %37 = load i64, ptr %10, align 8, !tbaa !11
  %38 = add i64 %37, -1
  store i64 %38, ptr %10, align 8, !tbaa !11
  %39 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 %38
  store i8 %36, ptr %39, align 1, !tbaa !13
  br label %27, !llvm.loop !14

40:                                               ; preds = %31
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = trunc i32 %41 to i8
  %43 = load i64, ptr %10, align 8, !tbaa !11
  %44 = add i64 %43, -1
  store i64 %44, ptr %10, align 8, !tbaa !11
  %45 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 %44
  store i8 %42, ptr %45, align 1, !tbaa !13
  %46 = load i64, ptr %10, align 8, !tbaa !11
  %47 = add i64 %46, -1
  store i64 %47, ptr %10, align 8, !tbaa !11
  %48 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 %47
  store i8 -1, ptr %48, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %49 = load i64, ptr %10, align 8, !tbaa !11
  %50 = sub i64 8, %49
  store i64 %50, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %51 = load i64, ptr %12, align 8, !tbaa !11
  %52 = load i64, ptr %8, align 8, !tbaa !11
  %53 = add i64 %51, %52
  %54 = trunc i64 %53 to i32
  store i32 %54, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %55 = load i32, ptr %13, align 4, !tbaa !5
  %56 = call noundef ptr @_ZN4juce11MidiMessage13allocateSpaceEi(ptr noundef nonnull align 8 dereferenceable(20) %0, i32 noundef %55)
  store ptr %56, ptr %14, align 8, !tbaa !9
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = getelementptr inbounds %"class.juce::MidiMessage", ptr %0, i32 0, i32 2
  store i32 %57, ptr %58, align 8, !tbaa !16
  %59 = load ptr, ptr %14, align 8, !tbaa !9
  %60 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 0
  %61 = load i64, ptr %10, align 8, !tbaa !11
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  %63 = load i64, ptr %12, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %59, ptr align 1 %62, i64 %63, i1 false)
  %64 = load ptr, ptr %14, align 8, !tbaa !9
  %65 = load i64, ptr %12, align 8, !tbaa !11
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  %67 = getelementptr inbounds %"class.juce::StringRef", ptr %2, i32 0, i32 0
  %68 = call noundef ptr @_ZNK4juce16CharPointer_UTF810getAddressEv(ptr noundef nonnull align 8 dereferenceable(8) %67) #4
  %69 = load i64, ptr %8, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %66, ptr align 1 %68, i64 %69, i1 false)
  store i1 true, ptr %7, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %70 = load i1, ptr %7, align 1
  br i1 %70, label %72, label %71

71:                                               ; preds = %40
  call void @_ZN4juce11MidiMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  br label %72

72:                                               ; preds = %71, %40
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce16CharPointer_UTF810getAddressEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

declare void @_ZN4juce11MidiMessageC1Ev(ptr)

declare void @_ZN4juce11MidiMessageD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !6, i64 16}
!17 = !{!"_ZTSN4juce11MidiMessageE", !7, i64 0, !18, i64 8, !6, i64 16}
!18 = !{!"double", !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::MidiMessage" = type <{ %"union.juce::MidiMessage::PackedData", double, i32, [4 x i8] }>
%"union.juce::MidiMessage::PackedData" = 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce11MidiMessage13textMetaEventEiNS_9StringRefE(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiMessage") align 8 %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca [8 x i8], align 1
  tail call void @_ZN4juce11MidiMessageC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  %5 = tail call noundef i64 @_ZNK4juce16CharPointer_UTF811sizeInBytesEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  %6 = add i64 %5, -1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %7 = trunc i64 %6 to i8
  %8 = and i8 %7, 127
  %9 = getelementptr inbounds i8, ptr %4, i64 7
  store i8 %8, ptr %9, align 1, !tbaa !5
  %.not22 = icmp ult i64 %6, 128
  br i1 %.not22, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.0.lcssa = phi i64 [ 7, %3 ], [ %25, %.lr.ph ]
  %10 = trunc i32 %1 to i8
  %11 = add i64 %.0.lcssa, -1
  %12 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 %11
  store i8 %10, ptr %12, align 1, !tbaa !5
  %13 = add i64 %.0.lcssa, -2
  %14 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 %13
  store i8 -1, ptr %14, align 1, !tbaa !5
  %15 = sub i64 10, %.0.lcssa
  %16 = add i64 %15, %6
  %17 = trunc i64 %16 to i32
  %18 = tail call noundef ptr @_ZN4juce11MidiMessage13allocateSpaceEi(ptr noundef nonnull align 8 dereferenceable(20) %0, i32 noundef %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %17, ptr %19, align 8, !tbaa !8
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %18, ptr nonnull align 1 %14, i64 %15, i1 false)
  %20 = getelementptr inbounds i8, ptr %18, i64 %15
  %21 = tail call noundef ptr @_ZNK4juce16CharPointer_UTF810getAddressEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #4
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %20, ptr align 1 %21, i64 %6, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret void

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.024 = phi i64 [ %25, %.lr.ph ], [ 7, %3 ]
  %.02023 = phi i64 [ %22, %.lr.ph ], [ %6, %3 ]
  %22 = lshr i64 %.02023, 7
  %23 = trunc i64 %22 to i8
  %24 = or i8 %23, -128
  %25 = add nsw i64 %.024, -1
  %26 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 %25
  store i8 %24, ptr %26, align 1, !tbaa !5
  %.not = icmp ult i64 %.02023, 16384
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK4juce16CharPointer_UTF811sizeInBytesEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce16CharPointer_UTF810getAddressEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

declare void @_ZN4juce11MidiMessageC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 16}
!9 = !{!"_ZTSN4juce11MidiMessageE", !6, i64 0, !10, i64 8, !11, i64 16}
!10 = !{!"double", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass