// File: /workspace/github_c_makefile_star2_O2/seanpringle[P]xoat/./menubox.c
// Function: menubox_create
Menubox* menubox_create(Window parent, unsigned long flags, short x, short y, short w, short h, short padding, char *font, char *fg_focus, char *bg_focus, char *fg_blur, char *bg_blur)
{
	Menubox *mb = calloc(1, sizeof(Menubox));
	mb->boxes = (Textbox**) calloc(1, sizeof(Textbox));
	mb->ids = (int*) calloc(1, sizeof(int));
	mb->show = (int*) calloc(1, sizeof(int));

	mb->flags = flags;
	mb->parent = parent;
	mb->font = font;
	mb->fg_focus = fg_focus;
	mb->fg_blur = fg_blur;
	mb->bg_focus = bg_focus;
	mb->bg_blur = bg_blur;
	mb->padding = padding;
	mb->box_active = 0;

	mb->x = x; mb->y = y; mb->w = MAX(1, w); mb->h = MAX(1, h);

	XColor color; Colormap map = DefaultColormap(display, DefaultScreen(display));
	unsigned int cp = XAllocNamedColor(display, map, bg_blur, &color, &color) ? color.pixel: None;

	mb->window = XCreateSimpleWindow(display, mb->parent, mb->x, mb->y, mb->w, mb->h, 0, None, cp);

	// calc line height
	mb->input = textbox_create(mb->window, TB_AUTOHEIGHT|TB_EDITABLE, mb->padding, mb->padding, mb->w, 0, mb->font, mb->fg_blur, mb->bg_blur, "", "> ");
	mb->line_height = mb->input->h;

	// auto height/width modes get handled here
	menubox_moveresize(mb, mb->x, mb->y, mb->w, mb->h);

	return mb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, 0x14(%rsp)
movl %r8d, %ebx
movl %ecx, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %r13
movq %rdi, 0x20(%rsp)
movswl 0x70(%rsp), %r14d
pushq $0x1
popq %r12
pushq $0x78
popq %rsi
movq %r12, %rdi
callq 0x3500
movq %rax, %r15
movl $0x80, %esi
movq %r12, %rdi
callq 0x3500
movq %rax, 0x58(%r15)
pushq $0x4
popq %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3500
movq %rax, 0x60(%r15)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3500
movq %rax, 0x68(%r15)
movq 0x18(%rsp), %rax
movq %rax, (%r15)
movq %r13, 0x10(%r15)
movq 0x78(%rsp), %rax
movq %rax, 0x28(%r15)
movaps 0x80(%rsp), %xmm0
movups %xmm0, 0x30(%r15)
movq 0x90(%rsp), %rax
movq %rax, 0x40(%r15)
movq 0x98(%rsp), %rdx
movq %rdx, 0x48(%r15)
movw %r14w, 0x22(%r15)
movl %r14d, %r13d
movl 0xc(%rsp), %eax
movw %ax, 0x18(%r15)
movl 0x10(%rsp), %r12d
movw %r12w, 0x1a(%r15)
cmpw $0x2, %bx
pushq $0x1
popq %rbp
cmovll %ebp, %ebx
movw %bx, 0x1c(%r15)
movl 0x14(%rsp), %eax
cmpw $0x2, %ax
cmovgel %eax, %ebp
movw %bp, 0x1e(%r15)
movq 0xa6f2(%rip), %rdi      # 0xebb0
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x50(%rax,%rcx), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rcx
movq %r14, %r8
callq 0x31a0
xorl %r10d, %r10d
testl %eax, %eax
movl (%r14), %eax
movq 0xa6bc(%rip), %rdi      # 0xebb0
cmovneq %rax, %r10
subq $0x8, %rsp
movq 0x28(%rsp), %rsi
movl 0x14(%rsp), %r14d
movl %r14d, %edx
movl %r12d, %ecx
movl %ebx, %r8d
movl %ebp, %r9d
pushq %r10
pushq $0x0
pushq $0x0
callq 0x31e0
addq $0x20, %rsp
movq %rax, 0x8(%r15)
subq $0x8, %rsp
leaq 0x5e7f(%rip), %r10      # 0xa3af
leaq 0x61d3(%rip), %r11      # 0xa70a
movl $0x80001, %esi          # imm = 0x80001
movq %rax, %rdi
movl %r13d, %ecx
movl %r13d, %edx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq %r10
pushq %r11
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
pushq 0xa0(%rsp)
callq 0x3a28
addq $0x30, %rsp
movq %rax, 0x70(%r15)
movzwl 0x1e(%rax), %eax
movw %ax, 0x20(%r15)
movq %r15, %rdi
movl %r14d, %esi
movl %r12d, %edx
movl %ebx, %ecx
movl %ebp, %r8d
callq 0x459f
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq