// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl $0x0, 0x14(%rsp)
movl (%rdi), %ebp
andl $0x2, %ebp
orl $0x4, %ebp
movl %ebp, (%rdi)
testq %rsi, %rsi
je 0x574b9
movq %rcx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movl 0x104(%rsi), %eax
movsd (%r8), %xmm4
movsd 0x8(%r8), %xmm6
movss 0x10c(%rsi), %xmm5
ucomiss %xmm4, %xmm5
movb $0x1, %cl
jb 0x57229
movaps %xmm4, %xmm3
addss %xmm6, %xmm3
ucomiss %xmm5, %xmm3
jbe 0x57229
movss 0x110(%r14), %xmm5
movaps %xmm4, %xmm3
addps %xmm6, %xmm3
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
cmpnleps %xmm5, %xmm4
cmpnltps %xmm3, %xmm5
orps %xmm4, %xmm5
movd %xmm5, %esi
cmpl $0x1, %eax
setne %cl
orb %sil, %cl
movl 0x78(%rsp), %r12d
movl 0x108(%r14), %esi
movsd (%r15), %xmm9
movsd 0x8(%r15), %xmm3
movaps %xmm9, %xmm7
shufps $0x55, %xmm9, %xmm7     # xmm7 = xmm7[1,1],xmm9[1,1]
movaps %xmm3, %xmm8
shufps $0x55, %xmm3, %xmm8     # xmm8 = xmm8[1,1],xmm3[1,1]
movss 0x144(%r14), %xmm4
ucomiss %xmm9, %xmm4
jb 0x57296
movaps %xmm9, %xmm5
addss %xmm3, %xmm5
ucomiss %xmm4, %xmm5
jbe 0x57296
movss 0x148(%r14), %xmm4
ucomiss %xmm7, %xmm4
jb 0x57296
addps %xmm3, %xmm9
shufps $0x55, %xmm9, %xmm9     # xmm9 = xmm9[1,1,1,1]
ucomiss %xmm4, %xmm9
jbe 0x57296
movl $0x12, (%rbx)
movl $0x12, %ebp
xorl %edi, %edi
testl %r12d, %r12d
sete %dil
movss 0x15c(%r14,%rdi,4), %xmm3
testl %eax, %eax
sete %al
orb %cl, %al
testb $0x1, %al
jne 0x57324
testl %esi, %esi
jne 0x57324
movl $0x22, (%rbx)
testl %r12d, %r12d
je 0x57417
movss 0x154(%r14), %xmm3
movss 0x8(%r15), %xmm4
divss %xmm4, %xmm3
mulss %xmm1, %xmm3
addss %xmm0, %xmm3
movaps %xmm1, %xmm2
subss %xmm4, %xmm2
minss %xmm2, %xmm3
xorps %xmm0, %xmm0
maxss %xmm3, %xmm0
movaps %xmm0, %xmm2
divss %xmm1, %xmm2
mulss %xmm4, %xmm2
addss (%r15), %xmm2
movss 0x8(%r8), %xmm1
mulss 0x1658e(%rip), %xmm1    # 0x6d8a0
addss %xmm2, %xmm1
movss %xmm1, 0x10c(%r14)
jmp 0x57469
cmpl $0x0, 0xe8(%r14)
movl 0xec(%r14), %eax
je 0x5734c
testl %eax, %eax
je 0x57351
testl %r12d, %r12d
sete %al
testl %edx, %edx
setne %r13b
testb %al, %r13b
je 0x57357
jmp 0x573b0
cmpl $0x1, %eax
ja 0x57339
testl %edx, %edx
setne %r13b
movss %xmm3, 0x1c(%rsp)
movss %xmm2, 0x18(%rsp)
movaps %xmm8, 0x20(%rsp)
movss %xmm1, 0x10(%rsp)
movss %xmm0, 0xc(%rsp)
movsd (%r9), %xmm0
movsd 0x8(%r9), %xmm1
leaq 0x14(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5160c
testl %eax, %eax
je 0x574c8
testl %r12d, %r12d
movss 0xc(%rsp), %xmm0
movaps 0x20(%rsp), %xmm8
je 0x573b0
subss 0x8(%r15), %xmm0
jmp 0x573b5
subss %xmm8, %xmm0
xorps %xmm1, %xmm1
maxss %xmm1, %xmm0
movsd (%r15), %xmm6
movsd 0x8(%r15), %xmm1
testb $0x10, %bpl
je 0x57479
movss 0x14c(%r14), %xmm2
ucomiss %xmm6, %xmm2
jb 0x5740f
movaps %xmm6, %xmm3
addss %xmm1, %xmm3
ucomiss %xmm2, %xmm3
jbe 0x5740f
movaps %xmm6, %xmm5
shufps $0x55, %xmm6, %xmm5     # xmm5 = xmm5[1,1],xmm6[1,1]
movss 0x150(%r14), %xmm4
ucomiss %xmm5, %xmm4
jb 0x5740f
movaps %xmm6, %xmm5
addps %xmm1, %xmm5
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
ucomiss %xmm4, %xmm5
ja 0x57489
orl $0x8, %ebp
jmp 0x574b7
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
movss 0x158(%r14), %xmm2
divss %xmm8, %xmm2
mulss %xmm1, %xmm2
addss %xmm0, %xmm2
movaps %xmm1, %xmm3
subss %xmm8, %xmm3
minss %xmm3, %xmm2
xorps %xmm0, %xmm0
maxss %xmm2, %xmm0
movaps %xmm0, %xmm2
divss %xmm1, %xmm2
mulss %xmm8, %xmm2
addss %xmm7, %xmm2
mulss 0x16444(%rip), %xmm6    # 0x6d8a0
addss %xmm2, %xmm6
movss %xmm6, 0x110(%r14)
movsd (%r15), %xmm6
movsd 0x8(%r15), %xmm1
movl $0x22, %ebp
movss 0x14c(%r14), %xmm2
movaps %xmm6, %xmm3
addss %xmm1, %xmm3
ucomiss %xmm6, %xmm2
jb 0x574b9
ucomiss %xmm2, %xmm3
jbe 0x574b9
movaps %xmm6, %xmm3
shufps $0x55, %xmm6, %xmm3     # xmm3 = xmm3[1,1],xmm6[1,1]
movss 0x150(%r14), %xmm2
ucomiss %xmm3, %xmm2
jb 0x574b9
addps %xmm1, %xmm6
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
ucomiss %xmm2, %xmm6
jbe 0x574b9
orl $0x40, %ebp
movl %ebp, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0xe0(%r14)
movl 0xe4(%r14), %eax
je 0x574e6
testl %r12d, %r12d
sete %cl
testl %eax, %eax
setne %al
jmp 0x574f2
testl %r12d, %r12d
sete %cl
cmpl $0x2, %eax
setae %al
andb %r13b, %al
testb %cl, %al
je 0x5751b
movss 0xc(%rsp), %xmm0
movaps 0x20(%rsp), %xmm2
addss %xmm2, %xmm0
movss 0x10(%rsp), %xmm1
subss %xmm2, %xmm1
minss %xmm1, %xmm0
jmp 0x573bc
movq 0x70(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
leaq 0x14(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5160c
testl %eax, %eax
je 0x57564
testl %r12d, %r12d
je 0x574f9
movss 0x8(%r15), %xmm1
movss 0xc(%rsp), %xmm0
addss %xmm1, %xmm0
movss 0x10(%rsp), %xmm2
subss %xmm1, %xmm2
minss %xmm2, %xmm0
jmp 0x573bc
testb %r13b, %r13b
je 0x575a3
xorps %xmm0, %xmm0
movss 0x1c(%rsp), %xmm2
ucomiss %xmm0, %xmm2
movss 0xc(%rsp), %xmm0
je 0x575ae
movss 0x18(%rsp), %xmm1
mulss %xmm2, %xmm1
subss %xmm1, %xmm0
testl %r12d, %r12d
movss 0x10(%rsp), %xmm2
movaps 0x20(%rsp), %xmm1
je 0x575df
subss 0x8(%r15), %xmm2
jmp 0x575e3
movss 0xc(%rsp), %xmm0
jmp 0x573bc
cmpl $0x0, 0xd0(%r14)
movl 0xd4(%r14), %eax
movss 0x10(%rsp), %xmm1
movaps 0x20(%rsp), %xmm2
je 0x575f8
testl %eax, %eax
je 0x575fd
testl %r12d, %r12d
jne 0x573bc
xorps %xmm0, %xmm0
jmp 0x573bc
subss %xmm1, %xmm2
movaps %xmm0, %xmm1
minss %xmm2, %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
ja 0x573bc
jmp 0x5763b
cmpl $0x2, %eax
jae 0x575ce
cmpl $0x0, 0xd8(%r14)
movl 0xdc(%r14), %eax
je 0x57623
testl %r12d, %r12d
sete %cl
testl %eax, %eax
setne %al
testb %al, %cl
je 0x573bc
jmp 0x57637
testl %r12d, %r12d
setne %cl
cmpl $0x2, %eax
setb %al
orb %cl, %al
jne 0x573bc
subss %xmm2, %xmm1
movaps %xmm1, %xmm0
jmp 0x573bc