int convert_yuv422_to_rgb24_pixel(int y, int u, int v) {
  unsigned int pixel32 = 0;
  unsigned char *pixel = (unsigned char *)&pixel32;
  int r, g, b;
  r = y + (1.370705 * (v - 128));
  g = y - (0.698001 * (v - 128)) - (0.337633 * (u - 128));
  b = y + (1.732446 * (u - 128));
  if (r > 255)
    r = 255;
  if (g > 255)
    g = 255;
  if (b > 255)
    b = 255;
  if (r < 0)
    r = 0;
  if (g < 0)
    g = 0;
  if (b < 0)
    b = 0;
  pixel[0] = r;
  pixel[1] = g;
  pixel[2] = b;
  return pixel32;
}


x86 assembly (clang, -O0):
<convert_yuv422_to_rgb24_pixel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xee3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb3(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe8f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jle    11c4 <convert_yuv422_to_rgb24_pixel+0xc4>
movl   $0xff,-0x1c(%rbp)
cmpl   $0xff,-0x20(%rbp)
jle    11d8 <convert_yuv422_to_rgb24_pixel+0xd8>
movl   $0xff,-0x20(%rbp)
cmpl   $0xff,-0x24(%rbp)
jle    11ec <convert_yuv422_to_rgb24_pixel+0xec>
movl   $0xff,-0x24(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11fd <convert_yuv422_to_rgb24_pixel+0xfd>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    120e <convert_yuv422_to_rgb24_pixel+0x10e>
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    121f <convert_yuv422_to_rgb24_pixel+0x11f>
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_yuv422_to_rgb24_pixel>:
cvtsi2sd %edi,%xmm0
add    $0xffffff80,%edx
cvtsi2sd %edx,%xmm1
movsd  0xeed(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
cvttsd2si %xmm2,%eax
mulsd  0xee1(%rip),%xmm1
add    $0xffffff80,%esi
xorps  %xmm2,%xmm2
cvtsi2sd %esi,%xmm2
addsd  %xmm0,%xmm1
unpcklpd %xmm2,%xmm2
mulpd  0xecf(%rip),%xmm2
unpcklpd %xmm1,%xmm0
addpd  %xmm0,%xmm2
cvttpd2dq %xmm2,%xmm0
cmp    $0xff,%eax
mov    $0xff,%ecx
cmovl  %eax,%ecx
movdqa 0xebe(%rip),%xmm1
movdqa %xmm1,%xmm2
pcmpgtd %xmm0,%xmm2
pand   %xmm2,%xmm0
pandn  %xmm1,%xmm2
por    %xmm0,%xmm2
xor    %eax,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
pxor   %xmm0,%xmm0
movdqa %xmm2,%xmm1
pcmpgtd %xmm0,%xmm1
pand   %xmm2,%xmm1
movdqa %xmm1,%xmm0
pslld  $0x8,%xmm0
pslld  $0x10,%xmm1
movd   %xmm1,%ecx
or     %eax,%ecx
pshufd $0x55,%xmm0,%xmm0
movd   %xmm0,%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @convert_yuv422_to_rgb24_pixel(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%12 = bitcast i32* %7 to i8*
store i8* %12, i8** %8
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = load i32, i32* %6
%16 = sub nsw i32 %15, 128
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double 0x3FF5EE685DB76B3C, double %17, double %14)
%19 = fptosi double %18 to i32
store i32 %19, i32* %9
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to double
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 128
%24 = sitofp i32 %23 to double
%25 = call double @llvm.fmuladd.f64(double -6.980010e-01, double %24, double %21)
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 128
%28 = sitofp i32 %27 to double
%29 = call double @llvm.fmuladd.f64(double -3.376330e-01, double %28, double %25)
%30 = fptosi double %29 to i32
store i32 %30, i32* %10
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to double
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 128
%35 = sitofp i32 %34 to double
%36 = call double @llvm.fmuladd.f64(double 0x3FFBB8194C016052, double %35, double %32)
%37 = fptosi double %36 to i32
store i32 %37, i32* %11
%38 = load i32, i32* %9
%39 = icmp sgt i32 %38, 255
br i1 %39, label %40, label %41
40: ; preds = %3
store i32 255, i32* %9
br label %41
41: ; preds = %40, %3
%42 = load i32, i32* %10
%43 = icmp sgt i32 %42, 255
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 255, i32* %10
br label %45
45: ; preds = %44, %41
%46 = load i32, i32* %11
%47 = icmp sgt i32 %46, 255
br i1 %47, label %48, label %49
48: ; preds = %45
store i32 255, i32* %11
br label %49
49: ; preds = %48, %45
%50 = load i32, i32* %9
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %49
store i32 0, i32* %9
br label %53
53: ; preds = %52, %49
%54 = load i32, i32* %10
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %53
store i32 0, i32* %10
br label %57
57: ; preds = %56, %53
%58 = load i32, i32* %11
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %57
store i32 0, i32* %11
br label %61
61: ; preds = %60, %57
%62 = load i32, i32* %9
%63 = trunc i32 %62 to i8
%64 = load i8*, i8** %8
%65 = getelementptr inbounds i8, i8* %64, i64 0
store i8 %63, i8* %65
%66 = load i32, i32* %10
%67 = trunc i32 %66 to i8
%68 = load i8*, i8** %8
%69 = getelementptr inbounds i8, i8* %68, i64 1
store i8 %67, i8* %69
%70 = load i32, i32* %11
%71 = trunc i32 %70 to i8
%72 = load i8*, i8** %8
%73 = getelementptr inbounds i8, i8* %72, i64 2
store i8 %71, i8* %73
%74 = load i32, i32* %7
ret i32 %74
}

LLVM IR (-O2):
define i32 @convert_yuv422_to_rgb24_pixel(i32 %0, i32 %1, i32 %2) {
%4 = sitofp i32 %0 to double
%5 = add nsw i32 %2, -128
%6 = sitofp i32 %5 to double
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x3FF5EE685DB76B3C, double %4)
%8 = fptosi double %7 to i32
%9 = tail call double @llvm.fmuladd.f64(double %6, double -6.980010e-01, double %4)
%10 = add nsw i32 %1, -128
%11 = sitofp i32 %10 to double
%12 = insertelement <2 x double> poison, double %11, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
%14 = insertelement <2 x double> poison, double %4, i64 0
%15 = insertelement <2 x double> %14, double %9, i64 1
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> <double 0x3FFBB8194C016052, double -3.376330e-01>, <2 x double> %15)
%17 = fptosi <2 x double> %16 to <2 x i32>
%18 = icmp slt i32 %8, 255
%19 = select i1 %18, i32 %8, i32 255
%20 = icmp slt <2 x i32> %17, <i32 255, i32 255>
%21 = select <2 x i1> %20, <2 x i32> %17, <2 x i32> <i32 255, i32 255>
%22 = icmp sgt i32 %19, 0
%23 = select i1 %22, i32 %19, i32 0
%24 = icmp sgt <2 x i32> %21, zeroinitializer
%25 = select <2 x i1> %24, <2 x i32> %21, <2 x i32> zeroinitializer
%26 = shl nuw nsw <2 x i32> %25, <i32 16, i32 8>
%27 = and <2 x i32> %26, <i32 16711680, i32 65280>
%28 = extractelement <2 x i32> %27, i64 0
%29 = or i32 %28, %23
%30 = extractelement <2 x i32> %27, i64 1
%31 = or i32 %29, %30
ret i32 %31
}