#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 triplet(int, int, int);
int YCbCr2RGB(int v) {
  float r, g, b;
  r = 1.164 * ((float)((v >> 16) & 0xff) - 16.0) +
      1.596 * ((float)(v & 0xff) - 128.0);
  g = 1.164 * ((float)((v >> 16) & 0xff) - 16.0) -
      0.813 * ((float)(v & 0xff) - 128.0) -
      0.392 * ((float)((v >> 8) & 0xff) - 128.0);
  b = 1.164 * ((float)((v >> 16) & 0xff) - 16.0) +
      2.017 * ((float)((v >> 8) & 0xff) - 128.0);
  if (r < 0.0)
    r = 0.0;
  if (g < 0.0)
    g = 0.0;
  if (b < 0.0)
    b = 0.0;
  if (r > 255.0)
    r = 255.0;
  if (g > 255.0)
    g = 255.0;
  if (b > 255.0)
    b = 255.0;
  return (triplet((int)r, (int)g, (int)b));
}


x86 assembly (clang, -O0):
<YCbCr2RGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xee2(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xebe(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  0xed2(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe96(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe82(%rip),%xmm0
subsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xe5e(%rip),%xmm0
subsd  %xmm0,%xmm2
movsd  0xe6a(%rip),%xmm0
mulsd  %xmm2,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe1f(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0c(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xe10(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xddc(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xdb5(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  0xda1(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd8d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12a2 <YCbCr2RGB+0x192>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12c0 <YCbCr2RGB+0x1b0>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12de <YCbCr2RGB+0x1ce>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd49(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1306 <YCbCr2RGB+0x1f6>
movss  0xd3f(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd21(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    132e <YCbCr2RGB+0x21e>
movss  0xd17(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcf9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1356 <YCbCr2RGB+0x246>
movss  0xcef(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
cvttss2si -0x8(%rbp),%edi
cvttss2si -0xc(%rbp),%esi
cvttss2si -0x10(%rbp),%edx
call   1030 <triplet@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<YCbCr2RGB>:
mov    %edi,%eax
movzbl %al,%ecx
mov    %edi,%edx
shr    $0x10,%edx
movzbl %dl,%edx
cvtsi2ss %edx,%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2ss %ecx,%xmm1
addsd  0xecf(%rip),%xmm0
cvtss2sd %xmm1,%xmm1
movsd  0xecb(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  0xec7(%rip),%xmm3
mulsd  0xec7(%rip),%xmm0
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
cvtsd2ss %xmm3,%xmm3
movzbl %ah,%eax
mulsd  0xeb8(%rip),%xmm1
addsd  %xmm0,%xmm1
cvtsi2ss %eax,%xmm4
cvtss2sd %xmm4,%xmm4
addsd  %xmm2,%xmm4
movsd  0xea8(%rip),%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
mulsd  0xe99(%rip),%xmm4
addsd  %xmm0,%xmm4
xorps  %xmm0,%xmm0
cvtsd2ss %xmm4,%xmm0
xorps  %xmm2,%xmm2
xorps  %xmm4,%xmm4
maxss  %xmm3,%xmm4
xorps  %xmm3,%xmm3
maxss  %xmm1,%xmm3
maxss  %xmm0,%xmm2
movss  0xe79(%rip),%xmm0
movaps %xmm0,%xmm1
minss  %xmm4,%xmm1
movaps %xmm0,%xmm4
minss  %xmm3,%xmm4
minss  %xmm2,%xmm0
cvttss2si %xmm1,%edi
cvttss2si %xmm4,%esi
cvttss2si %xmm0,%edx
jmp    1030 <triplet@plt>

LLVM IR (-O0):
define i32 @YCbCr2RGB(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = ashr i32 %6, 16
%8 = and i32 %7, 255
%9 = sitofp i32 %8 to float
%10 = fpext float %9 to double
%11 = fsub double %10, 1.600000e+01
%12 = load i32, i32* %2
%13 = and i32 %12, 255
%14 = sitofp i32 %13 to float
%15 = fpext float %14 to double
%16 = fsub double %15, 1.280000e+02
%17 = fmul double 1.596000e+00, %16
%18 = call double @llvm.fmuladd.f64(double 1.164000e+00, double %11, double %17)
%19 = fptrunc double %18 to float
store float %19, float* %3
%20 = load i32, i32* %2
%21 = ashr i32 %20, 16
%22 = and i32 %21, 255
%23 = sitofp i32 %22 to float
%24 = fpext float %23 to double
%25 = fsub double %24, 1.600000e+01
%26 = load i32, i32* %2
%27 = and i32 %26, 255
%28 = sitofp i32 %27 to float
%29 = fpext float %28 to double
%30 = fsub double %29, 1.280000e+02
%31 = fmul double 0x3FEA04189374BC6A, %30
%32 = fneg double %31
%33 = call double @llvm.fmuladd.f64(double 1.164000e+00, double %25, double %32)
%34 = load i32, i32* %2
%35 = ashr i32 %34, 8
%36 = and i32 %35, 255
%37 = sitofp i32 %36 to float
%38 = fpext float %37 to double
%39 = fsub double %38, 1.280000e+02
%40 = call double @llvm.fmuladd.f64(double -3.920000e-01, double %39, double %33)
%41 = fptrunc double %40 to float
store float %41, float* %4
%42 = load i32, i32* %2
%43 = ashr i32 %42, 16
%44 = and i32 %43, 255
%45 = sitofp i32 %44 to float
%46 = fpext float %45 to double
%47 = fsub double %46, 1.600000e+01
%48 = load i32, i32* %2
%49 = ashr i32 %48, 8
%50 = and i32 %49, 255
%51 = sitofp i32 %50 to float
%52 = fpext float %51 to double
%53 = fsub double %52, 1.280000e+02
%54 = fmul double 2.017000e+00, %53
%55 = call double @llvm.fmuladd.f64(double 1.164000e+00, double %47, double %54)
%56 = fptrunc double %55 to float
store float %56, float* %5
%57 = load float, float* %3
%58 = fpext float %57 to double
%59 = fcmp olt double %58, 0.000000e+00
br i1 %59, label %60, label %61
60: ; preds = %1
store float 0.000000e+00, float* %3
br label %61
61: ; preds = %60, %1
%62 = load float, float* %4
%63 = fpext float %62 to double
%64 = fcmp olt double %63, 0.000000e+00
br i1 %64, label %65, label %66
65: ; preds = %61
store float 0.000000e+00, float* %4
br label %66
66: ; preds = %65, %61
%67 = load float, float* %5
%68 = fpext float %67 to double
%69 = fcmp olt double %68, 0.000000e+00
br i1 %69, label %70, label %71
70: ; preds = %66
store float 0.000000e+00, float* %5
br label %71
71: ; preds = %70, %66
%72 = load float, float* %3
%73 = fpext float %72 to double
%74 = fcmp ogt double %73, 2.550000e+02
br i1 %74, label %75, label %76
75: ; preds = %71
store float 2.550000e+02, float* %3
br label %76
76: ; preds = %75, %71
%77 = load float, float* %4
%78 = fpext float %77 to double
%79 = fcmp ogt double %78, 2.550000e+02
br i1 %79, label %80, label %81
80: ; preds = %76
store float 2.550000e+02, float* %4
br label %81
81: ; preds = %80, %76
%82 = load float, float* %5
%83 = fpext float %82 to double
%84 = fcmp ogt double %83, 2.550000e+02
br i1 %84, label %85, label %86
85: ; preds = %81
store float 2.550000e+02, float* %5
br label %86
86: ; preds = %85, %81
%87 = load float, float* %3
%88 = fptosi float %87 to i32
%89 = load float, float* %4
%90 = fptosi float %89 to i32
%91 = load float, float* %5
%92 = fptosi float %91 to i32
%93 = call i32 @triplet(i32 %88, i32 %90, i32 %92)
ret i32 %93
}

LLVM IR (-O2):
define i32 @YCbCr2RGB(i32 %0) {
%2 = lshr i32 %0, 16
%3 = and i32 %2, 255
%4 = sitofp i32 %3 to float
%5 = fpext float %4 to double
%6 = fadd double %5, -1.600000e+01
%7 = and i32 %0, 255
%8 = sitofp i32 %7 to float
%9 = fpext float %8 to double
%10 = fadd double %9, -1.280000e+02
%11 = fmul double %10, 1.596000e+00
%12 = tail call double @llvm.fmuladd.f64(double %6, double 1.164000e+00, double %11)
%13 = fptrunc double %12 to float
%14 = fmul double %10, 0xBFEA04189374BC6A
%15 = tail call double @llvm.fmuladd.f64(double %6, double 1.164000e+00, double %14)
%16 = lshr i32 %0, 8
%17 = and i32 %16, 255
%18 = sitofp i32 %17 to float
%19 = fpext float %18 to double
%20 = fadd double %19, -1.280000e+02
%21 = tail call double @llvm.fmuladd.f64(double %20, double -3.920000e-01, double %15)
%22 = fptrunc double %21 to float
%23 = fmul double %20, 2.017000e+00
%24 = tail call double @llvm.fmuladd.f64(double %6, double 1.164000e+00, double %23)
%25 = fptrunc double %24 to float
%26 = fcmp olt float %13, 0.000000e+00
%27 = select i1 %26, float 0.000000e+00, float %13
%28 = fcmp olt float %22, 0.000000e+00
%29 = select i1 %28, float 0.000000e+00, float %22
%30 = fcmp olt float %25, 0.000000e+00
%31 = select i1 %30, float 0.000000e+00, float %25
%32 = fcmp ogt float %27, 2.550000e+02
%33 = select i1 %32, float 2.550000e+02, float %27
%34 = fcmp ogt float %29, 2.550000e+02
%35 = select i1 %34, float 2.550000e+02, float %29
%36 = fcmp ogt float %31, 2.550000e+02
%37 = select i1 %36, float 2.550000e+02, float %31
%38 = fptosi float %33 to i32
%39 = fptosi float %35 to i32
%40 = fptosi float %37 to i32
%41 = tail call i32 @triplet(i32 %38, i32 %39, i32 %40)
ret i32 %41
}