#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 */
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
void vga_early_scroll(void) {
  int row;
  for (row = 0; row < 24; row++)
    memcpy(&((uint16_t *)0xB8000)[row * 80],
           &((uint16_t *)0xB8000)[row * 80 + 80], 160);
  memset(&((uint16_t *)0xB8000)[row * 80], 0, 160);
}


x86 assembly (clang, -O0):
<vga_early_scroll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x18,-0x4(%rbp)
jge    1178 <vga_early_scroll+0x58>
imul   $0x50,-0x4(%rbp),%eax
cltq
mov    $0xb8000,%edi
shl    $0x2,%rax
add    %rax,%rdi
imul   $0x50,-0x4(%rbp),%eax
add    $0x50,%eax
cltq
mov    $0xb8000,%esi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0xa0,%edx
call   1040 <memcpy@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <vga_early_scroll+0xf>
imul   $0x50,-0x4(%rbp),%eax
cltq
mov    $0xb8000,%edi
shl    $0x2,%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1030 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vga_early_scroll>:
push   %r14
push   %rbx
push   %rax
mov    $0xb8000,%edi
mov    $0x18,%ebx
xchg   %ax,%ax
lea    0x140(%rdi),%r14
mov    %r14,%rsi
mov    $0xa0,%edx
call   1040 <memcpy@plt>
mov    %r14,%rdi
add    $0xffffffffffffffff,%rbx
jne    1130 <vga_early_scroll+0x10>
mov    $0xb9e00,%edi
xor    %esi,%esi
mov    $0xa0,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <memset@plt>

LLVM IR (-O0):
define void @vga_early_scroll() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %16, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 24
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = load i32, i32* %1
%7 = mul nsw i32 %6, 80
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* inttoptr (i64 753664 to i32*), i64 %8
%10 = load i32, i32* %1
%11 = mul nsw i32 %10, 80
%12 = add nsw i32 %11, 80
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* inttoptr (i64 753664 to i32*), i64 %13
%15 = call i32 @memcpy(i32* %9, i32* %14, i32 160)
br label %16
16: ; preds = %5
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
br label %2
19: ; preds = %2
%20 = load i32, i32* %1
%21 = mul nsw i32 %20, 80
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* inttoptr (i64 753664 to i32*), i64 %22
%24 = call i32 @memset(i32* %23, i32 0, i32 160)
ret void
}

LLVM IR (-O2):
define void @vga_early_scroll() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %8, %1 ]
%3 = mul nuw nsw i64 %2, 80
%4 = getelementptr inbounds i32, i32* inttoptr (i64 753664 to i32*), i64 %3
%5 = add nuw nsw i64 %3, 80
%6 = getelementptr inbounds i32, i32* inttoptr (i64 753664 to i32*), i64 %5
%7 = tail call i32 @memcpy(i32* %4, i32* %6, i32 160)
%8 = add nuw nsw i64 %2, 1
%9 = icmp eq i64 %8, 24
br i1 %9, label %10, label %1
10: ; preds = %1
%11 = tail call i32 @memset(i32* inttoptr (i64 761344 to i32*), i32 0, i32 160)
ret void
}