#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 /*<<< orphan*/ printf(char *, int, int, int, int, int, int, int, int, int);
int yuv2rgb(double y, double u, double v) {
  int ret = 0;
  double dr = y + 1.14 * v;
  double dg = y - 0.39 * u - 0.58 * v;
  double db = y + 2.03 * u;
  int r = (int)dr;
  int g = (int)dg;
  int b = (int)db;
  printf("(0x%02x, 0x%02x, 0x%02x) --> (%d(0x%02x), %d(0x%02x), %d(0x%02x))\n",
         (int)y, (int)u, (int)v, r, r, g, g, b, b);
  ret = b & 0xff;
  ret |= (g & 0xff) << 8;
  ret |= (r & 0xff) << 16;
  return ret;
}


x86 assembly (clang, -O0):
<yuv2rgb>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xed7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xeb0(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe93(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvttsd2si -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
cvttsd2si -0x38(%rbp),%eax
mov    %eax,-0x48(%rbp)
cvttsd2si -0x40(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cvttsd2si -0x10(%rbp),%esi
cvttsd2si -0x18(%rbp),%edx
cvttsd2si -0x20(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    -0x44(%rbp),%r9d
mov    -0x48(%rbp),%ebx
mov    -0x48(%rbp),%r11d
mov    -0x4c(%rbp),%r10d
mov    -0x4c(%rbp),%eax
lea    0xe3b(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x48(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x44(%rbp),%eax
and    $0xff,%eax
shl    $0x10,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<yuv2rgb>:
push   %rbp
push   %r14
push   %rbx
movsd  0xee4(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
movsd  0xedc(%rip),%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm0,%xmm4
cvttsd2si %xmm2,%ecx
mulsd  0xed0(%rip),%xmm2
cvttsd2si %xmm1,%edx
addsd  %xmm4,%xmm2
mulsd  0xec8(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm3,%r14d
cvttsd2si %xmm2,%ebx
cvttsd2si %xmm1,%ebp
cvttsd2si %xmm0,%esi
lea    0xeb4(%rip),%rdi
mov    %r14d,%r8d
mov    %r14d,%r9d
push   %rbp
push   %rbp
push   %rbx
push   %rbx
call   1030 <printf@plt>
add    $0x20,%rsp
movzbl %bpl,%eax
shl    $0x8,%ebx
movzwl %bx,%ecx
or     %eax,%ecx
movzbl %r14b,%eax
shl    $0x10,%eax
or     %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"(0x%02x, 0x%02x, 0x%02x) --> (%d(0x%02x), %d(0x%02x), %d(0x%02x))\0A\00"
define i32 @yuv2rgb(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store i32 0, i32* %7
%14 = load double, double* %4
%15 = load double, double* %6
%16 = call double @llvm.fmuladd.f64(double 1.140000e+00, double %15, double %14)
store double %16, double* %8
%17 = load double, double* %4
%18 = load double, double* %5
%19 = call double @llvm.fmuladd.f64(double -3.900000e-01, double %18, double %17)
%20 = load double, double* %6
%21 = call double @llvm.fmuladd.f64(double -5.800000e-01, double %20, double %19)
store double %21, double* %9
%22 = load double, double* %4
%23 = load double, double* %5
%24 = call double @llvm.fmuladd.f64(double 2.030000e+00, double %23, double %22)
store double %24, double* %10
%25 = load double, double* %8
%26 = fptosi double %25 to i32
store i32 %26, i32* %11
%27 = load double, double* %9
%28 = fptosi double %27 to i32
store i32 %28, i32* %12
%29 = load double, double* %10
%30 = fptosi double %29 to i32
store i32 %30, i32* %13
%31 = load double, double* %4
%32 = fptosi double %31 to i32
%33 = load double, double* %5
%34 = fptosi double %33 to i32
%35 = load double, double* %6
%36 = fptosi double %35 to i32
%37 = load i32, i32* %11
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = load i32, i32* %12
%41 = load i32, i32* %13
%42 = load i32, i32* %13
%43 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %34, i32 %36, i32 %37, i32 %38, i32 %39, i32 %40, i32 %41, i32 %42)
%44 = load i32, i32* %13
%45 = and i32 %44, 255
store i32 %45, i32* %7
%46 = load i32, i32* %12
%47 = and i32 %46, 255
%48 = shl i32 %47, 8
%49 = load i32, i32* %7
%50 = or i32 %49, %48
store i32 %50, i32* %7
%51 = load i32, i32* %11
%52 = and i32 %51, 255
%53 = shl i32 %52, 16
%54 = load i32, i32* %7
%55 = or i32 %54, %53
store i32 %55, i32* %7
%56 = load i32, i32* %7
ret i32 %56
}

LLVM IR (-O2):
@.str = [67 x i8] c"(0x%02x, 0x%02x, 0x%02x) --> (%d(0x%02x), %d(0x%02x), %d(0x%02x))\0A\00"
define i32 @yuv2rgb(double %0, double %1, double %2) {
%4 = tail call double @llvm.fmuladd.f64(double %2, double 1.140000e+00, double %0)
%5 = tail call double @llvm.fmuladd.f64(double %1, double -3.900000e-01, double %0)
%6 = tail call double @llvm.fmuladd.f64(double %2, double -5.800000e-01, double %5)
%7 = tail call double @llvm.fmuladd.f64(double %1, double 2.030000e+00, double %0)
%8 = fptosi double %4 to i32
%9 = fptosi double %6 to i32
%10 = fptosi double %7 to i32
%11 = fptosi double %0 to i32
%12 = fptosi double %1 to i32
%13 = fptosi double %2 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12, i32 %13, i32 %8, i32 %8, i32 %9, i32 %9, i32 %10, i32 %10)
%15 = and i32 %10, 255
%16 = shl i32 %9, 8
%17 = and i32 %16, 65280
%18 = or i32 %17, %15
%19 = shl i32 %8, 16
%20 = and i32 %19, 16711680
%21 = or i32 %18, %20
ret i32 %21
}