// File: /workspace/github_c_makefile_star2_O0/andys8[P]st/x.c
// Function: xinit
void
xinit(int cols, int rows)
{
	XGCValues gcvalues;
	Cursor cursor;
	Window parent;
	pid_t thispid = getpid();
	XColor xmousefg, xmousebg;

	if (!(xw.dpy = XOpenDisplay(NULL)))
		die("can't open display\n");
	xw.scr = XDefaultScreen(xw.dpy);
	xw.vis = XDefaultVisual(xw.dpy, xw.scr);

	/* font */
	if (!FcInit())
		die("could not init fontconfig.\n");

	usedfont = (opt_font == NULL)? font : opt_font;
	xloadfonts(usedfont, 0);

	/* colors */
	xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
	xloadcols();

	/* adjust fixed window geometry */
	win.w = 2 * borderpx + cols * win.cw;
	win.h = 2 * borderpx + rows * win.ch;
	if (xw.gm & XNegative)
		xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
	if (xw.gm & YNegative)
		xw.t += DisplayHeight(xw.dpy, xw.scr) - win.h - 2;

	/* Events */
	xw.attrs.background_pixel = dc.col[defaultbg].pixel;
	xw.attrs.border_pixel = dc.col[defaultbg].pixel;
	xw.attrs.bit_gravity = NorthWestGravity;
	xw.attrs.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask
		| ExposureMask | VisibilityChangeMask | StructureNotifyMask
		| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
	xw.attrs.colormap = xw.cmap;

	if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
		parent = XRootWindow(xw.dpy, xw.scr);
	xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
			win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
			xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
			| CWEventMask | CWColormap, &xw.attrs);

	memset(&gcvalues, 0, sizeof(gcvalues));
	gcvalues.graphics_exposures = False;
	dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
			&gcvalues);
	xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
			DefaultDepth(xw.dpy, xw.scr));
	XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
	XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);

	/* font spec buffer */
	xw.specbuf = xmalloc(cols * sizeof(GlyphFontSpec));

	/* Xft rendering context */
	xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);

	/* input methods */
	if (!ximopen(xw.dpy)) {
		XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
	                                       ximinstantiate, NULL);
	}

	/* white cursor, black outline */
    cursor = XcursorLibraryLoadCursor(xw.dpy, mouseshape);
	XDefineCursor(xw.dpy, xw.win, cursor);

	xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
	xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
	xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
	xw.netwmiconname = XInternAtom(xw.dpy, "_NET_WM_ICON_NAME", False);
	XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);

	xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
	XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
			PropModeReplace, (uchar *)&thispid, 1);

	win.mode = MODE_NUMLOCK;
	resettitle();
	xhints();
	XMapWindow(xw.dpy, xw.win);
	XSync(xw.dpy, False);

	clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1);
	clock_gettime(CLOCK_MONOTONIC, &xsel.tclick2);
	xsel.primary = NULL;
	xsel.clipboard = NULL;
	xsel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0);
	if (xsel.xtarget == None)
		xsel.xtarget = XA_STRING;

	boxdraw_xinit(xw.dpy, xw.cmap, xw.draw, xw.vis);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
