; 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 i32 @_ZN4juce10roundToIntIdEEiT_(double noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef, double noundef, double noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce19AudioDataConverters21convertFloatToInt24LEEPKfPvii(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 0x415FFFFFC0000000, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %13, ptr %10, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %14, %15
  br i1 %16, label %20, label %17

17:                                               ; preds = %4
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = icmp sle i32 %18, 4
  br i1 %19, label %20, label %45

20:                                               ; preds = %17, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %41, %20
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %44

26:                                               ; preds = %21
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds float, ptr %27, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = fpext float %31 to double
  %33 = fmul double 0x415FFFFFC0000000, %32
  %34 = call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef 0xC15FFFFFC0000000, double noundef 0x415FFFFFC0000000, double noundef %33) #3
  %35 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %34) #3
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN4juce9ByteOrder24littleEndian24BitToCharsEiPv(i32 noundef %35, ptr noundef %36) #3
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = sext i32 %37 to i64
  %40 = getelementptr inbounds i8, ptr %38, i64 %39
  store ptr %40, ptr %10, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %26
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %11, align 4, !tbaa !9
  br label %21, !llvm.loop !15

44:                                               ; preds = %25
  br label %75

45:                                               ; preds = %17
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = mul nsw i32 %46, %47
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = sext i32 %48 to i64
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  store ptr %51, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %52 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %52, ptr %12, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %58, %45
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %12, align 4, !tbaa !9
  %56 = icmp sge i32 %55, 0
  br i1 %56, label %58, label %57

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

58:                                               ; preds = %53
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = sext i32 %59 to i64
  %62 = sub i64 0, %61
  %63 = getelementptr inbounds i8, ptr %60, i64 %62
  store ptr %63, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %64, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !13
  %69 = fpext float %68 to double
  %70 = fmul double 0x415FFFFFC0000000, %69
  %71 = call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef 0xC15FFFFFC0000000, double noundef 0x415FFFFFC0000000, double noundef %70) #3
  %72 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %71) #3
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN4juce9ByteOrder24littleEndian24BitToCharsEiPv(i32 noundef %72, ptr noundef %73) #3
  br label %53, !llvm.loop !17

74:                                               ; preds = %57
  br label %75

75:                                               ; preds = %74, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce9ByteOrder24littleEndian24BitToCharsEiPv(i32 noundef, ptr noundef) #2 align 2

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 = { 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 #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 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 nounwind uwtable
declare dso_local noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce19AudioDataConverters21convertFloatToInt24LEEPKfPvii(ptr noundef readonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = icmp ne ptr %1, %0
  %6 = icmp slt i32 %3, 5
  %or.cond = or i1 %5, %6
  %7 = icmp sgt i32 %2, 0
  br i1 %or.cond, label %.preheader, label %17

.preheader:                                       ; preds = %4
  br i1 %7, label %.lr.ph33, label %.loopexit

.lr.ph33:                                         ; preds = %.preheader
  %8 = sext i32 %3 to i64
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %9

9:                                                ; preds = %.lr.ph33, %9
  %indvars.iv36 = phi i64 [ 0, %.lr.ph33 ], [ %indvars.iv.next37, %9 ]
  %.02331 = phi ptr [ %1, %.lr.ph33 ], [ %16, %9 ]
  %10 = getelementptr inbounds float, ptr %0, i64 %indvars.iv36
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fpext float %11 to double
  %13 = fmul double %12, 0x415FFFFFC0000000
  %14 = tail call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef 0xC15FFFFFC0000000, double noundef 0x415FFFFFC0000000, double noundef %13) #2
  %15 = tail call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %14) #2
  tail call void @_ZN4juce9ByteOrder24littleEndian24BitToCharsEiPv(i32 noundef %15, ptr noundef %.02331) #2
  %16 = getelementptr inbounds i8, ptr %.02331, i64 %8
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next37, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %9, !llvm.loop !9

17:                                               ; preds = %4
  br i1 %7, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %17
  %18 = mul nuw nsw i32 %3, %2
  %19 = zext nneg i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %1, i64 %19
  %21 = zext nneg i32 %3 to i64
  %22 = sub nsw i64 0, %21
  %23 = zext nneg i32 %2 to i64
  br label %24

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ %23, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %.129 = phi ptr [ %20, %.lr.ph ], [ %25, %24 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %25 = getelementptr inbounds i8, ptr %.129, i64 %22
  %26 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = fpext float %27 to double
  %29 = fmul double %28, 0x415FFFFFC0000000
  %30 = tail call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef 0xC15FFFFFC0000000, double noundef 0x415FFFFFC0000000, double noundef %29) #2
  %31 = tail call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %30) #2
  tail call void @_ZN4juce9ByteOrder24littleEndian24BitToCharsEiPv(i32 noundef %31, ptr noundef %25) #2
  %32 = icmp ugt i64 %indvars.iv, 1
  br i1 %32, label %24, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %24, %9, %17, %.preheader
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce9ByteOrder24littleEndian24BitToCharsEiPv(i32 noundef, ptr noundef) local_unnamed_addr #1 align 2

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


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass