// File: /workspace/github_c_makefile_star2_O0/seanpringle[P]xoat/./menubox.c
// Function: menubox_filter
void menubox_filter(Menubox *mb)
{
	int filter = strlen(mb->input->text) > 0;
	char *pattern = strdup(mb->input->text);
	for (char *p = pattern; *p; *p = tolower(*p), p++);

	for (int i = 0; i < mb->box_count; i++)
	{
		char *subject = strdup(mb->boxes[i]->text);
		for (char *p = subject; *p; *p = tolower(*p), p++);
		mb->show[i] = (!filter || regex_match(pattern, subject));
		free(subject);
	}
	free(pattern);

	// active entry maybe filtered. step backward
	while (!mb->show[mb->box_active] && mb->box_active > 0)
		mb->box_active--;

	// active entry maybe filtered. step forward
	while (!mb->show[mb->box_active] && mb->box_active < mb->box_count-1)
		mb->box_active++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rax
movq 0x50(%rax), %rdi
callq 0x3250
cmpq $0x0, %rax
seta %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rax
movq 0x50(%rax), %rdi
callq 0x3430
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x59e6
jmp 0x59c4
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x3480
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x59b9
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jae 0x5a9e
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
callq 0x3430
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x5a4f
jmp 0x5a2d
movq -0x38(%rbp), %rax
movsbl (%rax), %edi
callq 0x3480
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x5a22
movb $0x1, %al
cmpl $0x0, -0xc(%rbp)
movb %al, -0x39(%rbp)
je 0x5a70
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3ae0
cmpl $0x0, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x30(%rbp), %rdi
callq 0x3220
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x59ed
movq -0x18(%rbp), %rdi
callq 0x3220
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, %edx
xorl %eax, %eax
cmpl $0x0, (%rcx,%rdx,4)
movb %al, -0x3a(%rbp)
jne 0x5ad1
movq -0x8(%rbp), %rax
cmpl $0x0, 0x54(%rax)
seta %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
testb $0x1, %al
jne 0x5ada
jmp 0x5ae9
movq -0x8(%rbp), %rax
movl 0x54(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x54(%rax)
jmp 0x5aa7
jmp 0x5aeb
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, %edx
xorl %eax, %eax
cmpl $0x0, (%rcx,%rdx,4)
movb %al, -0x3b(%rbp)
jne 0x5b20
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x50(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
setb %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
testb $0x1, %al
jne 0x5b29
jmp 0x5b38
movq -0x8(%rbp), %rax
movl 0x54(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x54(%rax)
jmp 0x5aeb
addq $0x40, %rsp
popq %rbp
retq
nop