; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_VecNd)

; 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 double @llvm.fabs.f64(double) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @VecNd_constMulSelf(ptr noundef, double noundef, i32 noundef) #2

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

11:                                               ; preds = %44, %3
  %12 = load i32, ptr %10, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp ult i32 %12, %13
  br i1 %14, label %15, label %47

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load i32, ptr %10, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds double, ptr %16, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = call double @llvm.fabs.f64(double %20)
  store double %21, ptr %8, align 8, !tbaa !11
  %22 = load double, ptr %8, align 8, !tbaa !11
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %23, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = fcmp ogt double %22, %27
  br i1 %28, label %29, label %43

29:                                               ; preds = %15
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds double, ptr %30, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = load double, ptr %8, align 8, !tbaa !11
  %36 = fdiv double %34, %35
  store double %36, ptr %9, align 8, !tbaa !11
  %37 = load double, ptr %9, align 8, !tbaa !11
  %38 = load double, ptr %7, align 8, !tbaa !11
  %39 = fcmp olt double %37, %38
  br i1 %39, label %40, label %42

40:                                               ; preds = %29
  %41 = load double, ptr %9, align 8, !tbaa !11
  store double %41, ptr %7, align 8, !tbaa !11
  br label %42

42:                                               ; preds = %40, %29
  br label %43

43:                                               ; preds = %42, %15
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %10, align 4, !tbaa !9
  br label %11, !llvm.loop !13

47:                                               ; preds = %11
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load double, ptr %7, align 8, !tbaa !11
  %50 = load i32, ptr %6, align 4, !tbaa !9
  call void @VecNd_constMulSelf(ptr noundef %48, double noundef %49, i32 noundef %50)
  %51 = load double, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %51
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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/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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

; Function Attrs: nounwind uwtable
declare dso_local void @VecNd_constMulSelf(ptr noundef, double noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef double @VecNd_scaleSelf(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %wide.trip.count = zext i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %4 = icmp eq i32 %2, 1
  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 i64 %wide.trip.count, 4294967294
  br label %.lr.ph

.lr.ph:                                           ; preds = %25, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %25 ]
  %.01722 = phi double [ 1.000000e+00, %.lr.ph.preheader.new ], [ %.1.1, %25 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %25 ]
  %5 = getelementptr inbounds double, ptr %0, i64 %indvars.iv
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = tail call double @llvm.fabs.f64(double %6)
  %8 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fcmp ogt double %7, %9
  br i1 %10, label %11, label %.lr.ph.1

11:                                               ; preds = %.lr.ph
  %12 = fdiv double %9, %7
  %13 = fcmp olt double %12, %.01722
  br i1 %13, label %14, label %.lr.ph.1

14:                                               ; preds = %11
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %14, %11
  %.1 = phi double [ %12, %14 ], [ %.01722, %11 ], [ %.01722, %.lr.ph ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %15 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.next
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = tail call double @llvm.fabs.f64(double %16)
  %18 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = fcmp ogt double %17, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %.lr.ph.1
  %22 = fdiv double %19, %17
  %23 = fcmp olt double %22, %.1
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %25

25:                                               ; preds = %24, %21, %.lr.ph.1
  %.1.1 = phi double [ %22, %24 ], [ %.1, %21 ], [ %.1, %.lr.ph.1 ]
  %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.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %25, %.lr.ph.preheader
  %.1.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %.1.1, %25 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %25 ]
  %.01722.unr = phi double [ 1.000000e+00, %.lr.ph.preheader ], [ %.1.1, %25 ]
  %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
  %26 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.unr
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = tail call double @llvm.fabs.f64(double %27)
  %29 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.unr
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = fcmp ogt double %28, %30
  br i1 %31, label %32, label %._crit_edge

32:                                               ; preds = %.lr.ph.epil
  %33 = fdiv double %30, %28
  %34 = fcmp olt double %33, %.01722.unr
  br i1 %34, label %35, label %._crit_edge

35:                                               ; preds = %32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %35, %32, %.lr.ph.epil, %3
  %.017.lcssa = phi double [ 1.000000e+00, %3 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %33, %35 ], [ %.01722.unr, %32 ], [ %.01722.unr, %.lr.ph.epil ]
  tail call void @VecNd_constMulSelf(ptr noundef %0, double noundef %.017.lcssa, i32 noundef %2)
  ret double %.017.lcssa
}

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

!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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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