#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 */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void yuva_to_yuvyuv(unsigned char *input, unsigned char *output, int width,
                    int height) {
  memcpy(output, input, (width * height * 3) / 2);
  input += (width * height * 3) / 2;
  output += (width * height * 3) / 2;
  memcpy(output, input, width * height);
  output += width * height;
  memset(output, 0, (width * height) / 2);
}


x86 assembly (clang, -O0):
<yuva_to_yuvyuv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
imul   -0x18(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yuva_to_yuvyuv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
imul   %ecx,%r14d
lea    (%r14,%r14,2),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %rsi,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
movslq %ebp,%rax
add    %rax,%r15
add    %rax,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <memcpy@plt>
movslq %r14d,%rax
add    %rax,%rbx
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
mov    %rbx,%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <memset@plt>

LLVM IR (-O0):
define void @yuva_to_yuvyuv(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = mul nsw i32 %11, %12
%14 = mul nsw i32 %13, 3
%15 = sdiv i32 %14, 2
%16 = call i32 @memcpy(i8* %9, i8* %10, i32 %15)
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = mul nsw i32 %17, %18
%20 = mul nsw i32 %19, 3
%21 = sdiv i32 %20, 2
%22 = load i8*, i8** %5
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8* %24, i8** %5
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = mul nsw i32 %25, %26
%28 = mul nsw i32 %27, 3
%29 = sdiv i32 %28, 2
%30 = load i8*, i8** %6
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = load i8*, i8** %5
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = mul nsw i32 %35, %36
%38 = call i32 @memcpy(i8* %33, i8* %34, i32 %37)
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = mul nsw i32 %39, %40
%42 = load i8*, i8** %6
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i8, i8* %42, i64 %43
store i8* %44, i8** %6
%45 = load i8*, i8** %6
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = mul nsw i32 %46, %47
%49 = sdiv i32 %48, 2
%50 = call i32 @memset(i8* %45, i32 0, i32 %49)
ret void
}

LLVM IR (-O2):
define void @yuva_to_yuvyuv(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %3, %2
%6 = mul nsw i32 %5, 3
%7 = sdiv i32 %6, 2
%8 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %7)
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %1, i64 %9
%12 = tail call i32 @memcpy(i8* %11, i8* %10, i32 %5)
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = sdiv i32 %5, 2
%16 = tail call i32 @memset(i8* %14, i32 0, i32 %15)
ret void
}