callq 0x5270
movl %eax, -0x9c(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x52b0
movq %rax, 0x1329c(%rip)     # 0x222e8
cmpq $0x0, %rax
jne 0xf060
leaq 0x6148(%rip), %rdi      # 0x151a1
movb $0x0, %al
callq 0x5b20
movq 0x13281(%rip), %rdi     # 0x222e8
callq 0x5480
movl %eax, 0x13366(%rip)     # 0x223d8
movq 0x1326f(%rip), %rdi     # 0x222e8
movl 0x13359(%rip), %esi     # 0x223d8
callq 0x5290
movq %rax, 0x132d5(%rip)     # 0x22360
callq 0x5960
cmpl $0x0, %eax
jne 0xf0a3
leaq 0x6119(%rip), %rdi      # 0x151b5
movb $0x0, %al
callq 0x5b20
cmpq $0x0, 0x1338d(%rip)     # 0x22438
jne 0xf0bd
movq 0xaf24(%rip), %rax      # 0x19fd8
movq %rax, -0xc8(%rbp)
jmp 0xf0cb
movq 0x13374(%rip), %rax     # 0x22438
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, 0x133df(%rip)     # 0x224b8
movq 0x133d8(%rip), %rdi     # 0x224b8
xorps %xmm0, %xmm0
callq 0xfd90
movq 0x131f9(%rip), %rdi     # 0x222e8
movl 0x132e3(%rip), %esi     # 0x223d8
callq 0x55a0
movq %rax, 0x131ef(%rip)     # 0x222f0
callq 0xcbb0
movl 0x13304(%rip), %eax     # 0x22410
shll %eax
movl -0x4(%rbp), %ecx
imull 0x132ec(%rip), %ecx     # 0x22404
addl %ecx, %eax
movl %eax, 0x132d8(%rip)     # 0x223f8
movl 0x132ea(%rip), %eax     # 0x22410
shll %eax
movl -0x8(%rbp), %ecx
imull 0x132ce(%rip), %ecx     # 0x22400
addl %ecx, %eax
movl %eax, 0x132c2(%rip)     # 0x223fc
movl 0x132a8(%rip), %eax     # 0x223e8
andl $0x10, %eax
cmpl $0x0, %eax
je 0xf17c
movq 0x13199(%rip), %rax     # 0x222e8
movq 0xe8(%rax), %rax
movslq 0x1327b(%rip), %rcx     # 0x223d8
shlq $0x7, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
subl 0x1328b(%rip), %eax     # 0x223f8
subl $0x2, %eax
addl 0x1326a(%rip), %eax     # 0x223e0
movl %eax, 0x13264(%rip)     # 0x223e0
movl 0x13266(%rip), %eax     # 0x223e8
andl $0x20, %eax
cmpl $0x0, %eax
je 0xf1be
movq 0x13157(%rip), %rax     # 0x222e8
movq 0xe8(%rax), %rax
movslq 0x13239(%rip), %rcx     # 0x223d8
shlq $0x7, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
subl 0x1324d(%rip), %eax     # 0x223fc
subl $0x2, %eax
addl 0x1322c(%rip), %eax     # 0x223e4
movl %eax, 0x13226(%rip)     # 0x223e4
movq 0x1302b(%rip), %rax     # 0x221f0
movl 0xa5c5(%rip), %ecx      # 0x19790
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x13194(%rip)     # 0x22370
movq 0x1300d(%rip), %rax     # 0x221f0
movl 0xa5a7(%rip), %ecx      # 0x19790
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x13186(%rip)     # 0x22380
movl $0x1, 0x13184(%rip)     # 0x22388
movq $0x23a00f, 0x131a1(%rip) # imm = 0x23A00F
movq 0x130da(%rip), %rax     # 0x222f0
movq %rax, 0x131ab(%rip)     # 0x223c8
cmpq $0x0, 0x13233(%rip)     # 0x22458
je 0xf246
movq 0x1322a(%rip), %rdi     # 0x22458
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x54b0
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
jne 0xf25f
movq 0x1309b(%rip), %rdi     # 0x222e8
movl 0x13185(%rip), %esi     # 0x223d8
callq 0x52a0
movq %rax, -0x98(%rbp)
movq 0x13082(%rip), %rax     # 0x222e8
movq %rax, -0xe8(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl 0x1315f(%rip), %eax     # 0x223e0
movl %eax, -0xd8(%rbp)
movl 0x13157(%rip), %eax     # 0x223e4
movl %eax, -0xd4(%rbp)
movl 0x1315f(%rip), %eax     # 0x223f8
movl %eax, -0xd0(%rbp)
movl 0x13157(%rip), %eax     # 0x223fc
movl %eax, -0xcc(%rbp)
movq 0x13036(%rip), %rdi     # 0x222e8
movl 0x13120(%rip), %esi     # 0x223d8
callq 0x5810
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movl -0xd8(%rbp), %edx
movl -0xd4(%rbp), %ecx
movl -0xd0(%rbp), %r8d
movl -0xcc(%rbp), %r9d
movl %eax, %r11d
movq 0x13071(%rip), %r10     # 0x22360
xorl %eax, %eax
leaq 0x12ff0(%rip), %rax     # 0x222e8
addq $0x80, %rax
movl $0x0, (%rsp)
movl %r11d, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq $0x281a, 0x20(%rsp)     # imm = 0x281A
movq %rax, 0x28(%rsp)
callq 0x5230
movq %rax, 0x12fc7(%rip)     # 0x222f8
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x5090
movl $0x0, -0x24(%rbp)
movq 0x12f96(%rip), %rdi     # 0x222e8
movq -0x98(%rbp), %rsi
movl $0x10000, %edx          # imm = 0x10000
leaq -0x88(%rbp), %rcx
callq 0x5570
movq %rax, 0x12f6f(%rip)     # 0x222e0
movq 0x12f70(%rip), %rdi     # 0x222e8
movq 0x12f79(%rip), %rsi     # 0x222f8
movl 0x13073(%rip), %edx     # 0x223f8
movl 0x13071(%rip), %ecx     # 0x223fc
movq 0x12f56(%rip), %rax     # 0x222e8
movq 0xe8(%rax), %rax
movslq 0x13038(%rip), %r8      # 0x223d8
shlq $0x7, %r8
addq %r8, %rax
movl 0x38(%rax), %r8d
callq 0x58d0
movq %rax, 0x12f49(%rip)     # 0x22300
movq 0x12f2a(%rip), %rdi     # 0x222e8
movq 0x12f1b(%rip), %rsi     # 0x222e0
movq 0x12e24(%rip), %rax     # 0x221f0
movl 0xa3be(%rip), %ecx      # 0x19790
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdx
callq 0x53a0
movq 0x12f00(%rip), %rdi     # 0x222e8
movq 0x12f11(%rip), %rsi     # 0x22300
movq 0x12eea(%rip), %rdx     # 0x222e0
movl 0x12ffb(%rip), %r9d     # 0x223f8
movl 0x12ff9(%rip), %eax     # 0x223fc
xorl %r8d, %r8d
movl %r8d, %ecx
movl %eax, (%rsp)
callq 0x53b0
movslq -0x4(%rbp), %rdi
shlq $0x4, %rdi
callq 0x5ad0
movq %rax, 0x12ee3(%rip)     # 0x22308
movq 0x12ebc(%rip), %rdi     # 0x222e8
movq 0x12ecd(%rip), %rsi     # 0x22300
movq 0x12f26(%rip), %rdx     # 0x22360
movq 0x12eaf(%rip), %rcx     # 0x222f0
callq 0x5900
movq %rax, 0x12f0b(%rip)     # 0x22358
movq 0x12e94(%rip), %rdi     # 0x222e8
callq 0x100a0
cmpl $0x0, %eax
jne 0xf47f
movq 0x12e83(%rip), %rdi     # 0x222e8
xorl %eax, %eax
movl %eax, %r9d
leaq 0xd8f(%rip), %r8        # 0x10200
movq %r9, %rsi
movq %r9, %rdx
movq %r9, %rcx
callq 0x52f0
movq 0x12e62(%rip), %rdi     # 0x222e8
movq 0xab53(%rip), %rsi      # 0x19fe0
callq 0x54d0
movq %rax, -0x90(%rbp)
movq 0x12e48(%rip), %rdi     # 0x222e8
movq 0x12e51(%rip), %rsi     # 0x222f8
movq -0x90(%rbp), %rdx
callq 0x5780
movq 0x12e2e(%rip), %rdi     # 0x222e8
leaq 0x5d10(%rip), %rsi      # 0x151d1
xorl %edx, %edx
callq 0x57c0
movq %rax, 0x12e41(%rip)     # 0x22310
movq 0x12e12(%rip), %rdi     # 0x222e8
leaq 0x5cfc(%rip), %rsi      # 0x151d9
xorl %edx, %edx
callq 0x57c0
movq %rax, 0x12e2d(%rip)     # 0x22318
movq 0x12df6(%rip), %rdi     # 0x222e8
leaq 0x5cf1(%rip), %rsi      # 0x151ea
xorl %edx, %edx
callq 0x57c0
movq %rax, 0x12e19(%rip)     # 0x22320
movq 0x12dda(%rip), %rdi     # 0x222e8
leaq 0x5ce2(%rip), %rsi      # 0x151f7
xorl %edx, %edx
callq 0x57c0
movq %rax, 0x12e05(%rip)     # 0x22328
movq 0x12dbe(%rip), %rdi     # 0x222e8
movq 0x12dc7(%rip), %rsi     # 0x222f8
leaq 0x12db0(%rip), %rdx     # 0x222e8
addq $0x30, %rdx
movl $0x1, %ecx
callq 0x5420
movq 0x12d9b(%rip), %rdi     # 0x222e8
leaq 0x5cb5(%rip), %rsi      # 0x15209
xorl %edx, %edx
callq 0x57c0
movq %rax, 0x12dce(%rip)     # 0x22330
movq 0x12d7f(%rip), %rdi     # 0x222e8
movq 0x12d88(%rip), %rsi     # 0x222f8
movq 0x12db9(%rip), %rdx     # 0x22330
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
leaq -0x9c(%rbp), %rax
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x5840
movl $0x20000, 0x12e61(%rip) # imm = 0x20000
callq 0x8690
callq 0x10250
movq 0x12d30(%rip), %rdi     # 0x222e8
movq 0x12d39(%rip), %rsi     # 0x222f8
callq 0x54e0
movq 0x12d1d(%rip), %rdi     # 0x222e8
xorl %esi, %esi
callq 0x5640
movl $0x1, %edi
leaq 0x12e8a(%rip), %rsi     # 0x22468
addq $0x18, %rsi
callq 0x5120
movl $0x1, %edi
leaq 0x12e75(%rip), %rsi     # 0x22468
addq $0x28, %rsi
callq 0x5120
movq $0x0, 0x12e69(%rip) # 0x22470
movq $0x0, 0x12e66(%rip) # 0x22478
movq 0x12ccf(%rip), %rdi     # 0x222e8
leaq 0x5bf5(%rip), %rsi      # 0x15215
xorl %edx, %edx
callq 0x57c0
movq %rax, 0x12e3a(%rip)     # 0x22468
cmpq $0x0, 0x12e32(%rip)     # 0x22468
jne 0xf643
movq $0x1f, 0x12e25(%rip) # 0x22468
movq 0x12c9e(%rip), %rdi     # 0x222e8
movq 0x12c9f(%rip), %rsi     # 0x222f0
movq 0x12d00(%rip), %rdx     # 0x22358
movq 0x12d01(%rip), %rcx     # 0x22360
callq 0x11ff0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)