#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 clamp(double);
void yuv2rgb(unsigned char Y, unsigned char Cb, unsigned char Cr, int *ER,
             int *EG, int *EB) {
  double y1, pb, pr, r, g, b;
  y1 = (255 / 219.0) * (Y - 16);
  pb = (255 / 224.0) * (Cb - 128);
  pr = (255 / 224.0) * (Cr - 128);
  r = 1.0 * y1 + 0 * pb + 1.402 * pr;
  g = 1.0 * y1 - 0.344 * pb - 0.714 * pr;
  b = 1.0 * y1 + 1.722 * pb + 0 * pr;
  *ER = clamp(r);
  *EG = clamp(g);
  *EB = clamp(b);
}


x86 assembly (clang, -O0):
<yuv2rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movzbl -0x1(%rbp),%eax
sub    $0x10,%eax
cvtsi2sd %eax,%xmm1
movsd  0xedf(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movzbl -0x2(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb9(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movzbl -0x3(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe9b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
xorps  %xmm0,%xmm0
mulsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xe4a(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe15(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xdf3(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
xorps  %xmm2,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <clamp@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x48(%rbp),%xmm0
call   1030 <clamp@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x50(%rbp),%xmm0
call   1030 <clamp@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yuv2rgb>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
add    $0xfffffff0,%edi
cvtsi2sd %edi,%xmm1
mulsd  0xed8(%rip),%xmm1
add    $0xffffff80,%esi
cvtsi2sd %esi,%xmm2
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%rbx
movsd  0xec8(%rip),%xmm0
mulsd  %xmm0,%xmm2
add    $0xffffff80,%edx
cvtsi2sd %edx,%xmm5
mulsd  %xmm0,%xmm5
xorpd  %xmm3,%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm1,%xmm4
movsd  0xea9(%rip),%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm4,%xmm0
movsd  0xea1(%rip),%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm1,%xmm4
movsd  0xe99(%rip),%xmm6
mulsd  %xmm5,%xmm6
mulsd  0xe95(%rip),%xmm2
addsd  %xmm4,%xmm6
movsd  %xmm6,(%rsp)
addsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm5
addsd  %xmm2,%xmm5
movsd  %xmm5,0x8(%rsp)
call   1030 <clamp@plt>
mov    %eax,(%rbx)
movsd  (%rsp),%xmm0
call   1030 <clamp@plt>
mov    %eax,(%r15)
movsd  0x8(%rsp),%xmm0
call   1030 <clamp@plt>
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @yuv2rgb(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = sub nsw i32 %20, 16
%22 = sitofp i32 %21 to double
%23 = fmul double 0x3FF2A150A8542A15, %22
store double %23, double* %13
%24 = load i8, i8* %8
%25 = zext i8 %24 to i32
%26 = sub nsw i32 %25, 128
%27 = sitofp i32 %26 to double
%28 = fmul double 0x3FF236DB6DB6DB6E, %27
store double %28, double* %14
%29 = load i8, i8* %9
%30 = zext i8 %29 to i32
%31 = sub nsw i32 %30, 128
%32 = sitofp i32 %31 to double
%33 = fmul double 0x3FF236DB6DB6DB6E, %32
store double %33, double* %15
%34 = load double, double* %13
%35 = load double, double* %14
%36 = fmul double 0.000000e+00, %35
%37 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %34, double %36)
%38 = load double, double* %15
%39 = call double @llvm.fmuladd.f64(double 1.402000e+00, double %38, double %37)
store double %39, double* %16
%40 = load double, double* %13
%41 = load double, double* %14
%42 = fmul double 3.440000e-01, %41
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %40, double %43)
%45 = load double, double* %15
%46 = call double @llvm.fmuladd.f64(double -7.140000e-01, double %45, double %44)
store double %46, double* %17
%47 = load double, double* %13
%48 = load double, double* %14
%49 = fmul double 1.722000e+00, %48
%50 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %47, double %49)
%51 = load double, double* %15
%52 = call double @llvm.fmuladd.f64(double 0.000000e+00, double %51, double %50)
store double %52, double* %18
%53 = load double, double* %16
%54 = call i32 @clamp(double %53)
%55 = load i32*, i32** %10
store i32 %54, i32* %55
%56 = load double, double* %17
%57 = call i32 @clamp(double %56)
%58 = load i32*, i32** %11
store i32 %57, i32* %58
%59 = load double, double* %18
%60 = call i32 @clamp(double %59)
%61 = load i32*, i32** %12
store i32 %60, i32* %61
ret void
}

LLVM IR (-O2):
define void @yuv2rgb(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = zext i8 %0 to i32
%8 = add nsw i32 %7, -16
%9 = sitofp i32 %8 to double
%10 = fmul double %9, 0x3FF2A150A8542A15
%11 = zext i8 %1 to i32
%12 = add nsw i32 %11, -128
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 0x3FF236DB6DB6DB6E
%15 = zext i8 %2 to i32
%16 = add nsw i32 %15, -128
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 0x3FF236DB6DB6DB6E
%19 = fmul double %14, 0.000000e+00
%20 = fadd double %10, %19
%21 = tail call double @llvm.fmuladd.f64(double %18, double 1.402000e+00, double %20)
%22 = fmul double %14, 3.440000e-01
%23 = fsub double %10, %22
%24 = tail call double @llvm.fmuladd.f64(double %18, double -7.140000e-01, double %23)
%25 = fmul double %14, 1.722000e+00
%26 = fadd double %10, %25
%27 = tail call double @llvm.fmuladd.f64(double %18, double 0.000000e+00, double %26)
%28 = tail call i32 @clamp(double %21)
store i32 %28, i32* %3
%29 = tail call i32 @clamp(double %24)
store i32 %29, i32* %4
%30 = tail call i32 @clamp(double %27)
store i32 %30, i32* %5
ret void
}