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

; 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: mustprogress uwtable
define dso_local void @_ZN4juce11MidiMessage22timeSignatureMetaEventEii(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiMessage") align 8 %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [7 x i8], align 1
  store ptr %0, ptr %4, align 8
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %14, %3
  %11 = load i32, ptr %7, align 4, !tbaa !5
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %14, label %19

14:                                               ; preds = %10
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = shl i32 %15, 1
  store i32 %16, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %8, align 4, !tbaa !5
  br label %10, !llvm.loop !9

19:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 7, ptr %9) #2
  store i8 -1, ptr %9, align 1, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %9, i64 1
  store i8 88, ptr %20, align 1, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %9, i64 2
  store i8 4, ptr %21, align 1, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %9, i64 3
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = trunc i32 %23 to i8
  store i8 %24, ptr %22, align 1, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %9, i64 4
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = trunc i32 %26 to i8
  store i8 %27, ptr %25, align 1, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %9, i64 5
  store i8 1, ptr %28, align 1, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %9, i64 6
  store i8 96, ptr %29, align 1, !tbaa !11
  %30 = getelementptr inbounds [7 x i8], ptr %9, i64 0, i64 0
  call void @_ZN4juce11MidiMessageC1EPKvid(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %30, i32 noundef 7, double noundef 0.000000e+00)
  call void @llvm.lifetime.end.p0(i64 7, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

declare void @_ZN4juce11MidiMessageC1EPKvid(ptr, ptr, i32, double)

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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !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 uwtable
define dso_local void @_ZN4juce11MidiMessage22timeSignatureMetaEventEii(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiMessage") align 8 %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca [7 x i8], align 1
  %5 = icmp sgt i32 %2, 1
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.08 = phi i8 [ %7, %.lr.ph ], [ 0, %3 ]
  %.067 = phi i32 [ %6, %.lr.ph ], [ 1, %3 ]
  %6 = shl i32 %.067, 1
  %7 = add i8 %.08, 1
  %8 = icmp slt i32 %6, %2
  br i1 %8, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.0.lcssa = phi i8 [ 0, %3 ], [ %7, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 7, ptr nonnull %4) #2
  store i8 -1, ptr %4, align 1, !tbaa !7
  %9 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 88, ptr %9, align 1, !tbaa !7
  %10 = getelementptr inbounds i8, ptr %4, i64 2
  store i8 4, ptr %10, align 1, !tbaa !7
  %11 = getelementptr inbounds i8, ptr %4, i64 3
  %12 = trunc i32 %1 to i8
  store i8 %12, ptr %11, align 1, !tbaa !7
  %13 = getelementptr inbounds i8, ptr %4, i64 4
  store i8 %.0.lcssa, ptr %13, align 1, !tbaa !7
  %14 = getelementptr inbounds i8, ptr %4, i64 5
  store i8 1, ptr %14, align 1, !tbaa !7
  %15 = getelementptr inbounds i8, ptr %4, i64 6
  store i8 96, ptr %15, align 1, !tbaa !7
  call void @_ZN4juce11MidiMessageC1EPKvid(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull %4, i32 noundef 7, double noundef 0.000000e+00)
  call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %4) #2
  ret void
}

declare void @_ZN4juce11MidiMessageC1EPKvid(ptr, ptr, i32, double) local_unnamed_addr

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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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