// File: /workspace/github_c_makefile_star2_O0/arkanis[P]process-map/./deps/raygui.h
// Function: ConvertRGBtoHSV
static Vector3 ConvertRGBtoHSV(Vector3 rgb)
{
    Vector3 hsv = { 0 };
    float min = 0.0f;
    float max = 0.0f;
    float delta = 0.0f;

    min = (rgb.x < rgb.y)? rgb.x : rgb.y;
    min = (min < rgb.z)? min  : rgb.z;

    max = (rgb.x > rgb.y)? rgb.x : rgb.y;
    max = (max > rgb.z)? max  : rgb.z;

    hsv.z = max;            // Value
    delta = max - min;

    if (delta < 0.00001f)
    {
        hsv.y = 0.0f;
        hsv.x = 0.0f;       // Undefined, maybe NAN?
        return hsv;
    }

    if (max > 0.0f)
    {
        // NOTE: If max is 0, this divide would cause a crash
        hsv.y = (delta/max);    // Saturation
    }
    else
    {
        // NOTE: If max is 0, then r = g = b = 0, s = 0, h is undefined
        hsv.y = 0.0f;
        hsv.x = 0.0f;        // Undefined, maybe NAN?
        return hsv;
    }

    // NOTE: Comparing float values could not work properly
    if (rgb.x >= max) hsv.x = (rgb.y - rgb.z)/delta;    // Between yellow & magenta
    else
    {
        if (rgb.y >= max) hsv.x = 2.0f + (rgb.z - rgb.x)/delta;  // Between cyan & yellow
        else hsv.x = 4.0f + (rgb.x - rgb.y)/delta;      // Between magenta & cyan
    }

    hsv.x *= 60.0f;     // Convert to degrees

    if (hsv.x < 0.0f) hsv.x += 360.0f;

    return hsv;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movlpd %xmm0, -0x28(%rbp)
movss %xmm1, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0xc(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x6060
xorps %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x18(%rbp), %xmm1
movss -0x14(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xffb3
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
jmp 0xffbd
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x4c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x2c(%rbp), %xmm1
movss -0x10(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xffe2
movss -0x2c(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
jmp 0xffec
movss -0x10(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x18(%rbp), %xmm0
ucomiss -0x14(%rbp), %xmm0
jbe 0x1000d
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
jmp 0x10017
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm0
ucomiss -0x10(%rbp), %xmm0
jbe 0x10038
movss -0x30(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
jmp 0x10042
movss -0x10(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
movss -0x30(%rbp), %xmm0
subss -0x2c(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss 0x7bfcf(%rip), %xmm0    # 0x8c03c
ucomiss -0x34(%rbp), %xmm0
jbe 0x10088
xorps %xmm0, %xmm0
movss %xmm0, -0x8(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x1015a
movss -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x100a6
movss -0x34(%rbp), %xmm0
divss -0x30(%rbp), %xmm0
movss %xmm0, -0x8(%rbp)
jmp 0x100bb
xorps %xmm0, %xmm0
movss %xmm0, -0x8(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x1015a
movss -0x18(%rbp), %xmm0
ucomiss -0x30(%rbp), %xmm0
jb 0x100dc
movss -0x14(%rbp), %xmm0
subss -0x10(%rbp), %xmm0
divss -0x34(%rbp), %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x1012b
movss -0x14(%rbp), %xmm0
ucomiss -0x30(%rbp), %xmm0
jb 0x10109
movss -0x10(%rbp), %xmm1
subss -0x18(%rbp), %xmm1
divss -0x34(%rbp), %xmm1
movss 0x7bf0a(%rip), %xmm0    # 0x8c008
addss %xmm1, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x10129
movss -0x18(%rbp), %xmm1
subss -0x14(%rbp), %xmm1
divss -0x34(%rbp), %xmm1
movss 0x7bf04(%rip), %xmm0    # 0x8c024
addss %xmm1, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x1012b
movss 0x7bf0d(%rip), %xmm0    # 0x8c040
mulss -0xc(%rbp), %xmm0
movss %xmm0, -0xc(%rbp)
xorps %xmm0, %xmm0
ucomiss -0xc(%rbp), %xmm0
jbe 0x10158
movss 0x7bef6(%rip), %xmm0    # 0x8c044
addss -0xc(%rbp), %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x1015a
movl -0x4(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0xc(%rbp), %rax
movq %rax, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movss -0x40(%rbp), %xmm1
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)