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

; 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 noundef double @_Z10initcausalPdid(ptr noundef %0, i32 noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %12 = load double, ptr %6, align 8, !tbaa !11
  store double %12, ptr %7, align 8, !tbaa !11
  %13 = load double, ptr %6, align 8, !tbaa !11
  %14 = fdiv double 1.000000e+00, %13
  store double %14, ptr %9, align 8, !tbaa !11
  %15 = load double, ptr %6, align 8, !tbaa !11
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = sitofp i32 %16 to double
  %18 = fsub double %17, 1.000000e+00
  %19 = call double @pow(double noundef %15, double noundef %18) #4
  store double %19, ptr %8, align 8, !tbaa !11
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %20, i64 0
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = load double, ptr %8, align 8, !tbaa !11
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = sub nsw i32 %25, 1
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %24, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = call double @llvm.fmuladd.f64(double %23, double %29, double %22)
  store double %30, ptr %10, align 8, !tbaa !11
  %31 = load double, ptr %8, align 8, !tbaa !11
  %32 = load double, ptr %8, align 8, !tbaa !11
  %33 = fmul double %31, %32
  %34 = load double, ptr %9, align 8, !tbaa !11
  %35 = fmul double %33, %34
  store double %35, ptr %8, align 8, !tbaa !11
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %58, %3
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = sub nsw i32 %38, 2
  %40 = icmp sle i32 %37, %39
  br i1 %40, label %41, label %61

41:                                               ; preds = %36
  %42 = load double, ptr %7, align 8, !tbaa !11
  %43 = load double, ptr %8, align 8, !tbaa !11
  %44 = fadd double %42, %43
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %45, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = load double, ptr %10, align 8, !tbaa !11
  %51 = call double @llvm.fmuladd.f64(double %44, double %49, double %50)
  store double %51, ptr %10, align 8, !tbaa !11
  %52 = load double, ptr %6, align 8, !tbaa !11
  %53 = load double, ptr %7, align 8, !tbaa !11
  %54 = fmul double %53, %52
  store double %54, ptr %7, align 8, !tbaa !11
  %55 = load double, ptr %9, align 8, !tbaa !11
  %56 = load double, ptr %8, align 8, !tbaa !11
  %57 = fmul double %56, %55
  store double %57, ptr %8, align 8, !tbaa !11
  br label %58

58:                                               ; preds = %41
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %11, align 4, !tbaa !9
  br label %36, !llvm.loop !13

61:                                               ; preds = %36
  %62 = load double, ptr %10, align 8, !tbaa !11
  %63 = load double, ptr %7, align 8, !tbaa !11
  %64 = load double, ptr %7, align 8, !tbaa !11
  %65 = fneg double %63
  %66 = call double @llvm.fmuladd.f64(double %65, double %64, double 1.000000e+00)
  %67 = fdiv double %62, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %67
}

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

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

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

; 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 = { nounwind "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) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !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 nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local noundef double @_Z10initcausalPdid(ptr nocapture noundef readonly %0, i32 noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = fdiv double 1.000000e+00, %2
  %5 = sitofp i32 %1 to double
  %6 = fadd double %5, -1.000000e+00
  %7 = tail call double @pow(double noundef %2, double noundef %6) #3
  %8 = load double, ptr %0, align 8, !tbaa !5
  %9 = sext i32 %1 to i64
  %10 = getelementptr double, ptr %0, i64 %9
  %11 = getelementptr i8, ptr %10, i64 -8
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = tail call double @llvm.fmuladd.f64(double %7, double %12, double %8)
  %.not28 = icmp slt i32 %1, 3
  br i1 %.not28, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %14 = fmul double %7, %7
  %15 = zext nneg i32 %1 to i64
  %xtraiter = and i64 %15, 1
  %16 = icmp eq i32 %1, 3
  br i1 %16, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %17 = and i64 %15, 2147483646
  %invariant.gep = getelementptr inbounds i8, ptr %0, i64 8
  %18 = add nsw i64 %17, -4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %.02531 = phi double [ %13, %.lr.ph.preheader.new ], [ %26, %.lr.ph ]
  %.02630 = phi double [ %2, %.lr.ph.preheader.new ], [ %27, %.lr.ph ]
  %.pn29 = phi double [ %14, %.lr.ph.preheader.new ], [ %.027.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %.027 = fmul double %4, %.pn29
  %19 = fadd double %.02630, %.027
  %20 = getelementptr inbounds double, ptr %0, i64 %indvars.iv
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = tail call double @llvm.fmuladd.f64(double %19, double %21, double %.02531)
  %23 = fmul double %.02630, %2
  %.027.1 = fmul double %4, %.027
  %24 = fadd double %23, %.027.1
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv
  %25 = load double, ptr %gep, align 8, !tbaa !5
  %26 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %22)
  %27 = fmul double %23, %2
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %18
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa38.ph = phi double [ poison, %.lr.ph.preheader ], [ %26, %.lr.ph ]
  %.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %.02531.unr = phi double [ %13, %.lr.ph.preheader ], [ %26, %.lr.ph ]
  %.02630.unr = phi double [ %2, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %.pn29.unr = phi double [ %14, %.lr.ph.preheader ], [ %.027.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %.027.epil = fmul double %4, %.pn29.unr
  %28 = fadd double %.02630.unr, %.027.epil
  %29 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.unr
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = tail call double @llvm.fmuladd.f64(double %28, double %30, double %.02531.unr)
  %32 = fmul double %.02630.unr, %2
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %3
  %.026.lcssa = phi double [ %2, %3 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %32, %.lr.ph.epil ]
  %.025.lcssa = phi double [ %13, %3 ], [ %.lcssa38.ph, %._crit_edge.loopexit.unr-lcssa ], [ %31, %.lr.ph.epil ]
  %33 = fneg double %.026.lcssa
  %34 = tail call double @llvm.fmuladd.f64(double %33, double %.026.lcssa, double 1.000000e+00)
  %35 = fdiv double %.025.lcssa, %34
  ret double %35
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nofree nounwind memory(write, 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 nofree nounwind willreturn memory(write) "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 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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