// File: /workspace/github_c_makefile_star2_O3/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 0x6ac2(%rip), %rcx      # 0xb9a8
movl %eax, (%rcx)
movq 0x28(%rdi), %rdi
xorl %eax, %eax
callq 0x3381
testq %rax, %rax
je 0x5102
movq %rax, %rbx
movq 0x20(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x58ca
movq %rax, %r15
testq %rax, %rax
je 0x4f43
movl 0x28(%r15), %eax
leaq 0x6411(%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 0x4f7c
movq 0x20(%r14), %rsi
cmpq 0x28(%r14), %rsi
je 0x4f7c
leaq 0x6a34(%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
addq $0x10, %rsp
movl 0x54(%r14), %eax
cmpl $0x3, %eax
je 0x4fe8
cmpl $0x2, %eax
je 0x4fc8
cmpl $0x1, %eax
jne 0x5102
testq %r15, %r15
je 0x5102
leaq 0x69e5(%rip), %rax      # 0xb988
movq (%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x2350
movq %r15, %rdi
xorl %eax, %eax
callq 0x5866
movq %r15, %rdi
xorl %eax, %eax
callq 0x56cd
jmp 0x5102
movl 0x50(%r14), %eax
notl %eax
testb $0x5, %al
jne 0x504e
leaq 0x64ff(%rip), %rsi      # 0xb4d8
movq %r14, %rdi
xorl %eax, %eax
callq 0x5ba2
jmp 0x5102
leaq 0x6b51(%rip), %r15      # 0xbb40
movq (%r15), %rax
testq %rax, %rax
je 0x500a
cmpq %rbx, 0xf8(%rax)
jne 0x500a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4ae5
leaq 0x64af(%rip), %rsi      # 0xb4c0
movq %r14, %rdi
xorl %eax, %eax
callq 0x5ba2
leal 0x1(%rax), %ecx
cmpl $0x5, %ecx
ja 0x50db
leaq 0x25fe(%rip), %rax      # 0x762c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x6932(%rip), %rax      # 0xb970
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x510c
jmp 0x50ea
leaq 0x260c(%rip), %rsi      # 0x7661
movq %rbx, %rdi
callq 0x510c
jmp 0x5102
leaq 0x4(%rsp), %r14
movl $0x0, (%r14)
movl $0x1, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6139
movl (%r14), %esi
movq %rax, %rdi
callq 0x52c1
jmp 0x50ea
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6139
movq %rax, %rdi
callq 0x5182
jmp 0x50ea
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6139
movq %rax, %rdi
callq 0x524b
jmp 0x50ea
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6139
movq %rax, %rdi
callq 0x530b
jmp 0x50ea
addl $-0x5, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x53e1
movq (%r15), %rdi
testq %rdi, %rdi
je 0x5102
cmpq %rbx, 0xf8(%rdi)
jne 0x5102
xorl %eax, %eax
callq 0x4a0e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq