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

; 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce11MidiMessage16isTempoMetaEventEv(ptr noundef nonnull align 8 dereferenceable(20)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK4juce11MidiMessage27getTempoMetaEventTickLengthEs(ptr noundef nonnull align 8 dereferenceable(20) %0, i16 noundef signext %1) #1 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = load i16, ptr %5, align 2, !tbaa !9
  %10 = sext i16 %9 to i32
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %25

12:                                               ; preds = %2
  %13 = call noundef zeroext i1 @_ZNK4juce11MidiMessage16isTempoMetaEventEv(ptr noundef nonnull align 8 dereferenceable(20) %8) #2
  br i1 %13, label %19, label %14

14:                                               ; preds = %12
  %15 = load i16, ptr %5, align 2, !tbaa !9
  %16 = sext i16 %15 to i32
  %17 = sitofp i32 %16 to double
  %18 = fdiv double 5.000000e-01, %17
  store double %18, ptr %3, align 8
  br label %44

19:                                               ; preds = %12
  %20 = call noundef double @_ZNK4juce11MidiMessage29getTempoSecondsPerQuarterNoteEv(ptr noundef nonnull align 8 dereferenceable(20) %8) #2
  %21 = load i16, ptr %5, align 2, !tbaa !9
  %22 = sext i16 %21 to i32
  %23 = sitofp i32 %22 to double
  %24 = fdiv double %20, %23
  store double %24, ptr %3, align 8
  br label %44

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %26 = load i16, ptr %5, align 2, !tbaa !9
  %27 = sext i16 %26 to i32
  %28 = sub nsw i32 0, %27
  %29 = ashr i32 %28, 8
  store i32 %29, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %30 = load i32, ptr %6, align 4, !tbaa !11
  switch i32 %30, label %35 [
    i32 24, label %31
    i32 25, label %32
    i32 29, label %33
    i32 30, label %34
  ]

31:                                               ; preds = %25
  store double 2.400000e+01, ptr %7, align 8, !tbaa !13
  br label %36

32:                                               ; preds = %25
  store double 2.500000e+01, ptr %7, align 8, !tbaa !13
  br label %36

33:                                               ; preds = %25
  store double 2.997000e+01, ptr %7, align 8, !tbaa !13
  br label %36

34:                                               ; preds = %25
  store double 3.000000e+01, ptr %7, align 8, !tbaa !13
  br label %36

35:                                               ; preds = %25
  store double 3.000000e+01, ptr %7, align 8, !tbaa !13
  br label %36

36:                                               ; preds = %35, %34, %33, %32, %31
  %37 = load double, ptr %7, align 8, !tbaa !13
  %38 = fdiv double 1.000000e+00, %37
  %39 = load i16, ptr %5, align 2, !tbaa !9
  %40 = sext i16 %39 to i32
  %41 = and i32 %40, 255
  %42 = sitofp i32 %41 to double
  %43 = fdiv double %38, %42
  store double %43, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %44

44:                                               ; preds = %36, %19, %14
  %45 = load double, ptr %3, align 8
  ret double %45
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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"

@switch.table._ZNK4juce11MidiMessage27getTempoMetaEventTickLengthEs = private unnamed_addr constant [7 x double] [double 2.400000e+01, double 2.500000e+01, double 3.000000e+01, double 3.000000e+01, double 3.000000e+01, double 2.997000e+01, double 3.000000e+01], align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce11MidiMessage16isTempoMetaEventEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK4juce11MidiMessage29getTempoSecondsPerQuarterNoteEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK4juce11MidiMessage27getTempoMetaEventTickLengthEs(ptr noundef nonnull align 8 dereferenceable(20) %0, i16 noundef signext %1) local_unnamed_addr #0 align 2 {
  %3 = sext i16 %1 to i32
  %4 = icmp sgt i16 %1, 0
  br i1 %4, label %5, label %9

5:                                                ; preds = %2
  %6 = tail call noundef zeroext i1 @_ZNK4juce11MidiMessage16isTempoMetaEventEv(ptr noundef nonnull align 8 dereferenceable(20) %0) #1
  br i1 %6, label %7, label %17

7:                                                ; preds = %5
  %8 = tail call noundef double @_ZNK4juce11MidiMessage29getTempoSecondsPerQuarterNoteEv(ptr noundef nonnull align 8 dereferenceable(20) %0) #1
  br label %17

9:                                                ; preds = %2
  %10 = sub nsw i32 0, %3
  %11 = lshr i32 %10, 8
  %switch.tableidx = add nsw i32 %11, -24
  %12 = icmp ult i32 %switch.tableidx, 7
  br i1 %12, label %switch.lookup, label %14

switch.lookup:                                    ; preds = %9
  %13 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [7 x double], ptr @switch.table._ZNK4juce11MidiMessage27getTempoMetaEventTickLengthEs, i64 0, i64 %13
  %switch.load = load double, ptr %switch.gep, align 8
  br label %14

14:                                               ; preds = %9, %switch.lookup
  %.0 = phi double [ %switch.load, %switch.lookup ], [ 3.000000e+01, %9 ]
  %15 = fdiv double 1.000000e+00, %.0
  %16 = and i32 %3, 255
  br label %17

17:                                               ; preds = %5, %14, %7
  %.sink11 = phi i32 [ %16, %14 ], [ %3, %7 ], [ %3, %5 ]
  %.sink = phi double [ %15, %14 ], [ %8, %7 ], [ 5.000000e-01, %5 ]
  %18 = uitofp nneg i32 %.sink11 to double
  %19 = fdiv double %.sink, %18
  ret double %19
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass