#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;

/* Variables and functions */
int /*<<< orphan*/ yuv2rgb_c_internal(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *, void *,
                                      int /*<<< orphan*/ *, int);
void yuv2rgb_c(void *dst, uint8_t *py, uint8_t *pu, uint8_t *pv, int width,
               int height, int rgb_stride, int y_stride, int uv_stride) {
  height >>= 1;
  do {
    yuv2rgb_c_internal(py, py + y_stride, pu, pv, dst,
                       ((uint8_t *)dst) + rgb_stride, width);
    py += 2 * y_stride;
    pu += uv_stride;
    pv += uv_stride;
    dst = ((uint8_t *)dst) + 2 * rgb_stride;
  } while (--height);
}


x86 assembly (clang, -O0):
<yuv2rgb_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x28(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq 0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x8(%rbp),%r9
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r9
mov    -0x24(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <yuv2rgb_c_internal@plt>
mov    0x18(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    0x20(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jne    1142 <yuv2rgb_c+0x32>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yuv2rgb_c>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r15d
mov    %r8d,0x14(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
movslq 0x70(%rsp),%rcx
movslq 0x78(%rsp),%rdx
movslq 0x80(%rsp),%r14
sar    %r15d
lea    (%rdx,%rdx,1),%eax
movslq %eax,%rsi
lea    (%rcx,%rcx,1),%eax
cltq
shl    $0x2,%r14
shl    $0x2,%rdx
mov    %rdx,0x28(%rsp)
shl    $0x2,%rsi
mov    %rsi,0x20(%rsp)
shl    $0x2,%rcx
mov    %rcx,0x30(%rsp)
shl    $0x2,%rax
mov    %rax,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rax
lea    (%rax,%rbp,1),%rsi
mov    0x30(%rsp),%rax
lea    (%rbx,%rax,1),%r9
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
mov    %rbp,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
call   1030 <yuv2rgb_c_internal@plt>
add    %r14,%r12
add    %r14,%r13
add    0x20(%rsp),%rbp
add    0x18(%rsp),%rbx
add    $0xffffffff,%r15d
jne    1180 <yuv2rgb_c+0x70>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @yuv2rgb_c(i8* %0, i32* %1, i32* %2, i32* %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = ashr i32 %5, 1
%11 = sext i32 %7 to i64
%12 = sext i32 %6 to i64
%13 = shl nsw i32 %7, 1
%14 = sext i32 %13 to i64
%15 = sext i32 %8 to i64
%16 = shl nsw i32 %6, 1
%17 = sext i32 %16 to i64
br label %18
18: ; preds = %18, %9
%19 = phi i32* [ %3, %9 ], [ %30, %18 ]
%20 = phi i32 [ %10, %9 ], [ %33, %18 ]
%21 = phi i32* [ %2, %9 ], [ %29, %18 ]
%22 = phi i32* [ %1, %9 ], [ %28, %18 ]
%23 = phi i8* [ %0, %9 ], [ %32, %18 ]
%24 = getelementptr inbounds i32, i32* %22, i64 %11
%25 = bitcast i8* %23 to i32*
%26 = getelementptr inbounds i32, i32* %25, i64 %12
%27 = tail call i32 @yuv2rgb_c_internal(i32* %22, i32* %24, i32* %21, i32* %19, i8* %23, i32* %26, i32 %4)
%28 = getelementptr inbounds i32, i32* %22, i64 %14
%29 = getelementptr inbounds i32, i32* %21, i64 %15
%30 = getelementptr inbounds i32, i32* %19, i64 %15
%31 = getelementptr inbounds i32, i32* %25, i64 %17
%32 = bitcast i32* %31 to i8*
%33 = add nsw i32 %20, -1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %18
35: ; preds = %18
ret void
}