; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/modules/juce_audio_formats/codecs/flac/libFLAC/win_40b79384_FLAC (tukey)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @FLAC__window_hann(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @FLAC__window_rectangle(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @FLAC__window_tukey(ptr noundef %0, i32 noundef %1, float noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !11
  %9 = load float, ptr %6, align 4, !tbaa !11
  %10 = fpext float %9 to double
  %11 = fcmp ole double %10, 0.000000e+00
  br i1 %11, label %12, label %15

12:                                               ; preds = %3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i32, ptr %5, align 4, !tbaa !9
  call void @FLAC__window_rectangle(ptr noundef %13, i32 noundef %14)
  br label %79

15:                                               ; preds = %3
  %16 = load float, ptr %6, align 4, !tbaa !11
  %17 = fpext float %16 to double
  %18 = fcmp oge double %17, 1.000000e+00
  br i1 %18, label %19, label %22

19:                                               ; preds = %15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  call void @FLAC__window_hann(ptr noundef %20, i32 noundef %21)
  br label %78

22:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %23 = load float, ptr %6, align 4, !tbaa !11
  %24 = fdiv float %23, 2.000000e+00
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = sitofp i32 %25 to float
  %27 = fmul float %24, %26
  %28 = fptosi float %27 to i32
  %29 = sub nsw i32 %28, 1
  store i32 %29, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !9
  call void @FLAC__window_rectangle(ptr noundef %30, i32 noundef %31)
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %34, label %77

34:                                               ; preds = %22
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %73, %34
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %39, label %76

39:                                               ; preds = %35
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = sitofp i32 %40 to double
  %42 = fmul double 0x400921FB54442D18, %41
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = sitofp i32 %43 to double
  %45 = fdiv double %42, %44
  %46 = call double @cos(double noundef %45) #4
  %47 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %46, double 5.000000e-01)
  %48 = fptrunc double %47 to float
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %49, i64 %51
  store float %48, ptr %52, align 4, !tbaa !11
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = add nsw i32 %53, %54
  %56 = sitofp i32 %55 to double
  %57 = fmul double 0x400921FB54442D18, %56
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = sitofp i32 %58 to double
  %60 = fdiv double %57, %59
  %61 = call double @cos(double noundef %60) #4
  %62 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %61, double 5.000000e-01)
  %63 = fptrunc double %62 to float
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = sub nsw i32 %65, %66
  %68 = sub nsw i32 %67, 1
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = add nsw i32 %68, %69
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %64, i64 %71
  store float %63, ptr %72, align 4, !tbaa !11
  br label %73

73:                                               ; preds = %39
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %8, align 4, !tbaa !9
  br label %35, !llvm.loop !13

76:                                               ; preds = %35
  br label %77

77:                                               ; preds = %76, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %78

78:                                               ; preds = %77, %19
  br label %79

79:                                               ; preds = %78, %12
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @FLAC__window_hann(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @FLAC__window_rectangle(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @FLAC__window_tukey(ptr noundef %0, i32 noundef %1, float noundef %2) local_unnamed_addr #2 {
  %4 = fcmp ugt float %2, 0.000000e+00
  br i1 %4, label %6, label %5

5:                                                ; preds = %3
  tail call void @FLAC__window_rectangle(ptr noundef %0, i32 noundef %1)
  br label %.loopexit

6:                                                ; preds = %3
  %7 = fcmp ult float %2, 1.000000e+00
  br i1 %7, label %9, label %8

8:                                                ; preds = %6
  tail call void @FLAC__window_hann(ptr noundef %0, i32 noundef %1)
  br label %.loopexit

9:                                                ; preds = %6
  %10 = fmul float %2, 5.000000e-01
  %11 = sitofp i32 %1 to float
  %12 = fmul float %10, %11
  %13 = fptosi float %12 to i32
  tail call void @FLAC__window_rectangle(ptr noundef %0, i32 noundef %1)
  %14 = icmp sgt i32 %13, 1
  br i1 %14, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %9
  %15 = add nsw i32 %13, -1
  %16 = uitofp nneg i32 %15 to double
  %17 = sub i32 %1, %13
  %18 = sext i32 %17 to i64
  %wide.trip.count = zext nneg i32 %13 to i64
  %invariant.gep = getelementptr float, ptr %0, i64 %18
  br label %19

19:                                               ; preds = %.preheader, %19
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %19 ]
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  %21 = uitofp nneg i32 %20 to double
  %22 = fmul double %21, 0x400921FB54442D18
  %23 = fdiv double %22, %16
  %24 = tail call double @cos(double noundef %23) #3
  %25 = tail call double @llvm.fmuladd.f64(double %24, double -5.000000e-01, double 5.000000e-01)
  %26 = fptrunc double %25 to float
  %27 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  store float %26, ptr %27, align 4, !tbaa !5
  %28 = trunc i64 %indvars.iv to i32
  %29 = add i32 %15, %28
  %30 = sitofp i32 %29 to double
  %31 = fmul double %30, 0x400921FB54442D18
  %32 = fdiv double %31, %16
  %33 = tail call double @cos(double noundef %32) #3
  %34 = tail call double @llvm.fmuladd.f64(double %33, double -5.000000e-01, double 5.000000e-01)
  %35 = fptrunc double %34 to float
  %gep = getelementptr float, ptr %invariant.gep, i64 %indvars.iv
  store float %35, ptr %gep, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %19, !llvm.loop !9

.loopexit:                                        ; preds = %19, %9, %8, %5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass