// File: /workspace/github_c_makefile_star2_O3/acidDrain[P]st/x.c
// Function: xinit
void
xinit(int w, int h)
{
	XGCValues gcvalues;
	Cursor cursor;
	Window parent;
	pid_t thispid = getpid();
	XColor xmousefg, xmousebg;
	XWindowAttributes attr;
	XVisualInfo vis;

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

	if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
		parent = XRootWindow(xw.dpy, xw.scr);
		xw.depth = 32;
	} else {
		XGetWindowAttributes(xw.dpy, parent, &attr);
		xw.depth = attr.depth;
	}

	XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
	xw.vis = vis.visual;

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

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

	/* spare fonts */
	xloadsparefonts();

	/* colors */
	xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
	xloadcols();

	/* adjust fixed window geometry */
	switch (geometry) {
	case CellGeometry:
		win.w = 2 * borderpx + w * win.cw;
		win.h = 2 * borderpx + h * win.ch;
		break;
	case PixelGeometry:
		win.w = w;
		win.h = h;
		break;
	}
	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;

	xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
			win.w, win.h, 0, xw.depth, InputOutput,
			xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
			| CWEventMask | CWColormap, &xw.attrs);

	memset(&gcvalues, 0, sizeof(gcvalues));
	gcvalues.graphics_exposures = False;
	xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
	dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
	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 = 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);
	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
