#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*/ out(int, int);
void clrscr() {
  unsigned char *vidmem = (unsigned char *)0xB8000;
  const long size = 80 * 25;
  long loop;
  for (loop = 0; loop < size; loop++) {
    *vidmem++ = 0;
    *vidmem++ = 0xF;
  }
  out(0x3D4, 14);
  out(0x3D5, 0);
  out(0x3D4, 15);
  out(0x3D5, 0);
}


x86 assembly (clang, -O0):
<clrscr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xb8000,%eax
mov    %rax,-0x8(%rbp)
movq   $0x7d0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x7d0,-0x18(%rbp)
jge    1174 <clrscr+0x64>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0xf,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1131 <clrscr+0x21>
mov    $0x3d4,%edi
mov    $0xe,%esi
call   1030 <out@plt>
mov    $0x3d5,%edi
xor    %esi,%esi
call   1030 <out@plt>
mov    $0x3d4,%edi
mov    $0xf,%esi
call   1030 <out@plt>
mov    $0x3d5,%edi
xor    %esi,%esi
call   1030 <out@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clrscr>:
push   %rax
mov    $0x38,%eax
mov    $0xb8000,%ecx
movaps 0xede(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movaps %xmm0,-0x70(%rcx,%rax,2)
movaps %xmm0,-0x60(%rcx,%rax,2)
cmp    $0x7f8,%rax
je     1165 <clrscr+0x55>
movaps %xmm0,-0x50(%rcx,%rax,2)
movaps %xmm0,-0x40(%rcx,%rax,2)
movaps %xmm0,-0x30(%rcx,%rax,2)
movaps %xmm0,-0x20(%rcx,%rax,2)
movaps %xmm0,-0x10(%rcx,%rax,2)
movaps %xmm0,(%rcx,%rax,2)
add    $0x40,%rax
jmp    1130 <clrscr+0x20>
mov    $0x3d4,%edi
mov    $0xe,%esi
call   1030 <out@plt>
mov    $0x3d5,%edi
xor    %esi,%esi
call   1030 <out@plt>
mov    $0x3d4,%edi
mov    $0xf,%esi
call   1030 <out@plt>
mov    $0x3d5,%edi
xor    %esi,%esi
pop    %rax
jmp    1030 <out@plt>

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

LLVM IR (-O2):
define void @clrscr() {
br label %1
1: ; preds = %12, %0
%2 = phi i64 [ 0, %0 ], [ %36, %12 ]
%3 = shl nuw i64 %2, 1
%4 = shl nuw i64 %2, 1
%5 = or i64 %4, 16
%6 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %3
%7 = bitcast i8* %6 to <16 x i8>*
%8 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %5
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %7
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %9
%10 = or i64 %2, 16
%11 = icmp eq i64 %10, 2000
br i1 %11, label %37, label %12
12: ; preds = %1
%13 = shl nuw i64 %10, 1
%14 = shl nuw i64 %10, 1
%15 = or i64 %14, 16
%16 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %13
%17 = bitcast i8* %16 to <16 x i8>*
%18 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %15
%19 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %17
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %19
%20 = or i64 %2, 32
%21 = shl nuw i64 %20, 1
%22 = shl nuw i64 %20, 1
%23 = or i64 %22, 16
%24 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %21
%25 = bitcast i8* %24 to <16 x i8>*
%26 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %23
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %25
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %27
%28 = or i64 %2, 48
%29 = shl nuw i64 %28, 1
%30 = shl nuw i64 %28, 1
%31 = or i64 %30, 16
%32 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %29
%33 = bitcast i8* %32 to <16 x i8>*
%34 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %31
%35 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %33
store <16 x i8> <i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15, i8 0, i8 15>, <16 x i8>* %35
%36 = add nuw nsw i64 %2, 64
br label %1
37: ; preds = %1
%38 = tail call i32 @out(i32 980, i32 14)
%39 = tail call i32 @out(i32 981, i32 0)
%40 = tail call i32 @out(i32 980, i32 15)
%41 = tail call i32 @out(i32 981, i32 0)
ret void
}