// File: /workspace/github_c_makefile_star2_O2/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 0x6e96(%rip), %rcx      # 0xb9a8
movl %eax, (%rcx)
movq 0x28(%rdi), %rdi
xorl %eax, %eax
callq 0x303c
testq %rax, %rax
je 0x4d21
movq %rax, %rbx
movq 0x20(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x5576
movq %rax, %r15
testq %rax, %rax
je 0x4b6f
movl 0x28(%r15), %eax
leaq 0x67e5(%rip), %rcx      # 0xb330
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 0x4ba6
movq 0x20(%r14), %rsi
cmpq 0x28(%r14), %rsi
je 0x4ba6
leaq 0x6e08(%rip), %rax      # 0xb988
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
popq %rcx
popq %rdx
movl 0x54(%r14), %eax
cmpl $0x3, %eax
je 0x4c12
cmpl $0x2, %eax
je 0x4bf2
cmpl $0x1, %eax
jne 0x4d21
testq %r15, %r15
je 0x4d21
leaq 0x6dbb(%rip), %rax      # 0xb988
movq (%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x2350
movq %r15, %rdi
xorl %eax, %eax
callq 0x5526
movq %r15, %rdi
xorl %eax, %eax
callq 0x5367
jmp 0x4d21
movl 0x50(%r14), %eax
notl %eax
testb $0x5, %al
jne 0x4c78
leaq 0x68d5(%rip), %rsi      # 0xb4d8
movq %r14, %rdi
xorl %eax, %eax
callq 0x5832
jmp 0x4d21
leaq 0x6f27(%rip), %r15      # 0xbb40
movq (%r15), %rax
testq %rax, %rax
je 0x4c34
cmpq %rbx, 0xf8(%rax)
jne 0x4c34
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4745
leaq 0x6885(%rip), %rsi      # 0xb4c0
movq %r14, %rdi
xorl %eax, %eax
callq 0x5832
leal 0x1(%rax), %ecx
cmpl $0x5, %ecx
ja 0x4cfc
leaq 0x29d4(%rip), %rax      # 0x762c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x6d08(%rip), %rax      # 0xb970
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x4d2b
jmp 0x4d09
leaq 0x29e2(%rip), %rsi      # 0x7661
movq %rbx, %rdi
callq 0x4d2b
jmp 0x4d21
leaq 0x4(%rsp), %r14
andl $0x0, (%r14)
pushq $0x1
popq %rdi
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x5d86
movl (%r14), %esi
movq %rax, %rdi
callq 0x4f1e
jmp 0x4d09
pushq $0x1
popq %rdi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x5d86
movq %rax, %rdi
callq 0x4ddf
jmp 0x4d09
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x5d86
movq %rax, %rdi
callq 0x4ea8
jmp 0x4d09
pushq $0x1
popq %rdi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x5d86
movq %rax, %rdi
callq 0x4f68
jmp 0x4d09
addl $-0x5, %eax
pushq $0x1
popq %rsi
movl %eax, %edi
callq 0x504e
movq (%r15), %rdi
testq %rdi, %rdi
je 0x4d21
cmpq %rbx, 0xf8(%rdi)
jne 0x4d21
xorl %eax, %eax
callq 0x467f
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq