; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/library.ll (Z3varPfi)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z3varPfi(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds float, ptr %10, i64 0
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store float 0.000000e+00, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store float 0.000000e+00, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %28, %2
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load float, ptr %18, align 4, !tbaa !11
  %20 = load float, ptr %6, align 4, !tbaa !11
  %21 = fadd float %20, %19
  store float %21, ptr %6, align 4, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load float, ptr %22, align 4, !tbaa !11
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load float, ptr %24, align 4, !tbaa !11
  %26 = load float, ptr %7, align 4, !tbaa !11
  %27 = call float @llvm.fmuladd.f32(float %23, float %25, float %26)
  store float %27, ptr %7, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %17
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %8, align 4, !tbaa !9
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds float, ptr %31, i32 1
  store ptr %32, ptr %5, align 8, !tbaa !5
  br label %12, !llvm.loop !13

33:                                               ; preds = %16
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = sitofp i32 %34 to float
  %36 = load float, ptr %6, align 4, !tbaa !11
  %37 = fdiv float %36, %35
  store float %37, ptr %6, align 4, !tbaa !11
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = sitofp i32 %38 to float
  %40 = load float, ptr %7, align 4, !tbaa !11
  %41 = fdiv float %40, %39
  store float %41, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %42 = load float, ptr %7, align 4, !tbaa !11
  %43 = load float, ptr %6, align 4, !tbaa !11
  %44 = load float, ptr %6, align 4, !tbaa !11
  %45 = fneg float %43
  %46 = call float @llvm.fmuladd.f32(float %45, float %44, float %42)
  store float %46, ptr %9, align 4, !tbaa !11
  %47 = load float, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret float %47
}

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef float @_Z3varPfi(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = icmp sgt i32 %1, 0
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %xtraiter = and i32 %1, 3
  %4 = icmp ult i32 %1, 4
  br i1 %4, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %1, 2147483644
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa29.ph = phi float [ poison, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %.lcssa.ph = phi float [ poison, %.lr.ph.preheader ], [ %28, %.lr.ph ]
  %.024.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %29, %.lr.ph ]
  %.01822.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %28, %.lr.ph ]
  %.01921.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.024.epil = phi ptr [ %8, %.lr.ph.epil ], [ %.024.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01822.epil = phi float [ %7, %.lr.ph.epil ], [ %.01822.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01921.epil = phi float [ %6, %.lr.ph.epil ], [ %.01921.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %5 = load float, ptr %.024.epil, align 4, !tbaa !5
  %6 = fadd float %.01921.epil, %5
  %7 = tail call float @llvm.fmuladd.f32(float %5, float %5, float %.01822.epil)
  %8 = getelementptr inbounds i8, ptr %.024.epil, i64 4
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %2
  %.019.lcssa = phi float [ 0.000000e+00, %2 ], [ %.lcssa29.ph, %._crit_edge.loopexit.unr-lcssa ], [ %6, %.lr.ph.epil ]
  %.018.lcssa = phi float [ 0.000000e+00, %2 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %7, %.lr.ph.epil ]
  %9 = sitofp i32 %1 to float
  %10 = fdiv float %.019.lcssa, %9
  %11 = fdiv float %.018.lcssa, %9
  %12 = fneg float %10
  %13 = tail call float @llvm.fmuladd.f32(float %12, float %10, float %11)
  ret float %13

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.024 = phi ptr [ %0, %.lr.ph.preheader.new ], [ %29, %.lr.ph ]
  %.01822 = phi float [ 0.000000e+00, %.lr.ph.preheader.new ], [ %28, %.lr.ph ]
  %.01921 = phi float [ 0.000000e+00, %.lr.ph.preheader.new ], [ %27, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %14 = load float, ptr %.024, align 4, !tbaa !5
  %15 = fadd float %.01921, %14
  %16 = tail call float @llvm.fmuladd.f32(float %14, float %14, float %.01822)
  %17 = getelementptr inbounds i8, ptr %.024, i64 4
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = fadd float %15, %18
  %20 = tail call float @llvm.fmuladd.f32(float %18, float %18, float %16)
  %21 = getelementptr inbounds i8, ptr %.024, i64 8
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = fadd float %19, %22
  %24 = tail call float @llvm.fmuladd.f32(float %22, float %22, float %20)
  %25 = getelementptr inbounds i8, ptr %.024, i64 12
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = fadd float %23, %26
  %28 = tail call float @llvm.fmuladd.f32(float %26, float %26, float %24)
  %29 = getelementptr inbounds i8, ptr %.024, i64 16
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass