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

; 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: nounwind
declare double @pow(double noundef, double noundef) #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
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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Encoder8rgbToXyzE3VecIfE(ptr dead_on_unwind noalias writable sret(%struct.Vec) align 8 %0, ptr noundef %1) #3 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 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %7 = load float, ptr %6, align 8, !tbaa !9
  %8 = fcmp ogt float %7, 0x3FA4B5DCC0000000
  br i1 %8, label %9, label %18

9:                                                ; preds = %2
  %10 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %11 = load float, ptr %10, align 8, !tbaa !9
  %12 = fadd float %11, 0x3FAC28F5C0000000
  %13 = fdiv float %12, 0x3FF0E147A0000000
  %14 = fpext float %13 to double
  %15 = call double @pow(double noundef %14, double noundef 0x4003333340000000) #4
  %16 = fptrunc double %15 to float
  %17 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  store float %16, ptr %17, align 8, !tbaa !9
  br label %23

18:                                               ; preds = %2
  %19 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %20 = load float, ptr %19, align 8, !tbaa !9
  %21 = fdiv float %20, 0x4029D70A40000000
  %22 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  store float %21, ptr %22, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %18, %9
  %24 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %25 = load float, ptr %24, align 4, !tbaa !12
  %26 = fcmp ogt float %25, 0x3FA4B5DCC0000000
  br i1 %26, label %27, label %36

27:                                               ; preds = %23
  %28 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %29 = load float, ptr %28, align 4, !tbaa !12
  %30 = fadd float %29, 0x3FAC28F5C0000000
  %31 = fdiv float %30, 0x3FF0E147A0000000
  %32 = fpext float %31 to double
  %33 = call double @pow(double noundef %32, double noundef 0x4003333340000000) #4
  %34 = fptrunc double %33 to float
  %35 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  store float %34, ptr %35, align 4, !tbaa !12
  br label %41

36:                                               ; preds = %23
  %37 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %38 = load float, ptr %37, align 4, !tbaa !12
  %39 = fdiv float %38, 0x4029D70A40000000
  %40 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  store float %39, ptr %40, align 4, !tbaa !12
  br label %41

41:                                               ; preds = %36, %27
  %42 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %43 = load float, ptr %42, align 8, !tbaa !13
  %44 = fcmp ogt float %43, 0x3FA4B5DCC0000000
  br i1 %44, label %45, label %54

45:                                               ; preds = %41
  %46 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %47 = load float, ptr %46, align 8, !tbaa !13
  %48 = fadd float %47, 0x3FAC28F5C0000000
  %49 = fdiv float %48, 0x3FF0E147A0000000
  %50 = fpext float %49 to double
  %51 = call double @pow(double noundef %50, double noundef 0x4003333340000000) #4
  %52 = fptrunc double %51 to float
  %53 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  store float %52, ptr %53, align 8, !tbaa !13
  br label %59

54:                                               ; preds = %41
  %55 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %56 = load float, ptr %55, align 8, !tbaa !13
  %57 = fdiv float %56, 0x4029D70A40000000
  %58 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  store float %57, ptr %58, align 8, !tbaa !13
  br label %59

59:                                               ; preds = %54, %45
  %60 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %61 = load float, ptr %60, align 8, !tbaa !9
  %62 = fmul float %61, 1.000000e+02
  %63 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  store float %62, ptr %63, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %65 = load float, ptr %64, align 4, !tbaa !12
  %66 = fmul float %65, 1.000000e+02
  %67 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  store float %66, ptr %67, align 4, !tbaa !12
  %68 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %69 = load float, ptr %68, align 8, !tbaa !13
  %70 = fmul float %69, 1.000000e+02
  %71 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  store float %70, ptr %71, align 8, !tbaa !13
  %72 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %73 = load float, ptr %72, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %75 = load float, ptr %74, align 4, !tbaa !12
  %76 = fmul float %75, 0x3FD6E286E0000000
  %77 = call float @llvm.fmuladd.f32(float %73, float 0x3FDA65AF80000000, float %76)
  %78 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %79 = load float, ptr %78, align 8, !tbaa !13
  %80 = call float @llvm.fmuladd.f32(float %79, float 0x3FC7189380000000, float %77)
  %81 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 1
  store float %80, ptr %81, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %83 = load float, ptr %82, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %85 = load float, ptr %84, align 4, !tbaa !12
  %86 = fmul float %85, 0x3FE6E286E0000000
  %87 = call float @llvm.fmuladd.f32(float %83, float 0x3FCB38DDA0000000, float %86)
  %88 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %89 = load float, ptr %88, align 8, !tbaa !13
  %90 = call float @llvm.fmuladd.f32(float %89, float 0x3FB27A0FA0000000, float %87)
  %91 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 2
  store float %90, ptr %91, align 4, !tbaa !12
  %92 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 1
  %93 = load float, ptr %92, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 2
  %95 = load float, ptr %94, align 4, !tbaa !12
  %96 = fmul float %95, 0x3FBE835DE0000000
  %97 = call float @llvm.fmuladd.f32(float %93, float 0x3F93CC4420000000, float %96)
  %98 = getelementptr inbounds %struct.Vec, ptr %1, i32 0, i32 3
  %99 = load float, ptr %98, align 8, !tbaa !13
  %100 = call float @llvm.fmuladd.f32(float %99, float 0x3FEE68E420000000, float %97)
  %101 = getelementptr inbounds %struct.Vec, ptr %0, i32 0, i32 3
  store float %100, ptr %101, align 8, !tbaa !13
  store i1 true, ptr %5, align 1
  %102 = load i1, ptr %5, align 1
  br i1 %102, label %104, label %103

