; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/flac-src/src/libFLAC/window.ll_FLAC (window_flattop)

; 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 float @llvm.fmuladd.f32(float, float, float) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @FLAC__window_flattop(ptr noundef %0, i32 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = sub nsw i32 %7, 1
  store i32 %8, 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 !9
  br label %9

9:                                                ; preds = %54, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %13, label %57

13:                                               ; preds = %9
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = sitofp i32 %14 to double
  %16 = fmul double 0x401921FB54442D18, %15
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = sitofp i32 %17 to double
  %19 = fdiv double %16, %18
  %20 = fptrunc double %19 to float
  %21 = call float @cosf(float noundef %20) #4
  %22 = call float @llvm.fmuladd.f32(float 0xBFDAAA1780000000, float %21, float 0x3FCB981740000000)
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = sitofp i32 %23 to double
  %25 = fmul double 0x402921FB54442D18, %24
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = sitofp i32 %26 to double
  %28 = fdiv double %25, %27
  %29 = fptrunc double %28 to float
  %30 = call float @cosf(float noundef %29) #4
  %31 = call float @llvm.fmuladd.f32(float 0x3FD1BEAE00000000, float %30, float %22)
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sitofp i32 %32 to double
  %34 = fmul double 0x4032D97C7F3321D2, %33
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sitofp i32 %35 to double
  %37 = fdiv double %34, %36
  %38 = fptrunc double %37 to float
  %39 = call float @cosf(float noundef %38) #4
  %40 = call float @llvm.fmuladd.f32(float 0xBFB5656E00000000, float %39, float %31)
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = sitofp i32 %41 to double
  %43 = fmul double 0x403921FB54442D18, %42
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sitofp i32 %44 to double
  %46 = fdiv double %43, %45
  %47 = fptrunc double %46 to float
  %48 = call float @cosf(float noundef %47) #4
  %49 = call float @llvm.fmuladd.f32(float 0x3F7C74D7E0000000, float %48, float %40)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %50, i64 %52
  store float %49, ptr %53, align 4, !tbaa !11
  br label %54

54:                                               ; preds = %13
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !13

57:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  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 float @llvm.fmuladd.f32(float, float, float) #0

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

; Function Attrs: nofree nounwind memory(write) uwtable
define dso_local void @FLAC__window_flattop(ptr nocapture noundef writeonly %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = icmp sgt i32 %1, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %4 = add nsw i32 %1, -1
  %5 = uitofp nneg i32 %4 to double
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %6

6:                                                ; preds = %.lr.ph, %6
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %6 ]
  %7 = trunc nuw nsw i64 %indvars.iv to i32
  %8 = uitofp nneg i32 %7 to double
  %9 = fmul double %8, 0x401921FB54442D18
  %10 = fdiv double %9, %5
  %11 = fptrunc double %10 to float
  %12 = tail call float @cosf(float noundef %11) #3
  %13 = tail call float @llvm.fmuladd.f32(float %12, float 0xBFDAAA1780000000, float 0x3FCB981740000000)
  %14 = fmul double %8, 0x402921FB54442D18
  %15 = fdiv double %14, %5
  %16 = fptrunc double %15 to float
  %17 = tail call float @cosf(float noundef %16) #3
  %18 = tail call float @llvm.fmuladd.f32(float %17, float 0x3FD1BEAE00000000, float %13)
  %19 = fmul double %8, 0x4032D97C7F3321D2
  %20 = fdiv double %19, %5
  %21 = fptrunc double %20 to float
  %22 = tail call float @cosf(float noundef %21) #3
  %23 = tail call float @llvm.fmuladd.f32(float %22, float 0xBFB5656E00000000, float %18)
  %24 = fmul double %8, 0x403921FB54442D18
  %25 = fdiv double %24, %5
  %26 = fptrunc double %25 to float
  %27 = tail call float @cosf(float noundef %26) #3
  %28 = tail call float @llvm.fmuladd.f32(float %27, float 0x3F7C74D7E0000000, float %23)
  %29 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  store float %28, ptr %29, 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 %._crit_edge, label %6, !llvm.loop !9

._crit_edge:                                      ; preds = %6, %2
  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 = { nofree nounwind memory(write) 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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass