#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ washdc_yuv_to_rgba_2pixels(int /*<<< orphan*/ *,
                                              unsigned int, unsigned int, int,
                                              int);
void washdc_conv_yuv422_rgba8888(void *rgba_out, void const *yuv_in,
                                 unsigned width, unsigned height) {
  uint8_t *rgbap = (uint8_t *)rgba_out;
  uint32_t const *tex_in = (uint32_t const *)yuv_in;
  unsigned half_width = width / 2;
  unsigned col, row;
  for (row = 0; row < height; row++) {
    for (col = 0; col < half_width; col++) {
      uint32_t in = *tex_in++;
      unsigned lum[2] = {(in >> 8) & 0xff, (in >> 24) & 0xff};
      int chrom_b = in & 0xff;
      int chrom_r = (in >> 16) & 0xff;
      washdc_yuv_to_rgba_2pixels(rgbap, lum[0], lum[1], chrom_b - 128,
                                 chrom_r - 128);
      rgbap += 8;
    }
  }
}


x86 assembly (clang, -O0):
<washdc_conv_yuv422_rgba8888>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    11fe <washdc_conv_yuv422_rgba8888+0xee>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    11eb <washdc_conv_yuv422_rgba8888+0xdb>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x44(%rbp),%ecx
sub    $0x80,%ecx
mov    -0x48(%rbp),%r8d
sub    $0x80,%r8d
call   1030 <washdc_yuv_to_rgba_2pixels@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1159 <washdc_conv_yuv422_rgba8888+0x49>
jmp    11f0 <washdc_conv_yuv422_rgba8888+0xe0>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1146 <washdc_conv_yuv422_rgba8888+0x36>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<washdc_conv_yuv422_rgba8888>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
je     11a4 <washdc_conv_yuv422_rgba8888+0x94>
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %edx,%eax
shr    %eax
cmp    $0x2,%eax
mov    $0x1,%ecx
cmovae %eax,%ecx
mov    %ecx,0x4(%rsp)
xor    %r13d,%r13d
jmp    1159 <washdc_conv_yuv422_rgba8888+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    %r15d,%r13d
je     11a4 <washdc_conv_yuv422_rgba8888+0x94>
cmp    $0x2,%r14d
jb     1150 <washdc_conv_yuv422_rgba8888+0x40>
mov    0x4(%rsp),%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%rbp),%eax
add    $0x4,%rbp
movzbl %ah,%esi
mov    %eax,%edx
shr    $0x18,%edx
movzbl %al,%ecx
shr    $0x10,%eax
movzbl %al,%r8d
add    $0xffffff80,%ecx
add    $0xffffff80,%r8d
mov    %rbx,%rdi
call   1030 <washdc_yuv_to_rgba_2pixels@plt>
add    $0x20,%rbx
add    $0xffffffff,%r12d
jne    1170 <washdc_conv_yuv422_rgba8888+0x60>
jmp    1150 <washdc_conv_yuv422_rgba8888+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @washdc_conv_yuv422_rgba8888(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [2 x i32]
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%18 = load i8*, i8** %5
%19 = bitcast i8* %18 to i32*
store i32* %19, i32** %9
%20 = load i8*, i8** %6
%21 = bitcast i8* %20 to i32*
store i32* %21, i32** %10
%22 = load i32, i32* %7
%23 = udiv i32 %22, 2
store i32 %23, i32* %11
store i32 0, i32* %13
br label %24
24: ; preds = %66, %4
%25 = load i32, i32* %13
%26 = load i32, i32* %8
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %69
28: ; preds = %24
store i32 0, i32* %12
br label %29
29: ; preds = %62, %28
%30 = load i32, i32* %12
%31 = load i32, i32* %11
%32 = icmp ult i32 %30, %31
br i1 %32, label %33, label %65
33: ; preds = %29
%34 = load i32*, i32** %10
%35 = getelementptr inbounds i32, i32* %34, i32 1
store i32* %35, i32** %10
%36 = load i32, i32* %34
store i32 %36, i32* %14
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%38 = load i32, i32* %14
%39 = ashr i32 %38, 8
%40 = and i32 %39, 255
store i32 %40, i32* %37
%41 = getelementptr inbounds i32, i32* %37, i64 1
%42 = load i32, i32* %14
%43 = ashr i32 %42, 24
%44 = and i32 %43, 255
store i32 %44, i32* %41
%45 = load i32, i32* %14
%46 = and i32 %45, 255
store i32 %46, i32* %16
%47 = load i32, i32* %14
%48 = ashr i32 %47, 16
%49 = and i32 %48, 255
store i32 %49, i32* %17
%50 = load i32*, i32** %9
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%52 = load i32, i32* %51
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 1
%54 = load i32, i32* %53
%55 = load i32, i32* %16
%56 = sub nsw i32 %55, 128
%57 = load i32, i32* %17
%58 = sub nsw i32 %57, 128
%59 = call i32 @washdc_yuv_to_rgba_2pixels(i32* %50, i32 %52, i32 %54, i32 %56, i32 %58)
%60 = load i32*, i32** %9
%61 = getelementptr inbounds i32, i32* %60, i64 8
store i32* %61, i32** %9
br label %62
62: ; preds = %33
%63 = load i32, i32* %12
%64 = add i32 %63, 1
store i32 %64, i32* %12
br label %29
65: ; preds = %29
br label %66
66: ; preds = %65
%67 = load i32, i32* %13
%68 = add i32 %67, 1
store i32 %68, i32* %13
br label %24
69: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @washdc_conv_yuv422_rgba8888(i8* %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %39, label %6
6: ; preds = %4
%7 = lshr i32 %2, 1
%8 = bitcast i8* %1 to i32*
%9 = bitcast i8* %0 to i32*
%10 = icmp ult i32 %2, 2
%11 = call i32 @llvm.umax.i32(i32 %7, i32 1)
br label %12
12: ; preds = %6, %34
%13 = phi i32* [ %9, %6 ], [ %36, %34 ]
%14 = phi i32* [ %8, %6 ], [ %35, %34 ]
%15 = phi i32 [ 0, %6 ], [ %37, %34 ]
br i1 %10, label %34, label %16
16: ; preds = %12, %16
%17 = phi i32* [ %31, %16 ], [ %13, %12 ]
%18 = phi i32* [ %20, %16 ], [ %14, %12 ]
%19 = phi i32 [ %32, %16 ], [ 0, %12 ]
%20 = getelementptr inbounds i32, i32* %18, i64 1
%21 = load i32, i32* %18
%22 = lshr i32 %21, 8
%23 = and i32 %22, 255
%24 = lshr i32 %21, 24
%25 = and i32 %21, 255
%26 = lshr i32 %21, 16
%27 = and i32 %26, 255
%28 = add nsw i32 %25, -128
%29 = add nsw i32 %27, -128
%30 = tail call i32 @washdc_yuv_to_rgba_2pixels(i32* %17, i32 %23, i32 %24, i32 %28, i32 %29)
%31 = getelementptr inbounds i32, i32* %17, i64 8
%32 = add nuw nsw i32 %19, 1
%33 = icmp eq i32 %32, %11
br i1 %33, label %34, label %16
34: ; preds = %16, %12
%35 = phi i32* [ %14, %12 ], [ %20, %16 ]
%36 = phi i32* [ %13, %12 ], [ %31, %16 ]
%37 = add nuw i32 %15, 1
%38 = icmp eq i32 %37, %3
br i1 %38, label %39, label %12
39: ; preds = %34, %4
ret void
}