; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseResizerArea.ll (ZN4Simd4Base15ResizerByteArea14EstimateParamsEmmmPiS2_)

; 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: mustprogress uwtable
define dso_local void @_ZN4Simd4Base15ResizerByteArea14EstimateParamsEmmmPiS2_(ptr noundef nonnull align 8 dereferenceable(144) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5) #0 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca float, align 4
  %14 = alloca i64, align 8
  %15 = alloca float, align 4
  %16 = alloca i64, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = uitofp i64 %18 to float
  %20 = load i64, ptr %9, align 8, !tbaa !9
  %21 = uitofp i64 %20 to float
  %22 = fdiv float %19, %21
  store float %22, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %63, %6
  %24 = load i64, ptr %14, align 8, !tbaa !9
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = icmp ule i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %66

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %29 = load i64, ptr %14, align 8, !tbaa !9
  %30 = uitofp i64 %29 to float
  %31 = load float, ptr %13, align 4, !tbaa !11
  %32 = fmul float %30, %31
  store float %32, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %33 = load float, ptr %15, align 4, !tbaa !11
  %34 = call noundef float @_ZSt5floorf(float noundef %33)
  %35 = fptoui float %34 to i64
  store i64 %35, ptr %16, align 8, !tbaa !9
  %36 = load i64, ptr %16, align 8, !tbaa !9
  %37 = uitofp i64 %36 to float
  %38 = load float, ptr %15, align 4, !tbaa !11
  %39 = fsub float %38, %37
  store float %39, ptr %15, align 4, !tbaa !11
  %40 = load i64, ptr %16, align 8, !tbaa !9
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = icmp eq i64 %40, %41
  br i1 %42, label %43, label %46

43:                                               ; preds = %28
  %44 = load i64, ptr %16, align 8, !tbaa !9
  %45 = add i64 %44, -1
  store i64 %45, ptr %16, align 8, !tbaa !9
  store float 1.000000e+00, ptr %15, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %43, %28
  %47 = load i64, ptr %10, align 8, !tbaa !9
  %48 = uitofp i64 %47 to float
  %49 = load float, ptr %15, align 4, !tbaa !11
  %50 = fsub float 1.000000e+00, %49
  %51 = fmul float %48, %50
  %52 = load float, ptr %13, align 4, !tbaa !11
  %53 = fdiv float %51, %52
  %54 = fptosi float %53 to i32
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i64, ptr %14, align 8, !tbaa !9
  %57 = getelementptr inbounds i32, ptr %55, i64 %56
  store i32 %54, ptr %57, align 4, !tbaa !13
  %58 = load i64, ptr %16, align 8, !tbaa !9
  %59 = trunc i64 %58 to i32
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = load i64, ptr %14, align 8, !tbaa !9
  %62 = getelementptr inbounds i32, ptr %60, i64 %61
  store i32 %59, ptr %62, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %63

63:                                               ; preds = %46
  %64 = load i64, ptr %14, align 8, !tbaa !9
  %65 = add i64 %64, 1
  store i64 %65, ptr %14, align 8, !tbaa !9
  br label %23, !llvm.loop !15

66:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5floorf(float noundef) #2

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !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: mustprogress nounwind uwtable
define dso_local void @_ZN4Simd4Base15ResizerByteArea14EstimateParamsEmmmPiS2_(ptr nocapture noundef nonnull readnone align 8 dereferenceable(144) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 align 2 {
  %7 = uitofp i64 %1 to float
  %8 = uitofp i64 %2 to float
  %9 = fdiv float %7, %8
  %10 = uitofp i64 %3 to float
  br label %12

11:                                               ; preds = %12
  ret void

12:                                               ; preds = %6, %12
  %.02224 = phi i64 [ 0, %6 ], [ %29, %12 ]
  %13 = uitofp i64 %.02224 to float
  %14 = fmul float %9, %13
  %15 = tail call noundef float @_ZSt5floorf(float noundef %14)
  %16 = fptoui float %15 to i64
  %17 = uitofp i64 %16 to float
  %18 = icmp eq i64 %16, %1
  %19 = fsub float %17, %14
  %20 = fadd float %19, 1.000000e+00
  %21 = sext i1 %18 to i64
  %.0 = add i64 %21, %16
  %22 = select i1 %18, float 0.000000e+00, float %20
  %23 = fmul float %22, %10
  %24 = fdiv float %23, %9
  %25 = fptosi float %24 to i32
  %26 = getelementptr inbounds i32, ptr %4, i64 %.02224
  store i32 %25, ptr %26, align 4, !tbaa !5
  %27 = trunc i64 %.0 to i32
  %28 = getelementptr inbounds i32, ptr %5, i64 %.02224
  store i32 %27, ptr %28, align 4, !tbaa !5
  %29 = add i64 %.02224, 1
  %.not = icmp ugt i64 %29, %2
  br i1 %.not, label %11, label %12, !llvm.loop !9
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5floorf(float noundef) local_unnamed_addr #1

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass