; LLVM IR from jgaeddert/liquid-dsp :: examples (framesync64_performance_example)

; 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: nounwind uwtable
define dso_local void @frame64_add_noise(ptr noundef %0, float noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = load float, ptr %4, align 4, !tbaa !9
  %8 = fneg float %7
  %9 = fdiv float %8, 2.000000e+01
  %10 = call float @powf(float noundef 1.000000e+01, float noundef %9) #4
  store float %10, ptr %5, align 4, !tbaa !9
  %11 = load float, ptr %5, align 4, !tbaa !9
  %12 = fpext float %11 to double
  %13 = fmul double %12, 0x3FF6A09E667F3BCD
  %14 = fptrunc double %13 to float
  store float %14, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %47, %2
  %16 = load i32, ptr %6, align 4, !tbaa !11
  %17 = icmp ult i32 %16, 1440
  br i1 %17, label %18, label %50

18:                                               ; preds = %15
  %19 = load float, ptr %5, align 4, !tbaa !9
  %20 = call float (...) @randnf()
  %21 = call float (...) @randnf()
  %22 = fmul float 0.000000e+00, %21
  %23 = fmul float 1.000000e+00, %21
  %24 = fadd float %20, %22
  %25 = fmul float %19, %24
  %26 = fmul float %19, %23
  %27 = fpext float %25 to double
  %28 = fpext float %26 to double
  %29 = fmul double %27, 0x3FE6A09E667F3BCD
  %30 = fmul double %28, 0x3FE6A09E667F3BCD
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !11
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds { float, float }, ptr %31, i64 %33
  %35 = getelementptr inbounds { float, float }, ptr %34, i32 0, i32 0
  %36 = load float, ptr %35, align 4
  %37 = getelementptr inbounds { float, float }, ptr %34, i32 0, i32 1
  %38 = load float, ptr %37, align 4
  %39 = fpext float %36 to double
  %40 = fpext float %38 to double
  %41 = fadd double %39, %29
  %42 = fadd double %40, %30
  %43 = fptrunc double %41 to float
  %44 = fptrunc double %42 to float
  %45 = getelementptr inbounds { float, float }, ptr %34, i32 0, i32 0
  %46 = getelementptr inbounds { float, float }, ptr %34, i32 0, i32 1
  store float %43, ptr %45, align 4
  store float %44, ptr %46, align 4
  br label %47

47:                                               ; preds = %18
  %48 = load i32, ptr %6, align 4, !tbaa !11
  %49 = add i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !11
  br label %15, !llvm.loop !13

50:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #2

declare float @randnf(...) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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 = { "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 #4 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: nounwind uwtable
define dso_local void @frame64_add_noise(ptr nocapture noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = fdiv float %1, -2.000000e+01
  %4 = tail call float @powf(float noundef 1.000000e+01, float noundef %3) #3
  %5 = fpext float %4 to double
  %6 = fmul double %5, 0x3FF6A09E667F3BCD
  %7 = fptrunc double %6 to float
  %8 = insertelement <2 x float> poison, float %7, i64 0
  %9 = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> zeroinitializer
  br label %10

10:                                               ; preds = %2, %10
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %10 ]
  %11 = tail call float (...) @randnf() #3
  %12 = tail call float (...) @randnf() #3
  %13 = fmul float %12, 0.000000e+00
  %14 = fadd float %11, %13
  %15 = getelementptr inbounds { float, float }, ptr %0, i64 %indvars.iv
  %16 = insertelement <2 x float> poison, float %14, i64 0
  %17 = insertelement <2 x float> %16, float %12, i64 1
  %18 = fmul <2 x float> %17, %9
  %19 = fpext <2 x float> %18 to <2 x double>
  %20 = fmul <2 x double> %19, <double 0x3FE6A09E667F3BCD, double 0x3FE6A09E667F3BCD>
  %21 = load <2 x float>, ptr %15, align 4
  %22 = fpext <2 x float> %21 to <2 x double>
  %23 = fadd <2 x double> %20, %22
  %24 = fptrunc <2 x double> %23 to <2 x float>
  store <2 x float> %24, ptr %15, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1440
  br i1 %exitcond.not, label %25, label %10, !llvm.loop !5

25:                                               ; preds = %10
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @powf(float noundef, float noundef) local_unnamed_addr #1

declare float @randnf(...) local_unnamed_addr #2

attributes #0 = { 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 nofree nounwind willreturn memory(write) "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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass