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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7rgb2yuvPfS_S_S_S_S_ii(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6, i32 noundef %7) #2 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store i32 %6, ptr %15, align 4, !tbaa !9
  store i32 %7, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %19 = load i32, ptr %16, align 4, !tbaa !9
  %20 = load i32, ptr %15, align 4, !tbaa !9
  %21 = mul nsw i32 %19, %20
  store i32 %21, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %84, %8
  %23 = load i32, ptr %18, align 4, !tbaa !9
  %24 = load i32, ptr %17, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %87

27:                                               ; preds = %22
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load i32, ptr %18, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %28, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !11
  %33 = fpext float %32 to double
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load i32, ptr %18, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = fpext float %38 to double
  %40 = fmul double 5.870000e-01, %39
  %41 = call double @llvm.fmuladd.f64(double 2.990000e-01, double %33, double %40)
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load i32, ptr %18, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds float, ptr %42, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !11
  %47 = fpext float %46 to double
  %48 = call double @llvm.fmuladd.f64(double 1.140000e-01, double %47, double %41)
  %49 = fptrunc double %48 to float
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load i32, ptr %18, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %50, i64 %52
  store float %49, ptr %53, align 4, !tbaa !11
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %18, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %54, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !11
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = load i32, ptr %18, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %59, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !11
  %64 = fsub float %58, %63
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = load i32, ptr %18, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  store float %64, ptr %68, align 4, !tbaa !11
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = load i32, ptr %18, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %69, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !11
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = load i32, ptr %18, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds float, ptr %74, i64 %76
  %78 = load float, ptr %77, align 4, !tbaa !11
  %79 = fsub float %73, %78
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = load i32, ptr %18, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds float, ptr %80, i64 %82
  store float %79, ptr %83, align 4, !tbaa !11
  br label %84

84:                                               ; preds = %27
  %85 = load i32, ptr %18, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %18, align 4, !tbaa !9
  br label %22, !llvm.loop !13

87:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  ret void
}

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 double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z7rgb2yuvPfS_S_S_S_S_ii(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, i32 noundef %6, i32 noundef %7) local_unnamed_addr #1 {
  %9 = mul nsw i32 %7, %6
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %8
  %wide.trip.count = zext nneg i32 %9 to i64
  %min.iters.check = icmp ult i32 %9, 20
  br i1 %min.iters.check, label %.lr.ph.preheader79, label %vector.memcheck

