// File: /workspace/github_c_makefile_star2_O1/9wm[P]9wm/menu.c
// Function: button
void
button(XButtonEvent * e)
{
	int n, shift;
	Client *c;
	Window dw;
	ScreenInfo *s;

	curtime = e->time;
	s = getscreen(e->root);
	if (s == 0)
		return;
	c = getclient(e->window, 0);
	if (c) {
		e->x += c->x - BORDER + 1;
		e->y += c->y - BORDER + 1;
	} else if (e->window != e->root)
		XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw);
	switch (e->button) {
	case Button1:
		if (c) {
			XMapRaised(dpy, c->parent);
			top(c);
			active(c);
		}
		return;
	case Button2:
		if ((e->state & (ShiftMask | ControlMask)) == (ShiftMask | ControlMask)) {
			menuhit(e, &egg);
		} else {
			spawn(s, "9wm-mm");
		}
		return;
	default:
		return;
	case Button3:
		break;
	}

	if (current && current->screen == s)
		cmapnofocus(s);
	switch (n = menuhit(e, &b3menu)) {
	case 0:		/* New */
		spawn(s, termprog);
		break;
	case 1:		/* Reshape */
		reshape(selectwin(1, 0, s));
		break;
	case 2:		/* Move */
		move(selectwin(0, 0, s));
		break;
	case 3:		/* Delete */
		shift = 0;
		c = selectwin(1, &shift, s);
		delete(c, shift);
		break;
	case 4:		/* Hide */
		hide(selectwin(1, 0, s));
		break;
	default:		/* unhide window */
		unhide(n - B3FIXED, 1);
		break;
	case -1:		/* nothing */
		break;
	}
	if (current && current->screen == s)
		cmapfocus(current);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
movl 0x38(%rdi), %eax
leaq 0x6a96(%rip), %rcx      # 0xb998
movl %eax, (%rcx)
movq 0x28(%rdi), %rdi
xorl %eax, %eax
callq 0x340c
testq %rax, %rax
je 0x511e
movq %rax, %rbx
movq 0x20(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x58e1
movq %rax, %r15
testq %rax, %rax
je 0x4f5f
movl 0x28(%r15), %eax
leaq 0x63e5(%rip), %rcx      # 0xb320
movl (%rcx), %ecx
subl %ecx, %eax
movl 0x40(%r14), %edx
movl 0x44(%r14), %esi
addl %edx, %eax
incl %eax
movl %eax, 0x40(%r14)
movl 0x2c(%r15), %eax
subl %ecx, %eax
addl %esi, %eax
incl %eax
movl %eax, 0x44(%r14)
jmp 0x4f98
movq 0x20(%r14), %rsi
cmpq 0x28(%r14), %rsi
je 0x4f98
leaq 0x6a08(%rip), %rax      # 0xb978
movq (%rax), %rdi
movq 0x8(%rbx), %rdx
leaq 0x40(%r14), %r9
leaq 0x44(%r14), %rax
movl 0x40(%r14), %ecx
movl 0x44(%r14), %r8d
leaq 0x8(%rsp), %r10
pushq %r10
pushq %rax
callq 0x2070
addq $0x10, %rsp
movl 0x54(%r14), %eax
cmpl $0x3, %eax
je 0x5004
cmpl $0x2, %eax
je 0x4fe4
cmpl $0x1, %eax
jne 0x511e
testq %r15, %r15
je 0x511e
leaq 0x69b9(%rip), %rax      # 0xb978
movq (%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x2340
movq %r15, %rdi
xorl %eax, %eax
callq 0x587d
movq %r15, %rdi
xorl %eax, %eax
callq 0x56e6
jmp 0x511e
movl 0x50(%r14), %eax
notl %eax
testb $0x5, %al
jne 0x506a
leaq 0x64d3(%rip), %rsi      # 0xb4c8
movq %r14, %rdi
xorl %eax, %eax
callq 0x5c1d
jmp 0x511e
leaq 0x6b25(%rip), %r15      # 0xbb30
movq (%r15), %rax
testq %rax, %rax
je 0x5026
cmpq %rbx, 0xf8(%rax)
jne 0x5026
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4afd
leaq 0x6483(%rip), %rsi      # 0xb4b0
movq %r14, %rdi
xorl %eax, %eax
callq 0x5c1d
leal 0x1(%rax), %ecx
cmpl $0x5, %ecx
ja 0x50f7
leaq 0x25e2(%rip), %rax      # 0x762c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x6906(%rip), %rax      # 0xb960
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x5128
jmp 0x5106
leaq 0x25f0(%rip), %rsi      # 0x7661
movq %rbx, %rdi
callq 0x5128
jmp 0x511e
leaq 0x4(%rsp), %r14
movl $0x0, (%r14)
movl $0x1, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x61f0
movl (%r14), %esi
movq %rax, %rdi
callq 0x52dd
jmp 0x5106
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x61f0
movq %rax, %rdi
callq 0x519e
jmp 0x5106
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x61f0
movq %rax, %rdi
callq 0x5267
jmp 0x5106
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x61f0
movq %rax, %rdi
callq 0x5327
jmp 0x5106
addl $-0x5, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x53fd
movq (%r15), %rdi
testq %rdi, %rdi
je 0x511e
cmpq %rbx, 0xf8(%rdi)
jne 0x511e
xorl %eax, %eax
callq 0x4a43
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq