; LLVM IR from b00dle/libpcc :: src/Encoder.ll (ZN7Encoder8rgbToYuvERK3VecIfE)

; 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"

%struct.Vec = type <{ ptr, float, float, float, [4 x i8] }>

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Encoder8rgbToYuvERK3VecIfE(ptr dead_on_unwind noalias writable sret(%struct.Vec) align 8 %0, ptr noundef nonnull align 8 dereferenceable(20) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i1 false, ptr %5, align 1
  call void @_ZN3VecIfEC2Efff(ptr noundef nonnull align 8 dereferenceable(20) %0, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Vec, ptr %6, i32 0, i32 1
  %8 = load float, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Vec, ptr %9, i32 0, i32 2
  %11 = load float, ptr %10, align 4, !tbaa !12
  %12 = fmul float %11, 0x3FE2C8B440000000
  %13 = call float @llvm.fmuladd.f32(float %8, float 0x3FD322D0E0000000, float %12)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Vec, ptr %14, i32 0, i32 3
  %16 = load float, ptr %15, align 8, !tbaa !13
  %17 = call float @llvm.fmuladd.f32(float %16, float 0x3FBD2F1AA0000000, float %13)
  %18 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 1
  store float %17, ptr %18, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Vec, ptr %19, i32 0, i32 3
  %21 = load float, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 1
  %23 = load float, ptr %22, align 8, !tbaa !9
  %24 = fsub float %21, %23
  %25 = fmul float %24, 0x3FDF8D4FE0000000
  %26 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 2
  store float %25, ptr %26, align 4, !tbaa !12
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Vec, ptr %27, i32 0, i32 1
  %29 = load float, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 1
  %31 = load float, ptr %30, align 8, !tbaa !9
  %32 = fsub float %29, %31
  %33 = fmul float %32, 0x3FEC106240000000
  %34 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 3
  store float %33, ptr %34, align 8, !tbaa !13
  store i1 true, ptr %5, align 1
  %35 = load i1, ptr %5, align 1
  br i1 %35, label %37, label %36

36:                                               ; preds = %2
  call void @_ZN3VecIfED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #3
  br label %37

37:                                               ; preds = %36, %2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecIfEC2Efff(ptr noundef nonnull align 8 dereferenceable(20), float noundef, float noundef, float noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecIfED2Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress 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 = { 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, !11, i64 8}
!10 = !{!"_ZTS3VecIfE", !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 12}
!13 = !{!10, !11, i64 16}


; 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"

%struct.Vec = type <{ ptr, float, float, float, [4 x i8] }>

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7Encoder8rgbToYuvERK3VecIfE(ptr dead_on_unwind noalias nonnull writable sret(%struct.Vec) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(20) %1) local_unnamed_addr #1 align 2 {
  tail call void @_ZN3VecIfEC2Efff(ptr noundef nonnull align 8 dereferenceable(20) %0, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load float, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 12
  %6 = load float, ptr %5, align 4, !tbaa !10
  %7 = fmul float %6, 0x3FE2C8B440000000
  %8 = tail call float @llvm.fmuladd.f32(float %4, float 0x3FD322D0E0000000, float %7)
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load float, ptr %9, align 8, !tbaa !11
  %11 = tail call float @llvm.fmuladd.f32(float %10, float 0x3FBD2F1AA0000000, float %8)
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store float %11, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = insertelement <2 x float> poison, float %10, i64 0
  %15 = insertelement <2 x float> %14, float %4, i64 1
  %16 = insertelement <2 x float> poison, float %11, i64 0
  %17 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> zeroinitializer
  %18 = fsub <2 x float> %15, %17
  %19 = fmul <2 x float> %18, <float 0x3FDF8D4FE0000000, float 0x3FEC106240000000>
  store <2 x float> %19, ptr %13, align 4, !tbaa !12
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecIfEC2Efff(ptr noundef nonnull align 8 dereferenceable(20), float noundef, float noundef, float noundef) unnamed_addr #1 align 2

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

!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, !7, i64 8}
!6 = !{!"_ZTS3VecIfE", !7, i64 8, !7, i64 12, !7, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 12}
!11 = !{!6, !7, i64 16}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass