// File: /workspace/github_c_makefile_star2_O0/kaiserschmarrn0[P]mywm/mywm.c
// Function: main
int main(void) {
	signal(SIGINT, catch);
	signal(SIGTERM, catch);

	dpy = XOpenDisplay(0);
	conn = XGetXCBConnection(dpy);
	XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
	scr = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;

	XVisualInfo xv, *res = NULL;
	xv.depth = 32;
	int flag = 0;
	res = XGetVisualInfo(dpy, VisualDepthMask, &xv, &flag);
	if (flag > 0) {
		vis_ptr = res->visual;
		vis = res->visualid;
	} else {
		vis_ptr = DefaultVisual(dpy, 0);
		vis = scr->root_visual;
	}

	cm = xcb_generate_id(conn);
	xcb_create_colormap(conn, XCB_COLORMAP_ALLOC_NONE, cm, scr->root, vis);

	depth = (vis == scr->root_visual) ? XCB_COPY_FROM_PARENT : 32;

	for (int i = 0; i < LEN(fonts); i++) {
		xfts[i] = XftFontOpenName(dpy, 0, fonts[i]);
	}

	for (int i = 0; i < LEN(controls); i++) {
		for (int j = 0; j < PM_COUNT; j++) {
			pixmaps[i][j] = xcb_generate_id(conn);
			xcb_create_pixmap(conn, depth, pixmaps[i][j], scr->root,
					controls[i].geom.width, controls[i].geom.height);

			int w = controls[i].geom.width;
			int h = controls[i].geom.height;

			xcb_gcontext_t gc = xcb_generate_id(conn);
			uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
			uint32_t vals[2];
			vals[0] = controls[i].colors[PM_BG(j)];
			vals[1] = 0;
			xcb_create_gc(conn, gc, pixmaps[i][j], mask, vals);

			xcb_rectangle_t rect = { 0, 0, w, h };
			xcb_poly_fill_rectangle_checked(conn, pixmaps[i][j], gc, 1, &rect);

			xcb_free_gc(conn, gc);

			XftFont *font = xfts[controls[i].font_index];
			char *icon = controls[i].shape_fg;
			int len = strlen(icon);

			XGlyphInfo ret;
			XftTextExtentsUtf8(dpy, font, (XftChar8 *)icon, len, &ret);
			int x = (w - ret.width) / 2;
			int y = (controls[i].geom.height + font->ascent - font->descent) / 2;

			XftDraw *draw = XftDrawCreate(dpy, pixmaps[i][j], vis_ptr, cm);
			XftColor fg = xft_color(controls[i].colors[PM_FG(j)]);

			XftDrawStringUtf8(draw, &fg, font, x, y, (XftChar8 *)icon, len);
		}
	}

	uint32_t mask = XCB_CW_EVENT_MASK;
	uint32_t val = XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;

	xcb_change_window_attributes(conn, scr->root, mask, &val);
	xcb_flush(conn);
	
	const xcb_query_extension_reply_t *shape_reply = xcb_get_extension_data(conn, &xcb_shape_id);
	if (!shape_reply->present) {
		fprintf(stderr, "x server doesn't have xshape\n");
		return 1;
	}

	ewmh = calloc(1, sizeof(xcb_ewmh_connection_t));
	if (!ewmh) {
		fprintf(stderr, "couldn't allocate ewmh connection\n");
		return 1;
	}
	xcb_ewmh_init_atoms_replies(ewmh, xcb_ewmh_init_atoms(conn, ewmh), (void *)0);

	const char *wm_atom_name[3]; 
	wm_atom_name[0] = "WM_PROTOCOLS";
	wm_atom_name[1] = "WM_DELETE_WINDOW";
	wm_atom_name[2] = "WM_STATE";
	get_atoms(wm_atom_name, wm_atoms, WM_COUNT);

	const char *net_atom_name[1];
	net_atom_name[0] = "_NET_WM_STATE_FOCUSED";
	get_atoms(net_atom_name, &ewmh__NET_WM_STATE_FOCUSED, 0);

	xcb_atom_t supported_atoms[] = {
		ewmh->_NET_SUPPORTED,
		ewmh->_NET_WM_STATE,
		ewmh->_NET_WM_STATE_FULLSCREEN,
		ewmh->_NET_WM_STATE_STICKY,
		ewmh->_NET_WM_STATE_ABOVE,
		ewmh->_NET_WM_STATE_HIDDEN,
		ewmh->_NET_WM_WINDOW_TYPE,
		ewmh->_NET_WM_WINDOW_TYPE_DOCK,
		ewmh->_NET_FRAME_EXTENTS,

		ewmh__NET_WM_STATE_FOCUSED,

		wm_atoms[WM_PROTOCOLS],
		wm_atoms[WM_DELETE_WINDOW],
		wm_atoms[WM_STATE],
	};

	xcb_ewmh_set_supported(ewmh, 0, LEN(supported_atoms), supported_atoms);
	xcb_ewmh_set_wm_name(ewmh, scr->root, 4, "mywm");
	
	mask = XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE;
	for (int i = 0; i < LEN(grab_buttons); i++) {
		xcb_grab_button(conn, 0, scr->root, mask, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
				scr->root, XCB_NONE, grab_buttons[i].button, grab_buttons[i].mod);
	}

	grab_keys();

	for (int i = 0; i < XCB_NO_OPERATION; i++) events[i] = NULL;

	events[XCB_BUTTON_PRESS]      = button_press;
	events[XCB_CLIENT_MESSAGE]    = client_message;
	events[XCB_CONFIGURE_REQUEST] = configure_request;
	events[XCB_KEY_PRESS]         = key_press;
	events[XCB_KEY_RELEASE]       = key_release;
	events[XCB_MAP_REQUEST]       = map_request;
	events[XCB_UNMAP_NOTIFY]      = unmap_notify;
	events[XCB_DESTROY_NOTIFY]    = destroy_notify;
	events[XCB_ENTER_NOTIFY]      = enter_notify;
	events[XCB_LEAVE_NOTIFY]      = leave_notify;
	events[XCB_MAPPING_NOTIFY]    = mapping_notify;
	events[XCB_EXPOSE]            = expose;
	events[XCB_FOCUS_IN]          = focus_in;

	keysyms = xcb_key_symbols_alloc(conn);

#ifdef ROUNDED
	init_rounded_corners();
#endif
	
	create_snap_regions();
	create_margins();
	cursor_init();
	
	xcb_query_tree_reply_t *tr_reply = xcb_query_tree_reply(conn,
			xcb_query_tree(conn, scr->root), 0);

	stack[0].fwin = NULL;
	stack[1].fwin = NULL;
	stack[2].fwin = NULL;
	stack[3].fwin = NULL;

#ifdef PICKUP
	int ch_len = xcb_query_tree_children_length(tr_reply);
	xcb_window_t *children = xcb_query_tree_children(tr_reply);

	for (int i = 0; i < ch_len; i++) {
		xcb_get_window_attributes_reply_t *attr = xcb_get_window_attributes_reply(conn,
				xcb_get_window_attributes_unchecked(conn, children[i]), NULL);

		if (!attr || attr->override_redirect || attr->map_state != XCB_MAP_STATE_VIEWABLE) {
			continue;
		}

		create_window_existing(children[i]);
	}

	free(tr_reply);
#endif

	struct pollfd fd;
	fd.fd = xcb_get_file_descriptor(conn);
	fd.events = POLLIN;

	xcb_flush(conn);
	for (; !xcb_connection_has_error(conn) && sigcode == 0;) {
		if (poll(&fd, 1, -1) == -1) {
			break;
		}

		xcb_generic_event_t *ev;
		while((ev = xcb_poll_for_event(conn))) {
			if (ev->response_type == 0) {
				xcb_generic_error_t *error = (xcb_generic_error_t *) ev;
				printf("mywm: error:\n\terror_code: %d\n\tmajor_code: "
						"%d\n\tminor_code: %d\n", error->error_code,
						error->major_code, error->minor_code);
			}
	
			if (events[ev->response_type & ~0x80]) {
				events[ev->response_type & ~0x80](ev);
			}
			free(ev);
			
			xcb_flush(conn);
		}
	}

	die();

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movl $0x0, -0x4(%rbp)
movl $0x2, %edi
leaq 0xc72(%rip), %rsi       # 0x47e0
callq 0x33c0
movl $0xf, %edi
leaq 0xc61(%rip), %rsi       # 0x47e0
callq 0x33c0
xorl %eax, %eax
movl %eax, %edi
callq 0x3220
movq %rax, 0xc90c(%rip)      # 0x104a0
movq 0xc905(%rip), %rdi      # 0x104a0
callq 0x3070
movq %rax, 0xc8a1(%rip)      # 0x10448
movq 0xc8f2(%rip), %rdi      # 0x104a0
movl $0x1, %esi
callq 0x3470
movq 0xc889(%rip), %rdi      # 0x10448
callq 0x32b0
movq %rax, %rdi
callq 0x3240
movq %rax, -0x18(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq %rax, 0xc871(%rip)      # 0x10450
movq $0x0, -0x60(%rbp)
movl $0x20, -0x44(%rbp)
movl $0x0, -0x64(%rbp)
movq 0xc8a4(%rip), %rdi      # 0x104a0
movl $0x4, %esi
leaq -0x58(%rbp), %rdx
leaq -0x64(%rbp), %rcx
callq 0x3510
movq %rax, -0x60(%rbp)
cmpl $0x0, -0x64(%rbp)
jle 0x3c36
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc88a(%rip)      # 0x104b0
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, 0xc884(%rip)      # 0x104b8
jmp 0x3c5f
movq 0xc863(%rip), %rax      # 0x104a0
movq 0xe8(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, 0xc861(%rip)      # 0x104b0
movq 0xc7fa(%rip), %rax      # 0x10450
movl 0x20(%rax), %eax
movl %eax, 0xc859(%rip)      # 0x104b8
movq 0xc7e2(%rip), %rdi      # 0x10448
callq 0x3550
movl %eax, 0xc84b(%rip)      # 0x104bc
movq 0xc7d0(%rip), %rdi      # 0x10448
movl 0xc83e(%rip), %edx      # 0x104bc
movq 0xc7cb(%rip), %rax      # 0x10450
movl (%rax), %ecx
movl 0xc82a(%rip), %r8d      # 0x104b8
xorl %esi, %esi
callq 0x3430
movl %eax, -0x68(%rbp)
movl 0xc81a(%rip), %edx      # 0x104b8
movq 0xc7ab(%rip), %rax      # 0x10450
movl 0x20(%rax), %esi
movl $0x20, %eax
xorl %ecx, %ecx
cmpl %esi, %edx
cmoveq %rcx, %rax
movl %eax, 0xc805(%rip)      # 0x104c0
movl $0x0, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
cmpq $0x1, %rax
jae 0x3d06
movq 0xc7cd(%rip), %rdi      # 0x104a0
movslq -0x6c(%rbp), %rcx
leaq 0xc652(%rip), %rax      # 0x10330
movq (%rax,%rcx,8), %rdx
xorl %esi, %esi
callq 0x3420
movq %rax, %rdx
movslq -0x6c(%rbp), %rcx
leaq 0xc7b1(%rip), %rax      # 0x104a8
movq %rdx, (%rax,%rcx,8)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x3cc2
movl $0x0, -0x70(%rbp)
movslq -0x70(%rbp), %rax
cmpq $0x2, %rax
jae 0x408d
movl $0x0, -0x74(%rbp)
cmpl $0x4, -0x74(%rbp)
jge 0x407d
movq 0xc715(%rip), %rdi      # 0x10448
callq 0x3550
movl %eax, %edx
movslq -0x70(%rbp), %rcx
leaq 0xc73b(%rip), %rax      # 0x10480
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0xc6ee(%rip), %rdi      # 0x10448
movl 0xc760(%rip), %eax      # 0x104c0
movb %al, %sil
movslq -0x70(%rbp), %rcx
leaq 0xc712(%rip), %rax      # 0x10480
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq 0xc6cd(%rip), %rax      # 0x10450
movl (%rax), %ecx
movslq -0x70(%rbp), %r8
leaq 0xbc70(%rip), %rax      # 0xfa00
imulq $0x50, %r8, %r8
addq %r8, %rax
movw 0x4(%rax), %r8w
movslq -0x70(%rbp), %r9
leaq 0xbc59(%rip), %rax      # 0xfa00
imulq $0x50, %r9, %r9
addq %r9, %rax
movzbl %sil, %esi
movzwl %r8w, %r8d
movzwl 0x6(%rax), %r9d
callq 0x3100
movl %eax, -0x78(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0xbc32(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movzwl 0x4(%rax), %eax
movl %eax, -0x7c(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0xbc19(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
movl %eax, -0x80(%rbp)
movq 0xc64c(%rip), %rdi      # 0x10448
callq 0x3550
movl %eax, -0x84(%rbp)
movl $0x10004, -0x88(%rbp)   # imm = 0x10004
movslq -0x70(%rbp), %rcx
leaq 0xbbe4(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x74(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl 0x30(%rax,%rcx,4), %eax
movl %eax, -0x90(%rbp)
movl $0x0, -0x8c(%rbp)
movq 0xc5ff(%rip), %rdi      # 0x10448
movl -0x84(%rbp), %esi
movslq -0x70(%rbp), %rcx
leaq 0xc626(%rip), %rax      # 0x10480
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movl -0x88(%rbp), %ecx
leaq -0x90(%rbp), %r8
callq 0x3480
movl %eax, -0x94(%rbp)
movw $0x0, -0x9c(%rbp)
movw $0x0, -0x9a(%rbp)
movl -0x7c(%rbp), %eax
movw %ax, -0x98(%rbp)
movl -0x80(%rbp), %eax
movw %ax, -0x96(%rbp)
movq 0xc59b(%rip), %rdi      # 0x10448
movslq -0x70(%rbp), %rcx
leaq 0xc5c8(%rip), %rax      # 0x10480
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movl -0x84(%rbp), %edx
movl $0x1, %ecx
leaq -0x9c(%rbp), %r8
callq 0x3490
movl %eax, -0xa0(%rbp)
movq 0xc55e(%rip), %rdi      # 0x10448
movl -0x84(%rbp), %esi
callq 0x3190
movl %eax, -0xa4(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0xbafa(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq 0x2c(%rax), %rcx
leaq 0xc590(%rip), %rax      # 0x104a8
movq (%rax,%rcx,8), %rax
movq %rax, -0xb0(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0xbad2(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3280
movl %eax, -0xbc(%rbp)
movq 0xc547(%rip), %rdi      # 0x104a0
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movl -0xbc(%rbp), %ecx
leaq -0xc8(%rbp), %r8
callq 0x34e0
movl -0x7c(%rbp), %eax
movzwl -0xc8(%rbp), %ecx
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0xcc(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0xba62(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
movq -0xb0(%rbp), %rcx
addl (%rcx), %eax
movq -0xb0(%rbp), %rcx
subl 0x4(%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0xd0(%rbp)
movq 0xc4cf(%rip), %rdi      # 0x104a0
movslq -0x70(%rbp), %rcx
leaq 0xc4a4(%rip), %rax      # 0x10480
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, %esi
movq 0xc4bd(%rip), %rdx      # 0x104b0
movl 0xc4c3(%rip), %eax      # 0x104bc
movl %eax, %ecx
callq 0x35d0
movq %rax, -0xd8(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0xb9ee(%rip), %rax      # 0xfa00
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x74(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
movl 0x30(%rax,%rcx,4), %edi
callq 0xb100
movq %rax, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
movl -0xcc(%rbp), %ecx
movl -0xd0(%rbp), %r8d
movq -0xb8(%rbp), %r9
movl -0xbc(%rbp), %eax
leaq -0xe8(%rbp), %rsi
movl %eax, (%rsp)
callq 0x3180
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x3d22
jmp 0x407f
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x3d0d
movl $0x800, -0xec(%rbp)     # imm = 0x800
movl $0x180040, -0xf0(%rbp)  # imm = 0x180040
movq 0xc3a0(%rip), %rdi      # 0x10448
movq 0xc3a1(%rip), %rax      # 0x10450
movl (%rax), %esi
movl -0xec(%rbp), %edx
leaq -0xf0(%rbp), %rcx
callq 0x33a0
movl %eax, -0xf4(%rbp)
movq 0xc378(%rip), %rdi      # 0x10448
callq 0x3350
movq 0xc36c(%rip), %rdi      # 0x10448
movq 0xbefd(%rip), %rsi      # 0xffe0
callq 0x3170
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
cmpb $0x0, 0x8(%rax)
jne 0x4120
movq 0xbee5(%rip), %rax      # 0xffe8
movq (%rax), %rdi
leaq 0x7f17(%rip), %rsi      # 0xc024
movb $0x0, %al
callq 0x35c0
movl $0x1, -0x4(%rbp)
jmp 0x47d4
movl $0x1, %edi
movl $0x168, %esi            # imm = 0x168
callq 0x34c0
movq %rax, 0xc322(%rip)      # 0x10458
cmpq $0x0, 0xc31a(%rip)      # 0x10458
jne 0x4164
movq 0xbea1(%rip), %rax      # 0xffe8
movq (%rax), %rdi
leaq 0x7ef1(%rip), %rsi      # 0xc042
movb $0x0, %al
callq 0x35c0
movl $0x1, -0x4(%rbp)
jmp 0x47d4
movq 0xc2ed(%rip), %rax      # 0x10458
movq %rax, -0x1c8(%rbp)
movq 0xc2cf(%rip), %rdi      # 0x10448
movq 0xc2d8(%rip), %rsi      # 0x10458
callq 0x3200
movq -0x1c8(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x32a0
leaq 0x7ec6(%rip), %rax      # 0xc065
movq %rax, -0x120(%rbp)
leaq 0x7ec5(%rip), %rax      # 0xc072
movq %rax, -0x118(%rbp)
leaq 0x7ec8(%rip), %rax      # 0xc083
movq %rax, -0x110(%rbp)
leaq -0x120(%rbp), %rdi
leaq 0xc290(%rip), %rsi      # 0x10460
movl $0x3, %edx
callq 0x4800
leaq 0x7eab(%rip), %rax      # 0xc08c
movq %rax, -0x128(%rbp)
leaq -0x128(%rbp), %rdi
leaq 0xc2ce(%rip), %rsi      # 0x104c4
xorl %edx, %edx
callq 0x4800
movq 0xc254(%rip), %rax      # 0x10458
movl 0x20(%rax), %eax
movl %eax, -0x160(%rbp)
movq 0xc244(%rip), %rax      # 0x10458
movl 0x84(%rax), %eax
movl %eax, -0x15c(%rbp)
movq 0xc231(%rip), %rax      # 0x10458
movl 0x128(%rax), %eax
movl %eax, -0x158(%rbp)
movq 0xc21e(%rip), %rax      # 0x10458
movl 0x10c(%rax), %eax
movl %eax, -0x154(%rbp)
movq 0xc20b(%rip), %rax      # 0x10458
movl 0x12c(%rax), %eax
movl %eax, -0x150(%rbp)
movq 0xc1f8(%rip), %rax      # 0x10458
movl 0x124(%rax), %eax
movl %eax, -0x14c(%rbp)
movq 0xc1e5(%rip), %rax      # 0x10458
movl 0x80(%rax), %eax
movl %eax, -0x148(%rbp)
movq 0xc1d2(%rip), %rax      # 0x10458
movl 0xd4(%rax), %eax
movl %eax, -0x144(%rbp)
movq 0xc1bf(%rip), %rax      # 0x10458
movl 0xac(%rax), %eax
movl %eax, -0x140(%rbp)
movl 0xc219(%rip), %eax      # 0x104c4
movl %eax, -0x13c(%rbp)
movl 0xc1a9(%rip), %eax      # 0x10460
movl %eax, -0x138(%rbp)
movl 0xc1a1(%rip), %eax      # 0x10464
movl %eax, -0x134(%rbp)
movl 0xc199(%rip), %eax      # 0x10468
movl %eax, -0x130(%rbp)
movq 0xc17c(%rip), %rdi      # 0x10458
leaq -0x160(%rbp), %rcx
xorl %esi, %esi
movl $0xd, %edx
callq 0x34a0
movl %eax, -0x164(%rbp)
movq 0xc15c(%rip), %rdi      # 0x10458
movq 0xc14d(%rip), %rax      # 0x10450
movl (%rax), %esi
movl $0x4, %edx
leaq 0x7d91(%rip), %rcx      # 0xc0a2
callq 0x33b0
movl %eax, -0x168(%rbp)
movl $0xc, -0xec(%rbp)
movl $0x0, -0x16c(%rbp)
movslq -0x16c(%rbp), %rax
cmpq $0x2, %rax
jae 0x43dd
movq 0xc100(%rip), %rdi      # 0x10448
movq 0xc101(%rip), %rax      # 0x10450
movl (%rax), %edx
movl -0xec(%rbp), %eax
movw %ax, %cx
movq 0xc0ef(%rip), %rax      # 0x10450
movl (%rax), %r11d
movslq -0x16c(%rbp), %rsi
leaq 0xb72e(%rip), %rax      # 0xfaa0
shlq $0x4, %rsi
addq %rsi, %rax
movl 0x4(%rax), %eax
movb %al, %r10b
movslq -0x16c(%rbp), %rsi
leaq 0xb713(%rip), %rax      # 0xfaa0
shlq $0x4, %rsi
addq %rsi, %rax
xorl %esi, %esi
movl $0x1, %r9d
movzwl %cx, %ecx
movl %r9d, %r8d
movl %r11d, (%rsp)
movl $0x0, 0x8(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x10(%rsp)
movzwl (%rax), %eax
movl %eax, 0x18(%rsp)
callq 0x32c0
movl %eax, -0x170(%rbp)
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x4330
callq 0x53b0
movl $0x0, -0x174(%rbp)
cmpl $0x7f, -0x174(%rbp)
jge 0x441c
movslq -0x174(%rbp), %rcx
leaq 0xc0cd(%rip), %rax      # 0x104d0
movq $0x0, (%rax,%rcx,8)
movl -0x174(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x174(%rbp)
jmp 0x43ec
leaq 0x4ed(%rip), %rax       # 0x4910
movq %rax, 0xc0c6(%rip)      # 0x104f0
leaq 0x92f(%rip), %rax       # 0x4d60
movq %rax, 0xc1a0(%rip)      # 0x105d8
leaq 0xa21(%rip), %rax       # 0x4e60
movq %rax, 0xc142(%rip)      # 0x10588
leaq 0xc23(%rip), %rax       # 0x5070
movq %rax, 0xc08c(%rip)      # 0x104e0
leaq 0xcf5(%rip), %rax       # 0x5150
movq %rax, 0xc086(%rip)      # 0x104e8
leaq 0xd37(%rip), %rax       # 0x51a0
movq %rax, 0xc100(%rip)      # 0x10570
leaq 0xd79(%rip), %rax       # 0x51f0
movq %rax, 0xc0e2(%rip)      # 0x10560
leaq 0xddb(%rip), %rax       # 0x5260
movq %rax, 0xc0cc(%rip)      # 0x10558
leaq -0xc03(%rip), %rax      # 0x3890
movq %rax, 0xc06e(%rip)      # 0x10508
leaq -0xb31(%rip), %rax      # 0x3970
movq %rax, 0xc068(%rip)      # 0x10510
leaq 0xe01(%rip), %rax       # 0x52b0
movq %rax, 0xc12a(%rip)      # 0x105e0
leaq 0xe53(%rip), %rax       # 0x5310
movq %rax, 0xc06c(%rip)      # 0x10530
leaq 0xeb5(%rip), %rax       # 0x5380
movq %rax, 0xc046(%rip)      # 0x10518
movq 0xbf6f(%rip), %rdi      # 0x10448
callq 0x32f0
movq %rax, 0xbf8b(%rip)      # 0x10470
movb $0x0, %al
callq 0xa590
movb $0x0, %al
callq 0xa940
callq 0x6b00
movq 0xbf49(%rip), %rax      # 0x10448
movq %rax, -0x1d0(%rbp)
movq 0xbf3b(%rip), %rdi      # 0x10448
movq 0xbf3c(%rip), %rax      # 0x10450
movl (%rax), %esi
callq 0x31e0
movq -0x1d0(%rbp), %rdi
movl %eax, -0x184(%rbp)
movl -0x184(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3310
movq %rax, -0x180(%rbp)
leaq 0xc3eb(%rip), %rax      # 0x10930
movq $0x0, 0x48(%rax)
leaq 0xc3dc(%rip), %rax      # 0x10930
movq $0x0, 0x98(%rax)
leaq 0xc3ca(%rip), %rax      # 0x10930
movq $0x0, 0xe8(%rax)
leaq 0xc3b8(%rip), %rax      # 0x10930
movq $0x0, 0x138(%rax)
movq -0x180(%rbp), %rdi
callq 0x35e0
movl %eax, -0x188(%rbp)
movq -0x180(%rbp), %rdi
callq 0x3400
movq %rax, -0x190(%rbp)
movl $0x0, -0x194(%rbp)
movl -0x194(%rbp), %eax
cmpl -0x188(%rbp), %eax
jge 0x4668
movq 0xbe7d(%rip), %rax      # 0x10448
movq %rax, -0x1d8(%rbp)
movq 0xbe6f(%rip), %rdi      # 0x10448
movq -0x190(%rbp), %rax
movslq -0x194(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x3590
movq -0x1d8(%rbp), %rdi
movl %eax, -0x1a4(%rbp)
movl -0x1a4(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3290
movq %rax, -0x1a0(%rbp)
cmpq $0x0, -0x1a0(%rbp)
je 0x463c
movq -0x1a0(%rbp), %rax
movzbl 0x1b(%rax), %eax
cmpl $0x0, %eax
jne 0x463c
movq -0x1a0(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x2, %eax
je 0x463e
jmp 0x4654
movq -0x190(%rbp), %rax
movslq -0x194(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x7a40
movl -0x194(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x194(%rbp)
jmp 0x45b2
movq -0x180(%rbp), %rdi
callq 0x3270
movq 0xbdcd(%rip), %rdi      # 0x10448
callq 0x31f0
movl %eax, -0x1ac(%rbp)
movw $0x1, -0x1a8(%rbp)
movq 0xbdb2(%rip), %rdi      # 0x10448
callq 0x3350
movq 0xbda6(%rip), %rdi      # 0x10448
callq 0x30b0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1d9(%rbp)
jne 0x46c6
cmpl $0x0, 0xbd83(%rip)      # 0x10440
sete %al
movb %al, -0x1d9(%rbp)
movb -0x1d9(%rbp), %al
testb $0x1, %al
jne 0x46d5
jmp 0x47c8
leaq -0x1ac(%rbp), %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3330
cmpl $-0x1, %eax
jne 0x46f5
jmp 0x47c8
jmp 0x46f7
movq 0xbd4a(%rip), %rdi      # 0x10448
callq 0x3380
movq %rax, -0x1b8(%rbp)
cmpq $0x0, %rax
je 0x47c3
movq -0x1b8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4760
movq -0x1b8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movzbl 0x1(%rax), %esi
movq -0x1c0(%rbp), %rax
movzbl 0xa(%rax), %edx
movq -0x1c0(%rbp), %rax
movzwl 0x8(%rax), %ecx
leaq 0x794e(%rip), %rdi      # 0xc0a7
movb $0x0, %al
callq 0x3060
movq -0x1b8(%rbp), %rax
movzbl (%rax), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
movslq %eax, %rcx
leaq 0xbd57(%rip), %rax      # 0x104d0
cmpq $0x0, (%rax,%rcx,8)
je 0x47a6
movq -0x1b8(%rbp), %rax
movzbl (%rax), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
movslq %eax, %rcx
leaq 0xbd37(%rip), %rax      # 0x104d0
movq (%rax,%rcx,8), %rax
movq -0x1b8(%rbp), %rdi
callq *%rax
movq -0x1b8(%rbp), %rdi
callq 0x3270
movq 0xbc8f(%rip), %rdi      # 0x10448
callq 0x3350
jmp 0x46f7
jmp 0x469b
callq 0x3a00
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq