#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ clear_row(char, char, char, char);
int /*<<< orphan*/ copy_row(char, char, char, char, char);
void __scroll_down(signed char row_top, signed char row_bottom,
                   signed char col_left, signed char col_right,
                   signed char blank_attr, signed char scroll_count) {
  signed char row;
  for (row = row_bottom; row >= row_top; --row) {
    if (row - scroll_count < 0)
      clear_row(row, col_left, col_right, blank_attr);
    else
      copy_row(row, row - scroll_count, col_left, col_right, blank_attr);
  }
}


x86 assembly (clang, -O0):
<__scroll_down>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8d,-0x18(%rbp)
mov    %ecx,%eax
mov    -0x18(%rbp),%ecx
mov    %eax,-0x14(%rbp)
mov    %edx,%eax
mov    -0x14(%rbp),%edx
mov    %eax,-0x10(%rbp)
mov    %esi,%eax
mov    -0x10(%rbp),%esi
mov    %eax,-0xc(%rbp)
mov    %edi,%r8d
mov    -0xc(%rbp),%edi
mov    %r9b,%al
mov    %r8b,-0x1(%rbp)
mov    %dil,-0x2(%rbp)
mov    %sil,-0x3(%rbp)
mov    %dl,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    -0x2(%rbp),%al
mov    %al,-0x7(%rbp)
movsbl -0x7(%rbp),%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jl     11ea <__scroll_down+0xca>
movsbl -0x7(%rbp),%eax
movsbl -0x6(%rbp),%ecx
sub    %ecx,%eax
cmp    $0x0,%eax
jge    11ab <__scroll_down+0x8b>
mov    -0x7(%rbp),%dl
mov    -0x3(%rbp),%cl
mov    -0x4(%rbp),%al
movsbl %dl,%edi
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0x5(%rbp),%ecx
call   1040 <clear_row@plt>
jmp    11d8 <__scroll_down+0xb8>
mov    -0x7(%rbp),%sil
movsbl -0x7(%rbp),%eax
movsbl -0x6(%rbp),%ecx
sub    %ecx,%eax
mov    %al,%dl
mov    -0x3(%rbp),%cl
mov    -0x4(%rbp),%al
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x5(%rbp),%r8d
call   1030 <copy_row@plt>
jmp    11dd <__scroll_down+0xbd>
mov    -0x7(%rbp),%al
add    $0xff,%al
mov    %al,-0x7(%rbp)
jmp    1168 <__scroll_down+0x48>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__scroll_down>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r14d
cmp    %r14b,%bl
jge    1144 <__scroll_down+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movsbl %r9b,%r13d
movsbl %dl,%r15d
movsbl %cl,%r12d
movsbl %r8b,%ebp
jmp    1179 <__scroll_down+0x59>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
call   1030 <copy_row@plt>
add    $0xff,%bl
cmp    %r14b,%bl
jl     1135 <__scroll_down+0x15>
movsbl %bl,%edi
mov    %edi,%eax
sub    %r13d,%eax
jns    1160 <__scroll_down+0x40>
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
call   1040 <clear_row@plt>
jmp    1171 <__scroll_down+0x51>

LLVM IR (-O0):
define void @__scroll_down(i8 signext %0, i8 signext %1, i8 signext %2, i8 signext %3, i8 signext %4, i8 signext %5) {
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8 %3, i8* %10
store i8 %4, i8* %11
store i8 %5, i8* %12
%14 = load i8, i8* %8
store i8 %14, i8* %13
br label %15
15: ; preds = %47, %6
%16 = load i8, i8* %13
%17 = sext i8 %16 to i32
%18 = load i8, i8* %7
%19 = sext i8 %18 to i32
%20 = icmp sge i32 %17, %19
br i1 %20, label %21, label %50
21: ; preds = %15
%22 = load i8, i8* %13
%23 = sext i8 %22 to i32
%24 = load i8, i8* %12
%25 = sext i8 %24 to i32
%26 = sub nsw i32 %23, %25
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = load i8, i8* %13
%30 = load i8, i8* %9
%31 = load i8, i8* %10
%32 = load i8, i8* %11
%33 = call i32 @clear_row(i8 signext %29, i8 signext %30, i8 signext %31, i8 signext %32)
br label %46
34: ; preds = %21
%35 = load i8, i8* %13
%36 = load i8, i8* %13
%37 = sext i8 %36 to i32
%38 = load i8, i8* %12
%39 = sext i8 %38 to i32
%40 = sub nsw i32 %37, %39
%41 = trunc i32 %40 to i8
%42 = load i8, i8* %9
%43 = load i8, i8* %10
%44 = load i8, i8* %11
%45 = call i32 @copy_row(i8 signext %35, i8 signext %41, i8 signext %42, i8 signext %43, i8 signext %44)
br label %46
46: ; preds = %34, %28
br label %47
47: ; preds = %46
%48 = load i8, i8* %13
%49 = add i8 %48, -1
store i8 %49, i8* %13
br label %15
50: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @__scroll_down(i8 signext %0, i8 signext %1, i8 signext %2, i8 signext %3, i8 signext %4, i8 signext %5) {
%7 = icmp slt i8 %1, %0
br i1 %7, label %23, label %8
8: ; preds = %6
%9 = sext i8 %5 to i32
br label %10
10: ; preds = %8, %20
%11 = phi i8 [ %1, %8 ], [ %21, %20 ]
%12 = sext i8 %11 to i32
%13 = sub nsw i32 %12, %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @clear_row(i8 signext %11, i8 signext %2, i8 signext %3, i8 signext %4)
br label %20
17: ; preds = %10
%18 = trunc i32 %13 to i8
%19 = tail call i32 @copy_row(i8 signext %11, i8 signext %18, i8 signext %2, i8 signext %3, i8 signext %4)
br label %20
20: ; preds = %15, %17
%21 = add i8 %11, -1
%22 = icmp slt i8 %21, %0
br i1 %22, label %23, label %10
23: ; preds = %20, %6
ret void
}