// File: /workspace/github_c_makefile_star2_O0/odknt[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;
	cairo_surface_t *surface;

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

	configinit(xw.dpy);
	FT_Init_FreeType(&ftlib);

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

	/* 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));

	/* cairo rendering context */
	surface = cairo_xlib_surface_create(xw.dpy, xw.buf, xw.vis, win.w, win.h);
	xw.draw = cairo_create(surface);
	cairo_surface_destroy(surface);

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

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

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

	if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
		xmousefg.red   = 0xffff;
		xmousefg.green = 0xffff;
		xmousefg.blue  = 0xffff;
	}

	if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
		xmousebg.red   = 0x0000;
		xmousebg.green = 0x0000;
		xmousebg.blue  = 0x0000;
	}

	XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);

	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;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
callq 0x62e0
movl %eax, -0x9c(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x6340
movq %rax, 0x12194(%rip)     # 0x22590
cmpq $0x0, %rax
jne 0x10410
leaq 0x4f49(%rip), %rdi      # 0x15352
movb $0x0, %al
callq 0x6c20
movq 0x12179(%rip), %rdi     # 0x22590
callq 0x6590
movl %eax, 0x1225e(%rip)     # 0x22680
movq 0x12167(%rip), %rdi     # 0x22590
movl 0x12251(%rip), %esi     # 0x22680
callq 0x6300
movq %rax, 0x121cd(%rip)     # 0x22608
movq 0x1214e(%rip), %rdi     # 0x22590
callq 0x11340
leaq 0x12262(%rip), %rdi     # 0x226b0
callq 0x65b0
callq 0x6a60
cmpl $0x0, %eax
jne 0x1046b
leaq 0x4f02(%rip), %rdi      # 0x15366
movb $0x0, %al
callq 0x6c20
movq 0x1211e(%rip), %rdi     # 0x22590
movl 0x12208(%rip), %esi     # 0x22680
callq 0x66a0
movq %rax, 0x12114(%rip)     # 0x22598
callq 0xdda0
movl 0x9b6d(%rip), %eax      # 0x19ffc
shll %eax
movl -0x4(%rbp), %ecx
imull 0x12231(%rip), %ecx     # 0x226cc
addl %ecx, %eax
movl %eax, 0x1221d(%rip)     # 0x226c0
movl 0x9b53(%rip), %eax      # 0x19ffc
shll %eax
movl -0x8(%rbp), %ecx
imull 0x12213(%rip), %ecx     # 0x226c8
addl %ecx, %eax
movl %eax, 0x12207(%rip)     # 0x226c4
movl 0x121cd(%rip), %eax     # 0x22690
andl $0x10, %eax
cmpl $0x0, %eax
je 0x104ff
movq 0x120be(%rip), %rax     # 0x22590
movq 0xe8(%rax), %rax
movslq 0x121a0(%rip), %rcx     # 0x22680
shlq $0x7, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
subl 0x121d0(%rip), %eax     # 0x226c0
subl $0x2, %eax
addl 0x1218f(%rip), %eax     # 0x22688
movl %eax, 0x12189(%rip)     # 0x22688
movl 0x1218b(%rip), %eax     # 0x22690
andl $0x20, %eax
cmpl $0x0, %eax
je 0x10541
movq 0x1207c(%rip), %rax     # 0x22590
movq 0xe8(%rax), %rax
movslq 0x1215e(%rip), %rcx     # 0x22680
shlq $0x7, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
subl 0x12192(%rip), %eax     # 0x226c4
subl $0x2, %eax
addl 0x12151(%rip), %eax     # 0x2268c
movl %eax, 0x1214b(%rip)     # 0x2268c
movq 0x11f10(%rip), %rax     # 0x22458
movl 0x9262(%rip), %ecx      # 0x197b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x120b9(%rip)     # 0x22618
movq 0x11ef2(%rip), %rax     # 0x22458
movl 0x9244(%rip), %ecx      # 0x197b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x120ab(%rip)     # 0x22628
movl $0x1, 0x120a9(%rip)     # 0x22630
movq $0x23a00f, 0x120c6(%rip) # imm = 0x23A00F
movq 0x11fff(%rip), %rax     # 0x22598
movq %rax, 0x120d0(%rip)     # 0x22670
cmpq $0x0, 0x12170(%rip)     # 0x22718
je 0x105c9
movq 0x12167(%rip), %rdi     # 0x22718
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x65d0
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
jne 0x105e2
movq 0x11fc0(%rip), %rdi     # 0x22590
movl 0x120aa(%rip), %esi     # 0x22680
callq 0x6310
movq %rax, -0x98(%rbp)
movq 0x11fa7(%rip), %rax     # 0x22590
movq %rax, -0xe8(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl 0x12084(%rip), %eax     # 0x22688
movl %eax, -0xd8(%rbp)
movl 0x1207c(%rip), %eax     # 0x2268c
movl %eax, -0xd4(%rbp)
movl 0x120a4(%rip), %eax     # 0x226c0
movl %eax, -0xd0(%rbp)
movl 0x1209c(%rip), %eax     # 0x226c4
movl %eax, -0xcc(%rbp)
movq 0x11f5b(%rip), %rdi     # 0x22590
movl 0x12045(%rip), %esi     # 0x22680
callq 0x68d0
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 0x11f96(%rip), %r10     # 0x22608
xorl %eax, %eax
leaq 0x11f15(%rip), %rax     # 0x22590
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 0x62b0
movq %rax, 0x11eec(%rip)     # 0x225a0
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x60b0
movl $0x0, -0x24(%rbp)
movq 0x11ebb(%rip), %rdi     # 0x22590
movq -0x98(%rbp), %rsi
movl $0x10000, %edx          # imm = 0x10000
leaq -0x88(%rbp), %rcx
callq 0x6660
movq %rax, 0x11e94(%rip)     # 0x22588
movq 0x11e95(%rip), %rdi     # 0x22590
movq 0x11e9e(%rip), %rsi     # 0x225a0
movl 0x11fb8(%rip), %edx     # 0x226c0
movl 0x11fb6(%rip), %ecx     # 0x226c4
movq 0x11e7b(%rip), %rax     # 0x22590
movq 0xe8(%rax), %rax
movslq 0x11f5d(%rip), %r8      # 0x22680
shlq $0x7, %r8
addq %r8, %rax
movl 0x38(%rax), %r8d
callq 0x69b0
movq %rax, 0x11e6e(%rip)     # 0x225a8
movq 0x11e4f(%rip), %rdi     # 0x22590
movq 0x11e40(%rip), %rsi     # 0x22588
movq 0x11d09(%rip), %rax     # 0x22458
movl 0x905b(%rip), %ecx      # 0x197b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdx
callq 0x6470
movq 0x11e25(%rip), %rdi     # 0x22590
movq 0x11e36(%rip), %rsi     # 0x225a8
movq 0x11e0f(%rip), %rdx     # 0x22588
movl 0x11f40(%rip), %r9d     # 0x226c0
movl 0x11f3e(%rip), %eax     # 0x226c4
xorl %r8d, %r8d
movl %r8d, %ecx
movl %eax, (%rsp)
callq 0x6480
movslq -0x4(%rbp), %rdi
shlq $0x5, %rdi
callq 0x6bd0
movq %rax, 0x11e08(%rip)     # 0x225b0
movq 0x11de1(%rip), %rdi     # 0x22590
movq 0x11df2(%rip), %rsi     # 0x225a8
movq 0x11e4b(%rip), %rdx     # 0x22608
movl 0x11efd(%rip), %ecx     # 0x226c0
movl 0x11efa(%rip), %r8d     # 0x226c4
callq 0x6520
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x6500
movq %rax, 0x11e17(%rip)     # 0x22600
movq -0xc8(%rbp), %rdi
callq 0x68a0
cmpq $0x0, 0x11f03(%rip)     # 0x22700
jne 0x1080f
movq 0x8fb2(%rip), %rax      # 0x197b8
movq %rax, -0xf0(%rbp)
jmp 0x1081d
movq 0x11eea(%rip), %rax     # 0x22700
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, 0x11f3d(%rip)     # 0x22768
movq 0x11f36(%rip), %rdi     # 0x22768
xorps %xmm0, %xmm0
callq 0x113d0
movq 0x11d4f(%rip), %rdi     # 0x22590
callq 0x116e0
cmpl $0x0, %eax
jne 0x1086c
movq 0x11d3e(%rip), %rdi     # 0x22590
xorl %eax, %eax
movl %eax, %r9d
leaq 0x10a2(%rip), %r8       # 0x11900
movq %r9, %rsi
movq %r9, %rdx
movq %r9, %rcx
callq 0x6380
movq 0x11d1d(%rip), %rdi     # 0x22590
movl 0x9a6b(%rip), %esi      # 0x1a2e4
callq 0x6080
movq %rax, -0x90(%rbp)
movq 0x11d04(%rip), %rdi     # 0x22590
movq 0x11d0d(%rip), %rsi     # 0x225a0
movq -0x90(%rbp), %rdx
callq 0x6830
movq 0x11cea(%rip), %rdi     # 0x22590
movq 0x11ceb(%rip), %rsi     # 0x22598
movl 0x9a35(%rip), %eax      # 0x1a2e8
movl %eax, %ecx
leaq 0x8f04(%rip), %rax      # 0x197c0
movq (%rax,%rcx,8), %rdx
leaq -0xb0(%rbp), %rcx
callq 0x67d0
cmpl $0x0, %eax
jne 0x108ec
movw $0xffff, -0xa8(%rbp)    # imm = 0xFFFF
movw $0xffff, -0xa6(%rbp)    # imm = 0xFFFF
movw $0xffff, -0xa4(%rbp)    # imm = 0xFFFF
movq 0x11c9d(%rip), %rdi     # 0x22590
movq 0x11c9e(%rip), %rsi     # 0x22598
movl 0x11e70(%rip), %eax     # 0x22770
movl %eax, %ecx
leaq 0x8eb7(%rip), %rax      # 0x197c0
movq (%rax,%rcx,8), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x67d0
cmpl $0x0, %eax
jne 0x10939
movw $0x0, -0xb8(%rbp)
movw $0x0, -0xb6(%rbp)
movw $0x0, -0xb4(%rbp)
movq 0x11c50(%rip), %rdi     # 0x22590
movq -0x90(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x6330
movq 0x11c2f(%rip), %rdi     # 0x22590
leaq 0x4a1a(%rip), %rsi      # 0x15382
xorl %edx, %edx
callq 0x6870
movq %rax, 0x11c42(%rip)     # 0x225b8
movq 0x11c13(%rip), %rdi     # 0x22590
leaq 0x4a06(%rip), %rsi      # 0x1538a
xorl %edx, %edx
callq 0x6870
movq %rax, 0x11c2e(%rip)     # 0x225c0
movq 0x11bf7(%rip), %rdi     # 0x22590
leaq 0x49fb(%rip), %rsi      # 0x1539b
xorl %edx, %edx
callq 0x6870
movq %rax, 0x11c1a(%rip)     # 0x225c8
movq 0x11bdb(%rip), %rdi     # 0x22590
leaq 0x49ec(%rip), %rsi      # 0x153a8
xorl %edx, %edx
callq 0x6870
movq %rax, 0x11c06(%rip)     # 0x225d0
movq 0x11bbf(%rip), %rdi     # 0x22590
movq 0x11bc8(%rip), %rsi     # 0x225a0
leaq 0x11bb1(%rip), %rdx     # 0x22590
addq $0x30, %rdx
movl $0x1, %ecx
callq 0x6530
movq 0x11b9c(%rip), %rdi     # 0x22590
leaq 0x49bf(%rip), %rsi      # 0x153ba
xorl %edx, %edx
callq 0x6870
movq %rax, 0x11bcf(%rip)     # 0x225d8
movq 0x11b80(%rip), %rdi     # 0x22590
movq 0x11b89(%rip), %rsi     # 0x225a0
movq 0x11bba(%rip), %rdx     # 0x225d8
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
leaq -0x9c(%rbp), %rax
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x68f0
movl $0x20000, 0x11c86(%rip) # imm = 0x20000
callq 0x9bd0
callq 0x11950
movq 0x11b31(%rip), %rdi     # 0x22590
movq 0x11b3a(%rip), %rsi     # 0x225a0
callq 0x65f0
movq 0x11b1e(%rip), %rdi     # 0x22590
xorl %esi, %esi
callq 0x6730
movl $0x1, %edi
leaq 0x11ca3(%rip), %rsi     # 0x22728
addq $0x18, %rsi
callq 0x6140
movl $0x1, %edi
leaq 0x11c8e(%rip), %rsi     # 0x22728
addq $0x28, %rsi
callq 0x6140
movq $0x0, 0x11c82(%rip) # 0x22730
movq $0x0, 0x11c7f(%rip) # 0x22738
movq 0x11ad0(%rip), %rdi     # 0x22590
leaq 0x48ff(%rip), %rsi      # 0x153c6
xorl %edx, %edx
callq 0x6870
movq %rax, 0x11c53(%rip)     # 0x22728
cmpq $0x0, 0x11c4b(%rip)     # 0x22728
jne 0x10aea
movq $0x1f, 0x11c3e(%rip) # 0x22728
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)