// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_scrollbar_behavior
NK_LIB float
nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
    int has_scrolling, const struct nk_rect *scroll,
    const struct nk_rect *cursor, const struct nk_rect *empty0,
    const struct nk_rect *empty1, float scroll_offset,
    float target, float scroll_step, enum nk_orientation o)
{
    nk_flags ws = 0;
    int left_mouse_down;
    unsigned int left_mouse_clicked;
    int left_mouse_click_in_cursor;
    float scroll_delta;

    nk_widget_state_reset(state);
    if (!in) return scroll_offset;

    left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
    left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
    left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
        NK_BUTTON_LEFT, *cursor, nk_true);
    if (nk_input_is_mouse_hovering_rect(in, *scroll))
        *state = NK_WIDGET_STATE_HOVERED;

    scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
    if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
        /* update cursor by mouse dragging */
        float pixel, delta;
        *state = NK_WIDGET_STATE_ACTIVE;
        if (o == NK_VERTICAL) {
            float cursor_y;
            pixel = in->mouse.delta.y;
            delta = (pixel / scroll->h) * target;
            scroll_offset = NK_CLAMP(0, scroll_offset + delta, target - scroll->h);
            cursor_y = scroll->y + ((scroll_offset/target) * scroll->h);
            in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.y = cursor_y + cursor->h/2.0f;
        } else {
            float cursor_x;
            pixel = in->mouse.delta.x;
            delta = (pixel / scroll->w) * target;
            scroll_offset = NK_CLAMP(0, scroll_offset + delta, target - scroll->w);
            cursor_x = scroll->x + ((scroll_offset/target) * scroll->w);
            in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.x = cursor_x + cursor->w/2.0f;
        }
    } else if ((nk_input_is_key_pressed(in, NK_KEY_SCROLL_UP) && o == NK_VERTICAL && has_scrolling)||
            nk_button_behavior(&ws, *empty0, in, NK_BUTTON_DEFAULT)) {
        /* scroll page up by click on empty space or shortcut */
        if (o == NK_VERTICAL)
            scroll_offset = NK_MAX(0, scroll_offset - scroll->h);
        else scroll_offset = NK_MAX(0, scroll_offset - scroll->w);
    } else if ((nk_input_is_key_pressed(in, NK_KEY_SCROLL_DOWN) && o == NK_VERTICAL && has_scrolling) ||
        nk_button_behavior(&ws, *empty1, in, NK_BUTTON_DEFAULT)) {
        /* scroll page down by click on empty space or shortcut */
        if (o == NK_VERTICAL)
            scroll_offset = NK_MIN(scroll_offset + scroll->h, target - scroll->h);
        else scroll_offset = NK_MIN(scroll_offset + scroll->w, target - scroll->w);
    } else if (has_scrolling) {
        if ((scroll_delta < 0 || (scroll_delta > 0))) {
            /* update cursor by mouse scrolling */
            scroll_offset = scroll_offset + scroll_step * (-scroll_delta);
            if (o == NK_VERTICAL)
                scroll_offset = NK_CLAMP(0, scroll_offset, target - scroll->h);
            else scroll_offset = NK_CLAMP(0, scroll_offset, target - scroll->w);
        } else if (nk_input_is_key_pressed(in, NK_KEY_SCROLL_START)) {
            /* update cursor to the beginning  */
            if (o == NK_VERTICAL) scroll_offset = 0;
        } else if (nk_input_is_key_pressed(in, NK_KEY_SCROLL_END)) {
            /* update cursor to the end */
            if (o == NK_VERTICAL) scroll_offset = target - scroll->h;
        }
    }
    if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, *scroll))
        *state |= NK_WIDGET_STATE_ENTERED;
    else if (nk_input_is_mouse_prev_hovering_rect(in, *scroll))
        *state |= NK_WIDGET_STATE_LEFT;
    return scroll_offset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movaps %xmm0, %xmm4
movl $0x0, 0x14(%rsp)
movl (%rdi), %eax
andl $0x2, %eax
orl $0x4, %eax
movl %eax, (%rdi)
testq %rsi, %rsi
je 0x580b4
movaps %xmm1, %xmm5
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x104(%rsi), %eax
movsd (%r8), %xmm0
movss 0x10c(%rsi), %xmm6
ucomiss %xmm0, %xmm6
movb $0x1, %cl
jb 0x57e3e
movsd 0x8(%r8), %xmm1
movaps %xmm0, %xmm3
addss %xmm1, %xmm3
ucomiss %xmm6, %xmm3
jbe 0x57e3e
movss 0x110(%r14), %xmm3
addps %xmm0, %xmm1
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cmpnleps %xmm3, %xmm0
cmpnltps %xmm1, %xmm3
orps %xmm0, %xmm3
movd %xmm3, %edx
cmpl $0x1, %eax
setne %cl
orb %dl, %cl
movl 0x58(%rsp), %r12d
movl 0x108(%r14), %edx
movsd (%r15), %xmm0
movss 0x144(%r14), %xmm6
ucomiss %xmm0, %xmm6
jb 0x57e96
movsd 0x8(%r15), %xmm1
movaps %xmm0, %xmm3
addss %xmm1, %xmm3
ucomiss %xmm6, %xmm3
jbe 0x57e96
movaps %xmm0, %xmm3
shufps $0x55, %xmm0, %xmm3     # xmm3 = xmm3[1,1],xmm0[1,1]
movss 0x148(%r14), %xmm6
ucomiss %xmm3, %xmm6
jb 0x57e96
addps %xmm1, %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
ucomiss %xmm6, %xmm0
jbe 0x57e96
movl $0x12, (%rbx)
xorl %esi, %esi
testl %r12d, %r12d
sete %sil
movss 0x15c(%r14,%rsi,4), %xmm3
testl %eax, %eax
sete %al
orb %cl, %al
testb $0x1, %al
jne 0x57f24
testl %edx, %edx
jne 0x57f24
movl $0x22, (%rbx)
testl %r12d, %r12d
je 0x57fa2
movss 0x154(%r14), %xmm0
movss 0x8(%r15), %xmm1
divss %xmm1, %xmm0
mulss %xmm5, %xmm0
addss %xmm4, %xmm0
movaps %xmm5, %xmm2
subss %xmm1, %xmm2
minss %xmm2, %xmm0
xorps %xmm4, %xmm4
maxss %xmm0, %xmm4
movaps %xmm4, %xmm0
divss %xmm5, %xmm0
mulss %xmm1, %xmm0
addss (%r15), %xmm0
movss 0x8(%r8), %xmm1
mulss 0x1699e(%rip), %xmm1    # 0x6e8b0
addss %xmm0, %xmm1
movss %xmm1, 0x10c(%r14)
jmp 0x5800a
cmpl $0x0, 0xe8(%r14)
movl 0xec(%r14), %ecx
movb $0x1, %al
je 0x57f9b
testl %ecx, %ecx
jne 0x57f3d
xorl %eax, %eax
testl %r12d, %r12d
sete %cl
andb %al, %cl
testl %ebp, %ebp
setne %al
testb %cl, %al
jne 0x57f8e
movsd (%r9), %xmm0
movsd 0x8(%r9), %xmm1
leaq 0x14(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movss %xmm4, 0x10(%rsp)
movss %xmm5, 0xc(%rsp)
movss %xmm2, 0x1c(%rsp)
movss %xmm3, 0x18(%rsp)
callq 0x521be
movss 0x10(%rsp), %xmm4
testl %eax, %eax
je 0x580c4
testl %r12d, %r12d
je 0x57ffd
subss 0x8(%r15), %xmm4
jmp 0x58003
cmpl $0x1, %ecx
jbe 0x57f3b
jmp 0x57f3d
movss 0x158(%r14), %xmm0
movss 0xc(%r15), %xmm1
divss %xmm1, %xmm0
mulss %xmm5, %xmm0
addss %xmm4, %xmm0
movaps %xmm5, %xmm2
subss %xmm1, %xmm2
minss %xmm2, %xmm0
xorps %xmm4, %xmm4
maxss %xmm0, %xmm4
movaps %xmm4, %xmm0
divss %xmm5, %xmm0
mulss %xmm1, %xmm0
addss 0x4(%r15), %xmm0
movss 0xc(%r8), %xmm1
mulss 0x168c2(%rip), %xmm1    # 0x6e8b0
addss %xmm0, %xmm1
movss %xmm1, 0x110(%r14)
jmp 0x5800a
subss 0xc(%r15), %xmm4
xorps %xmm0, %xmm0
maxss %xmm0, %xmm4
movl (%rbx), %eax
testb $0x10, %al
jne 0x58061
movsd (%r15), %xmm0
movss 0x14c(%r14), %xmm2
ucomiss %xmm0, %xmm2
jb 0x580b4
movsd 0x8(%r15), %xmm1
movaps %xmm0, %xmm3
addss %xmm1, %xmm3
ucomiss %xmm2, %xmm3
jbe 0x580b4
movaps %xmm0, %xmm3
shufps $0x55, %xmm0, %xmm3     # xmm3 = xmm3[1,1],xmm0[1,1]
movss 0x150(%r14), %xmm2
ucomiss %xmm3, %xmm2
jb 0x580b4
addps %xmm1, %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movl $0x40, %ecx
ucomiss %xmm2, %xmm0
ja 0x580b0
jmp 0x580b4
movsd (%r15), %xmm0
movss 0x14c(%r14), %xmm2
ucomiss %xmm0, %xmm2
movl $0x8, %ecx
jb 0x580b0
movsd 0x8(%r15), %xmm1
movaps %xmm0, %xmm3
addss %xmm1, %xmm3
ucomiss %xmm2, %xmm3
jbe 0x580b0
movaps %xmm0, %xmm3
shufps $0x55, %xmm0, %xmm3     # xmm3 = xmm3[1,1],xmm0[1,1]
movss 0x150(%r14), %xmm2
ucomiss %xmm3, %xmm2
jb 0x580b0
addps %xmm1, %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
ucomiss %xmm2, %xmm0
ja 0x58010
orl %ecx, %eax
movl %eax, (%rbx)
movaps %xmm4, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0xe0(%r14)
movl 0xe4(%r14), %ecx
movb $0x1, %al
je 0x5812e
testl %ecx, %ecx
jne 0x580dd
xorl %eax, %eax
testl %ebp, %ebp
setne %cl
testl %r12d, %r12d
sete %dl
andb %al, %dl
testb %dl, %cl
jne 0x58121
movq 0x50(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
leaq 0x14(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x521be
movss 0x18(%rsp), %xmm3
movss 0x1c(%rsp), %xmm2
movss 0x10(%rsp), %xmm4
testl %eax, %eax
je 0x58152
testl %r12d, %r12d
je 0x58135
movss 0x8(%r15), %xmm0
jmp 0x5813b
cmpl $0x1, %ecx
jbe 0x580db
jmp 0x580dd
movss 0xc(%r15), %xmm0
addss %xmm0, %xmm4
movss 0xc(%rsp), %xmm1
subss %xmm0, %xmm1
minss %xmm1, %xmm4
jmp 0x5800a
testl %ebp, %ebp
je 0x5800a
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm3
movss 0xc(%rsp), %xmm1
je 0x5817d
mulss %xmm3, %xmm2
subss %xmm2, %xmm4
testl %r12d, %r12d
je 0x581a3
subss 0x8(%r15), %xmm1
jmp 0x581a9
cmpl $0x0, 0xd0(%r14)
movl 0xd4(%r14), %eax
je 0x581c4
testl %eax, %eax
je 0x581c9
testl %r12d, %r12d
jne 0x5800a
xorps %xmm4, %xmm4
jmp 0x5800a
subss 0xc(%r15), %xmm1
movaps %xmm4, %xmm0
minss %xmm1, %xmm0
xorps %xmm4, %xmm4
ucomiss %xmm0, %xmm4
ja 0x5800a
movaps %xmm0, %xmm4
jmp 0x5800a
cmpl $0x1, %eax
ja 0x58192
cmpl $0x0, 0xd8(%r14)
movl 0xdc(%r14), %ecx
movb $0x1, %al
je 0x58200
testl %ecx, %ecx
jne 0x581e2
xorl %eax, %eax
testl %r12d, %r12d
setne %cl
xorb $0x1, %al
orb %cl, %al
jne 0x5800a
subss 0xc(%r15), %xmm1
movaps %xmm1, %xmm4
jmp 0x5800a
cmpl $0x1, %ecx
jbe 0x581e0
jmp 0x581e2