void mar_v4l2_mmap_camera_yuv_to_rgb(unsigned char y, unsigned char u,
                                     unsigned char v, unsigned char *r,
                                     unsigned char *g, unsigned char *b) {
  int amp = 255;
  double R, G, B;
  R = amp * (0.004565 * y + 0.000001 * u + 0.006250 * v - 0.872);
  G = amp * (0.004565 * y - 0.001542 * u - 0.003183 * v + 0.531);
  B = amp * (0.004565 * y + 0.007935 * u - 1.088);
  if (R < 0)
    R = 0;
  if (G < 0)
    G = 0;
  if (B < 0)
    B = 0;
  if (R > 255)
    R = 255;
  if (G > 255)
    G = 255;
  if (B > 255)
    B = 255;
  *r = (unsigned char)(R);
  *g = (unsigned char)(G);
  *b = (unsigned char)(B);
}


x86 assembly (clang, -O0):
<mar_v4l2_mmap_camera_yuv_to_rgb>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0xff,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm2
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm3
movsd  0xefa(%rip),%xmm1
mulsd  %xmm3,%xmm1
movsd  0xeb6(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xece(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xeb6(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm2
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm3
movsd  0xe84(%rip),%xmm1
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe41(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe41(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe29(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm1
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm3
movsd  0xdf7(%rip),%xmm2
mulsd  %xmm3,%xmm2
movsd  0xde3(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xdcb(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1258 <mar_v4l2_mmap_camera_yuv_to_rgb+0x158>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    126e <mar_v4l2_mmap_camera_yuv_to_rgb+0x16e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1284 <mar_v4l2_mmap_camera_yuv_to_rgb+0x184>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdb7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a8 <mar_v4l2_mmap_camera_yuv_to_rgb+0x1a8>
movsd  0xda5(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xd93(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12cc <mar_v4l2_mmap_camera_yuv_to_rgb+0x1cc>
movsd  0xd81(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd6f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12f0 <mar_v4l2_mmap_camera_yuv_to_rgb+0x1f0>
movsd  0xd5d(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
cvttsd2si -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
cvttsd2si -0x38(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
cvttsd2si -0x40(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mar_v4l2_mmap_camera_yuv_to_rgb>:
cvtsi2sd %esi,%xmm3
movsd  0xef4(%rip),%xmm0
mulsd  %xmm3,%xmm0
movd   %edi,%xmm1
pinsrw $0x2,%edx,%xmm1
cvtdq2pd %xmm1,%xmm1
movsd  0xee3(%rip),%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm4,%xmm0
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
mulsd  0xed3(%rip),%xmm2
addsd  %xmm0,%xmm2
addsd  0xecf(%rip),%xmm2
movsd  0xecf(%rip),%xmm0
mulsd  %xmm0,%xmm2
movsd  0xecb(%rip),%xmm5
mulsd  %xmm3,%xmm5
addsd  %xmm4,%xmm5
mulsd  0xec3(%rip),%xmm3
mulpd  0xecb(%rip),%xmm1
unpcklpd %xmm5,%xmm3
addpd  %xmm3,%xmm1
addpd  0xecb(%rip),%xmm1
mulpd  0xed3(%rip),%xmm1
xorpd  %xmm3,%xmm3
xorpd  %xmm4,%xmm4
movapd %xmm1,%xmm5
cmpltpd %xmm4,%xmm5
movmskpd %xmm5,%eax
xorpd  %xmm4,%xmm4
test   $0x2,%al
jne    11b2 <mar_v4l2_mmap_camera_yuv_to_rgb+0xb2>
movapd %xmm1,%xmm4
unpckhpd %xmm1,%xmm4
xorpd  %xmm5,%xmm5
maxsd  %xmm2,%xmm5
test   $0x1,%al
jne    11c2 <mar_v4l2_mmap_camera_yuv_to_rgb+0xc2>
movapd %xmm1,%xmm3
movapd %xmm0,%xmm1
minsd  %xmm5,%xmm1
movapd %xmm0,%xmm2
minsd  %xmm4,%xmm2
cvttsd2si %xmm1,%eax
minsd  %xmm3,%xmm0
mov    %al,(%rcx)
cvttsd2si %xmm2,%eax
mov    %al,(%r8)
cvttsd2si %xmm0,%eax
mov    %al,(%r9)
ret

LLVM IR (-O0):
define void @mar_v4l2_mmap_camera_yuv_to_rgb(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
store i32 255, i32* %13
%17 = load i32, i32* %13
%18 = sitofp i32 %17 to double
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = sitofp i32 %20 to double
%22 = load i8, i8* %8
%23 = zext i8 %22 to i32
%24 = sitofp i32 %23 to double
%25 = fmul double 0x3EB0C6F7A0B5ED8D, %24
%26 = call double @llvm.fmuladd.f64(double 4.565000e-03, double %21, double %25)
%27 = load i8, i8* %9
%28 = zext i8 %27 to i32
%29 = sitofp i32 %28 to double
%30 = call double @llvm.fmuladd.f64(double 6.250000e-03, double %29, double %26)
%31 = fsub double %30, 8.720000e-01
%32 = fmul double %18, %31
store double %32, double* %14
%33 = load i32, i32* %13
%34 = sitofp i32 %33 to double
%35 = load i8, i8* %7
%36 = zext i8 %35 to i32
%37 = sitofp i32 %36 to double
%38 = load i8, i8* %8
%39 = zext i8 %38 to i32
%40 = sitofp i32 %39 to double
%41 = fmul double 1.542000e-03, %40
%42 = fneg double %41
%43 = call double @llvm.fmuladd.f64(double 4.565000e-03, double %37, double %42)
%44 = load i8, i8* %9
%45 = zext i8 %44 to i32
%46 = sitofp i32 %45 to double
%47 = call double @llvm.fmuladd.f64(double -3.183000e-03, double %46, double %43)
%48 = fadd double %47, 5.310000e-01
%49 = fmul double %34, %48
store double %49, double* %15
%50 = load i32, i32* %13
%51 = sitofp i32 %50 to double
%52 = load i8, i8* %7
%53 = zext i8 %52 to i32
%54 = sitofp i32 %53 to double
%55 = load i8, i8* %8
%56 = zext i8 %55 to i32
%57 = sitofp i32 %56 to double
%58 = fmul double 0x3F804039ABF33871, %57
%59 = call double @llvm.fmuladd.f64(double 4.565000e-03, double %54, double %58)
%60 = fsub double %59, 1.088000e+00
%61 = fmul double %51, %60
store double %61, double* %16
%62 = load double, double* %14
%63 = fcmp olt double %62, 0.000000e+00
br i1 %63, label %64, label %65
64: ; preds = %6
store double 0.000000e+00, double* %14
br label %65
65: ; preds = %64, %6
%66 = load double, double* %15
%67 = fcmp olt double %66, 0.000000e+00
br i1 %67, label %68, label %69
68: ; preds = %65
store double 0.000000e+00, double* %15
br label %69
69: ; preds = %68, %65
%70 = load double, double* %16
%71 = fcmp olt double %70, 0.000000e+00
br i1 %71, label %72, label %73
72: ; preds = %69
store double 0.000000e+00, double* %16
br label %73
73: ; preds = %72, %69
%74 = load double, double* %14
%75 = fcmp ogt double %74, 2.550000e+02
br i1 %75, label %76, label %77
76: ; preds = %73
store double 2.550000e+02, double* %14
br label %77
77: ; preds = %76, %73
%78 = load double, double* %15
%79 = fcmp ogt double %78, 2.550000e+02
br i1 %79, label %80, label %81
80: ; preds = %77
store double 2.550000e+02, double* %15
br label %81
81: ; preds = %80, %77
%82 = load double, double* %16
%83 = fcmp ogt double %82, 2.550000e+02
br i1 %83, label %84, label %85
84: ; preds = %81
store double 2.550000e+02, double* %16
br label %85
85: ; preds = %84, %81
%86 = load double, double* %14
%87 = fptoui double %86 to i8
%88 = load i8*, i8** %10
store i8 %87, i8* %88
%89 = load double, double* %15
%90 = fptoui double %89 to i8
%91 = load i8*, i8** %11
store i8 %90, i8* %91
%92 = load double, double* %16
%93 = fptoui double %92 to i8
%94 = load i8*, i8** %12
store i8 %93, i8* %94
ret void
}

LLVM IR (-O2):
define void @mar_v4l2_mmap_camera_yuv_to_rgb(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* nocapture writeonly %3, i8* nocapture writeonly %4, i8* nocapture writeonly %5) {
%7 = uitofp i8 %1 to double
%8 = fmul double %7, 0x3EB0C6F7A0B5ED8D
%9 = insertelement <2 x i8> poison, i8 %0, i64 0
%10 = insertelement <2 x i8> %9, i8 %2, i64 1
%11 = uitofp <2 x i8> %10 to <2 x double>
%12 = extractelement <2 x double> %11, i64 0
%13 = tail call double @llvm.fmuladd.f64(double %12, double 4.565000e-03, double %8)
%14 = extractelement <2 x double> %11, i64 1
%15 = tail call double @llvm.fmuladd.f64(double %14, double 6.250000e-03, double %13)
%16 = fadd double %15, -8.720000e-01
%17 = fmul double %16, 2.550000e+02
%18 = fmul double %7, -1.542000e-03
%19 = tail call double @llvm.fmuladd.f64(double %12, double 4.565000e-03, double %18)
%20 = fmul double %7, 0x3F804039ABF33871
%21 = insertelement <2 x double> poison, double %20, i64 0
%22 = insertelement <2 x double> %21, double %19, i64 1
%23 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %11, <2 x double> <double 4.565000e-03, double -3.183000e-03>, <2 x double> %22)
%24 = fadd <2 x double> %23, <double -1.088000e+00, double 5.310000e-01>
%25 = fmul <2 x double> %24, <double 2.550000e+02, double 2.550000e+02>
%26 = fcmp olt double %17, 0.000000e+00
%27 = select i1 %26, double 0.000000e+00, double %17
%28 = fcmp olt <2 x double> %25, zeroinitializer
%29 = extractelement <2 x i1> %28, i64 1
%30 = extractelement <2 x double> %25, i64 1
%31 = select i1 %29, double 0.000000e+00, double %30
%32 = extractelement <2 x i1> %28, i64 0
%33 = extractelement <2 x double> %25, i64 0
%34 = select i1 %32, double 0.000000e+00, double %33
%35 = fcmp ogt double %27, 2.550000e+02
%36 = select i1 %35, double 2.550000e+02, double %27
%37 = fcmp ogt double %31, 2.550000e+02
%38 = select i1 %37, double 2.550000e+02, double %31
%39 = fcmp ogt double %34, 2.550000e+02
%40 = select i1 %39, double 2.550000e+02, double %34
%41 = fptoui double %36 to i8
store i8 %41, i8* %3
%42 = fptoui double %38 to i8
store i8 %42, i8* %4
%43 = fptoui double %40 to i8
store i8 %43, i8* %5
ret void
}