; 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 @_ZN4juce19AudioDataConverters21convertFloatToInt32BEEPKfPvii(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 0x41DFFFFFFFC00000, 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 %46

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 = %42, %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 %45

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 0x41DFFFFFFFC00000, %32
  %34 = call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef 0xC1DFFFFFFFC00000, double noundef 0x41DFFFFFFFC00000, double noundef %33) #3
  %35 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %34) #3
  %36 = call noundef i32 @_ZN4juce9ByteOrder18swapIfLittleEndianEj(i32 noundef %35) #3
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %36, ptr %37, align 4, !tbaa !9
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = sext i32 %38 to i64
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  store ptr %41, ptr %10, align 8, !tbaa !5
  br label %42

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

45:                                               ; preds = %25
  br label %77

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

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

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

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

76:                                               ; preds = %58
  br label %77

77:                                               ; preds = %76, %45
  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 i32 @_ZN4juce9ByteOrder18swapIfLittleEndianEj(i32 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 @_ZN4juce19AudioDataConverters21convertFloatToInt32BEEPKfPvii(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 %18

.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 ], [ %17, %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, 0x41DFFFFFFFC00000
  %14 = tail call noundef double @_ZN4juce6jlimitIdEET_S1_S1_S1_(double noundef 0xC1DFFFFFFFC00000, double noundef 0x41DFFFFFFFC00000, double noundef %13) #2
  %15 = tail call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %14) #2
  %16 = tail call noundef i32 @_ZN4juce9ByteOrder18swapIfLittleEndianEj(i32 noundef %15) #2
  store i32 %16, ptr %.02331, align 4, !tbaa !9
  %17 = 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

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

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

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

.loopexit:                                        ; preds = %25, %9, %18, %.preheader
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4juce9ByteOrder18swapIfLittleEndianEj(i32 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 = !{!10, !10, i64 0}
!10 = !{!"int", !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