// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x78, %rsp
movlpd %xmm0, 0x64(%rsp)
movlpd %xmm1, 0x6c(%rsp)
movq %rdi, 0x58(%rsp)
movl %esi, 0x54(%rsp)
movq %rdx, 0x48(%rsp)
movl %ecx, 0x44(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x5a9bd
movq 0x6a65f(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x56a05(%rip), %rsi     # 0xb13a0
leaq 0x56a1c(%rip), %rdx     # 0xb13be
movl $0x51b7, %ecx           # imm = 0x51B7
movb $0x0, %al
callq 0x13ec0
movq 0x6a63b(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x5a9bf
jmp 0x5a9c1
cmpq $0x0, 0x48(%rsp)
jne 0x5a9fc
movq 0x6a620(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x569c6(%rip), %rsi     # 0xb13a0
leaq 0x569dd(%rip), %rdx     # 0xb13be
movl $0x51b8, %ecx           # imm = 0x51B8
movb $0x0, %al
callq 0x13ec0
movq 0x6a5fc(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x5a9fe
jmp 0x5aa00
movq 0x58(%rsp), %rax
cmpq $0x0, 0x4780(%rax)
jne 0x5aa42
movq 0x6a5da(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x56980(%rip), %rsi     # 0xb13a0
leaq 0x56997(%rip), %rdx     # 0xb13be
movl $0x51b9, %ecx           # imm = 0x51B9
movb $0x0, %al
callq 0x13ec0
movq 0x6a5b6(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x5aa44
jmp 0x5aa46
movq 0x58(%rsp), %rax
movq 0x4780(%rax), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x5aa8f
movq 0x6a58d(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x56933(%rip), %rsi     # 0xb13a0
leaq 0x5694a(%rip), %rdx     # 0xb13be
movl $0x51ba, %ecx           # imm = 0x51BA
movb $0x0, %al
callq 0x13ec0
movq 0x6a569(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x5aa91
cmpq $0x0, 0x58(%rsp)
je 0x5aabe
movq 0x58(%rsp), %rax
cmpq $0x0, 0x4780(%rax)
je 0x5aabe
movq 0x58(%rsp), %rax
movq 0x4780(%rax), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x5aacb
movl $0x0, 0x74(%rsp)
jmp 0x5aeff
movq 0x58(%rsp), %rax
movq 0x4780(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0xa8(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %eax
andl $0xf4, %eax
cmpl $0x0, %eax
jne 0x5ab06
movb $0x1, %al
testb $0x1, %al
jne 0x5ab39
jmp 0x5ab06
movq 0x6a4e3(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x56889(%rip), %rsi     # 0xb13a0
leaq 0x568a0(%rip), %rdx     # 0xb13be
movl $0x51c0, %ecx           # imm = 0x51C0
movb $0x0, %al
callq 0x13ec0
movq 0x6a4bf(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x5ab3b
movq 0x48(%rsp), %rdi
callq 0x14050
movl %eax, 0x24(%rsp)
movq 0x48(%rsp), %rdi
movl 0x24(%rsp), %esi
movl $0x4, %edx
callq 0x135e0
movl %eax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x5abc8
movq 0x58(%rsp), %rdi
callq 0x557f0
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x1d8(%rax)
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x120(%rax)
movq 0x30(%rsp), %rax
movl $0x0, 0x15c(%rax)
movq 0x30(%rsp), %rax
movl $0x4, 0x128(%rax)
movq 0x30(%rsp), %rax
movl 0x158(%rax), %eax
cmpl 0x20(%rsp), %eax
je 0x5ac34
movq 0x30(%rsp), %rax
cmpl $0x0, 0x15c(%rax)
jne 0x5ac25
movq 0x38(%rsp), %rdi
movl $0x1e0, %esi            # imm = 0x1E0
callq 0x2f0e0
movl 0x20(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x158(%rax)
movq 0x30(%rsp), %rax
movl $0x1, 0x15c(%rax)
movq 0x30(%rsp), %rax
movl $0x4, 0x128(%rax)
jmp 0x5ac32
movl $0x0, 0x74(%rsp)
jmp 0x5aeff
jmp 0x5ac34
movq 0x38(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x4780(%rax)
movq 0x30(%rsp), %rax
movq 0xa8(%rax), %rax
movss 0x44(%rax), %xmm0
addss 0x64(%rsp), %xmm0
movss %xmm0, 0x64(%rsp)
movq 0x30(%rsp), %rax
movq 0xa8(%rax), %rax
movss 0x48(%rax), %xmm0
addss 0x68(%rsp), %xmm0
movss %xmm0, 0x68(%rsp)
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x1d8(%rax)
movq 0x38(%rsp), %rax
movq 0x64(%rsp), %rcx
movq %rcx, 0x4c(%rax)
movq 0x6c(%rsp), %rcx
movq %rcx, 0x54(%rax)
movq 0x58(%rsp), %rax
movl 0x4794(%rax), %ecx
movq 0x38(%rsp), %rax
movl %ecx, (%rax)
movq 0x58(%rsp), %rdi
callq 0x55d00
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0xa8(%rax)
movl 0x44(%rsp), %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x48(%rax)
movq 0x38(%rsp), %rax
movl 0x48(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x48(%rax)
cmpl $0x1, 0x54(%rsp)
jne 0x5ad04
movq 0x38(%rsp), %rax
movl 0x48(%rax), %ecx
orl $0x800, %ecx            # imm = 0x800
movl %ecx, 0x48(%rax)
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
movups 0x68(%rcx), %xmm0
movups 0x78(%rcx), %xmm1
movups 0x88(%rcx), %xmm2
movups 0x98(%rcx), %xmm3
movups %xmm3, 0x98(%rax)
movups %xmm2, 0x88(%rax)
movups %xmm1, 0x78(%rax)
movups %xmm0, 0x68(%rax)
movq 0x58(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x5af10
movq 0x58(%rsp), %rax
movq 0x2560(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
addq $0x68, %rdi
movsd 0x52af9(%rip), %xmm0    # 0xad864
movsd 0x52af9(%rip), %xmm1    # 0xad86c
callq 0x14c90
movq 0x58(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl $0x4, %edx
callq 0x55d50
cmpl $0x0, %eax
je 0x5ae54
movq 0x30(%rsp), %rax
movq 0xa8(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x5ade3
movq 0x10(%rsp), %rax
movl 0x4(%rax), %ecx
orl $0x1000, %ecx           # imm = 0x1000
movl %ecx, 0x4(%rax)
movq 0x10(%rsp), %rax
movl 0x4(%rax), %ecx
andl $0xfffeffff, %ecx       # imm = 0xFFFEFFFF
movl %ecx, 0x4(%rax)
movq 0x10(%rsp), %rax
movq 0x1c8(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x5ada6
movq 0x30(%rsp), %rax
movl $0x1, 0x15c(%rax)
movq 0x38(%rsp), %rcx
addq $0x5c, %rcx
movq 0x38(%rsp), %rax
movq 0xa8(%rax), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rcx
addq $0x5c, %rcx
addq $0x4, %rcx
movq 0x38(%rsp), %rax
movq 0xa8(%rax), %rax
movq %rcx, 0x20(%rax)
movq 0x30(%rsp), %rax
movq 0xa8(%rax), %rcx
movq 0x38(%rsp), %rax
movq 0xa8(%rax), %rax
movq %rcx, 0x1c8(%rax)
movl $0x1, 0x74(%rsp)
jmp 0x5aeff
movq 0x30(%rsp), %rax
movq 0xa8(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x5ae91
movq 0x8(%rsp), %rax
movl 0x4(%rax), %ecx
orl $0x10000, %ecx          # imm = 0x10000
movl %ecx, 0x4(%rax)
movq 0x8(%rsp), %rax
movq 0x1c8(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x5ae65
movq 0x30(%rsp), %rax
movl $0x0, 0x150(%rax)
movq 0x30(%rsp), %rax
movl $0x0, 0x15c(%rax)
movq 0x18(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x2560(%rax)
movq 0x30(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x4780(%rax)
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0xa8(%rax), %rsi
callq 0x588d0
movq 0x38(%rsp), %rax
movq $0x0, 0xa8(%rax)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax,%rax)