// File: /workspace/github_c_makefile_star2_O2/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 0x524bd
movq 0x32b5f(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x17871(%rip), %rsi     # 0x69d0c
leaq 0x17888(%rip), %rdx     # 0x69d2a
movl $0x5705, %ecx           # imm = 0x5705
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x4780(%r14), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x52503
movq 0x32b22(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x17834(%rip), %rsi     # 0x69d0c
leaq 0x1784b(%rip), %rdx     # 0x69d2a
movl $0x5706, %ecx           # imm = 0x5706
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x4780(%r14), %rax
testq %rax, %rax
je 0x5297f
movq 0xa8(%rax), %r15
testq %r15, %r15
je 0x5297f
testq %rbx, %rbx
jne 0x52546
movq 0x32ad1(%rip), %r12     # 0x84ff0
movq (%r12), %rdi
leaq 0x177e2(%rip), %rsi     # 0x69d0c
leaq 0x177f9(%rip), %rdx     # 0x69d2a
movl $0x570d, %ecx           # imm = 0x570D
xorl %eax, %eax
callq 0x12ea0
movq (%r12), %rdi
callq 0x13960
movss 0x24b8(%r14), %xmm5
movl 0x80(%r15), %eax
cmpl $0x2, %eax
pushq $0x1
popq %rdx
cmovgel %eax, %edx
movl 0x70(%r15), %ecx
cmpq $0x8, %rcx
ja 0x5298c
decl %edx
cvtsi2ss %edx, %xmm1
movss 0x24b4(%r14), %xmm6
movss 0x10(%r15), %xmm0
mulss %xmm6, %xmm1
movaps %xmm0, %xmm4
subss %xmm1, %xmm4
leaq 0x1459c(%rip), %rdx     # 0x66b30
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
maxss 0x1428f(%rip), %xmm4    # 0x66834
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 0x525e4
movss 0x90(%r15), %xmm1
cvtsi2ssl 0x74(%r15), %xmm2
movaps %xmm1, %xmm0
mulss %xmm2, %xmm0
mulss %xmm2, %xmm6
jmp 0x5291c
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 0x14169(%rip), %xmm1    # 0x66790
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 0x5297f
movq 0x88(%r15), %rcx
testq %rcx, %rcx
jne 0x526ba
movq 0x32982(%rip), %r14     # 0x84ff0
movq (%r14), %rdi
leaq 0x17694(%rip), %rsi     # 0x69d0c
leaq 0x176ab(%rip), %rdx     # 0x69d2a
movl $0x5737, %ecx           # imm = 0x5737
xorl %eax, %eax
movss %xmm5, 0xc(%rsp)
movaps %xmm6, 0x10(%rsp)
movaps %xmm4, 0x20(%rsp)
callq 0x12ea0
movq (%r14), %rdi
callq 0x13960
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 0x526d4
movss 0x90(%r15), %xmm2
mulss %xmm2, %xmm4
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 0x5291c
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 0x5291c
movslq 0x74(%r15), %rax
cvtsi2ss %eax, %xmm0
mulss %xmm0, %xmm6
movq 0x88(%r15), %rcx
movss (%rcx,%rax,4), %xmm1
movss 0x98(%r15), %xmm0
jmp 0x527c2
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 0x5291f
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)
andl $0x0, 0x74(%r15)
jmp 0x5291f
cvtsi2ssl 0x74(%r15), %xmm2
movss 0x90(%r15), %xmm1
movss 0x98(%r15), %xmm0
mulss %xmm2, %xmm6
testl %ebp, %ebp
je 0x5291c
movaps %xmm1, %xmm2
jmp 0x5290f
movss 0x28(%r15), %xmm0
movss 0xa8(%r15), %xmm1
addss 0xa0(%r15), %xmm0
movss %xmm1, 0x8(%rbx)
testl %ebp, %ebp
je 0x52804
addss %xmm0, %xmm1
ucomiss 0x30(%r15), %xmm1
jbe 0x52804
movss %xmm1, 0x30(%r15)
movq 0x18(%r15), %rax
movl (%rax), %eax
cvtsi2ss %rax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, (%rbx)
movss 0x2c(%r15), %xmm0
addss 0xa4(%r15), %xmm0
movq 0x20(%r15), %rax
movl (%rax), %eax
cvtsi2ss %rax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x4(%rbx)
movss 0xac(%r15), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x5297f
movl 0x74(%r15), %ecx
cmpl %eax, %ecx
movss %xmm5, 0xc(%rsp)
movaps %xmm6, 0x10(%rsp)
jl 0x5289b
movq 0x32789(%rip), %r14     # 0x84ff0
movq (%r14), %rdi
leaq 0x1749b(%rip), %rsi     # 0x69d0c
leaq 0x174b2(%rip), %rdx     # 0x69d2a
movl $0x5768, %ecx           # imm = 0x5768
xorl %eax, %eax
callq 0x12ea0
movq (%r14), %rdi
callq 0x13960
movaps 0x10(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
movl 0x74(%r15), %ecx
cmpl $0x10, %ecx
jl 0x528db
movq 0x32749(%rip), %r14     # 0x84ff0
movq (%r14), %rdi
leaq 0x1745b(%rip), %rsi     # 0x69d0c
leaq 0x17472(%rip), %rdx     # 0x69d2a
movl $0x5769, %ecx           # imm = 0x5769
xorl %eax, %eax
callq 0x12ea0
movq (%r14), %rdi
callq 0x13960
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 0x5291c
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
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 0x5296c
addss %xmm0, %xmm1
ucomiss 0x30(%r15), %xmm1
jbe 0x5296c
movss %xmm1, 0x30(%r15)
movq 0x18(%r15), %rax
movl (%rax), %eax
cvtsi2ss %rax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, (%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x3265d(%rip), %r14     # 0x84ff0
movq (%r14), %rdi
leaq 0x1736f(%rip), %rsi     # 0x69d0c
leaq 0x17386(%rip), %rdx     # 0x69d2a
movl $0x5771, %ecx           # imm = 0x5771
xorl %eax, %eax
movss %xmm5, 0xc(%rsp)
callq 0x12ea0
movq (%r14), %rdi
callq 0x13960
movss 0xc(%rsp), %xmm5
xorps %xmm2, %xmm2
xorps %xmm1, %xmm1
xorps %xmm0, %xmm0
jmp 0x5291f