#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*/ B8000_SetCursorPosition(int /*<<< orphan*/,
                                           int /*<<< orphan*/);
void B8000_ClearScreen(void) {
  unsigned char *textvram = (unsigned char *)0xB8000;
  for (int i = 0; i < 80 * 25; i++) {
    textvram[i * 2 + 0] = ' ';
    textvram[i * 2 + 1] = 0x0A;
  }
  B8000_SetCursorPosition(0, 0);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xb8000,%eax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x7d0,-0xc(%rbp)
jge    116b <B8000_ClearScreen+0x5b>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <B8000_ClearScreen+0x18>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <B8000_SetCursorPosition@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
mov    $0xb8030,%eax
xor    %ecx,%ecx
movaps 0xee2(%rip),%xmm0
xchg   %ax,%ax
movaps %xmm0,-0x30(%rax,%rcx,2)
movaps %xmm0,-0x20(%rax,%rcx,2)
cmp    $0x7c0,%rcx
je     1142 <B8000_ClearScreen+0x32>
movaps %xmm0,-0x10(%rax,%rcx,2)
movaps %xmm0,(%rax,%rcx,2)
add    $0x20,%rcx
jmp    1120 <B8000_ClearScreen+0x10>
xor    %edi,%edi
xor    %esi,%esi
jmp    1030 <B8000_SetCursorPosition@plt>

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

LLVM IR (-O2):
define void @B8000_ClearScreen() {
br label %1
1: ; preds = %13, %0
%2 = phi i64 [ 0, %0 ], [ %22, %13 ]
%3 = shl nuw nsw i64 %2, 1
%4 = shl nuw i64 %2, 1
%5 = or i64 %3, 1
%6 = or i64 %4, 17
%7 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %5
%8 = bitcast i8* %7 to <16 x i8>*
%9 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %6
%10 = bitcast i8* %9 to <16 x i8>*
store <16 x i8> <i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10>, <16 x i8>* %8
store <16 x i8> <i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10>, <16 x i8>* %10
%11 = or i64 %2, 16
%12 = icmp eq i64 %11, 2000
br i1 %12, label %23, label %13
13: ; preds = %1
%14 = shl nuw nsw i64 %11, 1
%15 = shl nuw i64 %11, 1
%16 = or i64 %14, 1
%17 = or i64 %15, 17
%18 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %16
%19 = bitcast i8* %18 to <16 x i8>*
%20 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %17
%21 = bitcast i8* %20 to <16 x i8>*
store <16 x i8> <i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10>, <16 x i8>* %19
store <16 x i8> <i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10, i8 32, i8 10>, <16 x i8>* %21
%22 = add nuw nsw i64 %2, 32
br label %1
23: ; preds = %1
%24 = tail call i32 @B8000_SetCursorPosition(i32 0, i32 0)
ret void
}