// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_draw
void menu_draw(struct menu *menu)
{
	int i = 0;
	struct menu_item *current = menu->current;
	if (!menu->needs_redraw) return;
	menu->needs_redraw = false;
	move_clear_line(menu, 0, 0);
	attron(A_UNDERLINE);
	addstr(current->title);
	attroff(A_UNDERLINE);
	int height = menu->area->height - 1;
	if (current->kind == ITEM_LINKS) {
		for (int l = current->frame;
		     l < (int)current->n_items && ++i < height; ++l) {
			int reverse = l == current->place;
			move_clear_line(menu, i, 0);
			if (reverse) attron(A_REVERSE);
			printw("%2d. %s ", l + 1, current->items[l].title);
			if (reverse) attroff(A_REVERSE);
		}
	} else if (current->kind == ITEM_TEXT) {
		for (int l = current->place;
		     l < (int)menu->n_lines && ++i < height; ++l) {
			struct string *line = &menu->lines[l];
			mvprintw(i, 0, "%-*.*s",
				menu->area->width, (int)line->len, line->text);
		}
	}
	if (++i >= height) i = height;
	for (int j = i; j <= height; ++j) {
		move_clear_line(menu, j, 0);
	}
	mvaddstr(i, 0, menu->msg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpb $0x1, 0x38(%rdi)
jne 0x8d17
movq %rdi, %rbx
movq 0x8(%rdi), %r12
movb $0x0, 0x38(%rdi)
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x8d26
movq 0x84b0(%rip), %r15      # 0x10fd8
movq (%r15), %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x2430
movq (%r15), %rdi
movq 0x8(%r12), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2370
movq (%r15), %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x20e0
movq 0x10(%rbx), %rax
movl 0xc(%rax), %r13d
leal -0x1(%r13), %eax
movl %eax, 0x4(%rsp)
movq %r12, 0x8(%rsp)
movl 0x10(%r12), %eax
cmpl $0x2, %eax
je 0x8c4d
cmpl $0x1, %eax
jne 0x8cbd
movq 0x8(%rsp), %rax
movslq 0x34(%rax), %r12
cmpl 0x28(%rax), %r12d
jge 0x8cbd
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x14(%rsp)
movl $0x1, %eax
imulq $0x38, %r12, %rbp
addq $0x8, %rbp
movl %eax, %r14d
cmpl %eax, 0x14(%rsp)
je 0x8cbd
movq 0x8(%rsp), %rax
movl 0x30(%rax), %r15d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8d26
cmpl %r15d, %r12d
jne 0x8bf3
movq 0x83f4(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x2430
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax,%rbp), %rdx
leal 0x1(%r12), %esi
leaq 0x430b(%rip), %rdi      # 0xcf17
xorl %eax, %eax
callq 0x2030
cmpl %r15d, %r12d
jne 0x8c2e
movq 0x83b9(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x20e0
incq %r12
movq 0x8(%rsp), %rax
movslq 0x28(%rax), %rcx
addq $0x38, %rbp
leal 0x1(%r14), %eax
cmpq %rcx, %r12
jl 0x8bb7
jmp 0x8cbd
movq 0x8(%rsp), %rax
movslq 0x30(%rax), %r15
cmpl 0x30(%rbx), %r15d
jge 0x8cbd
movl 0x4(%rsp), %ecx
cmpl $0x2, %ecx
movl $0x1, %eax
movl $0x1, %ebp
cmovgel %ecx, %ebp
movq %r15, %r12
shlq $0x4, %r12
orq $0x8, %r12
movl %eax, %r14d
cmpl %eax, %ebp
je 0x8cbd
movq 0x10(%rbx), %rax
movq 0x28(%rbx), %rdx
movl 0x8(%rax), %ecx
movl -0x8(%rdx,%r12), %r8d
movq (%rdx,%r12), %r9
movl %r14d, %edi
xorl %esi, %esi
leaq 0x427e(%rip), %rdx      # 0xcf20
xorl %eax, %eax
callq 0x21e0
incq %r15
movslq 0x30(%rbx), %rcx
addq $0x10, %r12
leal 0x1(%r14), %eax
cmpq %rcx, %r15
jl 0x8c7b
incl %r14d
movl 0x4(%rsp), %eax
cmpl %eax, %r14d
cmovgel %eax, %r14d
movl %r14d, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x8d26
incl %ebp
cmpl %r13d, %ebp
jl 0x8cce
movq 0x82f2(%rip), %r15      # 0x10fd8
movq (%r15), %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0x8d17
movq (%r15), %rdi
movq 0x20(%rbx), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2370
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq