// File: /workspace/github_c_makefile_star2_O0/doy[P]libvt100/src/screen.c
// Function: vt100_screen_scroll_down
void vt100_screen_scroll_down(VT100Screen *vt, int count)
{
    struct vt100_row *row;
    int bottom = vt->grid->scroll_bottom, top = vt->grid->scroll_top;
    int i;

    if (bottom - top + 1 > count) {
        for (i = 0; i < count; ++i) {
            row = vt100_screen_row_at(vt, bottom - i);
            free(row->cells);
        }
        row = vt100_screen_row_at(vt, top);
        memmove(
            row + count, row,
            (bottom - top + 1 - count) * sizeof(struct vt100_row));
        for (i = 0; i < count; ++i) {
            row = vt100_screen_row_at(vt, top + i);
            row->cells = calloc(vt->grid->max.col, sizeof(struct vt100_cell));
            row->wrapped = 0;
        }
    }
    else {
        for (i = 0; i < bottom - top + 1; ++i) {
            row = vt100_screen_row_at(vt, top + i);
            memset(
                row->cells, 0, vt->grid->max.col * sizeof(struct vt100_cell));
            row->wrapped = 0;
        }
    }

    vt->dirty = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x18(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
addl $0x1, %eax
cmpl -0xc(%rbp), %eax
jle 0x960d
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x9574
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
subl -0x24(%rbp), %esi
callq 0x8a60
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x3050
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9542
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x8a60
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movslq -0xc(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
addl $0x1, %eax
subl -0xc(%rbp), %eax
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x35f0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x960b
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
addl -0x24(%rbp), %esi
callq 0x8a60
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq 0xc(%rax), %rdi
movl $0x20, %esi
callq 0x33f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movb 0x8(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x8(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x95b6
jmp 0x9671
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl -0x20(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x966f
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
addl -0x24(%rbp), %esi
callq 0x8a60
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq 0xc(%rax), %rdx
shlq $0x5, %rdx
xorl %esi, %esi
callq 0x32f0
movq -0x18(%rbp), %rax
movb 0x8(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x8(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9614
jmp 0x9671
movq -0x8(%rbp), %rax
movw 0x49(%rax), %cx
andw $0xdfff, %cx            # imm = 0xDFFF
orw $0x2000, %cx            # imm = 0x2000
movw %cx, 0x49(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)