void kernel_clear_screen(char *vidptr) {
  for (unsigned int i = 0; i < 80 * 25 * 2; i += 2) {
    vidptr[i] = ' ';
    vidptr[i + 1] = 0x07;
  }
}


x86 assembly (clang, -O0):
<kernel_clear_screen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xfa0,-0xc(%rbp)
jae    1145 <kernel_clear_screen+0x45>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x7,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <kernel_clear_screen+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_clear_screen>:
mov    $0x38,%eax
movaps 0xef4(%rip),%xmm0
nopl   0x0(%rax)
movups %xmm0,-0x70(%rdi,%rax,2)
movups %xmm0,-0x60(%rdi,%rax,2)
cmp    $0x7f8,%rax
je     1145 <kernel_clear_screen+0x45>
movups %xmm0,-0x50(%rdi,%rax,2)
movups %xmm0,-0x40(%rdi,%rax,2)
movups %xmm0,-0x30(%rdi,%rax,2)
movups %xmm0,-0x20(%rdi,%rax,2)
movups %xmm0,-0x10(%rdi,%rax,2)
movups %xmm0,(%rdi,%rax,2)
add    $0x40,%rax
jmp    1110 <kernel_clear_screen+0x10>
ret

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

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