#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 */
float saturate(float);
unsigned int getColorFromRGBA(float red, float green, float blue, float alpha) {
  float r = saturate(red);
  float g = saturate(green);
  float b = saturate(blue);
  float a = saturate(alpha);
  return ((((int)(r * 255.0)) << 24) + (((int)(g * 255.0)) << 16) +
          (((int)(b * 255.0)) << 8) + (((int)(a * 255.0)) << 0));
}


x86 assembly (clang, -O0):
<getColorFromRGBA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe87(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
shl    $0x18,%eax
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
shl    $0x10,%ecx
add    %ecx,%eax
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe2f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
shl    $0x0,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getColorFromRGBA>:
sub    $0x18,%rsp
movss  %xmm3,0x14(%rsp)
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x8(%rsp)
call   1030 <saturate@plt>
movss  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
call   1030 <saturate@plt>
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe90(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
shl    $0x18,%eax
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm1
cvttsd2si %xmm1,%ecx
shl    $0x10,%ecx
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edx
add    %eax,%ecx
shl    $0x8,%edx
add    %ecx,%edx
cvtss2sd %xmm0,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
add    %edx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @getColorFromRGBA(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%13 = load float, float* %5
%14 = call float @saturate(float %13)
store float %14, float* %9
%15 = load float, float* %6
%16 = call float @saturate(float %15)
store float %16, float* %10
%17 = load float, float* %7
%18 = call float @saturate(float %17)
store float %18, float* %11
%19 = load float, float* %8
%20 = call float @saturate(float %19)
store float %20, float* %12
%21 = load float, float* %9
%22 = fpext float %21 to double
%23 = fmul double %22, 2.550000e+02
%24 = fptosi double %23 to i32
%25 = shl i32 %24, 24
%26 = load float, float* %10
%27 = fpext float %26 to double
%28 = fmul double %27, 2.550000e+02
%29 = fptosi double %28 to i32
%30 = shl i32 %29, 16
%31 = add nsw i32 %25, %30
%32 = load float, float* %11
%33 = fpext float %32 to double
%34 = fmul double %33, 2.550000e+02
%35 = fptosi double %34 to i32
%36 = shl i32 %35, 8
%37 = add nsw i32 %31, %36
%38 = load float, float* %12
%39 = fpext float %38 to double
%40 = fmul double %39, 2.550000e+02
%41 = fptosi double %40 to i32
%42 = shl i32 %41, 0
%43 = add nsw i32 %37, %42
ret i32 %43
}

LLVM IR (-O2):
define i32 @getColorFromRGBA(float %0, float %1, float %2, float %3) {
%5 = tail call float @saturate(float %0)
%6 = tail call float @saturate(float %1)
%7 = tail call float @saturate(float %2)
%8 = tail call float @saturate(float %3)
%9 = fpext float %5 to double
%10 = fmul double %9, 2.550000e+02
%11 = fptosi double %10 to i32
%12 = shl i32 %11, 24
%13 = fpext float %6 to double
%14 = fmul double %13, 2.550000e+02
%15 = fptosi double %14 to i32
%16 = shl i32 %15, 16
%17 = add nsw i32 %16, %12
%18 = fpext float %7 to double
%19 = fmul double %18, 2.550000e+02
%20 = fptosi double %19 to i32
%21 = shl i32 %20, 8
%22 = add nsw i32 %17, %21
%23 = fpext float %8 to double
%24 = fmul double %23, 2.550000e+02
%25 = fptosi double %24 to i32
%26 = add nsw i32 %22, %25
ret i32 %26
}