; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/splines.ll (Z7splinenPffS_i)

; 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: mustprogress nounwind uwtable
declare dso_local noundef float @_Z4ipowfi(float noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7splinenPffS_i(ptr noundef %0, float noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i32, ptr %8, align 4, !tbaa !11
  %14 = add nsw i32 %13, 1
  %15 = sext i32 %14 to i64
  %16 = mul i64 %15, 4
  call void @llvm.memset.p0.i64(ptr align 1 %12, i8 0, i64 %16, i1 false)
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %53, %4
  %18 = load i32, ptr %10, align 4, !tbaa !11
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = add nsw i32 %19, 1
  %21 = icmp sle i32 %18, %20
  br i1 %21, label %22, label %56

22:                                               ; preds = %17
  %23 = load float, ptr %6, align 4, !tbaa !9
  %24 = load i32, ptr %10, align 4, !tbaa !11
  %25 = sitofp i32 %24 to float
  %26 = fadd float %23, %25
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = call noundef float @_Z4ipowfi(float noundef %26, i32 noundef %27)
  store float %28, ptr %11, align 4, !tbaa !9
  %29 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %29, ptr %9, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %49, %22
  %31 = load i32, ptr %9, align 4, !tbaa !11
  %32 = load i32, ptr %8, align 4, !tbaa !11
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %34, label %52

34:                                               ; preds = %30
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !11
  %37 = load i32, ptr %10, align 4, !tbaa !11
  %38 = sub nsw i32 %36, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %35, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = load float, ptr %11, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %43, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !9
  %48 = call float @llvm.fmuladd.f32(float %41, float %42, float %47)
  store float %48, ptr %46, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %34
  %50 = load i32, ptr %9, align 4, !tbaa !11
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %9, align 4, !tbaa !11
  br label %30, !llvm.loop !13

52:                                               ; preds = %30
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %10, align 4, !tbaa !11
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %10, align 4, !tbaa !11
  br label %17, !llvm.loop !15

56:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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
declare dso_local noundef float @_Z4ipowfi(float noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7splinenPffS_i(ptr nocapture noundef %0, float noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = add i32 %3, 1
  %6 = sext i32 %5 to i64
  %7 = shl nsw i64 %6, 2
  tail call void @llvm.memset.p0.i64(ptr align 1 %0, i8 0, i64 %7, i1 false)
  %.not21 = icmp slt i32 %3, -1
  br i1 %.not21, label %._crit_edge25, label %.lr.ph24.preheader

.lr.ph24.preheader:                               ; preds = %4
  %8 = sext i32 %3 to i64
  %9 = add i32 %3, 2
  %wide.trip.count30 = zext i32 %9 to i64
  %wide.trip.count = zext i32 %5 to i64
  %10 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep32 = getelementptr i8, ptr %0, i64 %10
  %bound1 = icmp ugt ptr %scevgep32, %2
  %11 = add nsw i64 %wide.trip.count, -1
  br label %.lr.ph24

.lr.ph24:                                         ; preds = %.lr.ph24.preheader, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph24.preheader ], [ %indvars.iv.next, %._crit_edge ]
  %12 = sub nsw i64 %wide.trip.count, %indvars.iv
  %13 = shl nuw nsw i64 %indvars.iv, 2
  %scevgep = getelementptr i8, ptr %0, i64 %13
  %14 = sub nsw i64 %wide.trip.count, %indvars.iv
  %15 = shl i64 %14, 2
  %scevgep33 = getelementptr i8, ptr %2, i64 %15
  %16 = trunc nuw nsw i64 %indvars.iv to i32
  %17 = uitofp nneg i32 %16 to float
  %18 = fadd float %17, %1
  %19 = tail call noundef float @_Z4ipowfi(float noundef %18, i32 noundef %3)
  %.not1819 = icmp sgt i64 %indvars.iv, %8
  br i1 %.not1819, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph24
  %min.iters.check = icmp ult i64 %12, 8
  %bound0 = icmp ult ptr %scevgep, %scevgep33
  %found.conflict = and i1 %bound0, %bound1
  %or.cond = select i1 %min.iters.check, i1 true, i1 %found.conflict
  br i1 %or.cond, label %.lr.ph.preheader37, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %12, -8
  %ind.end = add i64 %indvars.iv, %n.vec
  %broadcast.splatinsert = insertelement <4 x float> poison, float %19, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  %20 = getelementptr float, ptr %0, i64 %indvars.iv
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %21 = getelementptr inbounds float, ptr %2, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %wide.load = load <4 x float>, ptr %21, align 4, !tbaa !5, !alias.scope !9
  %wide.load34 = load <4 x float>, ptr %22, align 4, !tbaa !5, !alias.scope !9
  %23 = getelementptr float, ptr %20, i64 %index
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %wide.load35 = load <4 x float>, ptr %23, align 4, !tbaa !5, !alias.scope !12, !noalias !9
  %wide.load36 = load <4 x float>, ptr %24, align 4, !tbaa !5, !alias.scope !12, !noalias !9
  %25 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %broadcast.splat, <4 x float> %wide.load35)
  %26 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load34, <4 x float> %broadcast.splat, <4 x float> %wide.load36)
  store <4 x float> %25, ptr %23, align 4, !tbaa !5, !alias.scope !12, !noalias !9
  store <4 x float> %26, ptr %24, align 4, !tbaa !5, !alias.scope !12, !noalias !9
  %index.next = add nuw i64 %index, 8
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %12, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader37

.lr.ph.preheader37:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv26.ph = phi i64 [ %indvars.iv, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %28 = sub i64 %wide.trip.count, %indvars.iv26.ph
  %xtraiter = and i64 %28, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader37
  %29 = sub nuw nsw i64 %indvars.iv26.ph, %indvars.iv
  %30 = getelementptr inbounds float, ptr %2, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = getelementptr inbounds float, ptr %0, i64 %indvars.iv26.ph
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = tail call float @llvm.fmuladd.f32(float %31, float %19, float %33)
  store float %34, ptr %32, align 4, !tbaa !5
  %indvars.iv.next27.prol = add nuw nsw i64 %indvars.iv26.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader37
  %indvars.iv26.unr = phi i64 [ %indvars.iv26.ph, %.lr.ph.preheader37 ], [ %indvars.iv.next27.prol, %.lr.ph.prol ]
  %35 = icmp eq i64 %indvars.iv26.ph, %11
  br i1 %35, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv26 = phi i64 [ %indvars.iv.next27.1, %.lr.ph ], [ %indvars.iv26.unr, %.lr.ph.prol.loopexit ]
  %36 = sub nuw nsw i64 %indvars.iv26, %indvars.iv
  %37 = getelementptr inbounds float, ptr %2, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = getelementptr inbounds float, ptr %0, i64 %indvars.iv26
  %40 = load float, ptr %39, align 4, !tbaa !5
  %41 = tail call float @llvm.fmuladd.f32(float %38, float %19, float %40)
  store float %41, ptr %39, align 4, !tbaa !5
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %42 = sub nuw nsw i64 %indvars.iv.next27, %indvars.iv
  %43 = getelementptr inbounds float, ptr %2, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next27
  %46 = load float, ptr %45, align 4, !tbaa !5
  %47 = tail call float @llvm.fmuladd.f32(float %44, float %19, float %46)
  store float %47, ptr %45, align 4, !tbaa !5
  %indvars.iv.next27.1 = add nuw nsw i64 %indvars.iv26, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next27.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %.lr.ph24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond31 = icmp eq i64 %indvars.iv.next, %wide.trip.count30
  br i1 %exitcond31, label %._crit_edge25, label %.lr.ph24, !llvm.loop !19

._crit_edge25:                                    ; preds = %._crit_edge, %4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #3

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15, !16}
!19 = distinct !{!19, !15}


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