#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fmaxf(float, float);
float fminf(float, int /*<<< orphan*/);
int rint(float);
uint32_t rgba_to_hex(float *c) {
  float r = fminf(1.f, fmaxf(0.f, c[0]));
  float g = fminf(1.f, fmaxf(0.f, c[1]));
  float b = fminf(1.f, fmaxf(0.f, c[2]));
  float a = fminf(1.f, fmaxf(0.f, c[3]));
  uint32_t rc, gc, bc, ac;
  rc = rint(r * 255.0);
  gc = rint(g * 255.0);
  bc = rint(b * 255.0);
  ac = rint(a * 255.0);
  return (rc << 24) | (gc << 16) | (bc << 8) | ac;
}


x86 assembly (clang, -O0):
<rgba_to_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
mov    %eax,%edi
movss  0xeb2(%rip),%xmm0
call   1030 <fminf@plt>
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
mov    %eax,%edi
movss  0xe8d(%rip),%xmm0
call   1030 <fminf@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
mov    %eax,%edi
movss  0xe68(%rip),%xmm0
call   1030 <fminf@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
mov    %eax,%edi
movss  0xe43(%rip),%xmm0
call   1030 <fminf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe20(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <rint@plt>
mov    %eax,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdff(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <rint@plt>
mov    %eax,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdde(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <rint@plt>
mov    %eax,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdbd(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <rint@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x18,%eax
mov    -0x20(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x24(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgba_to_hex>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
movss  0xeb1(%rip),%xmm0
mov    %eax,%edi
call   1030 <fminf@plt>
movss  %xmm0,0xc(%rsp)
movss  0x4(%rbx),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
movss  0xe8f(%rip),%xmm0
mov    %eax,%edi
call   1030 <fminf@plt>
movss  %xmm0,0x8(%rsp)
movss  0x8(%rbx),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
movss  0xe6d(%rip),%xmm0
mov    %eax,%edi
call   1030 <fminf@plt>
movss  %xmm0,0x4(%rsp)
movss  0xc(%rbx),%xmm1
xorps  %xmm0,%xmm0
call   1040 <fmaxf@plt>
movss  0xe4b(%rip),%xmm0
mov    %eax,%edi
call   1030 <fminf@plt>
movss  %xmm0,(%rsp)
movss  0xc(%rsp),%xmm0
mulss  0xe35(%rip),%xmm0
call   1050 <rint@plt>
mov    %eax,%r14d
movss  0x8(%rsp),%xmm0
mulss  0xe1f(%rip),%xmm0
call   1050 <rint@plt>
mov    %eax,%ebp
movss  0x4(%rsp),%xmm0
mulss  0xe0a(%rip),%xmm0
call   1050 <rint@plt>
mov    %eax,%ebx
movss  (%rsp),%xmm0
mulss  0xdf6(%rip),%xmm0
call   1050 <rint@plt>
shl    $0x18,%r14d
shl    $0x10,%ebp
or     %r14d,%ebp
shl    $0x8,%ebx
or     %ebx,%eax
or     %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rgba_to_hex(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store float* %0, float** %2
%11 = load float*, float** %2
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
%14 = call i32 @fmaxf(float 0.000000e+00, float %13)
%15 = call float @fminf(float 1.000000e+00, i32 %14)
store float %15, float* %3
%16 = load float*, float** %2
%17 = getelementptr inbounds float, float* %16, i64 1
%18 = load float, float* %17
%19 = call i32 @fmaxf(float 0.000000e+00, float %18)
%20 = call float @fminf(float 1.000000e+00, i32 %19)
store float %20, float* %4
%21 = load float*, float** %2
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
%24 = call i32 @fmaxf(float 0.000000e+00, float %23)
%25 = call float @fminf(float 1.000000e+00, i32 %24)
store float %25, float* %5
%26 = load float*, float** %2
%27 = getelementptr inbounds float, float* %26, i64 3
%28 = load float, float* %27
%29 = call i32 @fmaxf(float 0.000000e+00, float %28)
%30 = call float @fminf(float 1.000000e+00, i32 %29)
store float %30, float* %6
%31 = load float, float* %3
%32 = fpext float %31 to double
%33 = fmul double %32, 2.550000e+02
%34 = fptrunc double %33 to float
%35 = call i32 @rint(float %34)
store i32 %35, i32* %7
%36 = load float, float* %4
%37 = fpext float %36 to double
%38 = fmul double %37, 2.550000e+02
%39 = fptrunc double %38 to float
%40 = call i32 @rint(float %39)
store i32 %40, i32* %8
%41 = load float, float* %5
%42 = fpext float %41 to double
%43 = fmul double %42, 2.550000e+02
%44 = fptrunc double %43 to float
%45 = call i32 @rint(float %44)
store i32 %45, i32* %9
%46 = load float, float* %6
%47 = fpext float %46 to double
%48 = fmul double %47, 2.550000e+02
%49 = fptrunc double %48 to float
%50 = call i32 @rint(float %49)
store i32 %50, i32* %10
%51 = load i32, i32* %7
%52 = shl i32 %51, 24
%53 = load i32, i32* %8
%54 = shl i32 %53, 16
%55 = or i32 %52, %54
%56 = load i32, i32* %9
%57 = shl i32 %56, 8
%58 = or i32 %55, %57
%59 = load i32, i32* %10
%60 = or i32 %58, %59
ret i32 %60
}

LLVM IR (-O2):
define i32 @rgba_to_hex(float* nocapture %0) {
%2 = load float, float* %0
%3 = tail call i32 @fmaxf(float 0.000000e+00, float %2)
%4 = tail call float @fminf(float 1.000000e+00, i32 %3)
%5 = getelementptr inbounds float, float* %0, i64 1
%6 = load float, float* %5
%7 = tail call i32 @fmaxf(float 0.000000e+00, float %6)
%8 = tail call float @fminf(float 1.000000e+00, i32 %7)
%9 = getelementptr inbounds float, float* %0, i64 2
%10 = load float, float* %9
%11 = tail call i32 @fmaxf(float 0.000000e+00, float %10)
%12 = tail call float @fminf(float 1.000000e+00, i32 %11)
%13 = getelementptr inbounds float, float* %0, i64 3
%14 = load float, float* %13
%15 = tail call i32 @fmaxf(float 0.000000e+00, float %14)
%16 = tail call float @fminf(float 1.000000e+00, i32 %15)
%17 = fmul float %4, 2.550000e+02
%18 = tail call i32 @rint(float %17)
%19 = fmul float %8, 2.550000e+02
%20 = tail call i32 @rint(float %19)
%21 = fmul float %12, 2.550000e+02
%22 = tail call i32 @rint(float %21)
%23 = fmul float %16, 2.550000e+02
%24 = tail call i32 @rint(float %23)
%25 = shl i32 %18, 24
%26 = shl i32 %20, 16
%27 = or i32 %26, %25
%28 = shl i32 %22, 8
%29 = or i32 %27, %28
%30 = or i32 %29, %24
ret i32 %30
}