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

; 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 nounwind uwtable
define dso_local void @_ZN4Simd4Base20BilinearInterp32fBlZEPKfmiPjPfS4_S4_(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca float, align 4
  %23 = alloca float, align 4
  %24 = alloca float, align 4
  %25 = alloca float, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !11
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i32, ptr %10, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds float, ptr %26, i64 %28
  store ptr %29, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %95, %7
  %31 = load i64, ptr %16, align 8, !tbaa !9
  %32 = load i64, ptr %9, align 8, !tbaa !9
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %98

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = load i64, ptr %16, align 8, !tbaa !9
  %38 = getelementptr inbounds i32, ptr %36, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !11
  store i32 %39, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load i32, ptr %17, align 4, !tbaa !11
  %42 = add nsw i32 %41, 0
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %40, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !13
  store float %45, ptr %18, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i32, ptr %17, align 4, !tbaa !11
  %48 = add nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %46, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !13
  store float %51, ptr %19, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  %53 = load i32, ptr %17, align 4, !tbaa !11
  %54 = add nsw i32 %53, 0
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %52, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !13
  store float %57, ptr %20, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  %59 = load i32, ptr %17, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %58, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !13
  store float %63, ptr %21, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = load i64, ptr %16, align 8, !tbaa !9
  %66 = getelementptr inbounds float, ptr %64, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !13
  store float %67, ptr %22, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %68 = load float, ptr %22, align 4, !tbaa !13
  %69 = fsub float 1.000000e+00, %68
  store float %69, ptr %23, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = load i64, ptr %16, align 8, !tbaa !9
  %72 = getelementptr inbounds float, ptr %70, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !13
  store float %73, ptr %24, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %74 = load float, ptr %24, align 4, !tbaa !13
  %75 = fsub float 1.000000e+00, %74
  store float %75, ptr %25, align 4, !tbaa !13
  %76 = load float, ptr %23, align 4, !tbaa !13
  %77 = load float, ptr %25, align 4, !tbaa !13
  %78 = load float, ptr %18, align 4, !tbaa !13
  %79 = load float, ptr %24, align 4, !tbaa !13
  %80 = load float, ptr %19, align 4, !tbaa !13
  %81 = fmul float %79, %80
  %82 = call float @llvm.fmuladd.f32(float %77, float %78, float %81)
  %83 = load float, ptr %22, align 4, !tbaa !13
  %84 = load float, ptr %25, align 4, !tbaa !13
  %85 = load float, ptr %20, align 4, !tbaa !13
  %86 = load float, ptr %24, align 4, !tbaa !13
  %87 = load float, ptr %21, align 4, !tbaa !13
  %88 = fmul float %86, %87
  %89 = call float @llvm.fmuladd.f32(float %84, float %85, float %88)
  %90 = fmul float %83, %89
  %91 = call float @llvm.fmuladd.f32(float %76, float %82, float %90)
  %92 = load ptr, ptr %14, align 8, !tbaa !5
  %93 = load i64, ptr %16, align 8, !tbaa !9
  %94 = getelementptr inbounds float, ptr %92, i64 %93
  store float %91, ptr %94, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %95

95:                                               ; preds = %35
  %96 = load i64, ptr %16, align 8, !tbaa !9
  %97 = add i64 %96, 1
  store i64 %97, ptr %16, align 8, !tbaa !9
  br label %30, !llvm.loop !15

98:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !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 nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_ZN4Simd4Base20BilinearInterp32fBlZEPKfmiPjPfS4_S4_(ptr nocapture noundef readonly %0, i64 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #0 {
  %8 = sext i32 %2 to i64
  %9 = getelementptr inbounds float, ptr %0, i64 %8
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %7
  ret void

.lr.ph:                                           ; preds = %7, %.lr.ph
  %.032 = phi i64 [ %36, %.lr.ph ], [ 0, %7 ]
  %10 = getelementptr inbounds i32, ptr %3, i64 %.032
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds float, ptr %0, i64 %12
  %14 = load float, ptr %13, align 4, !tbaa !9
  %15 = add nsw i32 %11, 1
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds float, ptr %0, i64 %16
  %18 = load float, ptr %17, align 4, !tbaa !9
  %19 = getelementptr inbounds float, ptr %9, i64 %12
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = getelementptr inbounds float, ptr %9, i64 %16
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = getelementptr inbounds float, ptr %4, i64 %.032
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = fsub float 1.000000e+00, %24
  %26 = getelementptr inbounds float, ptr %5, i64 %.032
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = fsub float 1.000000e+00, %27
  %29 = fmul float %18, %27
  %30 = tail call float @llvm.fmuladd.f32(float %28, float %14, float %29)
  %31 = fmul float %22, %27
  %32 = tail call float @llvm.fmuladd.f32(float %28, float %20, float %31)
  %33 = fmul float %24, %32
  %34 = tail call float @llvm.fmuladd.f32(float %25, float %30, float %33)
  %35 = getelementptr inbounds float, ptr %6, i64 %.032
  store float %34, ptr %35, align 4, !tbaa !9
  %36 = add nuw i64 %.032, 1
  %exitcond.not = icmp eq i64 %36, %1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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 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}
!12 = !{!"llvm.loop.mustprogress"}


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