; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseResizerBilinear)

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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) #0

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

26:                                               ; preds = %84, %6
  %27 = load i64, ptr %14, align 8, !tbaa !9
  %28 = load i64, ptr %9, align 8, !tbaa !9
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %87

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %32 = load i64, ptr %14, align 8, !tbaa !9
  %33 = uitofp i64 %32 to float
  %34 = fadd float %33, 5.000000e-01
  %35 = load float, ptr %13, align 4, !tbaa !11
  %36 = call float @llvm.fmuladd.f32(float %34, float %35, float -5.000000e-01)
  store float %36, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %37 = load float, ptr %16, align 4, !tbaa !11
  %38 = call noundef float @_ZSt5floorf(float noundef %37)
  %39 = fptosi float %38 to i64
  store i64 %39, ptr %17, align 8, !tbaa !9
  %40 = load i64, ptr %17, align 8, !tbaa !9
  %41 = sitofp i64 %40 to float
  %42 = load float, ptr %16, align 4, !tbaa !11
  %43 = fsub float %42, %41
  store float %43, ptr %16, align 4, !tbaa !11
  %44 = load i64, ptr %17, align 8, !tbaa !9
  %45 = icmp slt i64 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %31
  store i64 0, ptr %17, align 8, !tbaa !9
  store float 0.000000e+00, ptr %16, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %46, %31
  %48 = load i64, ptr %17, align 8, !tbaa !9
  %49 = load i64, ptr %8, align 8, !tbaa !9
  %50 = sub nsw i64 %49, 2
  %51 = icmp sgt i64 %48, %50
  br i1 %51, label %52, label %55

52:                                               ; preds = %47
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = sub i64 %53, 2
  store i64 %54, ptr %17, align 8, !tbaa !9
  store float 1.000000e+00, ptr %16, align 4, !tbaa !11
  br label %55

55:                                               ; preds = %52, %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  store i64 0, ptr %18, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %80, %55
  %57 = load i64, ptr %18, align 8, !tbaa !9
  %58 = load i64, ptr %10, align 8, !tbaa !9
  %59 = icmp ult i64 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 5, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  br label %83

61:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %62 = load i64, ptr %14, align 8, !tbaa !9
  %63 = load i64, ptr %10, align 8, !tbaa !9
  %64 = mul i64 %62, %63
  %65 = load i64, ptr %18, align 8, !tbaa !9
  %66 = add i64 %64, %65
  store i64 %66, ptr %19, align 8, !tbaa !9
  %67 = load i64, ptr %10, align 8, !tbaa !9
  %68 = load i64, ptr %17, align 8, !tbaa !9
  %69 = mul i64 %67, %68
  %70 = load i64, ptr %18, align 8, !tbaa !9
  %71 = add i64 %69, %70
  %72 = trunc i64 %71 to i32
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = load i64, ptr %19, align 8, !tbaa !9
  %75 = getelementptr inbounds i32, ptr %73, i64 %74
  store i32 %72, ptr %75, align 4, !tbaa !13
  %76 = load float, ptr %16, align 4, !tbaa !11
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load i64, ptr %19, align 8, !tbaa !9
  %79 = getelementptr inbounds float, ptr %77, i64 %78
  store float %76, ptr %79, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  br label %80

80:                                               ; preds = %61
  %81 = load i64, ptr %18, align 8, !tbaa !9
  %82 = add i64 %81, 1
  store i64 %82, ptr %18, align 8, !tbaa !9
  br label %56, !llvm.loop !15

83:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %84

84:                                               ; preds = %83
  %85 = load i64, ptr %14, align 8, !tbaa !9
  %86 = add i64 %85, 1
  store i64 %86, ptr %14, align 8, !tbaa !9
  br label %26, !llvm.loop !17

87:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #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 = { 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 = { 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 #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++ 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"}
!17 = distinct !{!17, !16}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5floorf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Simd4Base20ResizerShortBilinear18EstimateIndexAlphaEmmmPiPf(ptr nocapture noundef nonnull readnone align 8 dereferenceable(160) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #2 align 2 {
  %7 = uitofp i64 %1 to float
  %8 = uitofp i64 %2 to float
  %9 = fdiv float %7, %8
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %6
  %10 = add nsw i64 %1, -2
  %.not40 = icmp eq i64 %3, 0
  br i1 %.not40, label %.lr.ph38.split, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %.lr.ph38
  %min.iters.check = icmp ult i64 %3, 8
  %n.vec = and i64 %3, -8
  %cmp.n = icmp eq i64 %n.vec, %3
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %.036.us = phi i64 [ %38, %._crit_edge.us ], [ 0, %.lr.ph.us.preheader ]
  %11 = uitofp i64 %.036.us to float
  %12 = fadd float %11, 5.000000e-01
  %13 = tail call float @llvm.fmuladd.f32(float %12, float %9, float -5.000000e-01)
  %14 = tail call noundef float @_ZSt5floorf(float noundef %13)
  %15 = fptosi float %14 to i64
  %16 = sitofp i64 %15 to float
  %17 = fsub float %13, %16
  %18 = icmp slt i64 %15, 0
  %.030.us = select i1 %18, float 0.000000e+00, float %17
  %.029.us = tail call i64 @llvm.smax.i64(i64 %15, i64 0)
  %19 = icmp sgt i64 %.029.us, %10
  %.131.us = select i1 %19, float 1.000000e+00, float %.030.us
  %.1.us = tail call i64 @llvm.smin.i64(i64 %.029.us, i64 %10)
  %20 = mul i64 %.036.us, %3
  %21 = mul i64 %.1.us, %3
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.us
  %broadcast.splatinsert = insertelement <4 x i64> poison, i64 %21, i64 0
  %broadcast.splat = shufflevector <4 x i64> %broadcast.splatinsert, <4 x i64> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert47 = insertelement <4 x float> poison, float %.131.us, i64 0
  %broadcast.splat48 = shufflevector <4 x float> %broadcast.splatinsert47, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i64> %vec.ind, <i64 4, i64 4, i64 4, i64 4>
  %22 = add i64 %index, %20
  %23 = add <4 x i64> %vec.ind, %broadcast.splat
  %24 = add <4 x i64> %step.add, %broadcast.splat
  %25 = trunc <4 x i64> %23 to <4 x i32>
  %26 = trunc <4 x i64> %24 to <4 x i32>
  %27 = getelementptr inbounds i32, ptr %4, i64 %22
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  store <4 x i32> %25, ptr %27, align 4, !tbaa !5
  store <4 x i32> %26, ptr %28, align 4, !tbaa !5
  %29 = getelementptr inbounds float, ptr %5, i64 %22
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <4 x float> %broadcast.splat48, ptr %29, align 4, !tbaa !9
  store <4 x float> %broadcast.splat48, ptr %30, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i64> %vec.ind, <i64 8, i64 8, i64 8, i64 8>
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph.us
  %.02835.us.ph = phi i64 [ 0, %.lr.ph.us ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.02835.us = phi i64 [ %37, %scalar.ph ], [ %.02835.us.ph, %scalar.ph.preheader ]
  %32 = add i64 %.02835.us, %20
  %33 = add i64 %.02835.us, %21
  %34 = trunc i64 %33 to i32
  %35 = getelementptr inbounds i32, ptr %4, i64 %32
  store i32 %34, ptr %35, align 4, !tbaa !5
  %36 = getelementptr inbounds float, ptr %5, i64 %32
  store float %.131.us, ptr %36, align 4, !tbaa !9
  %37 = add nuw i64 %.02835.us, 1
  %exitcond.not = icmp eq i64 %37, %3
  br i1 %exitcond.not, label %._crit_edge.us, label %scalar.ph, !llvm.loop !15

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %38 = add nuw i64 %.036.us, 1
  %exitcond42.not = icmp eq i64 %38, %2
  br i1 %exitcond42.not, label %._crit_edge39, label %.lr.ph.us, !llvm.loop !16

._crit_edge39:                                    ; preds = %._crit_edge.us, %.lr.ph38.split, %6
  ret void

.lr.ph38.split:                                   ; preds = %.lr.ph38, %.lr.ph38.split
  %.036 = phi i64 [ %43, %.lr.ph38.split ], [ 0, %.lr.ph38 ]
  %39 = uitofp i64 %.036 to float
  %40 = fadd float %39, 5.000000e-01
  %41 = tail call float @llvm.fmuladd.f32(float %40, float %9, float -5.000000e-01)
  %42 = tail call noundef float @_ZSt5floorf(float noundef %41)
  %43 = add nuw i64 %.036, 1
  %exitcond43.not = icmp eq i64 %43, %2
  br i1 %exitcond43.not, label %._crit_edge39, label %.lr.ph38.split, !llvm.loop !16
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }
attributes #2 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !14, !13}
!16 = distinct !{!16, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass