// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x38(%rax)
jne 0xd11e
jmp 0xd38f
movq -0x8(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0xd3a0
movq 0x8e9e(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %eax, %eax
movl %eax, %edx
callq 0x2440
movq 0x8e86(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2370
movq 0x8e6a(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %eax, %eax
movl %eax, %edx
callq 0x20e0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0xd27b
movq -0x18(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x35(%rbp)
jge 0xd1d0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
cmpl -0x1c(%rbp), %eax
setl %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0xd1dc
jmp 0xd276
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x30(%rcx), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
xorl %edx, %edx
callq 0xd3a0
cmpl $0x0, -0x24(%rbp)
je 0xd21d
movq 0x8dcc(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %eax, %eax
movl %eax, %edx
callq 0x2440
movl -0x20(%rbp), %esi
addl $0x1, %esi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
leaq 0x4e16(%rip), %rdi      # 0x12057
movb $0x0, %al
callq 0x2030
cmpl $0x0, -0x24(%rbp)
je 0xd266
movq 0x8d83(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %eax, %eax
movl %eax, %edx
callq 0x20e0
jmp 0xd268
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xd1a8
jmp 0xd31d
movq -0x18(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jne 0xd31b
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x36(%rbp)
jge 0xd2bb
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
cmpl -0x1c(%rbp), %eax
setl %al
movb %al, -0x36(%rbp)
movb -0x36(%rbp), %al
testb $0x1, %al
jne 0xd2c4
jmp 0xd319
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0xc(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl %eax, %r8d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r9
xorl %esi, %esi
leaq 0x4d5c(%rip), %rdx      # 0x12060
movb $0x0, %al
callq 0x21e0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xd293
jmp 0xd31b
jmp 0xd31d
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
cmpl -0x1c(%rbp), %eax
jl 0xd331
movl -0x1c(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0xd358
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
xorl %edx, %edx
callq 0xd3a0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xd337
movq 0x8c79(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movl -0xc(%rbp), %esi
xorl %edx, %edx
callq 0x2310
cmpl $-0x1, %eax
jne 0xd373
jmp 0xd38f
movq 0x8c5e(%rip), %rax      # 0x15fd8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2370
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)