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

/* Variables and functions */
int clamp_RGBA_component(scalar_t__);
uint16_t GetRGBA(int16_t y, int16_t u, int16_t v) {
  const float fY = (float)y + 2048.0f;
  const float fU = (float)u;
  const float fV = (float)v;
  const uint16_t r = clamp_RGBA_component((int16_t)(fY + 1.4025 * fV));
  const uint16_t g =
      clamp_RGBA_component((int16_t)(fY - 0.3443 * fU - 0.7144 * fV));
  const uint16_t b = clamp_RGBA_component((int16_t)(fY + 1.7729 * fU));
  return (r << 4) | (g >> 1) | (b >> 6) | 1;
}


x86 assembly (clang, -O0):
<GetRGBA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cvtsi2ssq -0x8(%rbp),%xmm0
movss  0xeee(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvtsi2ssq -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
cvtsi2ssq -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xead(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <clamp_RGBA_component@plt>
mov    %eax,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe76(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe55(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <clamp_RGBA_component@plt>
mov    %eax,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <clamp_RGBA_component@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x4,%eax
mov    -0x2c(%rbp),%ecx
sar    $0x1,%ecx
or     %ecx,%eax
mov    -0x30(%rbp),%ecx
sar    $0x6,%ecx
or     %ecx,%eax
or     $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetRGBA>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
cvtsi2ss %rdi,%xmm0
addss  0xedd(%rip),%xmm0
cvtsi2ss %rsi,%xmm1
movss  %xmm1,(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ss %rdx,%xmm1
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xeb7(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <clamp_RGBA_component@plt>
mov    %eax,%ebx
movss  (%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe92(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe88(%rip),%xmm1
addsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1030 <clamp_RGBA_component@plt>
movsd  (%rsp),%xmm0
mulsd  0xe6f(%rip),%xmm0
mov    %eax,%ebp
addsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <clamp_RGBA_component@plt>
shl    $0x4,%ebx
sar    %ebp
sar    $0x6,%eax
or     %ebx,%eax
or     %ebp,%eax
or     $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @GetRGBA(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%13 = load i64, i64* %4
%14 = sitofp i64 %13 to float
%15 = fadd float %14, 2.048000e+03
store float %15, float* %7
%16 = load i64, i64* %5
%17 = sitofp i64 %16 to float
store float %17, float* %8
%18 = load i64, i64* %6
%19 = sitofp i64 %18 to float
store float %19, float* %9
%20 = load float, float* %7
%21 = fpext float %20 to double
%22 = load float, float* %9
%23 = fpext float %22 to double
%24 = call double @llvm.fmuladd.f64(double 1.402500e+00, double %23, double %21)
%25 = fptosi double %24 to i64
%26 = call i32 @clamp_RGBA_component(i64 %25)
store i32 %26, i32* %10
%27 = load float, float* %7
%28 = fpext float %27 to double
%29 = load float, float* %8
%30 = fpext float %29 to double
%31 = call double @llvm.fmuladd.f64(double -3.443000e-01, double %30, double %28)
%32 = load float, float* %9
%33 = fpext float %32 to double
%34 = call double @llvm.fmuladd.f64(double -7.144000e-01, double %33, double %31)
%35 = fptosi double %34 to i64
%36 = call i32 @clamp_RGBA_component(i64 %35)
store i32 %36, i32* %11
%37 = load float, float* %7
%38 = fpext float %37 to double
%39 = load float, float* %8
%40 = fpext float %39 to double
%41 = call double @llvm.fmuladd.f64(double 1.772900e+00, double %40, double %38)
%42 = fptosi double %41 to i64
%43 = call i32 @clamp_RGBA_component(i64 %42)
store i32 %43, i32* %12
%44 = load i32, i32* %10
%45 = shl i32 %44, 4
%46 = load i32, i32* %11
%47 = ashr i32 %46, 1
%48 = or i32 %45, %47
%49 = load i32, i32* %12
%50 = ashr i32 %49, 6
%51 = or i32 %48, %50
%52 = or i32 %51, 1
ret i32 %52
}

LLVM IR (-O2):
define i32 @GetRGBA(i64 %0, i64 %1, i64 %2) {
%4 = sitofp i64 %0 to float
%5 = fadd float %4, 2.048000e+03
%6 = sitofp i64 %1 to float
%7 = sitofp i64 %2 to float
%8 = fpext float %5 to double
%9 = fpext float %7 to double
%10 = tail call double @llvm.fmuladd.f64(double %9, double 1.402500e+00, double %8)
%11 = fptosi double %10 to i64
%12 = tail call i32 @clamp_RGBA_component(i64 %11)
%13 = fpext float %6 to double
%14 = tail call double @llvm.fmuladd.f64(double %13, double -3.443000e-01, double %8)
%15 = tail call double @llvm.fmuladd.f64(double %9, double -7.144000e-01, double %14)
%16 = fptosi double %15 to i64
%17 = tail call i32 @clamp_RGBA_component(i64 %16)
%18 = tail call double @llvm.fmuladd.f64(double %13, double 1.772900e+00, double %8)
%19 = fptosi double %18 to i64
%20 = tail call i32 @clamp_RGBA_component(i64 %19)
%21 = shl i32 %12, 4
%22 = ashr i32 %17, 1
%23 = ashr i32 %20, 6
%24 = or i32 %21, %22
%25 = or i32 %24, %23
%26 = or i32 %25, 1
ret i32 %26
}