// File: /workspace/github_c_makefile_star2_O3/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, 0x8(%rsp)
movl %edi, %ebx
movq 0x7c72(%rip), %rax      # 0xf240
movswq 0x2(%rax), %r15
cmpq $0x0, 0x648(%rax)
je 0x75e2
callq 0x7401
movslq %ebx, %r14
leaq (%r15,%r15,8), %rax
leaq 0x75d0(%rip), %rcx      # 0xebc0
leaq (%rcx,%rax,8), %rax
movswl 0x8(%rax,%r14,8), %edx
movswl 0xa(%rax,%r14,8), %ecx
movq %rax, 0x10(%rsp)
movzwl 0x24(%rax), %eax
movl %eax, %esi
shrl $0xf, %esi
addl %eax, %esi
movswl %si, %r8d
movl %r8d, %eax
shrl %eax
movl %eax, 0xc(%rsp)
movq 0x7b84(%rip), %rdi      # 0xf1a8
movswl 0x7b95(%rip), %eax      # 0xf1c0
sarl %r8d
movl $0xb, %esi
movl $0xa, %r9d
pushq 0x7b89(%rip)            # 0xf1c8
pushq 0x7bab(%rip)            # 0xf1f0
pushq 0x7b85(%rip)            # 0xf1d0
pushq 0x7ba7(%rip)            # 0xf1f8
pushq 0x7bb1(%rip)            # 0xf208
pushq %rax
callq 0x4d10
addq $0x30, %rsp
movq %rax, %rbx
movq 0x7bd5(%rip), %rax      # 0xf240
movq %rbx, 0x648(%rax)
movw %r14w, (%rax)
movl 0x8(%rsp), %ecx
movw %cx, 0x2(%rax)
callq 0x604f
cmpw $0x0, 0x7715(%rip)      # 0xeda0
jle 0x7726
xorl %r15d, %r15d
leaq 0x7705(%rip), %rbp      # 0xeda0
xorl %r13d, %r13d
movq 0x8(%rbp,%r15,8), %r12
testq %r12, %r12
setne %al
cmpl $0x64, %r13d
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7710
cmpw $0x0, 0x104(%r12)
je 0x7710
cmpq %r14, 0x118(%r12)
jne 0x7710
movswl 0x100(%r12), %eax
cmpl 0x8(%rsp), %eax
jne 0x7710
movq (%r12), %rdi
callq 0x5f64
testq %rax, %rax
je 0x7710
movslq %r13d, %rcx
movq 0x7b4c(%rip), %rdx      # 0xf240
shlq $0x4, %rcx
movq %rax, 0x10(%rdx,%rcx)
movq (%r12), %rax
movq 0x7b38(%rip), %rdx      # 0xf240
movq %rax, 0x8(%rdx,%rcx)
incl %r13d
incq %r15
movswq 0x7685(%rip), %rax      # 0xeda0
cmpq %rax, %r15
jl 0x769e
jmp 0x7729
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
leaq (%rax,%r14,8), %r12
addq $0x8, %r12
movq 0x7b03(%rip), %rdi      # 0xf240
addq $0x8, %rdi
movslq %r13d, %r14
leaq -0x251(%rip), %rcx      # 0x74fa
movl $0x10, %r15d
movl $0x10, %edx
movq %r14, %rsi
callq 0x3420
testl %r14d, %r14d
jle 0x778b
movl %r13d, %r13d
xorl %r14d, %r14d
movq 0x7ad0(%rip), %rax      # 0xf240
movq (%rax,%r15), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4fcc
incq %r14
addq $0x10, %r15
cmpq %r14, %r13
jne 0x7769
movswl 0x4(%r12), %eax
movswl 0x1c(%rbx), %ecx
leal -0x64(%rax), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
movswl 0x6(%r12), %edx
movswl 0x1e(%rbx), %esi
leal -0x64(%rdx), %edi
cmpl %esi, %edi
cmovll %edi, %esi
subl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
shrl %ecx
subl %esi, %edx
movl %edx, %eax
shrl $0x1f, %eax
addl %edx, %eax
shrl %eax
addw (%r12), %cx
addw 0x2(%r12), %ax
movswl %cx, %esi
movswl %ax, %edx
movswl 0xc(%rsp), %ecx
movq %rbx, %rdi
movl $0xa, %r8d
callq 0x4edc
movq 0x70(%rbx), %rax
movq 0x73bc(%rip), %rdi      # 0xebb0
movq 0x8(%rax), %rsi
callq 0x3350
movq 0x73ac(%rip), %rdi      # 0xebb0
movq 0x8(%rbx), %rsi
callq 0x3350
movq %rbx, %rdi
callq 0x5113
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x50cc