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

/* Variables and functions */
void transfer_YUV161616_to_UYVA8888(unsigned char *(*output), uint16_t *input) {
  (*output)[0] = input[1] >> 8;
  (*output)[1] = input[0] >> 8;
  (*output)[2] = input[2] >> 8;
  (*output)[3] = input[3] >> 8;
  (*output) += 4;
}


x86 assembly (clang, -O0):
<transfer_YUV161616_to_UYVA8888>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_YUV161616_to_UYVA8888>:
mov    0x5(%rsi),%al
mov    (%rdi),%rcx
mov    %al,(%rcx)
mov    0x1(%rsi),%al
mov    (%rdi),%rcx
mov    %al,0x1(%rcx)
mov    0x9(%rsi),%al
mov    (%rdi),%rcx
mov    %al,0x2(%rcx)
mov    0xd(%rsi),%al
mov    (%rdi),%rcx
mov    %al,0x3(%rcx)
addq   $0x4,(%rdi)
ret

LLVM IR (-O0):
define void @transfer_YUV161616_to_UYVA8888(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
store i8** %0, i8*** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = load i32, i32* %6
%8 = ashr i32 %7, 8
%9 = trunc i32 %8 to i8
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 %9, i8* %12
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = ashr i32 %15, 8
%17 = trunc i32 %16 to i8
%18 = load i8**, i8*** %3
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 %17, i8* %20
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 2
%23 = load i32, i32* %22
%24 = ashr i32 %23, 8
%25 = trunc i32 %24 to i8
%26 = load i8**, i8*** %3
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %25, i8* %28
%29 = load i32*, i32** %4
%30 = getelementptr inbounds i32, i32* %29, i64 3
%31 = load i32, i32* %30
%32 = ashr i32 %31, 8
%33 = trunc i32 %32 to i8
%34 = load i8**, i8*** %3
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 3
store i8 %33, i8* %36
%37 = load i8**, i8*** %3
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i64 4
store i8* %39, i8** %37
ret void
}

LLVM IR (-O2):
define void @transfer_YUV161616_to_UYVA8888(i8** nocapture %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = load i32, i32* %3
%5 = lshr i32 %4, 8
%6 = trunc i32 %5 to i8
%7 = load i8*, i8** %0
store i8 %6, i8* %7
%8 = load i32, i32* %1
%9 = lshr i32 %8, 8
%10 = trunc i32 %9 to i8
%11 = load i8*, i8** %0
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %10, i8* %12
%13 = getelementptr inbounds i32, i32* %1, i64 2
%14 = load i32, i32* %13
%15 = lshr i32 %14, 8
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %0
%18 = getelementptr inbounds i8, i8* %17, i64 2
store i8 %16, i8* %18
%19 = getelementptr inbounds i32, i32* %1, i64 3
%20 = load i32, i32* %19
%21 = lshr i32 %20, 8
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %0
%24 = getelementptr inbounds i8, i8* %23, i64 3
store i8 %22, i8* %24
%25 = load i8*, i8** %0
%26 = getelementptr inbounds i8, i8* %25, i64 4
store i8* %26, i8** %0
ret void
}