// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_contextual_begin
NK_API nk_bool
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;
    struct nk_input* in;

    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);
    in = win->widgets_disabled ? 0 : &ctx->input;
    if (in) {
        is_clicked = nk_input_mouse_clicked(in, 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 = in->mouse.pos.x;
            body.y = in->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 $0x48, %rsp
movaps %xmm2, 0x30(%rsp)
movaps %xmm1, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl %esi, %ebx
movq %rdi, %r14
testq %rdi, %rdi
jne 0x3e5ab
movq 0x49a6a(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x337fc(%rip), %rsi     # 0x71d8c
leaq 0x33813(%rip), %rdx     # 0x71daa
movl $0x52c1, %ecx           # imm = 0x52C1
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
cmpq $0x0, 0x4780(%r14)
jne 0x3e5e1
movq 0x49a34(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x337c6(%rip), %rsi     # 0x71d8c
leaq 0x337dd(%rip), %rdx     # 0x71daa
movl $0x52c2, %ecx           # imm = 0x52C2
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x4780(%r14), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x3e61e
movq 0x499f7(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x33789(%rip), %rsi     # 0x71d8c
leaq 0x337a0(%rip), %rdx     # 0x71daa
movl $0x52c3, %ecx           # imm = 0x52C3
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
xorl %r15d, %r15d
testq %r14, %r14
je 0x3e796
movq 0x4780(%r14), %r13
testq %r13, %r13
je 0x3e796
cmpq $0x0, 0xa8(%r13)
je 0x3e796
movl 0x164(%r13), %ebp
incl %ebp
movl %ebp, 0x164(%r13)
cmpq 0x4778(%r14), %r13
jne 0x3e796
movq 0x120(%r13), %rax
xorl %r15d, %r15d
testq %rax, %rax
je 0x3e681
cmpl $0x10, 0x128(%r13)
sete %cl
jmp 0x3e683
xorl %ecx, %ecx
cmpl $0x0, 0x1b0(%r13)
movl $0x0, %r12d
cmoveq %r14, %r12
jne 0x3e796
movq %rcx, 0x8(%rsp)
movq %rax, (%rsp)
movq %r12, %rdi
movl $0x2, %esi
movaps 0x20(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
callq 0x12380
movl 0x16c(%r13), %ecx
testl %ecx, %ecx
sete %dl
cmpl %ecx, %ebp
sete %sil
orb %dl, %sil
cmpb $0x1, %sil
jne 0x3e796
testl %ecx, %ecx
sete %cl
movq 0x8(%rsp), %rdx
orb %dl, %cl
jne 0x3e6f3
movl $0x0, 0x16c(%r13)
testl %eax, %eax
setne %cl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x3e796
movl %ebp, 0x16c(%r13)
testl %eax, %eax
je 0x3e721
movss 0x144(%r12), %xmm1
addq $0x148, %r12            # imm = 0x148
jmp 0x3e730
movq (%rsp), %r12
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 0x300d9(%rip), %xmm2    # 0x6e820
xorps %xmm3, %xmm3
movq %r14, %rdi
movl %ebx, %esi
movaps 0x10(%rsp), %xmm1
movl $0x10, %edx
callq 0x3e7a8
testl %eax, %eax
je 0x3e772
movl %eax, %r15d
movl $0x10, 0x128(%r13)
jmp 0x3e796
xorl %r15d, %r15d
movl %r15d, 0x16c(%r13)
movl %r15d, 0x128(%r13)
movq 0x120(%r13), %rax
testq %rax, %rax
je 0x3e796
movl $0x0, 0x48(%rax)
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq