// File: /workspace/github_c_makefile_star2_O0/skeeto[P]goblin-com/src/main.c
// Function: text_page
static void
text_page(game_t *game, panel_t *terrain, const char *p, int w, int h)
{
    panel_t page;
    panel_center_init(&page, w + 4, h + 2);
    display_push(&page);
    font_t border = FONT(K, k);
    int numlines = text_numlines(p);
    int topline = 0;
    const char *top = p;

    int key = 0;
    do {
        switch (key) {
        case ARROW_D:
            if (topline < numlines - h) {
                topline++;
                top = text_next_line(top);
            }
            break;
        case ARROW_U:
            if (topline > 1) {
                topline--;
                top = text_prev_line(top);
            } else if (topline == 1) {
                topline = 0;
                top = p;
            }
            break;
        }
        panel_fill(&page, FONT_DEFAULT, ' ');
        panel_border(&page, border);
        if (numlines > h) {
            panel_printf(&page, w + 3, 1, "Rk{↑}");
            int o = (topline / (float)(numlines - h)) * (h - 3);
            panel_printf(&page, w + 3, o + 2, "wk{o}");
            panel_printf(&page, w + 3, h, "Rk{↓}");
        }
        const char *line = top;
        for (int y = 0; y < h && topline + y < numlines; y++) {
            int length = text_linelen(line);
            char copy[length + 1];
            memcpy(copy, line, length);
            copy[length] = '\0';
            panel_printf(&page, 2, y + 1, copy);
            line = text_next_line(line);
        }
    } while (!is_exit_key(key = game_getch(game, terrain)));

    display_pop_free();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3c90, %rsp           # imm = 0x3C90
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x1c(%rbp), %esi
addl $0x4, %esi
movl -0x20(%rbp), %edx
addl $0x2, %edx
leaq -0x3c38(%rbp), %rdi
callq 0x48e0
leaq -0x3c38(%rbp), %rdi
callq 0x47b0
movl 0x6ddf(%rip), %eax      # 0x9747
movl %eax, -0x3c3c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2c70
movl %eax, -0x3c40(%rbp)
movl $0x0, -0x3c44(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x3c50(%rbp)
movl $0x0, -0x3c54(%rbp)
movl -0x3c54(%rbp), %eax
movl %eax, -0x3c84(%rbp)
subl $0x141, %eax            # imm = 0x141
je 0x29fb
jmp 0x29b1
movl -0x3c84(%rbp), %eax
subl $0x142, %eax            # imm = 0x142
jne 0x2a4a
jmp 0x29c4
movl -0x3c44(%rbp), %eax
movl -0x3c40(%rbp), %ecx
subl -0x20(%rbp), %ecx
cmpl %ecx, %eax
jge 0x29f9
movl -0x3c44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c44(%rbp)
movq -0x3c50(%rbp), %rdi
callq 0x2cb0
movq %rax, -0x3c50(%rbp)
jmp 0x2a4a
cmpl $0x1, -0x3c44(%rbp)
jle 0x2a28
movl -0x3c44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c44(%rbp)
movq -0x3c50(%rbp), %rdi
callq 0x2ce0
movq %rax, -0x3c50(%rbp)
jmp 0x2a48
cmpl $0x1, -0x3c44(%rbp)
jne 0x2a46
movl $0x0, -0x3c44(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x3c50(%rbp)
jmp 0x2a48
jmp 0x2a4a
movb $0x7, -0x3c58(%rbp)
movb $0x0, -0x3c57(%rbp)
movb $0x1, -0x3c56(%rbp)
movb $0x0, -0x3c55(%rbp)
movl -0x3c58(%rbp), %esi
leaq -0x3c38(%rbp), %rdi
movl $0x20, %edx
callq 0x4960
movl -0x3c3c(%rbp), %esi
leaq -0x3c38(%rbp), %rdi
callq 0x5150
movl -0x3c40(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x2b31
movl -0x1c(%rbp), %esi
addl $0x3, %esi
leaq -0x3c38(%rbp), %rdi
movl $0x1, %edx
leaq 0x6865(%rip), %rcx      # 0x931c
movb $0x0, %al
callq 0x4c10
cvtsi2ssl -0x3c44(%rbp), %xmm0
movl -0x3c40(%rbp), %eax
subl -0x20(%rbp), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movl -0x20(%rbp), %eax
subl $0x3, %eax
cvtsi2ss %eax, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x3c5c(%rbp)
movl -0x1c(%rbp), %esi
addl $0x3, %esi
movl -0x3c5c(%rbp), %edx
addl $0x2, %edx
leaq -0x3c38(%rbp), %rdi
leaq 0x6818(%rip), %rcx      # 0x9324
movb $0x0, %al
callq 0x4c10
movl -0x1c(%rbp), %esi
addl $0x3, %esi
movl -0x20(%rbp), %edx
leaq -0x3c38(%rbp), %rdi
leaq 0x6800(%rip), %rcx      # 0x932a
movb $0x0, %al
callq 0x4c10
movq -0x3c50(%rbp), %rax
movq %rax, -0x3c68(%rbp)
movl $0x0, -0x3c6c(%rbp)
movl -0x3c6c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x20(%rbp), %ecx
movb %al, -0x3c85(%rbp)
jge 0x2b77
movl -0x3c44(%rbp), %eax
addl -0x3c6c(%rbp), %eax
cmpl -0x3c40(%rbp), %eax
setl %al
movb %al, -0x3c85(%rbp)
movb -0x3c85(%rbp), %al
testb $0x1, %al
jne 0x2b86
jmp 0x2c3e
movq -0x3c68(%rbp), %rdi
callq 0x2d20
movl %eax, -0x3c70(%rbp)
movl -0x3c70(%rbp), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0x3c78(%rbp)
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x3c90(%rbp)
movq %rdi, %rsp
movq %rax, -0x3c80(%rbp)
movq -0x3c68(%rbp), %rsi
movslq -0x3c70(%rbp), %rdx
callq 0x1190
movq -0x3c90(%rbp), %rcx
movslq -0x3c70(%rbp), %rax
movb $0x0, (%rcx,%rax)
movl -0x3c6c(%rbp), %edx
addl $0x1, %edx
leaq -0x3c38(%rbp), %rdi
movl $0x2, %esi
movb $0x0, %al
callq 0x4c10
movq -0x3c68(%rbp), %rdi
callq 0x2cb0
movq %rax, -0x3c68(%rbp)
movq -0x3c78(%rbp), %rax
movq %rax, %rsp
movl -0x3c6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c6c(%rbp)
jmp 0x2b49
jmp 0x2c40
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2d90
movl %eax, %edi
movl %edi, -0x3c54(%rbp)
callq 0x2d60
xorb $-0x1, %al
testb $0x1, %al
jne 0x299c
callq 0x4820
movq %rbp, %rsp
popq %rbp
retq
nop