// File: /workspace/github_c_makefile_star2_O2/space222[P]silo/./nuklear.h
// Function: nk_contextual_begin
NK_API int
nk_contextual_begin(struct nk_context *ctx, nk_flags flags, struct nk_vec2 size,
    struct nk_rect trigger_bounds)
{
    struct nk_window *win;
    struct nk_window *popup;
    struct nk_rect body;

    NK_STORAGE const struct nk_rect null_rect = {-1,-1,0,0};
    int is_clicked = 0;
    int is_open = 0;
    int ret = 0;

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

    win = ctx->current;
    ++win->popup.con_count;
    if (ctx->current != ctx->active)
        return 0;

    /* check if currently active contextual is active */
    popup = win->popup.win;
    is_open = (popup && win->popup.type == NK_PANEL_CONTEXTUAL);
    is_clicked = nk_input_mouse_clicked(&ctx->input, NK_BUTTON_RIGHT, trigger_bounds);
    if (win->popup.active_con && win->popup.con_count != win->popup.active_con)
        return 0;
    if (!is_open && win->popup.active_con)
        win->popup.active_con = 0;
    if ((!is_open && !is_clicked))
        return 0;

    /* calculate contextual position on click */
    win->popup.active_con = win->popup.con_count;
    if (is_clicked) {
        body.x = ctx->input.mouse.pos.x;
        body.y = ctx->input.mouse.pos.y;
    } else {
        body.x = popup->bounds.x;
        body.y = popup->bounds.y;
    }
    body.w = size.x;
    body.h = size.y;

    /* start nonblocking contextual popup */
    ret = nk_nonblock_begin(ctx, flags|NK_WINDOW_NO_SCROLLBAR, body,
            null_rect, NK_PANEL_CONTEXTUAL);
    if (ret) win->popup.type = NK_PANEL_CONTEXTUAL;
    else {
        win->popup.active_con = 0;
        win->popup.type = NK_PANEL_NONE;
        if (win->popup.win)
            win->popup.win->flags = 0;
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0xd220
movq %rdi, %r14
movq 0x3fe8(%rdi), %r15
testq %r15, %r15
je 0xd23f
cmpq $0x0, 0xa8(%r15)
je 0xd25e
movl 0x164(%r15), %ebp
incl %ebp
movl %ebp, 0x164(%r15)
cmpq 0x3fe0(%r14), %r15
je 0xd12d
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %ebx
movq 0x120(%r15), %r12
testq %r12, %r12
movaps %xmm0, (%rsp)
je 0xd14d
cmpl $0x10, 0x128(%r15)
sete %r13b
jmp 0xd150
xorl %r13d, %r13d
pushq $0x2
popq %rsi
movq %r14, %rdi
movaps %xmm1, %xmm0
movaps %xmm2, %xmm1
callq 0x7d60
movl 0x16c(%r15), %ecx
testl %ecx, %ecx
je 0xd17d
cmpl %ecx, %ebp
jne 0xd11c
testb %r13b, %r13b
jne 0xd18b
andl $0x0, 0x16c(%r15)
testl %eax, %eax
setne %cl
orb %cl, %r13b
cmpb $0x1, %r13b
jne 0xd11c
movl %ebp, 0x16c(%r15)
testl %eax, %eax
je 0xd1a8
movss 0x144(%r14), %xmm1
leaq 0x148(%r14), %r12
jmp 0xd1b3
movss 0x4c(%r12), %xmm1
addq $0x50, %r12
orl $0x20, %ebx
movss (%r12), %xmm0
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
movaps 0x13116(%rip), %xmm2    # 0x202e0
pushq $0x10
popq %rdx
xorps %xmm3, %xmm3
movq %r14, %rdi
movl %ebx, %esi
movaps (%rsp), %xmm1
callq 0xd27d
testl %eax, %eax
je 0xd1f5
movl $0x10, 0x128(%r15)
pushq $0x1
popq %rax
jmp 0xd11e
andl $0x0, 0x16c(%r15)
andl $0x0, 0x128(%r15)
movq 0x120(%r15), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0xd11e
andl $0x0, 0x48(%rcx)
jmp 0xd11e
leaq 0x164bc(%rip), %rdi     # 0x236e3
leaq 0x13475(%rip), %rsi     # 0x206a3
leaq 0x15835(%rip), %rcx     # 0x22a6a
movl $0x42ae, %edx           # imm = 0x42AE
callq 0x20a0
leaq 0x14f25(%rip), %rdi     # 0x2216b
leaq 0x13456(%rip), %rsi     # 0x206a3
leaq 0x15816(%rip), %rcx     # 0x22a6a
movl $0x42af, %edx           # imm = 0x42AF
callq 0x20a0
leaq 0x15082(%rip), %rdi     # 0x222e7
leaq 0x13437(%rip), %rsi     # 0x206a3
leaq 0x157f7(%rip), %rcx     # 0x22a6a
movl $0x42b0, %edx           # imm = 0x42B0
callq 0x20a0