#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 */
int /*<<< orphan*/ _hsv2rgb(float *, float *);
scalar_t__ roundf(float);
void _set_rgba_from_hsv(uint32_t *rgba, float h, float s, float v) {
  float hsv[3], rgb[3];
  unsigned char r, g, b, a;
  hsv[0] = h;
  hsv[1] = s;
  hsv[2] = v;
  _hsv2rgb(rgb, hsv);
  r = (unsigned char)roundf(rgb[0] * 255.0f);
  g = (unsigned char)roundf(rgb[1] * 255.0f);
  b = (unsigned char)roundf(rgb[2] * 255.0f);
  a = 255;
  *rgba = (a << 24) | (b << 16) | (g << 8) | r;
}


x86 assembly (clang, -O0):
<_set_rgba_from_hsv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    -0x2c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <_hsv2rgb@plt>
movss  0xe92(%rip),%xmm0
mulss  -0x2c(%rbp),%xmm0
call   1040 <roundf@plt>
mov    %al,-0x2d(%rbp)
movss  0xe7d(%rip),%xmm0
mulss  -0x28(%rbp),%xmm0
call   1040 <roundf@plt>
mov    %al,-0x2e(%rbp)
movss  0xe68(%rip),%xmm0
mulss  -0x24(%rbp),%xmm0
call   1040 <roundf@plt>
mov    %al,-0x2f(%rbp)
movb   $0xff,-0x30(%rbp)
movzbl -0x30(%rbp),%eax
shl    $0x18,%eax
movzbl -0x2f(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x2e(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x2d(%rbp),%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_set_rgba_from_hsv>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movss  %xmm0,0xc(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm2,0x14(%rsp)
mov    %rsp,%rdi
lea    0xc(%rsp),%rsi
call   1030 <_hsv2rgb@plt>
movss  (%rsp),%xmm0
mulss  0xeaa(%rip),%xmm0
call   1040 <roundf@plt>
mov    %rax,%rbx
movss  0x4(%rsp),%xmm0
mulss  0xe94(%rip),%xmm0
call   1040 <roundf@plt>
movss  0xe87(%rip),%xmm0
mulss  0x8(%rsp),%xmm0
call   1040 <roundf@plt>
mov    %bl,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @_set_rgba_from_hsv(i8* %0, float %1, float %2, float %3) {
%5 = alloca i8*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
store i8* %0, i8** %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%15 = load float, float* %6
%16 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
store float %15, float* %16
%17 = load float, float* %7
%18 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
store float %17, float* %18
%19 = load float, float* %8
%20 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
store float %19, float* %20
%21 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%22 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%23 = call i32 @_hsv2rgb(float* %21, float* %22)
%24 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%25 = load float, float* %24
%26 = fmul float %25, 2.550000e+02
%27 = call i64 @roundf(float %26)
%28 = trunc i64 %27 to i8
store i8 %28, i8* %11
%29 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 1
%30 = load float, float* %29
%31 = fmul float %30, 2.550000e+02
%32 = call i64 @roundf(float %31)
%33 = trunc i64 %32 to i8
store i8 %33, i8* %12
%34 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 2
%35 = load float, float* %34
%36 = fmul float %35, 2.550000e+02
%37 = call i64 @roundf(float %36)
%38 = trunc i64 %37 to i8
store i8 %38, i8* %13
store i8 -1, i8* %14
%39 = load i8, i8* %14
%40 = zext i8 %39 to i32
%41 = shl i32 %40, 24
%42 = load i8, i8* %13
%43 = zext i8 %42 to i32
%44 = shl i32 %43, 16
%45 = or i32 %41, %44
%46 = load i8, i8* %12
%47 = zext i8 %46 to i32
%48 = shl i32 %47, 8
%49 = or i32 %45, %48
%50 = load i8, i8* %11
%51 = zext i8 %50 to i32
%52 = or i32 %49, %51
%53 = trunc i32 %52 to i8
%54 = load i8*, i8** %5
store i8 %53, i8* %54
ret void
}

LLVM IR (-O2):
define void @_set_rgba_from_hsv(i8* nocapture writeonly %0, float %1, float %2, float %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = bitcast [3 x float]* %5 to i8*
%8 = bitcast [3 x float]* %6 to i8*
%9 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %1, float* %9
%10 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %2, float* %10
%11 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %3, float* %11
%12 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%13 = call i32 @_hsv2rgb(float* %12, float* %9)
%14 = load float, float* %12
%15 = fmul float %14, 2.550000e+02
%16 = call i64 @roundf(float %15)
%17 = trunc i64 %16 to i8
%18 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%19 = load float, float* %18
%20 = fmul float %19, 2.550000e+02
%21 = call i64 @roundf(float %20)
%22 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%23 = load float, float* %22
%24 = fmul float %23, 2.550000e+02
%25 = call i64 @roundf(float %24)
store i8 %17, i8* %0
ret void
}