; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4juce19AudioDataConverters21convertInt16LEToFloatEPKvPfii(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %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 4, ptr %9) #3
  store float 0x3F00002000000000, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %13, ptr %10, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %6, 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 sge 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 %10, align 8, !tbaa !5
  %28 = load i16, ptr %27, align 2, !tbaa !13
  %29 = call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %28) #3
  %30 = sext i16 %29 to i32
  %31 = sitofp i32 %30 to float
  %32 = fmul float 0x3F00002000000000, %31
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %33, i64 %35
  store float %32, ptr %36, align 4, !tbaa !11
  %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 %10, align 8, !tbaa !5
  %65 = load i16, ptr %64, align 2, !tbaa !13
  %66 = call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %65) #3
  %67 = sext i16 %66 to i32
  %68 = sitofp i32 %67 to float
  %69 = fmul float 0x3F00002000000000, %68
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds float, ptr %70, i64 %72
  store float %69, ptr %73, align 4, !tbaa !11
  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 4, ptr %9) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext) local_unnamed_addr #0 align 2

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

.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 [ %0, %.lr.ph33 ], [ %15, %9 ]
  %10 = load i16, ptr %.02331, align 2, !tbaa !5
  %11 = tail call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %10) #2
  %12 = sitofp i16 %11 to float
  %13 = fmul float %12, 0x3F00002000000000
  %14 = getelementptr inbounds float, ptr %1, i64 %indvars.iv36
  store float %13, ptr %14, align 4, !tbaa !9
  %15 = 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

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

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

23:                                               ; preds = %.lr.ph, %23
  %indvars.iv = phi i64 [ %22, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %.129 = phi ptr [ %19, %.lr.ph ], [ %24, %23 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %24 = getelementptr inbounds i8, ptr %.129, i64 %21
  %25 = load i16, ptr %24, align 2, !tbaa !5
  %26 = tail call noundef zeroext i16 @_ZN4juce9ByteOrder15swapIfBigEndianEt(i16 noundef zeroext %25) #2
  %27 = sitofp i16 %26 to float
  %28 = fmul float %27, 0x3F00002000000000
  %29 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next
  store float %28, ptr %29, align 4, !tbaa !9
  %30 = icmp ugt i64 %indvars.iv, 1
  br i1 %30, label %23, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %23, %9, %16, %.preheader
  ret void
}

attributes #0 = { 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 #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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !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