// File: /workspace/github_c_makefile_star2_O2/odknt[P]st/x.c
// Function: selrequest
void
selrequest(XEvent *e)
{
	XSelectionRequestEvent *xsre;
	XSelectionEvent xev;
	Atom xa_targets, string, clipboard;
	char *seltext;

	xsre = (XSelectionRequestEvent *) e;
	xev.type = SelectionNotify;
	xev.requestor = xsre->requestor;
	xev.selection = xsre->selection;
	xev.target = xsre->target;
	xev.time = xsre->time;
	if (xsre->property == None)
		xsre->property = xsre->target;

	/* reject */
	xev.property = None;

	xa_targets = XInternAtom(xw.dpy, "TARGETS", 0);
	if (xsre->target == xa_targets) {
		/* respond with the supported type */
		string = xsel.xtarget;
		XChangeProperty(xsre->display, xsre->requestor, xsre->property,
				XA_ATOM, 32, PropModeReplace,
				(uchar *) &string, 1);
		xev.property = xsre->property;
	} else if (xsre->target == xsel.xtarget || xsre->target == XA_STRING) {
		/*
		 * xith XA_STRING non ascii characters may be incorrect in the
		 * requestor. It is not our problem, use utf8.
		 */
		clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
		if (xsre->selection == XA_PRIMARY) {
			seltext = xsel.primary;
		} else if (xsre->selection == clipboard) {
			seltext = xsel.clipboard;
		} else {
			fprintf(stderr,
				"Unhandled clipboard selection 0x%lx\n",
				xsre->selection);
			return;
		}
		if (seltext != NULL) {
			XChangeProperty(xsre->display, xsre->requestor,
					xsre->property, xsre->target,
					8, PropModeReplace,
					(uchar *)seltext, strlen(seltext));
			xev.property = xsre->property;
		}
	}

	/* all done, send a notification to the listener */
	if (!XSendEvent(xsre->display, xsre->requestor, 1, 0, (XEvent *) &xev))
		fprintf(stderr, "Error sending SelectionNotify event\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movl $0x1f, 0x10(%rsp)
movups 0x28(%rdi), %xmm0
movups %xmm0, 0x30(%rsp)
movq 0x38(%rdi), %rax
movq %rax, 0x40(%rsp)
movq 0x48(%rdi), %rcx
movq %rcx, 0x50(%rsp)
cmpq $0x0, 0x40(%rdi)
jne 0xe939
movq %rax, 0x40(%rbx)
andq $0x0, 0x48(%rsp)
movq 0xfeba(%rip), %rdi      # 0x1e800
leaq 0x2d5a(%rip), %rsi      # 0x116a7
xorl %edx, %edx
callq 0x6860
movq 0x38(%rbx), %rcx
movq 0x10039(%rip), %rdx     # 0x1e998
cmpq %rax, %rcx
jne 0xe98a
leaq 0x8(%rsp), %rax
movq %rdx, (%rax)
movq 0x18(%rbx), %rdi
movq 0x28(%rbx), %rsi
movq 0x40(%rbx), %rdx
pushq $0x4
popq %rcx
pushq $0x20
popq %r8
xorl %r9d, %r9d
pushq $0x1
pushq %rax
jmp 0xea0d
cmpq %rdx, %rcx
setne %al
cmpq $0x1f, %rcx
setne %cl
testb %al, %cl
jne 0xea1f
movq 0xfe5a(%rip), %rdi      # 0x1e800
leaq 0x25e4(%rip), %rsi      # 0x10f91
xorl %edx, %edx
callq 0x6860
movq 0x30(%rbx), %rdx
cmpq $0x1, %rdx
jne 0xe9c7
leaq 0xffdb(%rip), %rax      # 0x1e9a0
jmp 0xe9d7
cmpq %rax, %rdx
jne 0xea67
leaq 0xffd1(%rip), %rax      # 0x1e9a8
movq (%rax), %r14
testq %r14, %r14
je 0xea1f
movq 0x18(%rbx), %r15
movq 0x28(%rbx), %r12
movq 0x40(%rbx), %r13
movq 0x38(%rbx), %rbp
movq %r14, %rdi
callq 0x6410
pushq $0x8
popq %r8
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %r9d, %r9d
pushq %rax
pushq %r14
callq 0x68e0
addq $0x10, %rsp
movq 0x40(%rbx), %rax
movq %rax, 0x48(%rsp)
movq 0x18(%rbx), %rdi
movq 0x28(%rbx), %rsi
pushq $0x1
popq %rdx
leaq 0x10(%rsp), %r8
xorl %ecx, %ecx
callq 0x6750
testl %eax, %eax
je 0xea49
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x85a0(%rip), %rax      # 0x16ff0
movq (%rax), %rcx
leaq 0x2c7a(%rip), %rdi      # 0x116d4
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x6950
jmp 0xea3a
movq 0x8582(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
leaq 0x2c37(%rip), %rsi      # 0x116af
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x69d0