#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ ILI9341_color565(float, float, float);
uint8_t rawpix(int YY, int UU, int VV) {
  float R = YY + 1.402 * (VV - 128);
  float G = YY - 0.34414 * (UU - 128) - 0.71414 * (VV - 128);
  float B = YY + 1.772 * (UU - 128);
  if (B < 0)
    B = 0;
  else if (B > 255)
    B = 255;
  if (G < 0)
    G = 0;
  else if (G > 255)
    G = 255;
  if (R < 0)
    R = 0;
  else if (R > 255)
    R = 255;
  uint16_t ret = ILI9341_color565(R, G, B);
  return ret;
}


x86 assembly (clang, -O0):
<rawpix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xede(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeac(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe88(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe56(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11d5 <rawpix+0xc5>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11fd <rawpix+0xed>
movss  -0x18(%rbp),%xmm0
movss  0xe3e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11f8 <rawpix+0xe8>
movss  0xe2d(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11fd <rawpix+0xed>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1217 <rawpix+0x107>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    123f <rawpix+0x12f>
movss  -0x14(%rbp),%xmm0
movss  0xdfc(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    123a <rawpix+0x12a>
movss  0xdeb(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    123f <rawpix+0x12f>
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    1259 <rawpix+0x149>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1281 <rawpix+0x171>
movss  -0x10(%rbp),%xmm0
movss  0xdba(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    127c <rawpix+0x16c>
movss  0xda9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1281 <rawpix+0x171>
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
call   1030 <ILI9341_color565@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rawpix>:
cvtsi2sd %edi,%xmm1
add    $0xffffff80,%edx
cvtsi2sd %edx,%xmm2
movsd  0xedd(%rip),%xmm0
mulsd  %xmm2,%xmm0
add    $0xffffff80,%esi
cvtsi2sd %esi,%xmm4
movsd  0xed2(%rip),%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm1,%xmm3
mulsd  0xeca(%rip),%xmm2
addsd  %xmm3,%xmm2
xorps  %xmm3,%xmm3
cvtsd2ss %xmm2,%xmm3
mulsd  0xebf(%rip),%xmm4
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm4
cvtsd2ss %xmm4,%xmm4
xorpd  %xmm1,%xmm1
ucomiss %xmm4,%xmm1
xorps  %xmm2,%xmm2
ja     1185 <rawpix+0x75>
ucomiss 0xea8(%rip),%xmm4
movaps %xmm4,%xmm2
jbe    1185 <rawpix+0x75>
movss  0xe9b(%rip),%xmm2
xorps  %xmm4,%xmm4
cvtsd2ss %xmm0,%xmm4
ucomiss %xmm3,%xmm1
ja     11a5 <rawpix+0x95>
ucomiss 0xe88(%rip),%xmm3
movaps %xmm3,%xmm1
jbe    11a5 <rawpix+0x95>
movss  0xe7b(%rip),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm4,%xmm0
ja     11c1 <rawpix+0xb1>
ucomiss 0xe6c(%rip),%xmm4
movaps %xmm4,%xmm0
jbe    11c1 <rawpix+0xb1>
movss  0xe5f(%rip),%xmm0
jmp    1030 <ILI9341_color565@plt>

LLVM IR (-O0):
define i32 @rawpix(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to double
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 128
%15 = sitofp i32 %14 to double
%16 = call double @llvm.fmuladd.f64(double 1.402000e+00, double %15, double %12)
%17 = fptrunc double %16 to float
store float %17, float* %7
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %5
%21 = sub nsw i32 %20, 128
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double -3.441400e-01, double %22, double %19)
%24 = load i32, i32* %6
%25 = sub nsw i32 %24, 128
%26 = sitofp i32 %25 to double
%27 = call double @llvm.fmuladd.f64(double -7.141400e-01, double %26, double %23)
%28 = fptrunc double %27 to float
store float %28, float* %8
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to double
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 128
%33 = sitofp i32 %32 to double
%34 = call double @llvm.fmuladd.f64(double 1.772000e+00, double %33, double %30)
%35 = fptrunc double %34 to float
store float %35, float* %9
%36 = load float, float* %9
%37 = fcmp olt float %36, 0.000000e+00
br i1 %37, label %38, label %39
38: ; preds = %3
store float 0.000000e+00, float* %9
br label %44
39: ; preds = %3
%40 = load float, float* %9
%41 = fcmp ogt float %40, 2.550000e+02
br i1 %41, label %42, label %43
42: ; preds = %39
store float 2.550000e+02, float* %9
br label %43
43: ; preds = %42, %39
br label %44
44: ; preds = %43, %38
%45 = load float, float* %8
%46 = fcmp olt float %45, 0.000000e+00
br i1 %46, label %47, label %48
47: ; preds = %44
store float 0.000000e+00, float* %8
br label %53
48: ; preds = %44
%49 = load float, float* %8
%50 = fcmp ogt float %49, 2.550000e+02
br i1 %50, label %51, label %52
51: ; preds = %48
store float 2.550000e+02, float* %8
br label %52
52: ; preds = %51, %48
br label %53
53: ; preds = %52, %47
%54 = load float, float* %7
%55 = fcmp olt float %54, 0.000000e+00
br i1 %55, label %56, label %57
56: ; preds = %53
store float 0.000000e+00, float* %7
br label %62
57: ; preds = %53
%58 = load float, float* %7
%59 = fcmp ogt float %58, 2.550000e+02
br i1 %59, label %60, label %61
60: ; preds = %57
store float 2.550000e+02, float* %7
br label %61
61: ; preds = %60, %57
br label %62
62: ; preds = %61, %56
%63 = load float, float* %7
%64 = load float, float* %8
%65 = load float, float* %9
%66 = call i32 @ILI9341_color565(float %63, float %64, float %65)
store i32 %66, i32* %10
%67 = load i32, i32* %10
ret i32 %67
}

LLVM IR (-O2):
define i32 @rawpix(i32 %0, i32 %1, i32 %2) {
%4 = sitofp i32 %0 to double
%5 = add nsw i32 %2, -128
%6 = sitofp i32 %5 to double
%7 = tail call double @llvm.fmuladd.f64(double %6, double 1.402000e+00, double %4)
%8 = fptrunc double %7 to float
%9 = add nsw i32 %1, -128
%10 = sitofp i32 %9 to double
%11 = tail call double @llvm.fmuladd.f64(double %10, double -3.441400e-01, double %4)
%12 = tail call double @llvm.fmuladd.f64(double %6, double -7.141400e-01, double %11)
%13 = fptrunc double %12 to float
%14 = tail call double @llvm.fmuladd.f64(double %10, double 1.772000e+00, double %4)
%15 = fptrunc double %14 to float
%16 = fcmp olt float %15, 0.000000e+00
br i1 %16, label %20, label %17
17: ; preds = %3
%18 = fcmp ogt float %15, 2.550000e+02
br i1 %18, label %19, label %20
19: ; preds = %17
br label %20
20: ; preds = %3, %17, %19
%21 = phi float [ 2.550000e+02, %19 ], [ %15, %17 ], [ 0.000000e+00, %3 ]
%22 = fcmp olt float %13, 0.000000e+00
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = fcmp ogt float %13, 2.550000e+02
br i1 %24, label %25, label %26
25: ; preds = %23
br label %26
26: ; preds = %20, %23, %25
%27 = phi float [ 2.550000e+02, %25 ], [ %13, %23 ], [ 0.000000e+00, %20 ]
%28 = fcmp olt float %8, 0.000000e+00
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = fcmp ogt float %8, 2.550000e+02
br i1 %30, label %31, label %32
31: ; preds = %29
br label %32
32: ; preds = %26, %29, %31
%33 = phi float [ 2.550000e+02, %31 ], [ %8, %29 ], [ 0.000000e+00, %26 ]
%34 = tail call i32 @ILI9341_color565(float %33, float %27, float %21)
ret i32 %34
}