#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;
typedef int int64_t;

/* Variables and functions */
void transfer_YUVA16161616_to_YUV444P(unsigned char *output_y,
                                      unsigned char *output_u,
                                      unsigned char *output_v, uint16_t *input,
                                      int output_column) {
  int64_t opacity = input[3];
  int64_t transparency = 0xffff - opacity;
  output_y[output_column] = ((int64_t)input[0] * opacity) / 0xffff00;
  output_u[output_column] =
      ((int64_t)input[1] * opacity + 0x8000 * transparency) / 0xffff00;
  output_v[output_column] =
      ((int64_t)input[2] * opacity + 0x8000 * transparency) / 0xffff00;
}


x86 assembly (clang, -O0):
<transfer_YUVA16161616_to_YUV444P>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    $0xffff,%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
imul   -0x28(%rbp),%eax
mov    $0xffff00,%ecx
cltd
idiv   %ecx
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
imul   -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0xf,%ecx
add    %ecx,%eax
mov    $0xffff00,%ecx
cltd
idiv   %ecx
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%eax
imul   -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0xf,%ecx
add    %ecx,%eax
mov    $0xffff00,%ecx
cltd
idiv   %ecx
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_YUVA16161616_to_YUV444P>:
mov    0xc(%rcx),%r9d
mov    (%rcx),%eax
imul   %r9d,%eax
movslq %eax,%r10
imul   $0xffffffff80008001,%r10,%rax
shr    $0x20,%rax
add    %eax,%r10d
mov    %r10d,%eax
shr    $0x1f,%eax
shr    $0x17,%r10d
add    %eax,%r10d
movslq %r8d,%r8
mov    %r10b,(%rdi,%r8,1)
mov    0x4(%rcx),%eax
imul   %r9d,%eax
mov    %r9d,%edi
shl    $0xf,%edi
mov    $0x7fff8000,%r10d
sub    %edi,%r10d
add    %r10d,%eax
cltq
imul   $0xffffffff80008001,%rax,%rdi
shr    $0x20,%rdi
add    %edi,%eax
mov    %eax,%edi
shr    $0x1f,%edi
shr    $0x17,%eax
add    %edi,%eax
mov    %al,(%rsi,%r8,1)
imul   0x8(%rcx),%r9d
add    %r10d,%r9d
movslq %r9d,%rax
imul   $0xffffffff80008001,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
shr    $0x17,%eax
add    %ecx,%eax
mov    %al,(%rdx,%r8,1)
ret

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

LLVM IR (-O2):
define void @transfer_YUVA16161616_to_YUV444P(i8* nocapture writeonly %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2, i32* nocapture %3, i32 %4) {
%6 = getelementptr inbounds i32, i32* %3, i64 3
%7 = load i32, i32* %6
%8 = load i32, i32* %3
%9 = mul nsw i32 %8, %7
%10 = sdiv i32 %9, 16776960
%11 = trunc i32 %10 to i8
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 %11, i8* %13
%14 = getelementptr inbounds i32, i32* %3, i64 1
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, %7
%17 = mul i32 %7, -32768
%18 = add i32 %17, 2147450880
%19 = add nsw i32 %16, %18
%20 = sdiv i32 %19, 16776960
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %21, i8* %22
%23 = getelementptr inbounds i32, i32* %3, i64 2
%24 = load i32, i32* %23
%25 = mul nsw i32 %24, %7
%26 = add nsw i32 %25, %18
%27 = sdiv i32 %26, 16776960
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds i8, i8* %2, i64 %12
store i8 %28, i8* %29
ret void
}