#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 */

/* Variables and functions */
double getHue(double, double, double, double, double);
double getLightness(double, double);
double getSaturation(double, double);
double max(double, double);
double min(double, double);
void getHSL(double hsl[3], int R, int G, int B) {
  double r = R / 255.0;
  double g = G / 255.0;
  double b = B / 255.0;
  double cMax = max(max(r, g), b);
  double cMin = min(min(r, g), b);
  double delta = cMax - cMin;
  double lightness = getLightness(cMax, cMin);
  hsl[0] = getHue(r, g, b, cMax, delta);
  hsl[1] = getSaturation(delta, lightness);
  hsl[2] = lightness;
}


x86 assembly (clang, -O0):
<getHSL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe78(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1060 <max@plt>
movsd  -0x30(%rbp),%xmm1
call   1060 <max@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <min@plt>
movsd  -0x30(%rbp),%xmm1
call   1040 <min@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <getLightness@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm4
call   1030 <getHue@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
call   1070 <getSaturation@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getHSL>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
cvtsi2sd %esi,%xmm0
movsd  0xe9c(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  %xmm0,0x28(%rsp)
cvtsi2sd %edx,%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rsp)
cvtsi2sd %ecx,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,(%rsp)
call   1060 <max@plt>
movsd  (%rsp),%xmm1
call   1060 <max@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <min@plt>
movsd  (%rsp),%xmm1
call   1040 <min@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
call   1050 <getLightness@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm4
call   1030 <getHue@plt>
movsd  %xmm0,(%rbx)
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1070 <getSaturation@plt>
movsd  %xmm0,0x8(%rbx)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @getHSL(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to double
%18 = fdiv double %17, 2.550000e+02
store double %18, double* %9
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to double
%21 = fdiv double %20, 2.550000e+02
store double %21, double* %10
%22 = load i32, i32* %8
%23 = sitofp i32 %22 to double
%24 = fdiv double %23, 2.550000e+02
store double %24, double* %11
%25 = load double, double* %9
%26 = load double, double* %10
%27 = call double @max(double %25, double %26)
%28 = load double, double* %11
%29 = call double @max(double %27, double %28)
store double %29, double* %12
%30 = load double, double* %9
%31 = load double, double* %10
%32 = call double @min(double %30, double %31)
%33 = load double, double* %11
%34 = call double @min(double %32, double %33)
store double %34, double* %13
%35 = load double, double* %12
%36 = load double, double* %13
%37 = fsub double %35, %36
store double %37, double* %14
%38 = load double, double* %12
%39 = load double, double* %13
%40 = call double @getLightness(double %38, double %39)
store double %40, double* %15
%41 = load double, double* %9
%42 = load double, double* %10
%43 = load double, double* %11
%44 = load double, double* %12
%45 = load double, double* %14
%46 = call double @getHue(double %41, double %42, double %43, double %44, double %45)
%47 = load double*, double** %5
%48 = getelementptr inbounds double, double* %47, i64 0
store double %46, double* %48
%49 = load double, double* %14
%50 = load double, double* %15
%51 = call double @getSaturation(double %49, double %50)
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 1
store double %51, double* %53
%54 = load double, double* %15
%55 = load double*, double** %5
%56 = getelementptr inbounds double, double* %55, i64 2
store double %54, double* %56
ret void
}

LLVM IR (-O2):
define void @getHSL(double* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = sitofp i32 %1 to double
%6 = fdiv double %5, 2.550000e+02
%7 = sitofp i32 %2 to double
%8 = fdiv double %7, 2.550000e+02
%9 = sitofp i32 %3 to double
%10 = fdiv double %9, 2.550000e+02
%11 = tail call double @max(double %6, double %8)
%12 = tail call double @max(double %11, double %10)
%13 = tail call double @min(double %6, double %8)
%14 = tail call double @min(double %13, double %10)
%15 = fsub double %12, %14
%16 = tail call double @getLightness(double %12, double %14)
%17 = tail call double @getHue(double %6, double %8, double %10, double %12, double %15)
store double %17, double* %0
%18 = tail call double @getSaturation(double %15, double %16)
%19 = getelementptr inbounds double, double* %0, i64 1
store double %18, double* %19
%20 = getelementptr inbounds double, double* %0, i64 2
store double %16, double* %20
ret void
}