#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 clipPixel(int const);
void convertPixelYUV444toARGB32(const unsigned char y, const unsigned char u,
                                const unsigned char v, unsigned char *dest) {
  const int C = (y - 16) * 298 + 128;
  const int D = u - 128;
  const int E = v - 128;
  dest[0] = clipPixel((C + 516 * D) >> 8);
  dest[1] = clipPixel((C - 100 * D - 208 * E) >> 8);
  dest[2] = clipPixel((C + 409 * E) >> 8);
  dest[3] = 255;
}


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

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

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

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