; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/flac-src/src/libFLAC/window.ll_FLAC (window_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 float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind
declare float @cosf(float 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 %89

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 %88

22:                                               ; preds = %15
  %23 = load float, ptr %6, align 4, !tbaa !11
  %24 = fcmp ogt float %23, 0.000000e+00
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load float, ptr %6, align 4, !tbaa !11
  %27 = fcmp olt float %26, 1.000000e+00
  br i1 %27, label %31, label %28

28:                                               ; preds = %25, %22
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !9
  call void @FLAC__window_tukey(ptr noundef %29, i32 noundef %30, float noundef 5.000000e-01)
  br label %87

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %32 = load float, ptr %6, align 4, !tbaa !11
  %33 = fdiv float %32, 2.000000e+00
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = sitofp i32 %34 to float
  %36 = fmul float %33, %35
  %37 = fptosi float %36 to i32
  %38 = sub nsw i32 %37, 1
  store i32 %38, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !9
  call void @FLAC__window_rectangle(ptr noundef %39, i32 noundef %40)
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %43, label %86

43:                                               ; preds = %31
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %82, %43
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %48, label %85

48:                                               ; preds = %44
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = sitofp i32 %49 to double
  %51 = fmul double 0x400921FB54442D18, %50
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = sitofp i32 %52 to double
  %54 = fdiv double %51, %53
  %55 = fptrunc double %54 to float
  %56 = call float @cosf(float noundef %55) #4
  %57 = call float @llvm.fmuladd.f32(float -5.000000e-01, float %56, float 5.000000e-01)
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds float, ptr %58, i64 %60
  store float %57, ptr %61, align 4, !tbaa !11
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = add nsw i32 %62, %63
  %65 = sitofp i32 %64 to double
  %66 = fmul double 0x400921FB54442D18, %65
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = sitofp i32 %67 to double
  %69 = fdiv double %66, %68
  %70 = fptrunc double %69 to float
  %71 = call float @cosf(float noundef %70) #4
  %72 = call float @llvm.fmuladd.f32(float -5.000000e-01, float %71, float 5.000000e-01)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = sub nsw i32 %74, %75
  %77 = sub nsw i32 %76, 1
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = add nsw i32 %77, %78
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds float, ptr %73, i64 %80
  store float %72, ptr %81, align 4, !tbaa !11
  br label %82

82:                                               ; preds = %48
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %8, align 4, !tbaa !9
  br label %44, !llvm.loop !13

85:                                               ; preds = %44
  br label %86

86:                                               ; preds = %85, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %87

87:                                               ; preds = %86, %28
  br label %88

88:                                               ; preds = %87, %19
  br label %89

89:                                               ; preds = %88, %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 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: 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 %FLAC__window_tukey.exit

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 %FLAC__window_tukey.exit

9:                                                ; preds = %6
  %10 = fcmp ogt float %2, 0.000000e+00
  %11 = fcmp olt float %2, 1.000000e+00
  %or.cond = and i1 %10, %11
  br i1 %or.cond, label %38, label %12

12:                                               ; preds = %9
  %13 = sitofp i32 %1 to float
  %14 = fmul float %13, 2.500000e-01
  %15 = fptosi float %14 to i32
  tail call void @FLAC__window_rectangle(ptr noundef %0, i32 noundef %1)
  %16 = icmp sgt i32 %15, 1
  br i1 %16, label %.preheader33, label %FLAC__window_tukey.exit

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

21:                                               ; preds = %.preheader33, %21
  %indvars.iv = phi i64 [ 0, %.preheader33 ], [ %indvars.iv.next, %21 ]
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  %23 = uitofp nneg i32 %22 to double
  %24 = fmul double %23, 0x400921FB54442D18
  %25 = fdiv double %24, %18
  %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 -5.000000e-01, float 5.000000e-01)
  %29 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  store float %28, ptr %29, align 4, !tbaa !5
  %30 = trunc i64 %indvars.iv to i32
  %31 = add i32 %17, %30
  %32 = sitofp i32 %31 to double
  %33 = fmul double %32, 0x400921FB54442D18
  %34 = fdiv double %33, %18
  %35 = fptrunc double %34 to float
  %36 = tail call float @cosf(float noundef %35) #3
  %37 = tail call float @llvm.fmuladd.f32(float %36, float -5.000000e-01, float 5.000000e-01)
  %gep = getelementptr float, ptr %invariant.gep, i64 %indvars.iv
  store float %37, 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 %FLAC__window_tukey.exit, label %21, !llvm.loop !9

38:                                               ; preds = %9
  %39 = fmul float %2, 5.000000e-01
  %40 = sitofp i32 %1 to float
  %41 = fmul float %39, %40
  %42 = fptosi float %41 to i32
  tail call void @FLAC__window_rectangle(ptr noundef %0, i32 noundef %1)
  %43 = icmp sgt i32 %42, 1
  br i1 %43, label %.preheader, label %FLAC__window_tukey.exit

.preheader:                                       ; preds = %38
  %44 = add nsw i32 %42, -1
  %45 = uitofp nneg i32 %44 to double
  %46 = sub i32 %1, %42
  %47 = sext i32 %46 to i64
  %wide.trip.count42 = zext nneg i32 %42 to i64
  %invariant.gep45 = getelementptr float, ptr %0, i64 %47
  br label %48

48:                                               ; preds = %.preheader, %48
  %indvars.iv39 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next40, %48 ]
  %49 = trunc nuw nsw i64 %indvars.iv39 to i32
  %50 = uitofp nneg i32 %49 to double
  %51 = fmul double %50, 0x400921FB54442D18
  %52 = fdiv double %51, %45
  %53 = fptrunc double %52 to float
  %54 = tail call float @cosf(float noundef %53) #3
  %55 = tail call float @llvm.fmuladd.f32(float %54, float -5.000000e-01, float 5.000000e-01)
  %56 = getelementptr inbounds float, ptr %0, i64 %indvars.iv39
  store float %55, ptr %56, align 4, !tbaa !5
  %57 = trunc i64 %indvars.iv39 to i32
  %58 = add i32 %44, %57
  %59 = sitofp i32 %58 to double
  %60 = fmul double %59, 0x400921FB54442D18
  %61 = fdiv double %60, %45
  %62 = fptrunc double %61 to float
  %63 = tail call float @cosf(float noundef %62) #3
  %64 = tail call float @llvm.fmuladd.f32(float %63, float -5.000000e-01, float 5.000000e-01)
  %gep46 = getelementptr float, ptr %invariant.gep45, i64 %indvars.iv39
  store float %64, ptr %gep46, align 4, !tbaa !5
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %FLAC__window_tukey.exit, label %48, !llvm.loop !9

FLAC__window_tukey.exit:                          ; preds = %21, %48, %12, %38, %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,InlinerPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass