#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_up(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_top; row <= row_bottom; ++row) {
    if (row + scroll_count > row_bottom)
      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_up>:
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    -0x1(%rbp),%al
mov    %al,-0x7(%rbp)
movsbl -0x7(%rbp),%eax
movsbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jg     11ed <__scroll_up+0xcd>
movsbl -0x7(%rbp),%eax
movsbl -0x6(%rbp),%ecx
add    %ecx,%eax
movsbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jle    11ae <__scroll_up+0x8e>
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    11db <__scroll_up+0xbb>
mov    -0x7(%rbp),%sil
movsbl -0x7(%rbp),%eax
movsbl -0x6(%rbp),%ecx
add    %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    11e0 <__scroll_up+0xc0>
mov    -0x7(%rbp),%al
add    $0x1,%al
mov    %al,-0x7(%rbp)
jmp    1168 <__scroll_up+0x48>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__scroll_up>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %esi,0x4(%rsp)
cmp    %sil,%bpl
jle    1145 <__scroll_up+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movsbl 0x4(%rsp),%r13d
movsbl %r9b,%r14d
movsbl %dl,%r15d
movsbl %cl,%r12d
movsbl %r8b,%ebx
jmp    117c <__scroll_up+0x5c>
nopl   (%rax)
movsbl %al,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebx,%r8d
call   1030 <copy_row@plt>
add    $0x1,%bpl
cmp    0x4(%rsp),%bpl
jg     1136 <__scroll_up+0x16>
movsbl %bpl,%edi
lea    (%rdi,%r14,1),%eax
cmp    %r13d,%eax
jle    1160 <__scroll_up+0x40>
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1040 <clear_row@plt>
jmp    1171 <__scroll_up+0x51>

LLVM IR (-O0):
define void @__scroll_up(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* %7
store i8 %14, i8* %13
br label %15
15: ; preds = %49, %6
%16 = load i8, i8* %13
%17 = sext i8 %16 to i32
%18 = load i8, i8* %8
%19 = sext i8 %18 to i32
%20 = icmp sle i32 %17, %19
br i1 %20, label %21, label %52
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 = add nsw i32 %23, %25
%27 = load i8, i8* %8
%28 = sext i8 %27 to i32
%29 = icmp sgt i32 %26, %28
br i1 %29, label %30, label %36
30: ; preds = %21
%31 = load i8, i8* %13
%32 = load i8, i8* %9
%33 = load i8, i8* %10
%34 = load i8, i8* %11
%35 = call i32 @clear_row(i8 signext %31, i8 signext %32, i8 signext %33, i8 signext %34)
br label %48
36: ; preds = %21
%37 = load i8, i8* %13
%38 = load i8, i8* %13
%39 = sext i8 %38 to i32
%40 = load i8, i8* %12
%41 = sext i8 %40 to i32
%42 = add nsw i32 %39, %41
%43 = trunc i32 %42 to i8
%44 = load i8, i8* %9
%45 = load i8, i8* %10
%46 = load i8, i8* %11
%47 = call i32 @copy_row(i8 signext %37, i8 signext %43, i8 signext %44, i8 signext %45, i8 signext %46)
br label %48
48: ; preds = %36, %30
br label %49
49: ; preds = %48
%50 = load i8, i8* %13
%51 = add i8 %50, 1
store i8 %51, i8* %13
br label %15
52: ; preds = %15
ret void
}

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