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


x86 assembly (clang, -O0):
<clear_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xb8000,%eax
mov    %rax,-0x8(%rbp)
movl   $0xfa0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1166 <clear_screen+0x56>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <clear_screen+0x1f>
xor    %edi,%edi
call   1030 <set_cursor@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_screen>:
mov    $0xb8070,%eax
xor    %ecx,%ecx
movaps 0xee2(%rip),%xmm0
xchg   %ax,%ax
movaps %xmm0,-0x70(%rax,%rcx,2)
movaps %xmm0,-0x60(%rax,%rcx,2)
cmp    $0x7c0,%rcx
je     1156 <clear_screen+0x46>
movaps %xmm0,-0x50(%rax,%rcx,2)
movaps %xmm0,-0x40(%rax,%rcx,2)
movaps %xmm0,-0x30(%rax,%rcx,2)
movaps %xmm0,-0x20(%rax,%rcx,2)
movaps %xmm0,-0x10(%rax,%rcx,2)
movaps %xmm0,(%rax,%rcx,2)
add    $0x40,%rcx
jmp    1120 <clear_screen+0x10>
xor    %edi,%edi
jmp    1030 <set_cursor@plt>

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

LLVM IR (-O2):
define void @clear_screen() {
br label %1
1: ; preds = %12, %0
%2 = phi i64 [ 0, %0 ], [ %34, %12 ]
%3 = shl nuw i64 %2, 1
%4 = or i64 %3, 1
%5 = or i64 %3, 17
%6 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %4
%7 = bitcast i8* %6 to <16 x i8>*
%8 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %5
%9 = bitcast i8* %8 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>* %7
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>* %9
%10 = or i64 %2, 16
%11 = icmp eq i64 %10, 2000
br i1 %11, label %35, label %12
12: ; preds = %1
%13 = shl nuw i64 %10, 1
%14 = or i64 %13, 1
%15 = or i64 %13, 17
%16 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %14
%17 = bitcast i8* %16 to <16 x i8>*
%18 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %15
%19 = bitcast i8* %18 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>* %17
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
%20 = shl nuw i64 %2, 1
%21 = or i64 %20, 65
%22 = or i64 %20, 81
%23 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %21
%24 = bitcast i8* %23 to <16 x i8>*
%25 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %22
%26 = bitcast i8* %25 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>* %24
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>* %26
%27 = shl nuw i64 %2, 1
%28 = or i64 %27, 97
%29 = or i64 %27, 113
%30 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %28
%31 = bitcast i8* %30 to <16 x i8>*
%32 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %29
%33 = bitcast i8* %32 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>* %31
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>* %33
%34 = add nuw nsw i64 %2, 64
br label %1
35: ; preds = %1
%36 = tail call i32 @set_cursor(i32 0)
ret void
}