// File: /workspace/github_c_makefile_star2_O1/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
cmpq $0x0, 0x4780(%rsi)
jne 0x58403
movq 0x2fc12(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x199a4(%rip), %rsi     # 0x71d8c
leaq 0x199bb(%rip), %rdx     # 0x71daa
movl $0x5705, %ecx           # imm = 0x5705
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x4780(%r14), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x58440
movq 0x2fbd5(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x19967(%rip), %rsi     # 0x71d8c
leaq 0x1997e(%rip), %rdx     # 0x71daa
movl $0x5706, %ecx           # imm = 0x5706
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x4780(%r14), %rax
testq %rax, %rax
je 0x588ea
movq 0xa8(%rax), %r15
testq %r15, %r15
je 0x588ea
testq %rbx, %rbx
jne 0x58493
movq 0x2fb84(%rip), %r12     # 0x87ff0
movq (%r12), %rdi
leaq 0x19915(%rip), %rsi     # 0x71d8c
leaq 0x1992c(%rip), %rdx     # 0x71daa
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 0x588f7
decl %edx
cvtsi2ss %edx, %xmm1
movss 0x24b4(%r14), %xmm6
movss 0x10(%r15), %xmm0
mulss %xmm6, %xmm1
movaps %xmm0, %xmm4
subss %xmm1, %xmm4
leaq 0x166cd(%rip), %rdx     # 0x6ebb0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
maxss 0x163c0(%rip), %xmm4    # 0x6e8b4
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 0x58536
movss 0x90(%r15), %xmm1
cvtsi2ssl 0x74(%r15), %xmm2
movaps %xmm1, %xmm0
mulss %xmm2, %xmm0
mulss %xmm2, %xmm6
jmp 0x5887d
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 0x162b7(%rip), %xmm1    # 0x6e830
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 0x588ea
cmpq $0x0, 0x88(%r15)
jne 0x58603
movq 0x2fa32(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x197c4(%rip), %rsi     # 0x71d8c
leaq 0x197db(%rip), %rdx     # 0x71daa
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 0x58624
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 0x5887d
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 0x5887d
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 0x5871b
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 0x58880
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 0x58880
cvtsi2ssl 0x74(%r15), %xmm2
movss 0x90(%r15), %xmm1
movss 0x98(%r15), %xmm0
mulss %xmm2, %xmm6
testl %ebp, %ebp
je 0x5887d
movaps %xmm1, %xmm2
jmp 0x58870
movss 0x28(%r15), %xmm0
addss 0xa0(%r15), %xmm0
movss %xmm0, (%rbx)
movss 0xa8(%r15), %xmm1
movss %xmm1, 0x8(%rbx)
testl %ebp, %ebp
je 0x58761
addss %xmm0, %xmm1
ucomiss 0x30(%r15), %xmm1
jbe 0x58761
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
movss %xmm0, 0x4(%rbx)
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 0x588ea
cmpl %eax, 0x74(%r15)
movss %xmm5, 0xc(%rsp)
movaps %xmm6, 0x10(%rsp)
jl 0x587fd
movq 0x2f823(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x195b5(%rip), %rsi     # 0x71d8c
leaq 0x195cc(%rip), %rdx     # 0x71daa
movl $0x5768, %ecx           # imm = 0x5768
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movaps 0x10(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
cmpl $0x10, 0x74(%r15)
jl 0x5883b
movq 0x2f7e5(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x19577(%rip), %rsi     # 0x71d8c
leaq 0x1958e(%rip), %rdx     # 0x71daa
movl $0x5769, %ecx           # imm = 0x5769
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movaps 0x10(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
movslq 0x74(%r15), %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 0x5887d
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)
movss 0x2c(%r15), %xmm3
movq 0x20(%r15), %rax
movl (%rax), %eax
xorps %xmm4, %xmm4
cvtsi2ss %rax, %xmm4
subss %xmm4, %xmm3
movss %xmm3, 0x4(%rbx)
addss 0x28(%r15), %xmm0
addss %xmm2, %xmm0
movss %xmm0, (%rbx)
testl %ebp, %ebp
je 0x588d4
addss %xmm0, %xmm1
ucomiss 0x30(%r15), %xmm1
jbe 0x588d4
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 0x2f6f2(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x19484(%rip), %rsi     # 0x71d8c
leaq 0x1949b(%rip), %rdx     # 0x71daa
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 0x58880