#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 float uint16_t;

/* Variables and functions */
float powf(float, int);
uint16_t tcs34725_calculateColorTemperature(uint16_t r, uint16_t g,
                                            uint16_t b) {
  float X, Y, Z;
  float xc, yc;
  float n;
  float cct;
  X = (-0.14282F * r) + (1.54924F * g) + (-0.95641F * b);
  Y = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
  Z = (-0.68202F * r) + (0.77073F * g) + (0.56332F * b);
  xc = (X) / (X + Y + Z);
  yc = (Y) / (X + Y + Z);
  n = (xc - 0.3320F) / (0.1858F - yc);
  cct =
      (449.0F * powf(n, 3)) + (3525.0F * powf(n, 2)) + (6823.3F * n) + 5520.33F;
  return (uint16_t)cct;
}


x86 assembly (clang, -O0):
<tcs34725_calculateColorTemperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm1
movss  0xf04(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  0xef3(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  0xeda(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm1
movss  0xebc(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  0xeab(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  0xe92(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm1
movss  0xe74(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  0xe63(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  0xe4a(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
addss  -0x14(%rbp),%xmm1
addss  -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
addss  -0x14(%rbp),%xmm1
addss  -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xdf2(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xde2(%rip),%xmm1
subss  -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
mov    $0x3,%edi
call   1030 <powf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
movss  -0x2c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  0xd9d(%rip),%xmm0
mulss  %xmm2,%xmm0
movss  0xd8d(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
movss  0xd74(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xd60(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcs34725_calculateColorTemperature>:
push   %rax
movaps %xmm1,%xmm3
shufps $0x0,%xmm1,%xmm3
mulps  0xee1(%rip),%xmm3
movaps %xmm0,%xmm4
shufps $0x0,%xmm0,%xmm4
mulps  0xee3(%rip),%xmm4
addps  %xmm3,%xmm4
movaps %xmm2,%xmm3
shufps $0x0,%xmm2,%xmm3
mulps  0xee2(%rip),%xmm3
mulss  0xeea(%rip),%xmm1
mulss  0xee6(%rip),%xmm0
addps  %xmm4,%xmm3
addss  %xmm1,%xmm0
mulss  0xedb(%rip),%xmm2
addss  %xmm0,%xmm2
movaps %xmm3,%xmm0
shufps $0x55,%xmm3,%xmm0
addss  %xmm3,%xmm0
addss  %xmm2,%xmm0
shufps $0x0,%xmm0,%xmm0
divps  %xmm0,%xmm3
movss  0xebd(%rip),%xmm0
addss  %xmm3,%xmm0
shufps $0x55,%xmm3,%xmm3
movss  0xeb1(%rip),%xmm1
subss  %xmm3,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
mov    $0x3,%edi
call   1030 <powf@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
mulss  0xe81(%rip),%xmm0
movss  0x4(%rsp),%xmm2
mulss  0xe77(%rip),%xmm2
movss  (%rsp),%xmm1
mulss  0xe6e(%rip),%xmm1
addss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  0xe62(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @tcs34725_calculateColorTemperature(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%14 = load float, float* %4
%15 = load float, float* %5
%16 = fmul float 0x3FF8C9AFE0000000, %15
%17 = call float @llvm.fmuladd.f32(float 0xBFC247ED00000000, float %14, float %16)
%18 = load float, float* %6
%19 = call float @llvm.fmuladd.f32(float 0xBFEE9AE920000000, float %18, float %17)
store float %19, float* %7
%20 = load float, float* %4
%21 = load float, float* %5
%22 = fmul float 0x3FF94100E0000000, %21
%23 = call float @llvm.fmuladd.f32(float 0xBFD4C73AC0000000, float %20, float %22)
%24 = load float, float* %6
%25 = call float @llvm.fmuladd.f32(float 0xBFE76BCE80000000, float %24, float %23)
store float %25, float* %8
%26 = load float, float* %4
%27 = load float, float* %5
%28 = fmul float 0x3FE8A9D200000000, %27
%29 = call float @llvm.fmuladd.f32(float 0xBFE5D31BA0000000, float %26, float %28)
%30 = load float, float* %6
%31 = call float @llvm.fmuladd.f32(float 0x3FE206B7A0000000, float %30, float %29)
store float %31, float* %9
%32 = load float, float* %7
%33 = load float, float* %7
%34 = load float, float* %8
%35 = fadd float %33, %34
%36 = load float, float* %9
%37 = fadd float %35, %36
%38 = fdiv float %32, %37
store float %38, float* %10
%39 = load float, float* %8
%40 = load float, float* %7
%41 = load float, float* %8
%42 = fadd float %40, %41
%43 = load float, float* %9
%44 = fadd float %42, %43
%45 = fdiv float %39, %44
store float %45, float* %11
%46 = load float, float* %10
%47 = fsub float %46, 0x3FD53F7CE0000000
%48 = load float, float* %11
%49 = fsub float 0x3FC7C84B60000000, %48
%50 = fdiv float %47, %49
store float %50, float* %12
%51 = load float, float* %12
%52 = call float @powf(float %51, i32 3)
%53 = load float, float* %12
%54 = call float @powf(float %53, i32 2)
%55 = fmul float 3.525000e+03, %54
%56 = call float @llvm.fmuladd.f32(float 4.490000e+02, float %52, float %55)
%57 = load float, float* %12
%58 = call float @llvm.fmuladd.f32(float 0x40BAA74CC0000000, float %57, float %56)
%59 = fadd float %58, 0x40B5905480000000
store float %59, float* %13
%60 = load float, float* %13
ret float %60
}

LLVM IR (-O2):
define float @tcs34725_calculateColorTemperature(float %0, float %1, float %2) {
%4 = insertelement <2 x float> poison, float %1, i64 0
%5 = shufflevector <2 x float> %4, <2 x float> poison, <2 x i32> zeroinitializer
%6 = fmul <2 x float> %5, <float 0x3FF8C9AFE0000000, float 0x3FF94100E0000000>
%7 = insertelement <2 x float> poison, float %0, i64 0
%8 = shufflevector <2 x float> %7, <2 x float> poison, <2 x i32> zeroinitializer
%9 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %8, <2 x float> <float 0xBFC247ED00000000, float 0xBFD4C73AC0000000>, <2 x float> %6)
%10 = insertelement <2 x float> poison, float %2, i64 0
%11 = shufflevector <2 x float> %10, <2 x float> poison, <2 x i32> zeroinitializer
%12 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %11, <2 x float> <float 0xBFEE9AE920000000, float 0xBFE76BCE80000000>, <2 x float> %9)
%13 = fmul float %1, 0x3FE8A9D200000000
%14 = tail call float @llvm.fmuladd.f32(float %0, float 0xBFE5D31BA0000000, float %13)
%15 = tail call float @llvm.fmuladd.f32(float %2, float 0x3FE206B7A0000000, float %14)
%16 = shufflevector <2 x float> %12, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%17 = fadd <2 x float> %12, %16
%18 = extractelement <2 x float> %17, i64 0
%19 = fadd float %15, %18
%20 = insertelement <2 x float> poison, float %19, i64 0
%21 = shufflevector <2 x float> %20, <2 x float> poison, <2 x i32> zeroinitializer
%22 = fdiv <2 x float> %12, %21
%23 = extractelement <2 x float> %22, i64 0
%24 = fadd float %23, 0xBFD53F7CE0000000
%25 = extractelement <2 x float> %22, i64 1
%26 = fsub float 0x3FC7C84B60000000, %25
%27 = fdiv float %24, %26
%28 = tail call float @powf(float %27, i32 3)
%29 = tail call float @powf(float %27, i32 2)
%30 = fmul float %29, 3.525000e+03
%31 = tail call float @llvm.fmuladd.f32(float %28, float 4.490000e+02, float %30)
%32 = tail call float @llvm.fmuladd.f32(float %27, float 0x40BAA74CC0000000, float %31)
%33 = fadd float %32, 0x40B5905480000000
ret float %33
}