// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_layout_widget_space
NK_LIB void
nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
    struct nk_window *win, int modify)
{
    struct nk_panel *layout;
    const struct nk_style *style;

    struct nk_vec2 spacing;

    float item_offset = 0;
    float item_width = 0;
    float item_spacing = 0;
    float panel_space = 0;

    NK_ASSERT(ctx);
    NK_ASSERT(ctx->current);
    NK_ASSERT(ctx->current->layout);
    if (!ctx || !ctx->current || !ctx->current->layout)
        return;

    win = ctx->current;
    layout = win->layout;
    style = &ctx->style;
    NK_ASSERT(bounds);

    spacing = style->window.spacing;
    panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
                                            layout->bounds.w, layout->row.columns);

    #define NK_FRAC(x) (x - (float)(int)x) /* will be used to remove fookin gaps */
    /* calculate the width of one item inside the current layout space */
    switch (layout->row.type) {
    case NK_LAYOUT_DYNAMIC_FIXED: {
        /* scaling fixed size widgets item width */
        float w = NK_MAX(1.0f,panel_space) / (float)layout->row.columns;
        item_offset = (float)layout->row.index * w;
        item_width = w + NK_FRAC(item_offset);
        item_spacing = (float)layout->row.index * spacing.x;
    } break;
    case NK_LAYOUT_DYNAMIC_ROW: {
        /* scaling single ratio widget width */
        float w = layout->row.item_width * panel_space;
        item_offset = layout->row.item_offset;
        item_width = w + NK_FRAC(item_offset);
        item_spacing = 0;

        if (modify) {
            layout->row.item_offset += w + spacing.x;
            layout->row.filled += layout->row.item_width;
            layout->row.index = 0;
        }
    } break;
    case NK_LAYOUT_DYNAMIC_FREE: {
        /* panel width depended free widget placing */
        bounds->x = layout->at_x + (layout->bounds.w * layout->row.item.x);
        bounds->x -= (float)*layout->offset_x;
        bounds->y = layout->at_y + (layout->row.height * layout->row.item.y);
        bounds->y -= (float)*layout->offset_y;
        bounds->w = layout->bounds.w  * layout->row.item.w + NK_FRAC(bounds->x);
        bounds->h = layout->row.height * layout->row.item.h + NK_FRAC(bounds->y);
        return;
    }
    case NK_LAYOUT_DYNAMIC: {
        /* scaling arrays of panel width ratios for every widget */
        float ratio, w;
        NK_ASSERT(layout->row.ratio);
        ratio = (layout->row.ratio[layout->row.index] < 0) ?
            layout->row.item_width : layout->row.ratio[layout->row.index];

        w = (ratio * panel_space);
        item_spacing = (float)layout->row.index * spacing.x;
        item_offset = layout->row.item_offset;
        item_width = w + NK_FRAC(item_offset);

        if (modify) {
            layout->row.item_offset += w;
            layout->row.filled += ratio;
        }
    } break;
    case NK_LAYOUT_STATIC_FIXED: {
        /* non-scaling fixed widgets item width */
        item_width = layout->row.item_width;
        item_offset = (float)layout->row.index * item_width;
        item_spacing = (float)layout->row.index * spacing.x;
    } break;
    case NK_LAYOUT_STATIC_ROW: {
        /* scaling single ratio widget width */
        item_width = layout->row.item_width;
        item_offset = layout->row.item_offset;
        item_spacing = (float)layout->row.index * spacing.x;
        if (modify) layout->row.item_offset += item_width;
    } break;
    case NK_LAYOUT_STATIC_FREE: {
        /* free widget placing */
        bounds->x = layout->at_x + layout->row.item.x;
        bounds->w = layout->row.item.w;
        if (((bounds->x + bounds->w) > layout->max_x) && modify)
            layout->max_x = (bounds->x + bounds->w);
        bounds->x -= (float)*layout->offset_x;
        bounds->y = layout->at_y + layout->row.item.y;
        bounds->y -= (float)*layout->offset_y;
        bounds->h = layout->row.item.h;
        return;
    }
    case NK_LAYOUT_STATIC: {
        /* non-scaling array of panel pixel width for every widget */
        item_spacing = (float)layout->row.index * spacing.x;
        item_width = layout->row.ratio[layout->row.index];
        item_offset = layout->row.item_offset;
        if (modify) layout->row.item_offset += item_width;
    } break;
    case NK_LAYOUT_TEMPLATE: {
        /* stretchy row layout with combined dynamic/static widget width*/
        float w;
        NK_ASSERT(layout->row.index < layout->row.columns);
        NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS);
        w = layout->row.templates[layout->row.index];
        item_offset = layout->row.item_offset;
        item_width = w + NK_FRAC(item_offset);
        item_spacing = (float)layout->row.index * spacing.x;
        if (modify) layout->row.item_offset += w;
    } break;
    #undef NK_FRAC
    default: NK_ASSERT(0); break;
    };

    /* set the bounds of the newly allocated widget */
    bounds->w = item_width;
    bounds->h = layout->row.height - spacing.y;
    bounds->y = layout->at_y - (float)*layout->offset_y;
    bounds->x = layout->at_x + item_offset + item_spacing;
    if (((bounds->x + bounds->w) > layout->max_x) && modify)
        layout->max_x = bounds->x + bounds->w;
    bounds->x -= (float)*layout->offset_x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x4780(%rsi), %rax
