// File: /workspace/github_c_makefile_star2_O2/seanpringle[P]xoat/./menu.c
// Function: menu_create
void menu_create(int spot, int mon)
{
	short x, y, w, h;
	int i, n = 0; Client *c;
	char *name = NULL;

	Monitor *m = &monitors[menu->monitor];
	
	if (menu->mb)
		menu_close();

	x = m->spots[spot].x;
	y = m->spots[spot].y;
	w = m->spots[SPOT3].w/2;
	h = 10;

	Menubox *mb = menubox_create(root, MB_AUTOHEIGHT|MB_AUTOWIDTH|MB_MINWIDTH, x, y, w, h, 
		settings.border, settings.menu, settings.title_focus, settings.border_focus, settings.title_blur, settings.border_blur);
	
	menu->mb = mb;
	menu->spot = spot;
	menu->monitor = mon;

	for_windows(i,c) if (n < sizeof(menu->items)/sizeof(MenuMap) && c->manage && c->spot == spot && c->monitor == mon && (name = window_get_name(c->window)) && name)
	{
		menu->items[n].name = name;
		menu->items[n].window = c->window;
		n++;
	}

	qsort(menu->items, n, sizeof(MenuMap), menu_sort);

	for (i = 0; i < n; i++)
		menubox_add(mb, i, menu->items[i].name);

	x = (m->spots[spot].w - MIN(mb->w, m->spots[spot].w-100))/2;
	y = (m->spots[spot].h - MIN(mb->h, m->spots[spot].h-100))/2;

	x += m->spots[spot].x;
	y += m->spots[spot].y;

	menubox_moveresize(mb, x, y, w, h);

	menubox_show(mb);
	menubox_draw(mb);
	menubox_grab(mb);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, (%rsp)
movl %edi, %ebx
movq 0x8864(%rip), %rax      # 0xf240
movswq 0x2(%rax), %r14
cmpq $0x0, 0x648(%rax)
je 0x69f0
callq 0x6833
movslq %ebx, %rbx
imulq $0x48, %r14, %rax
leaq 0x81c2(%rip), %rdx      # 0xebc0
leaq (%rdx,%rax), %rcx
leaq (%rcx,%rbx,8), %rcx
addq $0x8, %rcx
movswl (%rcx), %r11d
movq %rcx, 0x10(%rsp)
movswl 0x2(%rcx), %ecx
movzwl 0x24(%rax,%rdx), %eax
movw $0x2, %si
cwtd
idivw %si
movq 0x877c(%rip), %rdi      # 0xf1a8
movswl 0x878c(%rip), %r10d     # 0xf1c0
movswl %ax, %r8d
pushq $0xb
popq %rsi
pushq $0xa
popq %r9
movl %r11d, %edx
movl %r8d, 0x4(%rsp)
pushq 0x877b(%rip)            # 0xf1c8
pushq 0x879d(%rip)            # 0xf1f0
pushq 0x8777(%rip)            # 0xf1d0
pushq 0x8799(%rip)            # 0xf1f8
pushq 0x87a3(%rip)            # 0xf208
pushq %r10
callq 0x43ce
addq $0x30, %rsp
movq %rax, %r14
movq 0x87c6(%rip), %rax      # 0xf240
movq %r14, 0x648(%rax)
movw %bx, (%rax)
movl (%rsp), %ecx
movw %cx, 0x2(%rax)
callq 0x5607
movq %rbx, %rsi
xorl %r13d, %r13d
movzwl 0x8303(%rip), %ecx      # 0xeda0
leaq 0x82fc(%rip), %rbp      # 0xeda0
xorl %ebx, %ebx
movq %rsi, 0x8(%rsp)
movswq %cx, %rax
movslq %ebx, %r15
cmpq %rax, %r13
jge 0x6b3b
movq 0x8(%rbp,%r13,8), %r12
testq %r12, %r12
setne %al
cmpl $0x64, %ebx
setb %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x6b33
cmpw $0x0, 0x104(%r12)
je 0x6b33
cmpq %rsi, 0x118(%r12)
jne 0x6b33
movswl 0x100(%r12), %eax
cmpl (%rsp), %eax
jne 0x6b33
movq (%r12), %rdi
callq 0x551f
movzwl 0x8299(%rip), %ecx      # 0xeda0
testq %rax, %rax
je 0x6b2e
movq 0x872d(%rip), %rdx      # 0xf240
shlq $0x4, %r15
movq %rax, 0x10(%rdx,%r15)
movq (%r12), %rax
movq 0x8719(%rip), %rdx      # 0xf240
movq %rax, 0x8(%rdx,%r15)
incl %ebx
movq 0x8(%rsp), %rsi
incq %r13
jmp 0x6aab
movq 0x86fe(%rip), %rdi      # 0xf240
addq $0x8, %rdi
leaq -0x23b(%rip), %rcx      # 0x6912
pushq $0x10
popq %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x3420
xorl %r13d, %r13d
testl %r15d, %r15d
cmovlel %r13d, %ebx
cmpq %r13, %rbx
je 0x6b8a
movq 0x86ce(%rip), %rax      # 0xf240
movq (%rax,%r12), %rdx
movq %r14, %rdi
movl %r13d, %esi
callq 0x4680
incq %r13
addq $0x10, %r12
jmp 0x6b66
movq 0x10(%rsp), %r9
movswl 0x4(%r9), %eax
movswl 0x1c(%r14), %edx
leal -0x64(%rax), %ecx
cmpl %edx, %ecx
cmovll %ecx, %edx
movswl 0x6(%r9), %ecx
movswl 0x1e(%r14), %edi
leal -0x64(%rcx), %esi
cmpl %edi, %esi
cmovll %esi, %edi
subl %edx, %eax
pushq $0x2
popq %r8
cltd
idivl %r8d
movl %eax, %esi
subl %edi, %ecx
movl %ecx, %eax
cltd
idivl %r8d
addw (%r9), %si
addw 0x2(%r9), %ax
movswl %si, %esi
movswl %ax, %edx
pushq $0xa
popq %r8
movq %r14, %rdi
movl 0x4(%rsp), %ecx
callq 0x459f
movq %r14, %rdi
callq 0x48ab
movq %r14, %rdi
callq 0x47dd
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4798