// File: /workspace/github_c_makefile_star2_O2/0x0203[P]schack_poc/./nuklear_xlib.h
// Function: nk_xlib_init
NK_API struct nk_context*
nk_xlib_init(XFont *xfont, Display *dpy, int screen, Window root,
    unsigned int w, unsigned int h)
{
    struct nk_user_font *font = &xfont->handle;
    font->userdata = nk_handle_ptr(xfont);
    font->height = (float)xfont->height;
    font->width = nk_xfont_get_text_width;
    xlib.dpy = dpy;
    xlib.root = root;

    if (!setlocale(LC_ALL,"")) return 0;
    if (!XSupportsLocale()) return 0;
    if (!XSetLocaleModifiers("@im=none")) return 0;

    xlib.xa_clipboard = XInternAtom(dpy, "CLIPBOARD", False);
    xlib.xa_targets = XInternAtom(dpy, "TARGETS", False);
    xlib.xa_text = XInternAtom(dpy, "TEXT", False);
    xlib.xa_utf8_string = XInternAtom(dpy, "UTF8_STRING", False);

    /* create invisible cursor */
    {static XColor dummy; char data[1] = {0};
    Pixmap blank = XCreateBitmapFromData(dpy, root, data, 1, 1);
    if (blank == None) return 0;
    xlib.cursor = XCreatePixmapCursor(dpy, blank, blank, &dummy, &dummy, 0, 0);
    XFreePixmap(dpy, blank);}

    xlib.surf = nk_xsurf_create(screen, w, h);
    nk_init_default(&xlib.ctx, font);
    return &xlib.ctx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %ebp
movl %r8d, %r14d
movq %rcx, %r13
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
movq %rdi, 0x20(%rdi)
cvtsi2ssl 0x8(%rdi), %xmm0
movss %xmm0, 0x28(%rdi)
leaq 0x1bc(%rip), %rax       # 0x1cfa3
movq %rax, 0x30(%rdi)
movq %rsi, 0x1e82e(%rip)     # 0x3b620
movq %rcx, 0x1e82f(%rip)     # 0x3b628
leaq 0xd73f(%rip), %rsi      # 0x2a53f
pushq $0x6
popq %rdi
callq 0x3530
testq %rax, %rax
je 0x1cf8e
callq 0x31d0
testl %eax, %eax
je 0x1cf8e
leaq 0xd1fc(%rip), %rdi      # 0x2a021
callq 0x34c0
testq %rax, %rax
je 0x1cf8e
leaq 0xd1f0(%rip), %rsi      # 0x2a02a
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x1a7a5(%rip)     # 0x375f0
leaq 0xd1e2(%rip), %rsi      # 0x2a034
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x1a795(%rip)     # 0x375f8
leaq 0xeada(%rip), %rsi      # 0x2b944
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x1a785(%rip)     # 0x37600
leaq 0xd1ba(%rip), %rsi      # 0x2a03c
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x1a775(%rip)     # 0x37608
leaq 0x17(%rsp), %rdx
movb $0x0, (%rdx)
pushq $0x1
popq %rcx
movq %r12, %rdi
movq %r13, %rsi
movl %ecx, %r8d
callq 0x3360
testq %rax, %rax
je 0x1cf8e
movq %rax, %r13
addq $0x20, %rbx
andl $0x0, (%rsp)
leaq 0x1e771(%rip), %rcx     # 0x3b638
movq %r12, %rdi
movq %rax, %rsi
movq %rax, %rdx
movq %rcx, %r8
xorl %r9d, %r9d
callq 0x32c0
movq %rax, 0x1e736(%rip)     # 0x3b618
movq %r12, %rdi
movq %r13, %rsi
callq 0x3510
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x3470
movq %rax, %r12
movl %r14d, 0x28(%rax)
movl %ebp, 0x2c(%rax)
movq 0x1e717(%rip), %rdi     # 0x3b620
movq %rdi, 0x8(%rax)
movl %r15d, 0x10(%rax)
movq 0x1e710(%rip), %rsi     # 0x3b628
movq %rsi, 0x18(%rax)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3380
movq %rax, (%r12)
movq 0x1e6f0(%rip), %rdi     # 0x3b620
pushq $0x1
popq %rdx
movq %rax, %rsi
xorl %ecx, %ecx
movl %edx, %r8d
xorl %r9d, %r9d
callq 0x3320
movq 0x1e6d6(%rip), %rdi     # 0x3b620
movq 0x1e6d7(%rip), %rsi     # 0x3b628
movq 0xe8(%rdi), %rax
movslq %r15d, %rcx
shlq $0x7, %rcx
movl 0x38(%rax,%rcx), %r8d
movl %r14d, %edx
movl %ebp, %ecx
callq 0x3550
movq %rax, 0x20(%r12)
movq %r12, 0x1e696(%rip)     # 0x3b610
leaq 0x1a68f(%rip), %r14     # 0x37610
movq %r14, %rdi
movq %rbx, %rsi
callq 0x9744
jmp 0x1cf91
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq