#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
unsigned char clip(int);
void YUV444toRGB888(const unsigned char y, const unsigned char u,
                    const unsigned char v, unsigned char *dest) {
  const int C = y - 16;
  const int D = u - 128;
  const int E = v - 128;
  dest[0] = clip((298 * C + 409 * E + 128) >> 8);
  dest[1] = clip((298 * C - 100 * D - 208 * E + 128) >> 8);
  dest[2] = clip((298 * C + 516 * D + 128) >> 8);
}


x86 assembly (clang, -O0):
<YUV444toRGB888>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
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)
movzbl -0x1(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x14(%rbp)
movzbl -0x2(%rbp),%eax
sub    $0x80,%eax
mov    %eax,-0x18(%rbp)
movzbl -0x3(%rbp),%eax
sub    $0x80,%eax
mov    %eax,-0x1c(%rbp)
imul   $0x12a,-0x14(%rbp),%edi
imul   $0x199,-0x1c(%rbp),%eax
add    %eax,%edi
add    $0x80,%edi
sar    $0x8,%edi
call   1030 <clip@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
imul   $0x12a,-0x14(%rbp),%edi
imul   $0x64,-0x18(%rbp),%eax
sub    %eax,%edi
imul   $0xd0,-0x1c(%rbp),%eax
sub    %eax,%edi
add    $0x80,%edi
sar    $0x8,%edi
call   1030 <clip@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
imul   $0x12a,-0x14(%rbp),%edi
imul   $0x204,-0x18(%rbp),%eax
add    %eax,%edi
add    $0x80,%edi
sar    $0x8,%edi
call   1030 <clip@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<YUV444toRGB888>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %edx,%ebp
mov    %esi,%r14d
lea    -0x80(%r14),%ebx
add    $0xffffff80,%ebp
imul   $0x12a,%edi,%r12d
imul   $0x199,%ebp,%eax
lea    (%r12,%rax,1),%edi
add    $0xffffede0,%edi
sar    $0x8,%edi
call   1030 <clip@plt>
mov    %al,(%r15)
imul   $0xffffff9c,%ebx,%eax
imul   $0xffffff30,%ebp,%ecx
lea    (%r12,%rax,1),%edi
add    $0xffffede0,%edi
add    %ecx,%edi
sar    $0x8,%edi
call   1030 <clip@plt>
mov    %al,0x1(%r15)
shl    $0x9,%ebx
lea    (%rbx,%r14,4),%eax
add    $0xfffffe00,%eax
lea    (%r12,%rax,1),%edi
add    $0xffffede0,%edi
sar    $0x8,%edi
call   1030 <clip@plt>
mov    %al,0x2(%r15)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @YUV444toRGB888(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* %3) {
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8 %0, i8* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%12 = load i8, i8* %5
%13 = zext i8 %12 to i32
%14 = sub nsw i32 %13, 16
store i32 %14, i32* %9
%15 = load i8, i8* %6
%16 = zext i8 %15 to i32
%17 = sub nsw i32 %16, 128
store i32 %17, i32* %10
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = sub nsw i32 %19, 128
store i32 %20, i32* %11
%21 = load i32, i32* %9
%22 = mul nsw i32 298, %21
%23 = load i32, i32* %11
%24 = mul nsw i32 409, %23
%25 = add nsw i32 %22, %24
%26 = add nsw i32 %25, 128
%27 = ashr i32 %26, 8
%28 = call zeroext i8 @clip(i32 %27)
%29 = load i8*, i8** %8
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 %28, i8* %30
%31 = load i32, i32* %9
%32 = mul nsw i32 298, %31
%33 = load i32, i32* %10
%34 = mul nsw i32 100, %33
%35 = sub nsw i32 %32, %34
%36 = load i32, i32* %11
%37 = mul nsw i32 208, %36
%38 = sub nsw i32 %35, %37
%39 = add nsw i32 %38, 128
%40 = ashr i32 %39, 8
%41 = call zeroext i8 @clip(i32 %40)
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 1
store i8 %41, i8* %43
%44 = load i32, i32* %9
%45 = mul nsw i32 298, %44
%46 = load i32, i32* %10
%47 = mul nsw i32 516, %46
%48 = add nsw i32 %45, %47
%49 = add nsw i32 %48, 128
%50 = ashr i32 %49, 8
%51 = call zeroext i8 @clip(i32 %50)
%52 = load i8*, i8** %8
%53 = getelementptr inbounds i8, i8* %52, i64 2
store i8 %51, i8* %53
ret void
}

LLVM IR (-O2):
define void @YUV444toRGB888(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* nocapture writeonly %3) {
%5 = zext i8 %0 to i32
%6 = zext i8 %1 to i32
%7 = add nsw i32 %6, -128
%8 = zext i8 %2 to i32
%9 = add nsw i32 %8, -128
%10 = mul nuw nsw i32 %5, 298
%11 = mul nsw i32 %9, 409
%12 = add nsw i32 %10, -4640
%13 = add nsw i32 %12, %11
%14 = ashr i32 %13, 8
%15 = tail call zeroext i8 @clip(i32 %14)
store i8 %15, i8* %3
%16 = mul nsw i32 %7, -100
%17 = mul nsw i32 %9, -208
%18 = add nsw i32 %12, %16
%19 = add nsw i32 %18, %17
%20 = ashr i32 %19, 8
%21 = tail call zeroext i8 @clip(i32 %20)
%22 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %21, i8* %22
%23 = mul nsw i32 %7, 516
%24 = add nsw i32 %12, %23
%25 = ashr i32 %24, 8
%26 = tail call zeroext i8 @clip(i32 %25)
%27 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %26, i8* %27
ret void
}