.lr.ph.preheader79:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %11 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep = getelementptr i8, ptr %3, i64 %11
  %scevgep26 = getelementptr i8, ptr %4, i64 %11
  %scevgep27 = getelementptr i8, ptr %5, i64 %11
  %scevgep28 = getelementptr i8, ptr %0, i64 %11
  %scevgep29 = getelementptr i8, ptr %1, i64 %11
  %scevgep30 = getelementptr i8, ptr %2, i64 %11
  %bound0 = icmp ugt ptr %scevgep26, %3
  %bound1 = icmp ugt ptr %scevgep, %4
  %found.conflict = and i1 %bound0, %bound1
  %bound031 = icmp ugt ptr %scevgep27, %3
  %bound132 = icmp ugt ptr %scevgep, %5
  %found.conflict33 = and i1 %bound031, %bound132
  %conflict.rdx = or i1 %found.conflict, %found.conflict33
  %bound034 = icmp ugt ptr %scevgep28, %3
  %bound135 = icmp ugt ptr %scevgep, %0
  %found.conflict36 = and i1 %bound034, %bound135
  %conflict.rdx37 = or i1 %conflict.rdx, %found.conflict36
  %bound038 = icmp ugt ptr %scevgep29, %3
  %bound139 = icmp ugt ptr %scevgep, %1
  %found.conflict40 = and i1 %bound038, %bound139
  %conflict.rdx41 = or i1 %conflict.rdx37, %found.conflict40
  %bound042 = icmp ugt ptr %scevgep30, %3
  %bound143 = icmp ugt ptr %scevgep, %2
  %found.conflict44 = and i1 %bound042, %bound143
  %conflict.rdx45 = or i1 %conflict.rdx41, %found.conflict44
  %bound046 = icmp ugt ptr %scevgep27, %4
  %bound147 = icmp ugt ptr %scevgep26, %5
  %found.conflict48 = and i1 %bound046, %bound147
  %conflict.rdx49 = or i1 %conflict.rdx45, %found.conflict48
  %bound050 = icmp ugt ptr %scevgep28, %4
  %bound151 = icmp ugt ptr %scevgep26, %0
  %found.conflict52 = and i1 %bound050, %bound151
  %conflict.rdx53 = or i1 %conflict.rdx49, %found.conflict52
  %bound054 = icmp ugt ptr %scevgep29, %4
  %bound155 = icmp ugt ptr %scevgep26, %1
  %found.conflict56 = and i1 %bound054, %bound155
  %conflict.rdx57 = or i1 %conflict.rdx53, %found.conflict56
  %bound058 = icmp ugt ptr %scevgep30, %4
  %bound159 = icmp ugt ptr %scevgep26, %2
  %found.conflict60 = and i1 %bound058, %bound159
  %conflict.rdx61 = or i1 %conflict.rdx57, %found.conflict60
  %bound062 = icmp ugt ptr %scevgep28, %5
  %bound163 = icmp ugt ptr %scevgep27, %0
  %found.conflict64 = and i1 %bound062, %bound163
  %conflict.rdx65 = or i1 %conflict.rdx61, %found.conflict64
  %bound066 = icmp ugt ptr %scevgep29, %5
  %bound167 = icmp ugt ptr %scevgep27, %1
  %found.conflict68 = and i1 %bound066, %bound167
  %conflict.rdx69 = or i1 %conflict.rdx65, %found.conflict68
  %bound070 = icmp ugt ptr %scevgep30, %5
  %bound171 = icmp ugt ptr %scevgep27, %2
  %found.conflict72 = and i1 %bound070, %bound171
  %conflict.rdx73 = or i1 %conflict.rdx69, %found.conflict72
  br i1 %conflict.rdx73, label %.lr.ph.preheader79, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483644
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %12 = getelementptr inbounds float, ptr %0, i64 %index
  %wide.load = load <4 x float>, ptr %12, align 4, !tbaa !5, !alias.scope !9
  %13 = fpext <4 x float> %wide.load to <4 x double>
  %14 = getelementptr inbounds float, ptr %1, i64 %index
  %wide.load74 = load <4 x float>, ptr %14, align 4, !tbaa !5, !alias.scope !12
  %15 = fpext <4 x float> %wide.load74 to <4 x double>
  %16 = fmul <4 x double> %15, <double 5.870000e-01, double 5.870000e-01, double 5.870000e-01, double 5.870000e-01>
  %17 = tail call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %13, <4 x double> <double 2.990000e-01, double 2.990000e-01, double 2.990000e-01, double 2.990000e-01>, <4 x double> %16)
  %18 = getelementptr inbounds float, ptr %2, i64 %index
  %wide.load75 = load <4 x float>, ptr %18, align 4, !tbaa !5, !alias.scope !14
  %19 = fpext <4 x float> %wide.load75 to <4 x double>
  %20 = tail call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %19, <4 x double> <double 1.140000e-01, double 1.140000e-01, double 1.140000e-01, double 1.140000e-01>, <4 x double> %17)
  %21 = fptrunc <4 x double> %20 to <4 x float>
  %22 = getelementptr inbounds float, ptr %3, i64 %index
  store <4 x float> %21, ptr %22, align 4, !tbaa !5, !alias.scope !16, !noalias !18
  %wide.load76 = load <4 x float>, ptr %12, align 4, !tbaa !5, !alias.scope !9
  %23 = fsub <4 x float> %wide.load76, %21
  %24 = getelementptr inbounds float, ptr %4, i64 %index
  store <4 x float> %23, ptr %24, align 4, !tbaa !5, !alias.scope !21, !noalias !22
  %wide.load77 = load <4 x float>, ptr %18, align 4, !tbaa !5, !alias.scope !14
  %25 = fsub <4 x float> %wide.load77, %21
  %26 = getelementptr inbounds float, ptr %5, i64 %index
  store <4 x float> %25, ptr %26, align 4, !tbaa !5, !alias.scope !23, !noalias !24
  %index.next = add nuw i64 %index, 4
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !25

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader79

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %8
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader79, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader79 ]
  %28 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fpext float %29 to double
  %31 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = fpext float %32 to double
  %34 = fmul double %33, 5.870000e-01
  %35 = tail call double @llvm.fmuladd.f64(double %30, double 2.990000e-01, double %34)
  %36 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = fpext float %37 to double
  %39 = tail call double @llvm.fmuladd.f64(double %38, double 1.140000e-01, double %35)
  %40 = fptrunc double %39 to float
  %41 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  store float %40, ptr %41, align 4, !tbaa !5
  %42 = load float, ptr %28, align 4, !tbaa !5
  %43 = fsub float %42, %40
  %44 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %43, ptr %44, align 4, !tbaa !5
  %45 = load float, ptr %36, align 4, !tbaa !5
  %46 = load float, ptr %41, align 4, !tbaa !5
  %47 = fsub float %45, %46
  %48 = getelementptr inbounds float, ptr %5, i64 %indvars.iv
  store float %47, ptr %48, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !29
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 = !{!15}
!15 = distinct !{!15, !11}
!16 = !{!17}
!17 = distinct !{!17, !11}
!18 = !{!19, !20, !10, !13, !15}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}
!21 = !{!19}
!22 = !{!20, !10, !13, !15}
!23 = !{!20}
!24 = !{!10, !13, !15}
!25 = distinct !{!25, !26, !27, !28}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!"llvm.loop.isvectorized", i32 1}
!28 = !{!"llvm.loop.unroll.runtime.disable"}
!29 = distinct !{!29, !26, !27}


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