testq %rax, %rax
jne 0x57848
movq 0x2f7d4(%rip), %r15     # 0x86ff0
movq (%r15), %rdi
leaq 0x19576(%rip), %rsi     # 0x70d9c
leaq 0x1958d(%rip), %rdx     # 0x70dba
movl $0x5705, %ecx           # imm = 0x5705
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x4780(%r14), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x5788e
movq 0x2f797(%rip), %r15     # 0x86ff0
movq (%r15), %rdi
leaq 0x19539(%rip), %rsi     # 0x70d9c
leaq 0x19550(%rip), %rdx     # 0x70dba
movl $0x5706, %ecx           # imm = 0x5706
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x4780(%r14), %rax
testq %rax, %rax
je 0x57d24
movq 0xa8(%rax), %r15
testq %r15, %r15
je 0x57d24
testq %rbx, %rbx
jne 0x578d1
movq 0x2f746(%rip), %r12     # 0x86ff0
movq (%r12), %rdi
leaq 0x194e7(%rip), %rsi     # 0x70d9c
leaq 0x194fe(%rip), %rdx     # 0x70dba
movl $0x570d, %ecx           # imm = 0x570D
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
movss 0x24b8(%r14), %xmm5
movl 0x80(%r15), %eax
cmpl $0x2, %eax
movl $0x1, %edx
cmovgel %eax, %edx
movl 0x70(%r15), %ecx
cmpq $0x8, %rcx
ja 0x57d31
decl %edx
cvtsi2ss %edx, %xmm1
movss 0x24b4(%r14), %xmm6
movss 0x10(%r15), %xmm0
mulss %xmm6, %xmm1
movaps %xmm0, %xmm4
subss %xmm1, %xmm4
leaq 0x162a3(%rip), %rdx     # 0x6dbc4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
maxss 0x15f72(%rip), %xmm4    # 0x6d8a4
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss %xmm0, %xmm4
cvtsi2ssl 0x74(%r15), %xmm2
movaps %xmm4, %xmm0
mulss %xmm2, %xmm0
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm3
movaps %xmm0, %xmm1
subss %xmm3, %xmm1
addss %xmm4, %xmm1
jmp 0x57974
movss 0x90(%r15), %xmm1
cvtsi2ssl 0x74(%r15), %xmm2
movaps %xmm1, %xmm0
mulss %xmm2, %xmm0
mulss %xmm2, %xmm6
jmp 0x57cbb
movq 0x18(%r15), %rax
movq 0x20(%r15), %rcx
movsd 0x28(%r15), %xmm1
movsd 0xa0(%r15), %xmm2
movss 0x78(%r15), %xmm3
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
mulps %xmm0, %xmm2
addps %xmm1, %xmm2
movss (%rcx), %xmm1
movss (%rax), %xmm3
unpcklpd %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0]
movapd 0x15e59(%rip), %xmm1    # 0x6d810
orpd %xmm1, %xmm3
subpd %xmm1, %xmm3
cvtpd2ps %xmm3, %xmm1
subps %xmm1, %xmm2
movlps %xmm2, (%rbx)
movsd 0xa8(%r15), %xmm1
cvttps2dq %xmm2, %xmm3
cvtdq2ps %xmm3, %xmm3
subps %xmm3, %xmm2
mulps %xmm0, %xmm1
addps %xmm2, %xmm1
movlps %xmm1, 0x8(%rbx)
jmp 0x57d24
movq 0x88(%r15), %rcx
testq %rcx, %rcx
jne 0x57a4a
movq 0x2f5f2(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x19394(%rip), %rsi     # 0x70d9c
leaq 0x193ab(%rip), %rdx     # 0x70dba
movl $0x5737, %ecx           # imm = 0x5737
xorl %eax, %eax
movss %xmm5, 0xc(%rsp)
movaps %xmm6, 0x10(%rsp)
movaps %xmm4, 0x20(%rsp)
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movaps 0x20(%rsp), %xmm4
movaps 0x10(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
movq 0x88(%r15), %rcx
movslq 0x74(%r15), %rax
movss (%rcx,%rax,4), %xmm2
xorps %xmm0, %xmm0
ucomiss %xmm2, %xmm0
jbe 0x57a64
movss 0x90(%r15), %xmm2
mulss %xmm2, %xmm4
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss %xmm0, %xmm6
movss 0x98(%r15), %xmm0
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm3
movaps %xmm0, %xmm1
subss %xmm3, %xmm1
addss %xmm4, %xmm1
testl %ebp, %ebp
je 0x57cbb
movaps %xmm0, %xmm3
unpcklps %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
movss 0x9c(%r15), %xmm2
unpcklps %xmm2, %xmm4            # xmm4 = xmm4[0],xmm2[0],xmm4[1],xmm2[1]
addps %xmm3, %xmm4
movlps %xmm4, 0x98(%r15)
jmp 0x57cbb
movslq 0x74(%r15), %rax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss %xmm0, %xmm6
movq 0x88(%r15), %rcx
movss (%rcx,%rax,4), %xmm1
movss 0x98(%r15), %xmm0
jmp 0x57b5b
movss 0x90(%r15), %xmm3
movss 0x98(%r15), %xmm0
mulss %xmm3, %xmm4
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm2
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
addss %xmm4, %xmm1
xorps %xmm2, %xmm2
testl %ebp, %ebp
je 0x57cbe
addss %xmm4, %xmm6
movaps %xmm0, %xmm4
unpcklps %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1]
movss 0x9c(%r15), %xmm3
unpcklps %xmm3, %xmm6            # xmm6 = xmm6[0],xmm3[0],xmm6[1],xmm3[1]
addps %xmm4, %xmm6
movlps %xmm6, 0x98(%r15)
movl $0x0, 0x74(%r15)
jmp 0x57cbe
cvtsi2ssl 0x74(%r15), %xmm2
movss 0x90(%r15), %xmm1
movss 0x98(%r15), %xmm0
mulss %xmm2, %xmm6
testl %ebp, %ebp
je 0x57cbb
movaps %xmm1, %xmm2
jmp 0x57cae
movss 0x28(%r15), %xmm0
movss 0xa8(%r15), %xmm1
addss 0xa0(%r15), %xmm0
movss %xmm1, 0x8(%rbx)
testl %ebp, %ebp
je 0x57b9d
addss %xmm0, %xmm1
ucomiss 0x30(%r15), %xmm1
jbe 0x57b9d
movss %xmm1, 0x30(%r15)
movq 0x18(%r15), %rax
movl (%rax), %eax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, (%rbx)
movss 0x2c(%r15), %xmm0
addss 0xa4(%r15), %xmm0
movq 0x20(%r15), %rax
movl (%rax), %eax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x4(%rbx)
movss 0xac(%r15), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x57d24
movl 0x74(%r15), %ecx
cmpl %eax, %ecx
movss %xmm5, 0xc(%rsp)
movaps %xmm6, 0x10(%rsp)
jl 0x57c3a
movq 0x2f3ea(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x1918c(%rip), %rsi     # 0x70d9c
leaq 0x191a3(%rip), %rdx     # 0x70dba
movl $0x5768, %ecx           # imm = 0x5768
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movaps 0x10(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
movl 0x74(%r15), %ecx
cmpl $0x10, %ecx
jl 0x57c7a
movq 0x2f3aa(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x1914c(%rip), %rsi     # 0x70d9c
leaq 0x19163(%rip), %rdx     # 0x70dba
movl $0x5769, %ecx           # imm = 0x5769
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movaps 0x10(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
movl 0x74(%r15), %ecx
movslq %ecx, %rax
movss 0x98(%r15), %xmm0
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm2
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
cvtsi2ss %eax, %xmm3
movss 0xb4(%r15,%rax,4), %xmm2
addss %xmm2, %xmm1
mulss %xmm3, %xmm6
testl %ebp, %ebp
je 0x57cbb
addss %xmm0, %xmm2
movss %xmm2, 0x98(%r15)
movaps %xmm6, %xmm2
movss %xmm1, 0x8(%rbx)
movss 0x78(%r15), %xmm3
subss %xmm5, %xmm3
movss %xmm3, 0xc(%rbx)
movq 0x20(%r15), %rax
movl (%rax), %eax
xorps %xmm3, %xmm3
cvtsi2ss %rax, %xmm3
movss 0x2c(%r15), %xmm4
subss %xmm3, %xmm4
movss %xmm4, 0x4(%rbx)
addss 0x28(%r15), %xmm0
addss %xmm2, %xmm0
testl %ebp, %ebp
je 0x57d0e
addss %xmm0, %xmm1
ucomiss 0x30(%r15), %xmm1
jbe 0x57d0e
movss %xmm1, 0x30(%r15)
movq 0x18(%r15), %rax
movl (%rax), %eax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, (%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x2f2b8(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x1905a(%rip), %rsi     # 0x70d9c
leaq 0x19071(%rip), %rdx     # 0x70dba
movl $0x5771, %ecx           # imm = 0x5771
xorl %eax, %eax
movss %xmm5, 0xc(%rsp)
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movss 0xc(%rsp), %xmm5
xorps %xmm2, %xmm2
xorps %xmm1, %xmm1
xorps %xmm0, %xmm0
jmp 0x57cbe