#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*/ memory_copy(unsigned char *, unsigned char *, int);
void scroll_up() {
  int i;
  unsigned char *video_memory = (unsigned char *)0xb8000;
  for (i = 0; i <= 25; i++) {
    memory_copy((video_memory + 160), video_memory, 160);
    video_memory += 160;
  }
}


x86 assembly (clang, -O0):
<scroll_up>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xb8000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x19,-0x4(%rbp)
jg     1167 <scroll_up+0x57>
mov    -0x10(%rbp),%rdi
add    $0xa0,%rdi
mov    -0x10(%rbp),%rsi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    -0x10(%rbp),%rax
add    $0xa0,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1128 <scroll_up+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scroll_up>:
push   %rax
mov    $0xb80a0,%edi
mov    $0xb8000,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8140,%edi
mov    $0xb80a0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb81e0,%edi
mov    $0xb8140,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8280,%edi
mov    $0xb81e0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8320,%edi
mov    $0xb8280,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb83c0,%edi
mov    $0xb8320,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8460,%edi
mov    $0xb83c0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8500,%edi
mov    $0xb8460,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb85a0,%edi
mov    $0xb8500,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8640,%edi
mov    $0xb85a0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb86e0,%edi
mov    $0xb8640,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8780,%edi
mov    $0xb86e0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8820,%edi
mov    $0xb8780,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb88c0,%edi
mov    $0xb8820,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8960,%edi
mov    $0xb88c0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8a00,%edi
mov    $0xb8960,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8aa0,%edi
mov    $0xb8a00,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8b40,%edi
mov    $0xb8aa0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8be0,%edi
mov    $0xb8b40,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8c80,%edi
mov    $0xb8be0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8d20,%edi
mov    $0xb8c80,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8dc0,%edi
mov    $0xb8d20,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8e60,%edi
mov    $0xb8dc0,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8f00,%edi
mov    $0xb8e60,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb8fa0,%edi
mov    $0xb8f00,%esi
mov    $0xa0,%edx
call   1030 <memory_copy@plt>
mov    $0xb9040,%edi
mov    $0xb8fa0,%esi
mov    $0xa0,%edx
pop    %rax
jmp    1030 <memory_copy@plt>

LLVM IR (-O0):
define void @scroll_up() {
%1 = alloca i32
%2 = alloca i8*
store i8* inttoptr (i64 753664 to i8*), i8** %2
store i32 0, i32* %1
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %1
%5 = icmp sle i32 %4, 25
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 160
%9 = load i8*, i8** %2
%10 = call i32 @memory_copy(i8* %8, i8* %9, i32 160)
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 160
store i8* %12, i8** %2
br label %13
13: ; preds = %6
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %3
16: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @scroll_up() {
%1 = tail call i32 @memory_copy(i8* inttoptr (i64 753824 to i8*), i8* inttoptr (i64 753664 to i8*), i32 160)
%2 = tail call i32 @memory_copy(i8* inttoptr (i64 753984 to i8*), i8* inttoptr (i64 753824 to i8*), i32 160)
%3 = tail call i32 @memory_copy(i8* inttoptr (i64 754144 to i8*), i8* inttoptr (i64 753984 to i8*), i32 160)
%4 = tail call i32 @memory_copy(i8* inttoptr (i64 754304 to i8*), i8* inttoptr (i64 754144 to i8*), i32 160)
%5 = tail call i32 @memory_copy(i8* inttoptr (i64 754464 to i8*), i8* inttoptr (i64 754304 to i8*), i32 160)
%6 = tail call i32 @memory_copy(i8* inttoptr (i64 754624 to i8*), i8* inttoptr (i64 754464 to i8*), i32 160)
%7 = tail call i32 @memory_copy(i8* inttoptr (i64 754784 to i8*), i8* inttoptr (i64 754624 to i8*), i32 160)
%8 = tail call i32 @memory_copy(i8* inttoptr (i64 754944 to i8*), i8* inttoptr (i64 754784 to i8*), i32 160)
%9 = tail call i32 @memory_copy(i8* inttoptr (i64 755104 to i8*), i8* inttoptr (i64 754944 to i8*), i32 160)
%10 = tail call i32 @memory_copy(i8* inttoptr (i64 755264 to i8*), i8* inttoptr (i64 755104 to i8*), i32 160)
%11 = tail call i32 @memory_copy(i8* inttoptr (i64 755424 to i8*), i8* inttoptr (i64 755264 to i8*), i32 160)
%12 = tail call i32 @memory_copy(i8* inttoptr (i64 755584 to i8*), i8* inttoptr (i64 755424 to i8*), i32 160)
%13 = tail call i32 @memory_copy(i8* inttoptr (i64 755744 to i8*), i8* inttoptr (i64 755584 to i8*), i32 160)
%14 = tail call i32 @memory_copy(i8* inttoptr (i64 755904 to i8*), i8* inttoptr (i64 755744 to i8*), i32 160)
%15 = tail call i32 @memory_copy(i8* inttoptr (i64 756064 to i8*), i8* inttoptr (i64 755904 to i8*), i32 160)
%16 = tail call i32 @memory_copy(i8* inttoptr (i64 756224 to i8*), i8* inttoptr (i64 756064 to i8*), i32 160)
%17 = tail call i32 @memory_copy(i8* inttoptr (i64 756384 to i8*), i8* inttoptr (i64 756224 to i8*), i32 160)
%18 = tail call i32 @memory_copy(i8* inttoptr (i64 756544 to i8*), i8* inttoptr (i64 756384 to i8*), i32 160)
%19 = tail call i32 @memory_copy(i8* inttoptr (i64 756704 to i8*), i8* inttoptr (i64 756544 to i8*), i32 160)
%20 = tail call i32 @memory_copy(i8* inttoptr (i64 756864 to i8*), i8* inttoptr (i64 756704 to i8*), i32 160)
%21 = tail call i32 @memory_copy(i8* inttoptr (i64 757024 to i8*), i8* inttoptr (i64 756864 to i8*), i32 160)
%22 = tail call i32 @memory_copy(i8* inttoptr (i64 757184 to i8*), i8* inttoptr (i64 757024 to i8*), i32 160)
%23 = tail call i32 @memory_copy(i8* inttoptr (i64 757344 to i8*), i8* inttoptr (i64 757184 to i8*), i32 160)
%24 = tail call i32 @memory_copy(i8* inttoptr (i64 757504 to i8*), i8* inttoptr (i64 757344 to i8*), i32 160)
%25 = tail call i32 @memory_copy(i8* inttoptr (i64 757664 to i8*), i8* inttoptr (i64 757504 to i8*), i32 160)
%26 = tail call i32 @memory_copy(i8* inttoptr (i64 757824 to i8*), i8* inttoptr (i64 757664 to i8*), i32 160)
ret void
}