#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*/ get_offset(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ set_cursor_offset(int /*<<< orphan*/);
void clear_screen() {
  int screen_size = 80 * 25;
  int i;
  char *screen = (char *)0xb8000;
  for (i = 0; i < screen_size; i++) {
    screen[i * 2] = ' ';
    screen[i * 2 + 1] = 0x0f;
  }
  set_cursor_offset(get_offset(0, 0));
}


x86 assembly (clang, -O0):
<clear_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x7d0,-0x4(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117e <clear_screen+0x5e>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113f <clear_screen+0x1f>
xor    %esi,%esi
mov    %esi,%edi
call   1040 <get_offset@plt>
mov    %eax,%edi
call   1030 <set_cursor_offset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_screen>:
push   %rax
mov    $0xb8030,%eax
xor    %ecx,%ecx
movaps 0xed1(%rip),%xmm0
nop
movaps %xmm0,-0x30(%rax,%rcx,2)
movaps %xmm0,-0x20(%rax,%rcx,2)
cmp    $0x7c0,%rcx
je     1152 <clear_screen+0x32>
movaps %xmm0,-0x10(%rax,%rcx,2)
movaps %xmm0,(%rax,%rcx,2)
add    $0x20,%rcx
jmp    1130 <clear_screen+0x10>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <get_offset@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <set_cursor_offset@plt>

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

LLVM IR (-O2):
define void @clear_screen() {
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 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15>, <16 x i8>* %8
store <16 x i8> <i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15>, <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 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15>, <16 x i8>* %19
store <16 x i8> <i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15, i8 32, i8 15>, <16 x i8>* %21
%22 = add nuw nsw i64 %2, 32
br label %1
23: ; preds = %1
%24 = tail call i32 @get_offset(i32 0, i32 0)
%25 = tail call i32 @set_cursor_offset(i32 %24)
ret void
}