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

/* Variables and functions */
scalar_t__ roundf(float);
void _set_rgba_from_rgb(uint32_t *rgba, float r, float g, float b) {
  unsigned char rc, gc, bc, ac;
  rc = (unsigned char)roundf(r * 255.0f);
  gc = (unsigned char)roundf(g * 255.0f);
  bc = (unsigned char)roundf(b * 255.0f);
  ac = 255;
  *rgba = (ac << 24) | (bc << 16) | (gc << 8) | rc;
}


x86 assembly (clang, -O0):
<_set_rgba_from_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  0xecd(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
call   1030 <roundf@plt>
mov    %al,-0x15(%rbp)
movss  0xeb8(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
call   1030 <roundf@plt>
mov    %al,-0x16(%rbp)
movss  0xea3(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
call   1030 <roundf@plt>
mov    %al,-0x17(%rbp)
movb   $0xff,-0x18(%rbp)
movzbl -0x18(%rbp),%eax
shl    $0x18,%eax
movzbl -0x17(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x16(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x15(%rbp),%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_set_rgba_from_rgb>:
push   %r14
push   %rbx
push   %rax
movss  %xmm2,0x4(%rsp)
movss  %xmm1,(%rsp)
mov    %rdi,%r14
mulss  0xed6(%rip),%xmm0
call   1030 <roundf@plt>
mov    %rax,%rbx
movss  (%rsp),%xmm0
mulss  0xec1(%rip),%xmm0
call   1030 <roundf@plt>
movss  0x4(%rsp),%xmm0
mulss  0xeae(%rip),%xmm0
call   1030 <roundf@plt>
mov    %bl,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @_set_rgba_from_rgb(i8* %0, float %1, float %2, float %3) {
%5 = alloca i8*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
store i8* %0, i8** %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%13 = load float, float* %6
%14 = fmul float %13, 2.550000e+02
%15 = call i64 @roundf(float %14)
%16 = trunc i64 %15 to i8
store i8 %16, i8* %9
%17 = load float, float* %7
%18 = fmul float %17, 2.550000e+02
%19 = call i64 @roundf(float %18)
%20 = trunc i64 %19 to i8
store i8 %20, i8* %10
%21 = load float, float* %8
%22 = fmul float %21, 2.550000e+02
%23 = call i64 @roundf(float %22)
%24 = trunc i64 %23 to i8
store i8 %24, i8* %11
store i8 -1, i8* %12
%25 = load i8, i8* %12
%26 = zext i8 %25 to i32
%27 = shl i32 %26, 24
%28 = load i8, i8* %11
%29 = zext i8 %28 to i32
%30 = shl i32 %29, 16
%31 = or i32 %27, %30
%32 = load i8, i8* %10
%33 = zext i8 %32 to i32
%34 = shl i32 %33, 8
%35 = or i32 %31, %34
%36 = load i8, i8* %9
%37 = zext i8 %36 to i32
%38 = or i32 %35, %37
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %5
store i8 %39, i8* %40
ret void
}

LLVM IR (-O2):
define void @_set_rgba_from_rgb(i8* nocapture writeonly %0, float %1, float %2, float %3) {
%5 = fmul float %1, 2.550000e+02
%6 = tail call i64 @roundf(float %5)
%7 = trunc i64 %6 to i8
%8 = fmul float %2, 2.550000e+02
%9 = tail call i64 @roundf(float %8)
%10 = fmul float %3, 2.550000e+02
%11 = tail call i64 @roundf(float %10)
store i8 %7, i8* %0
ret void
}