103:                                              ; preds = %59
  call void @_ZN3VecIfED2Ev(ptr noundef nonnull align 8 dereferenceable(20) %0) #4
  br label %104

104:                                              ; preds = %103, %59
  ret void
}

attributes #0 = { 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 #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 = { 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 #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, !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 nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #0

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

; 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
define dso_local void @_ZN7Encoder8rgbToXyzE3VecIfE(ptr dead_on_unwind noalias nonnull writable sret(%struct.Vec) align 8 %0, ptr nocapture noundef %1) local_unnamed_addr #2 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 = fcmp ogt float %4, 0x3FA4B5DCC0000000
  br i1 %5, label %6, label %12

6:                                                ; preds = %2
  %7 = fadd float %4, 0x3FAC28F5C0000000
  %8 = fdiv float %7, 0x3FF0E147A0000000
  %9 = fpext float %8 to double
  %10 = tail call double @pow(double noundef %9, double noundef 0x4003333340000000) #4
  %11 = fptrunc double %10 to float
  br label %14

12:                                               ; preds = %2
  %13 = fdiv float %4, 0x4029D70A40000000
  br label %14

14:                                               ; preds = %12, %6
  %storemerge = phi float [ %13, %12 ], [ %11, %6 ]
  store float %storemerge, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 12
  %16 = load float, ptr %15, align 4, !tbaa !10
  %17 = fcmp ogt float %16, 0x3FA4B5DCC0000000
  br i1 %17, label %18, label %24

18:                                               ; preds = %14
  %19 = fadd float %16, 0x3FAC28F5C0000000
  %20 = fdiv float %19, 0x3FF0E147A0000000
  %21 = fpext float %20 to double
  %22 = tail call double @pow(double noundef %21, double noundef 0x4003333340000000) #4
  %23 = fptrunc double %22 to float
  br label %26

24:                                               ; preds = %14
  %25 = fdiv float %16, 0x4029D70A40000000
  br label %26

26:                                               ; preds = %24, %18
  %storemerge5 = phi float [ %25, %24 ], [ %23, %18 ]
  store float %storemerge5, ptr %15, align 4, !tbaa !10
  %27 = getelementptr inbounds i8, ptr %1, i64 16
  %28 = load float, ptr %27, align 8, !tbaa !11
  %29 = fcmp ogt float %28, 0x3FA4B5DCC0000000
  br i1 %29, label %30, label %36

30:                                               ; preds = %26
  %31 = fadd float %28, 0x3FAC28F5C0000000
  %32 = fdiv float %31, 0x3FF0E147A0000000
  %33 = fpext float %32 to double
  %34 = tail call double @pow(double noundef %33, double noundef 0x4003333340000000) #4
  %35 = fptrunc double %34 to float
  %.pre = load float, ptr %15, align 4, !tbaa !10
  br label %38

36:                                               ; preds = %26
  %37 = fdiv float %28, 0x4029D70A40000000
  br label %38

38:                                               ; preds = %36, %30
  %39 = phi float [ %storemerge5, %36 ], [ %.pre, %30 ]
  %storemerge6 = phi float [ %37, %36 ], [ %35, %30 ]
  %40 = load float, ptr %3, align 8, !tbaa !5
  %41 = insertelement <2 x float> poison, float %40, i64 0
  %42 = insertelement <2 x float> %41, float %39, i64 1
  %43 = fmul <2 x float> %42, <float 1.000000e+02, float 1.000000e+02>
  store <2 x float> %43, ptr %3, align 8, !tbaa !12
  %44 = fmul float %storemerge6, 1.000000e+02
  store float %44, ptr %27, align 8, !tbaa !11
  %45 = extractelement <2 x float> %43, i64 1
  %46 = extractelement <2 x float> %43, i64 0
  %47 = getelementptr inbounds i8, ptr %0, i64 8
  %48 = shufflevector <2 x float> %43, <2 x float> poison, <2 x i32> <i32 1, i32 1>
  %49 = fmul <2 x float> %48, <float 0x3FD6E286E0000000, float 0x3FE6E286E0000000>
  %50 = shufflevector <2 x float> %43, <2 x float> poison, <2 x i32> zeroinitializer
  %51 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %50, <2 x float> <float 0x3FDA65AF80000000, float 0x3FCB38DDA0000000>, <2 x float> %49)
  %52 = insertelement <2 x float> poison, float %44, i64 0
  %53 = shufflevector <2 x float> %52, <2 x float> poison, <2 x i32> zeroinitializer
  %54 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %53, <2 x float> <float 0x3FC7189380000000, float 0x3FB27A0FA0000000>, <2 x float> %51)
  store <2 x float> %54, ptr %47, align 8, !tbaa !12
  %55 = fmul float %45, 0x3FBE835DE0000000
  %56 = tail call float @llvm.fmuladd.f32(float %46, float 0x3F93CC4420000000, float %55)
  %57 = tail call float @llvm.fmuladd.f32(float %44, float 0x3FEE68E420000000, float %56)
  %58 = getelementptr inbounds i8, ptr %0, i64 16
  store float %57, ptr %58, align 8, !tbaa !11
  ret void
}

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

attributes #0 = { 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 #1 = { mustprogress 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 = { 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, !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: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass