// File: /workspace/github_c_makefile_star2_O0/skeeto[P]goblin-com/src/main.c
// Function: ui_heroes
static void
ui_heroes(game_t *game, panel_t *terrain)
{
    panel_t p;
    int w = 50;
    int h = 22;
    panel_center_init(&p, w, h);
    display_push(&p);

    int per_page = h - 3;
    int total = countof(game->heroes);
    int page_max = total / per_page;
    int page = 0;
    int selection = 0;
    int key = 0;
    do {
        panel_fill(&p, FONT_DEFAULT, ' ');
        panel_border(&p, FONT(w, k));
        panel_printf(&p, 1, 1,
                     "wk{Name             Squad   HP   AP  STR  DEX MIND}");
        switch (key) {
        case ARROW_U:
            if (selection > 0)
                selection--;
            break;
        case ARROW_D:
            if (selection < (page + 1) * per_page - 1)
                selection++;
            break;
        case '>':
            if (page < page_max) {
                page++;
                selection = page * per_page;
            }
            break;
        case '<':
            if (page > 0) {
                page--;
                selection = page * per_page;
            }
            break;
        case '+':
        case '=':
        case '-': {
            hero_t *h = game->heroes + selection;
            if (h->active) {
                int new_squad = h->squad + (key == '-' ? -1 : 1);
                if (new_squad >= -1 && new_squad < (int)countof(game->squads)) {
                    if (h->squad >= 0)
                        game->squads[h->squad].member_count--;
                    h->squad = new_squad;
                    if (h->squad >= 0)
                        game->squads[h->squad].member_count++;
                }
            }
        } break;
        case 13: {
            hero_t *h = game->heroes + selection;
            if (!h->active && selection < game->max_hero)
                ui_hire(game, terrain, selection);
        }break;
        }
        panel_printf(&p, 1, h - 1, "Rk{<} wk{Page %d} Rk{>}", page + 1);
        for (int i = 0; i < per_page; i++) {
            int si = page * per_page + i;
            if (si > total)
                break;
            hero_t *h = game->heroes + si;
            char format[] = "Ck{%-16s} Rk{ }Yk{%4c}Rk{ }%4d %4d %4d %4d %4d";
            if (selection == si) {
                format[1] = 'r';
                format[13] = '-';
                format[25] = '+';
            }
            if (!h->active) {
                format[0] = 'K';
                format[9] = '\0';
                if (si < game->max_hero) {
                    strcpy(h->name, "(Rk{enter} to hire)");
                    if (selection == si)
                        h->name[2] = 'r';
                } else {
                    h->name[0] = '\0';
                }
            }
            panel_printf(&p, 1, i + 2, format,
                         h->name, h->squad < 0 ? ' ' : h->squad + 'A',
                         h->hp_max, h->ap_max,
                         h->str, h->dex, h->mind);
        }
    } while (!is_exit_key(key = game_getch(game, terrain)));
    display_pop_free();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x3d00, %rsp           # imm = 0x3D00
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movl $0x32, -0x3c3c(%rbp)
movl $0x16, -0x3c40(%rbp)
movl -0x3c3c(%rbp), %esi
movl -0x3c40(%rbp), %edx
leaq -0x3c38(%rbp), %rdi
callq 0x48e0
leaq -0x3c38(%rbp), %rdi
callq 0x47b0
movl -0x3c40(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x3c44(%rbp)
movl $0x80, -0x3c48(%rbp)
movl -0x3c48(%rbp), %eax
cltd
idivl -0x3c44(%rbp)
movl %eax, -0x3c4c(%rbp)
movl $0x0, -0x3c50(%rbp)
movl $0x0, -0x3c54(%rbp)
movl $0x0, -0x3c58(%rbp)
movb $0x7, -0x3c5c(%rbp)
movb $0x0, -0x3c5b(%rbp)
movb $0x1, -0x3c5a(%rbp)
movb $0x0, -0x3c59(%rbp)
movl -0x3c5c(%rbp), %esi
leaq -0x3c38(%rbp), %rdi
movq %rdi, -0x3cd0(%rbp)
movl $0x20, %edx
callq 0x4960
movq -0x3cd0(%rbp), %rdi
movb $0x7, -0x3c60(%rbp)
movb $0x0, -0x3c5f(%rbp)
movb $0x0, -0x3c5e(%rbp)
movb $0x0, -0x3c5d(%rbp)
movl -0x3c60(%rbp), %esi
callq 0x5150
movq -0x3cd0(%rbp), %rdi
leaq 0x7353(%rip), %rcx      # 0x95d1
xorl %eax, %eax
movl $0x1, %edx
movl %edx, %esi
callq 0x4c10
movl -0x3c58(%rbp), %eax
movl %eax, -0x3cc4(%rbp)
subl $0xd, %eax
je 0x24ab
jmp 0x22a3
movl -0x3cc4(%rbp), %eax
subl $0x2b, %eax
je 0x23c8
jmp 0x22b4
movl -0x3cc4(%rbp), %eax
subl $0x2d, %eax
je 0x23c8
jmp 0x22c5
movl -0x3cc4(%rbp), %eax
subl $0x3c, %eax
je 0x2398
jmp 0x22d6
movl -0x3cc4(%rbp), %eax
subl $0x3d, %eax
je 0x23c8
jmp 0x22e7
movl -0x3cc4(%rbp), %eax
subl $0x3e, %eax
je 0x2363
jmp 0x22f4
movl -0x3cc4(%rbp), %eax
subl $0x141, %eax            # imm = 0x141
je 0x2315
jmp 0x2303
movl -0x3cc4(%rbp), %eax
subl $0x142, %eax            # imm = 0x142
je 0x2332
jmp 0x24fd
cmpl $0x0, -0x3c54(%rbp)
jle 0x232d
movl -0x3c54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c54(%rbp)
jmp 0x24fd
movl -0x3c54(%rbp), %eax
movl -0x3c50(%rbp), %ecx
addl $0x1, %ecx
imull -0x3c44(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x235e
movl -0x3c54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c54(%rbp)
jmp 0x24fd
movl -0x3c50(%rbp), %eax
cmpl -0x3c4c(%rbp), %eax
jge 0x2393
movl -0x3c50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c50(%rbp)
movl -0x3c50(%rbp), %eax
imull -0x3c44(%rbp), %eax
movl %eax, -0x3c54(%rbp)
jmp 0x24fd
cmpl $0x0, -0x3c50(%rbp)
jle 0x23c3
movl -0x3c50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c50(%rbp)
movl -0x3c50(%rbp), %eax
imull -0x3c44(%rbp), %eax
movl %eax, -0x3c54(%rbp)
jmp 0x24fd
movq -0x18(%rbp), %rax
addq $0x3cc, %rax            # imm = 0x3CC
movslq -0x3c54(%rbp), %rcx
imulq $0x34, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x3c68(%rbp)
movq -0x3c68(%rbp), %rax
testb $0x1, (%rax)
je 0x24a9
movq -0x3c68(%rbp), %rax
movl 0x30(%rax), %eax
movl -0x3c58(%rbp), %esi
movl $0x1, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $0x2d, %esi
cmovel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x3c6c(%rbp)
cmpl $-0x1, -0x3c6c(%rbp)
jl 0x24a7
cmpl $0x10, -0x3c6c(%rbp)
jge 0x24a7
movq -0x3c68(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jl 0x2463
movq -0x18(%rbp), %rax
addq $0x2c8, %rax            # imm = 0x2C8
movq -0x3c68(%rbp), %rcx
movslq 0x30(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
movl -0x3c6c(%rbp), %ecx
movq -0x3c68(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x3c68(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jl 0x24a5
movq -0x18(%rbp), %rax
addq $0x2c8, %rax            # imm = 0x2C8
movq -0x3c68(%rbp), %rcx
movslq 0x30(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x24a7
jmp 0x24a9
jmp 0x24fd
movq -0x18(%rbp), %rax
addq $0x3cc, %rax            # imm = 0x3CC
movslq -0x3c54(%rbp), %rcx
imulq $0x34, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x3c78(%rbp)
movq -0x3c78(%rbp), %rax
testb $0x1, (%rax)
jne 0x24fb
movl -0x3c54(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x3c8(%rcx), %eax
jge 0x24fb
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x3c54(%rbp), %edx
callq 0x4000
jmp 0x24fd
movl -0x3c40(%rbp), %edx
subl $0x1, %edx
movl -0x3c50(%rbp), %r8d
addl $0x1, %r8d
leaq -0x3c38(%rbp), %rdi
movl $0x1, %esi
leaq 0x70e1(%rip), %rcx      # 0x9605
movb $0x0, %al
callq 0x4c10
movl $0x0, -0x3c7c(%rbp)
movl -0x3c7c(%rbp), %eax
cmpl -0x3c44(%rbp), %eax
jge 0x2721
movl -0x3c50(%rbp), %eax
imull -0x3c44(%rbp), %eax
addl -0x3c7c(%rbp), %eax
movl %eax, -0x3c80(%rbp)
movl -0x3c80(%rbp), %eax
cmpl -0x3c48(%rbp), %eax
jle 0x2573
jmp 0x2721
movq -0x18(%rbp), %rax
addq $0x3cc, %rax            # imm = 0x3CC
movslq -0x3c80(%rbp), %rcx
imulq $0x34, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x3c88(%rbp)
leaq -0x3cc0(%rbp), %rdi
leaq 0x7170(%rip), %rsi      # 0x9710
movl $0x2f, %edx
callq 0x1190
movl -0x3c54(%rbp), %eax
cmpl -0x3c80(%rbp), %eax
jne 0x25cd
movb $0x72, -0x3cbf(%rbp)
movb $0x2d, -0x3cb3(%rbp)
movb $0x2b, -0x3ca7(%rbp)
movq -0x3c88(%rbp), %rax
testb $0x1, (%rax)
jne 0x2638
movb $0x4b, -0x3cc0(%rbp)
movb $0x0, -0x3cb7(%rbp)
movl -0x3c80(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x3c8(%rcx), %eax
jge 0x262b
movq -0x3c88(%rbp), %rdi
addq $0x1, %rdi
leaq 0x7012(%rip), %rsi      # 0x961d
callq 0x1050
movl -0x3c54(%rbp), %eax
cmpl -0x3c80(%rbp), %eax
jne 0x2629
movq -0x3c88(%rbp), %rax
movb $0x72, 0x3(%rax)
jmp 0x2636
movq -0x3c88(%rbp), %rax
movb $0x0, 0x1(%rax)
jmp 0x2638
movl -0x3c7c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x3ce4(%rbp)
leaq -0x3cc0(%rbp), %rax
movq %rax, -0x3ce0(%rbp)
movq -0x3c88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3cd8(%rbp)
movq -0x3c88(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jge 0x2681
movl $0x20, %eax
movl %eax, -0x3ce8(%rbp)
jmp 0x2694
movq -0x3c88(%rbp), %rax
movl 0x30(%rax), %eax
addl $0x41, %eax
movl %eax, -0x3ce8(%rbp)
movq -0x3cd8(%rbp), %r8
movq -0x3ce0(%rbp), %rcx
movl -0x3ce4(%rbp), %edx
movl -0x3ce8(%rbp), %r9d
movq -0x3c88(%rbp), %rax
movl 0x18(%rax), %r14d
movq -0x3c88(%rbp), %rax
movl 0x20(%rax), %ebx
movq -0x3c88(%rbp), %rax
movl 0x24(%rax), %r11d
movq -0x3c88(%rbp), %rax
movl 0x28(%rax), %r10d
movq -0x3c88(%rbp), %rax
movl 0x2c(%rax), %eax
leaq -0x3c38(%rbp), %rdi
movl $0x1, %esi
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movb $0x0, %al
callq 0x4c10
movl -0x3c7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c7c(%rbp)
jmp 0x2535
jmp 0x2723
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2d90
movl %eax, %edi
movl %edi, -0x3c58(%rbp)
callq 0x2d60
xorb $-0x1, %al
testb $0x1, %al
jne 0x2208
callq 0x4820
addq $0x3d00, %rsp           # imm = 0x3D00
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax,%rax)