#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 */
struct rgb {
  int dummy;
};

/* Variables and functions */
float fmaxf(int /*<<< orphan*/, int /*<<< orphan*/);
float fminf(float, float);
int /*<<< orphan*/ h2rgb(float, float, double);
int /*<<< orphan*/ rgb_create(float, float, float, struct rgb *);
void rgb_from_hsl2(double h, double s, double l, struct rgb *to) {
  h /= 360.0;
  s /= 100.0;
  l /= 100.0;
  float q = 0;
  if (l < 0.5)
    q = l * (1 + s);
  else
    q = (l + s) - (s * l);
  float p = 2 * l - q;
  float r = fmaxf(0, h2rgb(p, q, h + (1.0f / 3.0f)));
  float g = fmaxf(0, h2rgb(p, q, h));
  float b = fmaxf(0, h2rgb(p, q, h - (1.0f / 3.0f)));
  r = fminf(r, 1.0f);
  g = fminf(g, 1.0f);
  b = fminf(b, 1.0f);
  rgb_create(r, g, b, to);
}


x86 assembly (clang, -O0):
<rgb_from_hsl2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movsd  0xe63(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11cc <rgb_from_hsl2+0x9c>
movsd  -0x18(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1208 <rgb_from_hsl2+0xd8>
movsd  -0x18(%rbp),%xmm1
addsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movsd  -0x18(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
movsd  0xdd0(%rip),%xmm2
addsd  -0x8(%rbp),%xmm2
call   1030 <h2rgb@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1040 <fmaxf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
call   1030 <h2rgb@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1040 <fmaxf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  0xd7f(%rip),%xmm3
subsd  %xmm3,%xmm2
call   1030 <h2rgb@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1040 <fmaxf@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  0xd63(%rip),%xmm1
minss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x30(%rbp),%xmm0
movss  0xd4d(%rip),%xmm1
minss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x34(%rbp),%xmm0
movss  0xd37(%rip),%xmm1
minss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x34(%rbp),%xmm2
mov    -0x20(%rbp),%rdi
call   1050 <rgb_create@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgb_from_hsl2>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movapd %xmm0,%xmm3
divsd  0xebc(%rip),%xmm3
movsd  0xebc(%rip),%xmm0
divsd  %xmm0,%xmm1
divsd  %xmm0,%xmm2
movsd  0xeb4(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    1170 <rgb_from_hsl2+0x40>
addsd  0xeae(%rip),%xmm1
mulsd  %xmm2,%xmm1
jmp    1184 <rgb_from_hsl2+0x54>
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movss  %xmm1,0xc(%rsp)
addsd  %xmm2,%xmm2
subsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  %xmm0,0x8(%rsp)
movsd  0xe6e(%rip),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm3,0x18(%rsp)
call   1030 <h2rgb@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <fmaxf@plt>
movss  %xmm0,0x14(%rsp)
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1030 <h2rgb@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <fmaxf@plt>
movss  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm2
addsd  0xe24(%rip),%xmm2
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <h2rgb@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <fmaxf@plt>
movaps %xmm0,%xmm2
movss  0xe07(%rip),%xmm3
movss  0x14(%rsp),%xmm0
minss  %xmm3,%xmm0
movss  0x10(%rsp),%xmm1
minss  %xmm3,%xmm1
minss  %xmm3,%xmm2
mov    %rbx,%rdi
add    $0x20,%rsp
pop    %rbx
jmp    1050 <rgb_create@plt>

LLVM IR (-O0):
%struct.rgb = type { i32 }
define void @rgb_from_hsl2(double %0, double %1, double %2, %struct.rgb* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca %struct.rgb*
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store %struct.rgb* %3, %struct.rgb** %8
%14 = load double, double* %5
%15 = fdiv double %14, 3.600000e+02
store double %15, double* %5
%16 = load double, double* %6
%17 = fdiv double %16, 1.000000e+02
store double %17, double* %6
%18 = load double, double* %7
%19 = fdiv double %18, 1.000000e+02
store double %19, double* %7
store float 0.000000e+00, float* %9
%20 = load double, double* %7
%21 = fcmp olt double %20, 5.000000e-01
br i1 %21, label %22, label %28
22: ; preds = %4
%23 = load double, double* %7
%24 = load double, double* %6
%25 = fadd double 1.000000e+00, %24
%26 = fmul double %23, %25
%27 = fptrunc double %26 to float
store float %27, float* %9
br label %37
28: ; preds = %4
%29 = load double, double* %7
%30 = load double, double* %6
%31 = fadd double %29, %30
%32 = load double, double* %6
%33 = load double, double* %7
%34 = fneg double %32
%35 = call double @llvm.fmuladd.f64(double %34, double %33, double %31)
%36 = fptrunc double %35 to float
store float %36, float* %9
br label %37
37: ; preds = %28, %22
%38 = load double, double* %7
%39 = load float, float* %9
%40 = fpext float %39 to double
%41 = fneg double %40
%42 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %38, double %41)
%43 = fptrunc double %42 to float
store float %43, float* %10
%44 = load float, float* %10
%45 = load float, float* %9
%46 = load double, double* %5
%47 = fadd double %46, 0x3FD5555560000000
%48 = call i32 @h2rgb(float %44, float %45, double %47)
%49 = call float @fmaxf(i32 0, i32 %48)
store float %49, float* %11
%50 = load float, float* %10
%51 = load float, float* %9
%52 = load double, double* %5
%53 = call i32 @h2rgb(float %50, float %51, double %52)
%54 = call float @fmaxf(i32 0, i32 %53)
store float %54, float* %12
%55 = load float, float* %10
%56 = load float, float* %9
%57 = load double, double* %5
%58 = fsub double %57, 0x3FD5555560000000
%59 = call i32 @h2rgb(float %55, float %56, double %58)
%60 = call float @fmaxf(i32 0, i32 %59)
store float %60, float* %13
%61 = load float, float* %11
%62 = call float @llvm.minnum.f32(float %61, float 1.000000e+00)
store float %62, float* %11
%63 = load float, float* %12
%64 = call float @llvm.minnum.f32(float %63, float 1.000000e+00)
store float %64, float* %12
%65 = load float, float* %13
%66 = call float @llvm.minnum.f32(float %65, float 1.000000e+00)
store float %66, float* %13
%67 = load float, float* %11
%68 = load float, float* %12
%69 = load float, float* %13
%70 = load %struct.rgb*, %struct.rgb** %8
%71 = call i32 @rgb_create(float %67, float %68, float %69, %struct.rgb* %70)
ret void
}

LLVM IR (-O2):
%struct.rgb = type { i32 }
define void @rgb_from_hsl2(double %0, double %1, double %2, %struct.rgb* %3) {
%5 = fdiv double %0, 3.600000e+02
%6 = fdiv double %1, 1.000000e+02
%7 = fdiv double %2, 1.000000e+02
%8 = fcmp olt double %7, 5.000000e-01
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = fadd double %6, 1.000000e+00
%11 = fmul double %7, %10
br label %16
12: ; preds = %4
%13 = fadd double %6, %7
%14 = fneg double %6
%15 = tail call double @llvm.fmuladd.f64(double %14, double %7, double %13)
br label %16
16: ; preds = %12, %9
%17 = phi double [ %11, %9 ], [ %15, %12 ]
%18 = fptrunc double %17 to float
%19 = fpext float %18 to double
%20 = fneg double %19
%21 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double %20)
%22 = fptrunc double %21 to float
%23 = fadd double %5, 0x3FD5555560000000
%24 = tail call i32 @h2rgb(float %22, float %18, double %23)
%25 = tail call float @fmaxf(i32 0, i32 %24)
%26 = tail call i32 @h2rgb(float %22, float %18, double %5)
%27 = tail call float @fmaxf(i32 0, i32 %26)
%28 = fadd double %5, 0xBFD5555560000000
%29 = tail call i32 @h2rgb(float %22, float %18, double %28)
%30 = tail call float @fmaxf(i32 0, i32 %29)
%31 = tail call float @llvm.minnum.f32(float %25, float 1.000000e+00)
%32 = tail call float @llvm.minnum.f32(float %27, float 1.000000e+00)
%33 = tail call float @llvm.minnum.f32(float %30, float 1.000000e+00)
%34 = tail call i32 @rgb_create(float %31, float %32, float %33, %struct.rgb* %3)
ret void
}