#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int flags;
  unsigned long pixel;
  int /*<<< orphan*/ blue;
  int /*<<< orphan*/ green;
  int /*<<< orphan*/ red;
};
typedef TYPE_1__ XColor;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
int /*<<< orphan*/ DefaultColormap(int /*<<< orphan*/ *, int);
int DefaultScreen(int /*<<< orphan*/ *);
int DoBlue;
int DoGreen;
int DoRed;
int /*<<< orphan*/ XAllocColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_1__ *);
int /*<<< orphan*/ hsl2rgb(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *, double, double, double);
unsigned long hslcolor(Display *d, double h, double s, double l) {
  int scr = DefaultScreen(d);
  Colormap cmap = DefaultColormap(d, scr);
  XColor c;
  hsl2rgb(&c.red, &c.green, &c.blue, h, s, l);
  c.flags = DoRed | DoGreen | DoBlue;
  XAllocColor(d, cmap, &c);
  return c.pixel;
}


x86 assembly (clang, -O0):
<hslcolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <DefaultScreen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <DefaultColormap@plt>
mov    %eax,-0x28(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x18,%rdi
lea    -0x48(%rbp),%rsi
add    $0x14,%rsi
lea    -0x48(%rbp),%rdx
add    $0x10,%rdx
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1040 <hsl2rgb@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
mov    0x2e1e(%rip),%rcx
or     (%rcx),%eax
mov    0x2e1d(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x48(%rbp),%rdx
call   1030 <XAllocColor@plt>
mov    -0x40(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hslcolor>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rdi,%rbx
call   1060 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <DefaultColormap@plt>
mov    %eax,%ebp
lea    0x30(%rsp),%rdi
lea    0x2c(%rsp),%rsi
lea    0x28(%rsp),%rdx
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <hsl2rgb@plt>
mov    0x2e51(%rip),%rax
mov    0x2e32(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e2f(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x18(%rsp)
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <XAllocColor@plt>
mov    0x20(%rsp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64, i32, i32, i32 }
@DoRed = global i32 0
@DoGreen = global i32 0
@DoBlue = global i32 0
define i64 @hslcolor(i32* %0, double %1, double %2, double %3) {
%5 = alloca i32*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.TYPE_3__
store i32* %0, i32** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%12 = load i32*, i32** %5
%13 = call i32 @DefaultScreen(i32* %12)
store i32 %13, i32* %9
%14 = load i32*, i32** %5
%15 = load i32, i32* %9
%16 = call i32 @DefaultColormap(i32* %14, i32 %15)
store i32 %16, i32* %10
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 4
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 3
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 2
%20 = load double, double* %6
%21 = load double, double* %7
%22 = load double, double* %8
%23 = call i32 @hsl2rgb(i32* %17, i32* %18, i32* %19, double %20, double %21, double %22)
%24 = load i32, i32* @DoRed
%25 = load i32, i32* @DoGreen
%26 = or i32 %24, %25
%27 = load i32, i32* @DoBlue
%28 = or i32 %26, %27
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
store i32 %28, i32* %29
%30 = load i32*, i32** %5
%31 = load i32, i32* %10
%32 = call i32 @XAllocColor(i32* %30, i32 %31, %struct.TYPE_3__* %11)
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 1
%34 = load i64, i64* %33
ret i64 %34
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64, i32, i32, i32 }
@DoRed = global i32 0
@DoGreen = global i32 0
@DoBlue = global i32 0
define i64 @hslcolor(i32* %0, double %1, double %2, double %3) {
%5 = alloca %struct.TYPE_3__
%6 = tail call i32 @DefaultScreen(i32* %0)
%7 = tail call i32 @DefaultColormap(i32* %0, i32 %6)
%8 = bitcast %struct.TYPE_3__* %5 to i8*
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 4
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 3
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 2
%12 = call i32 @hsl2rgb(i32* %9, i32* %10, i32* %11, double %1, double %2, double %3)
%13 = load i32, i32* @DoRed
%14 = load i32, i32* @DoGreen
%15 = or i32 %14, %13
%16 = load i32, i32* @DoBlue
%17 = or i32 %15, %16
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 0
store i32 %17, i32* %18
%19 = call i32 @XAllocColor(i32* %0, i32 %7, %struct.TYPE_3__* %5)
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 1
%21 = load i64, i64* %20
ret i64 %21
}