pushq %r15
pushq %r14
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movl %esi, %ebx
movl %edi, %ebp
callq 0x52c0
movl %eax, 0xc(%rsp)
xorl %edi, %edi
callq 0x5300
movq %rax, 0x11814(%rip)     # 0x1df60
testq %rax, %rax
jne 0xc766
leaq 0x4834(%rip), %rdi      # 0x10f8c
xorl %eax, %eax
callq 0x5f46
movq 0x117fa(%rip), %rax     # 0x1df60
movq %rax, %rdi
callq 0x54d0
movl %eax, 0x118d4(%rip)     # 0x1e048
movq 0x11955(%rip), %rdi     # 0x1e0d0
testq %rdi, %rdi
je 0xc7b7
xorl %esi, %esi
xorl %edx, %edx
callq 0x5500
testq %rax, %rax
je 0xc7b1
movq %rax, %r14
movq 0x117c8(%rip), %rdi     # 0x1df60
leaq 0xf0(%rsp), %r15
movq %rax, %rsi
movq %r15, %rdx
callq 0x5830
movl 0x14(%r15), %edx
jmp 0xc7cd
movl 0x11891(%rip), %eax     # 0x1e048
movq 0x117a2(%rip), %rdi     # 0x1df60
movl %eax, %esi
callq 0x52e0
movq %rax, %r14
movl $0x20, %edx
movl %edx, 0x1187d(%rip)     # 0x1e050
movq 0x11786(%rip), %rdi     # 0x1df60
movl 0x11868(%rip), %esi     # 0x1e048
leaq 0x30(%rsp), %r15
movl $0x4, %ecx
movq %r15, %r8
callq 0x5250
movq (%r15), %rax
movq %rax, 0x117d4(%rip)     # 0x1dfd0
callq 0x5980
testl %eax, %eax
jne 0xc813
leaq 0x4794(%rip), %rdi      # 0x10fa0
xorl %eax, %eax
callq 0x5f46
movq 0x1188e(%rip), %rax     # 0x1e0a8
testq %rax, %rax
leaq 0x47d6(%rip), %rdi      # 0x10ffa
cmovneq %rax, %rdi
movq %rdi, 0x11901(%rip)     # 0x1e130
xorps %xmm0, %xmm0
callq 0xccc9
callq 0xcf5b
movq 0x1171d(%rip), %rdi     # 0x1df60
movq 0x11786(%rip), %rdx     # 0x1dfd0
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x52a0
movq %rax, 0x1170d(%rip)     # 0x1df68
callq 0xaa8a
cmpb $0x1, 0x11849(%rip)     # 0x1e0b0
jne 0xc87d
imull 0x11814(%rip), %ebp     # 0x1e084
addl $0x18, %ebp
imull 0x11806(%rip), %ebx     # 0x1e080
addl $0x18, %ebx
movl %ebp, 0x117f5(%rip)     # 0x1e078
movl %ebx, 0x117f3(%rip)     # 0x1e07c
movl 0x117cd(%rip), %eax     # 0x1e05c
movq 0x116ca(%rip), %rdi     # 0x1df60
testb $0x10, %al
je 0xc8c3
movq 0xe8(%rdi), %rcx
movslq 0x117a0(%rip), %rdx     # 0x1e048
shlq $0x7, %rdx
movl 0x18(%rcx,%rdx), %ecx
movl 0x1179e(%rip), %edx     # 0x1e054
subl %ebp, %ecx
addl %edx, %ecx
addl $-0x2, %ecx
movl %ecx, 0x11791(%rip)     # 0x1e054
movl 0x1178f(%rip), %ecx     # 0x1e058
testb $0x20, %al
je 0xc8f0
movq 0xe8(%rdi), %rax
movslq 0x1176d(%rip), %rdx     # 0x1e048
shlq $0x7, %rdx
movl 0x1c(%rax,%rdx), %eax
subl %ebx, %eax
addl %eax, %ecx
addl $-0x2, %ecx
movl %ecx, 0x11768(%rip)     # 0x1e058
movq 0x11571(%rip), %rax     # 0x1de68
movl 0x1155f(%rip), %edx     # 0x1de5c
shlq $0x4, %rdx
movq (%rax,%rdx), %rax
movq %rax, 0x116d4(%rip)     # 0x1dfe0
movq %rax, 0x116dd(%rip)     # 0x1dff0
movl $0x1, %eax
movl %eax, 0x116da(%rip)     # 0x1dff8
movq $0x23a00f, 0x116f7(%rip) # imm = 0x23A00F
movq 0x11638(%rip), %rdx     # 0x1df68
movq %rdx, 0x11701(%rip)     # 0x1e038
movl 0x11717(%rip), %edx     # 0x1e054
movl 0x1170c(%rip), %r10d    # 0x1e050
leaq 0x1168d(%rip), %r11     # 0x1dfd8
movq %r14, %rsi
movl %ebp, %r8d
movl %ebx, %r9d
pushq %r11
pushq $0x281a                 # imm = 0x281A
pushq 0x1166f(%rip)           # 0x1dfd0
pushq %rax
pushq %r10
pushq $0x0
callq 0x5270
addq $0x30, %rsp
movq %rax, 0x115fa(%rip)     # 0x1df70
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rbx
movaps %xmm0, (%rbx)
movaps %xmm0, 0x10(%rbx)
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, 0x30(%rbx)
movaps %xmm0, 0x40(%rbx)
movaps %xmm0, 0x50(%rbx)
movaps %xmm0, 0x60(%rbx)
movaps %xmm0, 0x70(%rbx)
movq 0x115bc(%rip), %rdi     # 0x1df60
movl 0x116ce(%rip), %edx     # 0x1e078
movl 0x116cc(%rip), %ecx     # 0x1e07c
movl 0x11699(%rip), %r8d     # 0x1e050
movq %rax, %rsi
callq 0x5900
movq %rax, 0x115b2(%rip)     # 0x1df78
movq 0x11593(%rip), %rdi     # 0x1df60
movl $0x10000, %edx          # imm = 0x10000
movq %rax, %rsi
movq %rbx, %rcx
callq 0x55b0
movq %rax, 0x11574(%rip)     # 0x1df58
movq 0x11575(%rip), %rdi     # 0x1df60
movq 0x11476(%rip), %rcx     # 0x1de68
movl 0x11464(%rip), %edx     # 0x1de5c
shlq $0x4, %rdx
movq (%rcx,%rdx), %rdx
movq %rax, %rsi
callq 0x53e0
movq 0x11551(%rip), %rdi     # 0x1df60
movq 0x11562(%rip), %rsi     # 0x1df78
movq 0x1153b(%rip), %rdx     # 0x1df58
movl 0x11654(%rip), %r9d     # 0x1e078
movl 0x11652(%rip), %eax     # 0x1e07c
subq $0x8, %rsp
xorl %ecx, %ecx
xorl %r8d, %r8d
pushq %rax
callq 0x53f0
addq $0x10, %rsp
movl 0xab11(%rip), %edi      # 0x17554
shlq $0x4, %rdi
callq 0x5f1c
movq %rax, 0x1152d(%rip)     # 0x1df80
movq 0x11506(%rip), %rdi     # 0x1df60
movq 0x11517(%rip), %rsi     # 0x1df78
movq 0x11568(%rip), %rdx     # 0x1dfd0
movq 0x114f9(%rip), %rcx     # 0x1df68
callq 0x5930
movq %rax, 0x1154d(%rip)     # 0x1dfc8
callq 0xd1b9
testl %eax, %eax
jne 0xcaa0
movq 0x114d5(%rip), %rdi     # 0x1df60
leaq 0x812(%rip), %r8        # 0xd2a4
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x5340
movq 0x114b9(%rip), %rdi     # 0x1df60
movl $0x98, %esi
callq 0x5090
movq %rax, %rbx
movq 0x114a5(%rip), %rdi     # 0x1df60
movq 0x114ae(%rip), %rsi     # 0x1df70
movq %rax, %rdx
callq 0x57b0
movq 0x1148f(%rip), %rdi     # 0x1df60
movq 0x11490(%rip), %rsi     # 0x1df68
movq 0x11581(%rip), %rax     # 0x1e060
movq 0x38(%rax), %rdx
leaq 0x20(%rsp), %rcx
callq 0x5750
testl %eax, %eax
jne 0xcb00
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movw $0xffff, 0x2c(%rsp)     # imm = 0xFFFF
movq 0x11459(%rip), %rdi     # 0x1df60
movq 0x1145a(%rip), %rsi     # 0x1df68
movq 0x1154b(%rip), %rax     # 0x1e060
movq (%rax), %rdx
leaq 0x10(%rsp), %rcx
callq 0x5750
testl %eax, %eax
jne 0xcb35
movl $0x0, 0x18(%rsp)
movw $0x0, 0x1c(%rsp)
movq 0x11424(%rip), %rdi     # 0x1df60
leaq 0x20(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %rbx, %rsi
callq 0x52f0
movq 0x1140b(%rip), %rdi     # 0x1df60
leaq 0x4460(%rip), %rsi      # 0x10fbc
xorl %edx, %edx
callq 0x57f0
movq %rax, 0x1141e(%rip)     # 0x1df88
movq 0x113ef(%rip), %rdi     # 0x1df60
leaq 0x444c(%rip), %rsi      # 0x10fc4
xorl %edx, %edx
callq 0x57f0
movq %rax, 0x1140a(%rip)     # 0x1df90
leaq 0x11403(%rip), %rbx     # 0x1df90
movq 0x113cc(%rip), %rdi     # 0x1df60
leaq 0x443a(%rip), %rsi      # 0x10fd5
xorl %edx, %edx
callq 0x57f0
movq %rax, 0x113ef(%rip)     # 0x1df98
movq 0x113b0(%rip), %rdi     # 0x1df60
movq 0x113b9(%rip), %rsi     # 0x1df70
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x5470
movq 0x11395(%rip), %rdi     # 0x1df60
leaq 0x4410(%rip), %rsi      # 0x10fe2
xorl %edx, %edx
callq 0x57f0
movq %rax, 0x113c0(%rip)     # 0x1dfa0
movq 0x11379(%rip), %rdi     # 0x1df60
movq 0x11382(%rip), %rsi     # 0x1df70
leaq 0xc(%rsp), %r10
movl $0x6, %ecx
movq %rax, %rdx
movl $0x20, %r8d
xorl %r9d, %r9d
pushq $0x1
pushq %r10
callq 0x5860
addq $0x10, %rsp
movl $0x20000, 0x1146d(%rip) # imm = 0x20000
callq 0x8120
callq 0xd2cd
movq 0x11334(%rip), %rdi     # 0x1df60
movq 0x1133d(%rip), %rsi     # 0x1df70
callq 0x5520
movq 0x11321(%rip), %rdi     # 0x1df60
xorl %esi, %esi
callq 0x5670
leaq 0x114ab(%rip), %rsi     # 0x1e0f8
movl $0x1, %edi
callq 0x5140
leaq 0x114aa(%rip), %rsi     # 0x1e108
movl $0x1, %edi
callq 0x5140
xorps %xmm0, %xmm0
movups %xmm0, 0x11476(%rip)    # 0x1e0e8
movq 0x112e7(%rip), %rdi     # 0x1df60
leaq 0x436e(%rip), %rsi      # 0x10fee
xorl %edx, %edx
callq 0x57f0
testq %rax, %rax
movl $0x1f, %ecx
cmovneq %rax, %rcx
movq %rcx, 0x11446(%rip)     # 0x1e0e0
movq 0x112bf(%rip), %rdi     # 0x1df60
movq 0x112c0(%rip), %rsi     # 0x1df68
movq 0x11319(%rip), %rdx     # 0x1dfc8
movq 0x1131a(%rip), %rcx     # 0x1dfd0
callq 0xe528
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r14
popq %r15
popq %rbp
retq