// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %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 0x1f1(%rip), %rax       # 0x20467
movq %rax, 0x30(%rdi)
movq %rsi, 0x1d39f(%rip)     # 0x3d620
movq %rcx, 0x1d3a0(%rip)     # 0x3d628
leaq 0xe120(%rip), %rsi      # 0x2e3af
movl $0x6, %edi
callq 0x3530
testq %rax, %rax
je 0x20452
callq 0x31d0
testl %eax, %eax
je 0x20452
leaq 0xdbdb(%rip), %rdi      # 0x2de91
callq 0x34c0
testq %rax, %rax
je 0x20452
leaq 0xdbcf(%rip), %rsi      # 0x2de9a
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x19314(%rip)     # 0x395f0
leaq 0xdbc1(%rip), %rsi      # 0x2dea4
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x19304(%rip)     # 0x395f8
leaq 0xf491(%rip), %rsi      # 0x2f78c
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x192f4(%rip)     # 0x39600
leaq 0xdb99(%rip), %rsi      # 0x2deac
movq %r12, %rdi
xorl %edx, %edx
callq 0x3490
movq %rax, 0x192e4(%rip)     # 0x39608
leaq 0x10(%rsp), %rdx
movb $0x0, (%rdx)
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x3360
testq %rax, %rax
je 0x20452
movq %rax, %r13
addq $0x20, %rbx
movl $0x0, (%rsp)
leaq 0x1d2d8(%rip), %rcx     # 0x3d638
movq %r12, %rdi
movq %rax, %rsi
movq %rax, %rdx
movq %rcx, %r8
xorl %r9d, %r9d
callq 0x32c0
movq %rax, 0x1d29d(%rip)     # 0x3d618
movq %r12, %rdi
movq %r13, %rsi
callq 0x3510
movl $0x1, %edi
movl $0x30, %esi
callq 0x3470
movq %rax, %r12
movl %r14d, 0x28(%rax)
movl %ebp, 0x2c(%rax)
movq 0x1d27a(%rip), %rdi     # 0x3d620
movq %rdi, 0x8(%rax)
movl %r15d, 0x10(%rax)
movq 0x1d273(%rip), %rsi     # 0x3d628
movq %rsi, 0x18(%rax)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3380
movq %rax, (%r12)
movq 0x1d253(%rip), %rdi     # 0x3d620
movq %rax, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x3320
movq 0x1d234(%rip), %rdi     # 0x3d620
movq 0x1d235(%rip), %rsi     # 0x3d628
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, 0x1d1f4(%rip)     # 0x3d610
leaq 0x10(%rsp), %rsi
movq $0x0, (%rsi)
leaq -0x1b139(%rip), %rax    # 0x52f6
movq %rax, 0x8(%rsi)
leaq -0x1b13c(%rip), %rax    # 0x52fe
movq %rax, 0x10(%rsi)
leaq 0x191cb(%rip), %r14     # 0x39610
movq %r14, %rdi
movq %rbx, %rdx
callq 0xa786
jmp 0x20455
xorl %r14d, %r14d
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq