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

; 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: nounwind uwtable
define dso_local void @FLAC__window_gauss(ptr noundef %0, i32 noundef %1, float noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = sub nsw i32 %11, 1
  store i32 %12, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = sitofp i32 %13 to double
  %15 = fdiv double %14, 2.000000e+00
  store double %15, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %16 = load float, ptr %6, align 4, !tbaa !11
  %17 = fcmp ogt float %16, 0.000000e+00
  br i1 %17, label %18, label %21

18:                                               ; preds = %3
  %19 = load float, ptr %6, align 4, !tbaa !11
  %20 = fcmp ole float %19, 5.000000e-01
  br i1 %20, label %24, label %21

21:                                               ; preds = %18, %3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !9
  call void @FLAC__window_gauss(ptr noundef %22, i32 noundef %23, float noundef 2.500000e-01)
  br label %53

24:                                               ; preds = %18
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %49, %24
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = icmp sle i32 %26, %27
  br i1 %28, label %29, label %52

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = sitofp i32 %30 to double
  %32 = load double, ptr %8, align 8, !tbaa !13
  %33 = fsub double %31, %32
  %34 = load float, ptr %6, align 4, !tbaa !11
  %35 = fpext float %34 to double
  %36 = load double, ptr %8, align 8, !tbaa !13
  %37 = fmul double %35, %36
  %38 = fdiv double %33, %37
  store double %38, ptr %10, align 8, !tbaa !13
  %39 = load double, ptr %10, align 8, !tbaa !13
  %40 = fmul double -5.000000e-01, %39
  %41 = load double, ptr %10, align 8, !tbaa !13
  %42 = fmul double %40, %41
  %43 = call double @exp(double noundef %42) #3
  %44 = fptrunc double %43 to float
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %45, i64 %47
  store float %44, ptr %48, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %49

49:                                               ; preds = %29
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %9, align 4, !tbaa !9
  br label %25, !llvm.loop !15

52:                                               ; preds = %25
  br label %53

53:                                               ; preds = %52, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 "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/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 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: nofree nounwind memory(write) uwtable
define dso_local void @FLAC__window_gauss(ptr nocapture noundef writeonly %0, i32 noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = add nsw i32 %1, -1
  %5 = sitofp i32 %4 to double
  %6 = fmul double %5, 5.000000e-01
  %7 = fcmp ogt float %2, 0.000000e+00
  %8 = fcmp ole float %2, 5.000000e-01
  %or.cond = and i1 %7, %8
  %.not.not22 = icmp sgt i32 %1, 0
  br i1 %or.cond, label %.preheader, label %.preheader18

.preheader18:                                     ; preds = %3
  br i1 %.not.not22, label %.lr.ph, label %FLAC__window_gauss.exit

.lr.ph:                                           ; preds = %.preheader18
  %9 = fmul double %6, 2.500000e-01
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %12

.preheader:                                       ; preds = %3
  br i1 %.not.not22, label %.lr.ph24, label %FLAC__window_gauss.exit

.lr.ph24:                                         ; preds = %.preheader
  %10 = fpext float %2 to double
  %11 = fmul double %6, %10
  %wide.trip.count30 = zext nneg i32 %1 to i64
  br label %22

12:                                               ; preds = %.lr.ph, %12
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %12 ]
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  %14 = uitofp nneg i32 %13 to double
  %15 = fsub double %14, %6
  %16 = fdiv double %15, %9
  %17 = fmul double %16, -5.000000e-01
  %18 = fmul double %16, %17
  %19 = tail call double @exp(double noundef %18) #2
  %20 = fptrunc double %19 to float
  %21 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  store float %20, ptr %21, 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_gauss.exit, label %12, !llvm.loop !9

22:                                               ; preds = %.lr.ph24, %22
  %indvars.iv27 = phi i64 [ 0, %.lr.ph24 ], [ %indvars.iv.next28, %22 ]
  %23 = trunc nuw nsw i64 %indvars.iv27 to i32
  %24 = uitofp nneg i32 %23 to double
  %25 = fsub double %24, %6
  %26 = fdiv double %25, %11
  %27 = fmul double %26, -5.000000e-01
  %28 = fmul double %26, %27
  %29 = tail call double @exp(double noundef %28) #2
  %30 = fptrunc double %29 to float
  %31 = getelementptr inbounds float, ptr %0, i64 %indvars.iv27
  store float %30, ptr %31, align 4, !tbaa !5
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %exitcond31.not = icmp eq i64 %indvars.iv.next28, %wide.trip.count30
  br i1 %exitcond31.not, label %FLAC__window_gauss.exit, label %22, !llvm.loop !9

FLAC__window_gauss.exit:                          ; preds = %12, %22, %.preheader18, %.preheader
  ret void
}

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

attributes #0 = { 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 #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 }

!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: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InlinerPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass