// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xb8, %rsp
movl 0xc8(%rsp), %eax
movq 0xc0(%rsp), %rax
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movl %edx, 0x9c(%rsp)
movq %rcx, 0x90(%rsp)
movq %r8, 0x88(%rsp)
movq %r9, 0x80(%rsp)
movss %xmm0, 0x7c(%rsp)
movss %xmm1, 0x78(%rsp)
movss %xmm2, 0x74(%rsp)
movl $0x0, 0x70(%rsp)
movq 0xa8(%rsp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x871f1
movq 0xa8(%rsp), %rax
movl $0x6, (%rax)
jmp 0x871ff
movq 0xa8(%rsp), %rax
movl $0x4, (%rax)
cmpq $0x0, 0xa0(%rsp)
jne 0x8721e
movss 0x7c(%rsp), %xmm0
movss %xmm0, 0xb4(%rsp)
jmp 0x87b27
movq 0xa0(%rsp), %rax
movl 0x104(%rax), %eax
movl %eax, 0x6c(%rsp)
movq 0xa0(%rsp), %rax
movl 0x108(%rax), %eax
movl %eax, 0x68(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x88(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
xorl %esi, %esi
movl $0x1, %edx
callq 0x13780
movl %eax, 0x64(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x90(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
callq 0x15440
cmpl $0x0, %eax
je 0x8729c
movq 0xa8(%rsp), %rax
movl $0x12, (%rax)
cmpl $0x0, 0xc8(%rsp)
jne 0x872be
movq 0xa0(%rsp), %rax
movss 0x160(%rax), %xmm0
movss %xmm0, 0x4c(%rsp)
jmp 0x872d4
movq 0xa0(%rsp), %rax
movss 0x15c(%rax), %xmm0
movss %xmm0, 0x4c(%rsp)
movss 0x4c(%rsp), %xmm0
movss %xmm0, 0x60(%rsp)
cmpl $0x0, 0x6c(%rsp)
je 0x87604
cmpl $0x0, 0x64(%rsp)
je 0x87604
cmpl $0x0, 0x68(%rsp)
jne 0x87604
movq 0xa8(%rsp), %rax
movl $0x22, (%rax)
cmpl $0x0, 0xc8(%rsp)
jne 0x87491
movq 0xa0(%rsp), %rax
movss 0x158(%rax), %xmm0
movss %xmm0, 0x5c(%rsp)
movss 0x5c(%rsp), %xmm0
movq 0x90(%rsp), %rax
divss 0xc(%rax), %xmm0
mulss 0x78(%rsp), %xmm0
movss %xmm0, 0x58(%rsp)
movss 0x7c(%rsp), %xmm1
addss 0x58(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8738a
movss 0x7c(%rsp), %xmm0
addss 0x58(%rsp), %xmm0
movss %xmm0, 0x48(%rsp)
jmp 0x873a3
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x48(%rsp)
movss 0x48(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x873bc
xorps %xmm0, %xmm0
movss %xmm0, 0x44(%rsp)
jmp 0x87419
movss 0x7c(%rsp), %xmm1
addss 0x58(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x873f4
movss 0x7c(%rsp), %xmm0
addss 0x58(%rsp), %xmm0
movss %xmm0, 0x40(%rsp)
jmp 0x8740d
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x40(%rsp)
movss 0x40(%rsp), %xmm0
movss %xmm0, 0x44(%rsp)
movss 0x44(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
movq 0x90(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x7c(%rsp), %xmm0
divss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
movss 0xc(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x54(%rsp)
movss 0x54(%rsp), %xmm0
movq 0x88(%rsp), %rax
movss 0xc(%rax), %xmm1
movss 0x26070(%rip), %xmm2    # 0xad4e4
divss %xmm2, %xmm1
addss %xmm1, %xmm0
movq 0xa0(%rsp), %rax
movss %xmm0, 0x110(%rax)
jmp 0x875ff
movq 0xa0(%rsp), %rax
movss 0x154(%rax), %xmm0
movss %xmm0, 0x5c(%rsp)
movss 0x5c(%rsp), %xmm0
movq 0x90(%rsp), %rax
divss 0x8(%rax), %xmm0
mulss 0x78(%rsp), %xmm0
movss %xmm0, 0x58(%rsp)
movss 0x7c(%rsp), %xmm1
addss 0x58(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x874fe
movss 0x7c(%rsp), %xmm0
addss 0x58(%rsp), %xmm0
movss %xmm0, 0x3c(%rsp)
jmp 0x87517
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x3c(%rsp)
movss 0x3c(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x87530
xorps %xmm0, %xmm0
movss %xmm0, 0x38(%rsp)
jmp 0x8758d
movss 0x7c(%rsp), %xmm1
addss 0x58(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x87568
movss 0x7c(%rsp), %xmm0
addss 0x58(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
jmp 0x87581
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x34(%rsp)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x38(%rsp)
movss 0x38(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
movq 0x90(%rsp), %rax
movss (%rax), %xmm1
movss 0x7c(%rsp), %xmm0
divss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x50(%rsp)
movss 0x50(%rsp), %xmm0
movq 0x88(%rsp), %rax
movss 0x8(%rax), %xmm1
movss 0x25efd(%rip), %xmm2    # 0xad4e4
divss %xmm2, %xmm1
addss %xmm1, %xmm0
movq 0xa0(%rsp), %rax
movss %xmm0, 0x10c(%rax)
jmp 0x87a9e
movq 0xa0(%rsp), %rdi
movl $0x1d, %esi
callq 0x13500
cmpl $0x0, %eax
je 0x8762f
cmpl $0x0, 0xc8(%rsp)
jne 0x8762f
cmpl $0x0, 0x9c(%rsp)
jne 0x8765d
movq 0x80(%rsp), %rax
movq 0xa0(%rsp), %rsi
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
leaq 0x70(%rsp), %rdi
xorl %edx, %edx
callq 0x78060
cmpl $0x0, %eax
je 0x87708
cmpl $0x0, 0xc8(%rsp)
jne 0x876b6
movss 0x7c(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x8769d
movss 0x7c(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x30(%rsp)
jmp 0x876a8
xorps %xmm0, %xmm0
movss %xmm0, 0x30(%rsp)
jmp 0x876a8
movss 0x30(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87703
movss 0x7c(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x876ec
movss 0x7c(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0x876f7
xorps %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0x876f7
movss 0x2c(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87a9c
movq 0xa0(%rsp), %rdi
movl $0x1c, %esi
callq 0x13500
cmpl $0x0, %eax
je 0x87733
cmpl $0x0, 0xc8(%rsp)
jne 0x87733
cmpl $0x0, 0x9c(%rsp)
jne 0x87761
movq 0xc0(%rsp), %rax
movq 0xa0(%rsp), %rsi
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
leaq 0x70(%rsp), %rdi
xorl %edx, %edx
callq 0x78060
cmpl $0x0, %eax
je 0x87848
cmpl $0x0, 0xc8(%rsp)
jne 0x877d8
movss 0x7c(%rsp), %xmm1
movq 0x90(%rsp), %rax
addss 0xc(%rax), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x877b1
movss 0x7c(%rsp), %xmm0
movq 0x90(%rsp), %rax
addss 0xc(%rax), %xmm0
movss %xmm0, 0x28(%rsp)
jmp 0x877ca
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x28(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87843
movss 0x7c(%rsp), %xmm1
movq 0x90(%rsp), %rax
addss 0x8(%rax), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8781e
movss 0x7c(%rsp), %xmm0
movq 0x90(%rsp), %rax
addss 0x8(%rax), %xmm0
movss %xmm0, 0x24(%rsp)
jmp 0x87837
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x24(%rsp)
movss 0x24(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87a9a
cmpl $0x0, 0x9c(%rsp)
je 0x87a98
xorps %xmm0, %xmm0
ucomiss 0x60(%rsp), %xmm0
ja 0x87872
movss 0x60(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x87a2a
movss 0x7c(%rsp), %xmm1
movss 0x74(%rsp), %xmm0
movss 0x60(%rsp), %xmm2
movd %xmm2, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x7c(%rsp)
cmpl $0x0, 0xc8(%rsp)
jne 0x8796d
movss 0x7c(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x878d9
movss 0x7c(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
jmp 0x878f2
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x20(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8790b
xorps %xmm0, %xmm0
movss %xmm0, 0x1c(%rsp)
jmp 0x8795c
movss 0x7c(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x87937
movss 0x7c(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x87950
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x18(%rsp)
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87a28
movss 0x7c(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x87999
movss 0x7c(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x879b2
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
movss 0x14(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x879cb
xorps %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
jmp 0x87a1c
movss 0x7c(%rsp), %xmm1
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x879f7
movss 0x7c(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
jmp 0x87a10
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x10(%rsp), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87a96
movq 0xa0(%rsp), %rdi
movl $0x1a, %esi
callq 0x13500
cmpl $0x0, %eax
je 0x87a56
cmpl $0x0, 0xc8(%rsp)
jne 0x87a54
xorps %xmm0, %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87a94
movq 0xa0(%rsp), %rdi
movl $0x1b, %esi
callq 0x13500
cmpl $0x0, %eax
je 0x87a92
cmpl $0x0, 0xc8(%rsp)
jne 0x87a90
movss 0x78(%rsp), %xmm0
movq 0x90(%rsp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x7c(%rsp)
jmp 0x87a92
jmp 0x87a94
jmp 0x87a96
jmp 0x87a98
jmp 0x87a9a
jmp 0x87a9c
jmp 0x87a9e
movq 0xa8(%rsp), %rax
movl (%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x87ae4
movq 0xa0(%rsp), %rdi
movq 0x90(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
callq 0x14d70
cmpl $0x0, %eax
jne 0x87ae4
movq 0xa8(%rsp), %rax
movl (%rax), %ecx
orl $0x8, %ecx
movl %ecx, (%rax)
jmp 0x87b18
movq 0xa0(%rsp), %rdi
movq 0x90(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
callq 0x14d70
cmpl $0x0, %eax
je 0x87b16
movq 0xa8(%rsp), %rax
movl (%rax), %ecx
orl $0x40, %ecx
movl %ecx, (%rax)
jmp 0x87b18
movss 0x7c(%rsp), %xmm0
movss %xmm0, 0xb4(%rsp)
movss 0xb4(%rsp), %xmm0
addq $0xb8, %rsp
retq
nopl (%rax,%rax)