; 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
define dso_local void @_ZN4juce19AudioDataConverters21convertFloatToInt16LEEPKfPvii(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 3.276700e+04, 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 %47

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 = %43, %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 %46

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 3.276700e+04, %32
  %34 = call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef -3.276700e+04, double noundef 3.276700e+04, double noundef %33) #3
  %35 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %34) #3
  %36 = trunc i32 %35 to i16
  %37 = call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %36) #3
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  store i16 %37, ptr %38, align 2, !tbaa !15
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = sext i32 %39 to i64
  %42 = getelementptr inbounds i8, ptr %40, i64 %41
  store ptr %42, ptr %10, align 8, !tbaa !5
  br label %43

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

46:                                               ; preds = %25
  br label %79

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

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

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

60:                                               ; preds = %55
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = sext i32 %61 to i64
  %64 = sub i64 0, %63
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  store ptr %65, ptr %10, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %66, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !13
  %71 = fpext float %70 to double
  %72 = fmul double 3.276700e+04, %71
  %73 = call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef -3.276700e+04, double noundef 3.276700e+04, double noundef %72) #3
  %74 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %73) #3
  %75 = trunc i32 %74 to i16
  %76 = call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %75) #3
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  store i16 %76, ptr %77, align 2, !tbaa !15
  br label %55, !llvm.loop !19

78:                                               ; preds = %59
  br label %79

79:                                               ; preds = %78, %46
  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 noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext) #2 align 2

; 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

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 = !{!16, !16, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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
define dso_local void @_ZN4juce19AudioDataConverters21convertFloatToInt16LEEPKfPvii(ptr noundef readonly %0, ptr noundef writeonly %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 %19

.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 ], [ %18, %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, 3.276700e+04
  %14 = tail call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef -3.276700e+04, double noundef 3.276700e+04, double noundef %13) #2
  %15 = tail call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %14) #2
  %16 = trunc i32 %15 to i16
  %17 = tail call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %16) #2
  store i16 %17, ptr %.02331, align 2, !tbaa !9
  %18 = 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 !11

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

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

26:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ %25, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %.129 = phi ptr [ %22, %.lr.ph ], [ %27, %26 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %27 = getelementptr inbounds i8, ptr %.129, i64 %24
  %28 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fpext float %29 to double
  %31 = fmul double %30, 3.276700e+04
  %32 = tail call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef -3.276700e+04, double noundef 3.276700e+04, double noundef %31) #2
  %33 = tail call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %32) #2
  %34 = trunc i32 %33 to i16
  %35 = tail call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %34) #2
  store i16 %35, ptr %27, align 2, !tbaa !9
  %36 = icmp ugt i64 %indvars.iv, 1
  br i1 %36, label %26, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %26, %9, %19, %.preheader
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext) local_unnamed_addr #1 align 2

; 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

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 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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