// File: /workspace/github_c_makefile_star2_O2/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_popup_begin
NK_API nk_bool
nk_popup_begin(struct nk_context *ctx, enum nk_popup_type type,
    const char *title, nk_flags flags, struct nk_rect rect)
{
    struct nk_window *popup;
    struct nk_window *win;
    struct nk_panel *panel;

    int title_len;
    nk_hash title_hash;
    nk_size allocated;

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

    win = ctx->current;
    panel = win->layout;
    NK_ASSERT(!((int)panel->type & (int)NK_PANEL_SET_POPUP) && "popups are not allowed to have popups");
    (void)panel;
    title_len = (int)nk_strlen(title);
    title_hash = nk_murmur_hash(title, (int)title_len, NK_PANEL_POPUP);

    popup = win->popup.win;
    if (!popup) {
        popup = (struct nk_window*)nk_create_window(ctx);
        popup->parent = win;
        win->popup.win = popup;
        win->popup.active = 0;
        win->popup.type = NK_PANEL_POPUP;
    }

    /* make sure we have correct popup */
    if (win->popup.name != title_hash) {
        if (!win->popup.active) {
            nk_zero(popup, sizeof(*popup));
            win->popup.name = title_hash;
            win->popup.active = 1;
            win->popup.type = NK_PANEL_POPUP;
        } else return 0;
    }

    /* popup position is local to window */
    ctx->current = popup;
    rect.x += win->layout->clip.x;
    rect.y += win->layout->clip.y;

    /* setup popup data */
    popup->parent = win;
    popup->bounds = rect;
    popup->seq = ctx->seq;
    popup->layout = (struct nk_panel*)nk_create_panel(ctx);
    popup->flags = flags;
    popup->flags |= NK_WINDOW_BORDER;
    if (type == NK_POPUP_DYNAMIC)
        popup->flags |= NK_WINDOW_DYNAMIC;

    popup->buffer = win->buffer;
    nk_start_popup(ctx, win);
    allocated = ctx->memory.allocated;
    nk_push_scissor(&popup->buffer, nk_null_rect);

    if (nk_panel_begin(ctx, title, NK_PANEL_POPUP)) {
        /* popup is running therefore invalidate parent panels */
        struct nk_panel *root;
        root = win->layout;
        while (root) {
            root->flags |= NK_WINDOW_ROM;
            root->flags &= ~(nk_flags)NK_WINDOW_REMOVE_ROM;
            root = root->parent;
        }
        win->popup.active = 1;
        popup->layout->offset_x = &popup->scrollbar.x;
        popup->layout->offset_y = &popup->scrollbar.y;
        popup->layout->parent = win->layout;
        return 1;
    } else {
        /* popup was closed/is invalid so cleanup */
        struct nk_panel *root;
        root = win->layout;
        while (root) {
            root->flags |= NK_WINDOW_REMOVE_ROM;
            root = root->parent;
        }
        win->popup.buf.active = 0;
        win->popup.active = 0;
        ctx->memory.allocated = allocated;
        ctx->current = win;
        nk_free_panel(ctx, popup->layout);
        popup->layout = 0;
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movaps %xmm1, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r13d
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x3a026
movq 0x4afef(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x2fd01(%rip), %rsi     # 0x69d0c
leaq 0x2fd18(%rip), %rdx     # 0x69d2a
movl $0x51b7, %ecx           # imm = 0x51B7
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
testq %r14, %r14
jne 0x3a057
movq 0x4afbe(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x2fcd0(%rip), %rsi     # 0x69d0c
leaq 0x2fce7(%rip), %rdx     # 0x69d2a
movl $0x51b8, %ecx           # imm = 0x51B8
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x4780(%rbx), %r15
testq %r15, %r15
jne 0x3a096
movq 0x4af86(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x2fc98(%rip), %rsi     # 0x69d0c
leaq 0x2fcaf(%rip), %rdx     # 0x69d2a
movl $0x51b9, %ecx           # imm = 0x51B9
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x4780(%rbx), %r15
cmpq $0x0, 0xa8(%r15)
jne 0x3a0df
movq 0x4af49(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x2fc5b(%rip), %rsi     # 0x69d0c
leaq 0x2fc72(%rip), %rdx     # 0x69d2a
xorl %r12d, %r12d
movl $0x51ba, %ecx           # imm = 0x51BA
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x4780(%rbx), %r15
testq %r15, %r15
je 0x3a356
movq 0xa8(%r15), %rax
xorl %r12d, %r12d
testq %rax, %rax
je 0x3a356
movl %r13d, 0x8(%rsp)
movl %ebp, 0xc(%rsp)
testb $-0xc, (%rax)
je 0x3a12e
movq 0x4aee9(%rip), %r13     # 0x84ff0
movq (%r13), %rdi
leaq 0x2fbfa(%rip), %rsi     # 0x69d0c
leaq 0x2fc11(%rip), %rdx     # 0x69d2a
movl $0x51c0, %ecx           # imm = 0x51C0
xorl %eax, %eax
callq 0x12ea0
movq (%r13), %rdi
callq 0x13960
movq %r14, %rdi
callq 0x13040
pushq $0x4
popq %rdx
movq %r14, %rdi
movl %eax, %esi
callq 0x125c0
movl %eax, %ebp
movq 0x120(%r15), %r13
testq %r13, %r13
jne 0x3a17d
movq %rbx, %rdi
callq 0x37368
movq %rax, %r13
movq %r15, 0x1d8(%rax)
movq %rax, 0x120(%r15)
andl $0x0, 0x15c(%r15)
movl $0x4, 0x128(%r15)
cmpl %ebp, 0x158(%r15)
je 0x3a1be
cmpl $0x0, 0x15c(%r15)
jne 0x3a356
movl $0x1e0, %esi            # imm = 0x1E0
movq %r13, %rdi
callq 0x23ed0
movl %ebp, 0x158(%r15)
movl $0x1, 0x15c(%r15)
movl $0x4, 0x128(%r15)
leaq 0xa8(%r15), %rbp
movq %r13, 0x4780(%rbx)
movq 0xa8(%r15), %rax
movsd 0x44(%rax), %xmm0
addps 0x10(%rsp), %xmm0
movq %r15, 0x1d8(%r13)
unpcklpd 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movups %xmm0, 0x4c(%r13)
movl 0x4794(%rbx), %eax
movl %eax, (%r13)
movq %rbx, %rdi
callq 0x37500
movq %rax, 0xa8(%r13)
xorl %eax, %eax
cmpl $0x1, 0x8(%rsp)
sete %al
shll $0xb, %eax
orl 0xc(%rsp), %eax
orl $0x1, %eax
movl %eax, 0x48(%r13)
leaq 0x68(%r13), %rdi
movups 0x68(%r15), %xmm0
movups 0x78(%r15), %xmm1
movups 0x88(%r15), %xmm2
movups 0x98(%r15), %xmm3
movups %xmm0, 0x68(%r13)
movups %xmm1, 0x78(%r13)
movups %xmm2, 0x88(%r13)
movups %xmm3, 0x98(%r13)
movdqu 0x98(%r15), %xmm0
movdqu %xmm0, 0x130(%r15)
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqu %xmm0, 0x140(%r15)
movl $0x1, 0x150(%r15)
movq 0x2560(%rbx), %r12
movaps 0x2c25f(%rip), %xmm0    # 0x664f0
movaps 0x2c268(%rip), %xmm1    # 0x66500
callq 0x13c50
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x37520
testl %eax, %eax
je 0x3a2df
movl $0xfffeefff, %eax       # imm = 0xFFFEEFFF
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x3a322
movl 0x4(%rbp), %ecx
andl %eax, %ecx
orl $0x1000, %ecx           # imm = 0x1000
movl %ecx, 0x4(%rbp)
addq $0x1c8, %rbp            # imm = 0x1C8
jmp 0x3a2b4
orb $0x1, 0x6(%rbp)
addq $0x1c8, %rbp            # imm = 0x1C8
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0x3a2d4
andl $0x0, 0x150(%r15)
andl $0x0, 0x15c(%r15)
movq %r12, 0x2560(%rbx)
movq %r15, 0x4780(%rbx)
movq 0xa8(%r13), %rsi
movq %rbx, %rdi
callq 0x51795
andq $0x0, 0xa8(%r13)
xorl %r12d, %r12d
jmp 0x3a356
movl $0x1, 0x15c(%r15)
leaq 0x5c(%r13), %rax
movq 0xa8(%r13), %rcx
movq %rax, 0x18(%rcx)
addq $0x60, %r13
movq %r13, 0x20(%rcx)
movq 0xa8(%r15), %rax
movq %rax, 0x1c8(%rcx)
pushq $0x1
popq %r12
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq