void scroll_screen() {
  unsigned short *v;
  int i;
  int n = (80 * 25);
  for (v = (unsigned short *)0xB8000, i = 0; i < n; i++) {
    *v = *(v + 80);
    ++v;
  }
  for (v = (unsigned short *)0xB8000 + n, i = 0; i < 80; i++) {
    *v++ = 0x0F & (0x20 << 8);
  }
}


x86 assembly (clang, -O0):
<scroll_screen>:
push   %rbp
mov    %rsp,%rbp
movl   $0x7d0,-0x10(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1153 <scroll_screen+0x53>
mov    -0x8(%rbp),%rax
mov    0xa0(%rax),%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    111b <scroll_screen+0x1b>
movslq -0x10(%rbp),%rcx
mov    $0xb8000,%eax
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x50,-0xc(%rbp)
jge    119a <scroll_screen+0x9a>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x8(%rbp)
movw   $0x0,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116e <scroll_screen+0x6e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<scroll_screen>:
mov    $0xb8130,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movaps -0x90(%rax,%rcx,2),%xmm0
ff
movaps -0x80(%rax,%rcx,2),%xmm1
movaps -0x70(%rax,%rcx,2),%xmm2
movaps -0x60(%rax,%rcx,2),%xmm3
movaps %xmm0,-0x130(%rax,%rcx,2)
ff
movaps %xmm1,-0x120(%rax,%rcx,2)
ff
movaps %xmm2,-0x110(%rax,%rcx,2)
ff
movaps %xmm3,-0x100(%rax,%rcx,2)
ff
movaps -0x50(%rax,%rcx,2),%xmm0
movaps -0x40(%rax,%rcx,2),%xmm1
movaps %xmm0,-0xf0(%rax,%rcx,2)
ff
movaps %xmm1,-0xe0(%rax,%rcx,2)
ff
movaps -0x30(%rax,%rcx,2),%xmm0
movaps -0x20(%rax,%rcx,2),%xmm1
movaps %xmm0,-0xd0(%rax,%rcx,2)
ff
movaps %xmm1,-0xc0(%rax,%rcx,2)
ff
movaps -0x10(%rax,%rcx,2),%xmm0
movaps (%rax,%rcx,2),%xmm1
movaps %xmm0,-0xb0(%rax,%rcx,2)
ff
movaps %xmm1,-0xa0(%rax,%rcx,2)
ff
add    $0x50,%rcx
cmp    $0x7d0,%rcx
jne    1110 <scroll_screen+0x10>
xorps  %xmm0,%xmm0
movaps %xmm0,0xb9030
movaps %xmm0,0xb9020
movaps %xmm0,0xb9010
movaps %xmm0,0xb9000
movaps %xmm0,0xb8ff0
movaps %xmm0,0xb8fe0
movaps %xmm0,0xb8fd0
movaps %xmm0,0xb8fc0
movaps %xmm0,0xb8fb0
movaps %xmm0,0xb8fa0
ret

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

LLVM IR (-O2):
define void @scroll_screen() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %57, %1 ]
%3 = getelementptr i16, i16* inttoptr (i64 753664 to i16*), i64 %2
%4 = getelementptr inbounds i16, i16* %3, i64 80
%5 = bitcast i16* %4 to <8 x i16>*
%6 = load <8 x i16>, <8 x i16>* %5
%7 = getelementptr inbounds i16, i16* %4, i64 8
%8 = bitcast i16* %7 to <8 x i16>*
%9 = load <8 x i16>, <8 x i16>* %8
%10 = bitcast i16* %3 to <8 x i16>*
store <8 x i16> %6, <8 x i16>* %10
%11 = getelementptr i16, i16* %3, i64 8
%12 = bitcast i16* %11 to <8 x i16>*
store <8 x i16> %9, <8 x i16>* %12
%13 = add nuw nsw i64 %2, 16
%14 = getelementptr i16, i16* inttoptr (i64 753664 to i16*), i64 %13
%15 = getelementptr inbounds i16, i16* %14, i64 80
%16 = bitcast i16* %15 to <8 x i16>*
%17 = load <8 x i16>, <8 x i16>* %16
%18 = getelementptr inbounds i16, i16* %15, i64 8
%19 = bitcast i16* %18 to <8 x i16>*
%20 = load <8 x i16>, <8 x i16>* %19
%21 = bitcast i16* %14 to <8 x i16>*
store <8 x i16> %17, <8 x i16>* %21
%22 = getelementptr i16, i16* %14, i64 8
%23 = bitcast i16* %22 to <8 x i16>*
store <8 x i16> %20, <8 x i16>* %23
%24 = add nuw nsw i64 %2, 32
%25 = getelementptr i16, i16* inttoptr (i64 753664 to i16*), i64 %24
%26 = getelementptr inbounds i16, i16* %25, i64 80
%27 = bitcast i16* %26 to <8 x i16>*
%28 = load <8 x i16>, <8 x i16>* %27
%29 = getelementptr inbounds i16, i16* %26, i64 8
%30 = bitcast i16* %29 to <8 x i16>*
%31 = load <8 x i16>, <8 x i16>* %30
%32 = bitcast i16* %25 to <8 x i16>*
store <8 x i16> %28, <8 x i16>* %32
%33 = getelementptr i16, i16* %25, i64 8
%34 = bitcast i16* %33 to <8 x i16>*
store <8 x i16> %31, <8 x i16>* %34
%35 = add nuw nsw i64 %2, 48
%36 = getelementptr i16, i16* inttoptr (i64 753664 to i16*), i64 %35
%37 = getelementptr inbounds i16, i16* %36, i64 80
%38 = bitcast i16* %37 to <8 x i16>*
%39 = load <8 x i16>, <8 x i16>* %38
%40 = getelementptr inbounds i16, i16* %37, i64 8
%41 = bitcast i16* %40 to <8 x i16>*
%42 = load <8 x i16>, <8 x i16>* %41
%43 = bitcast i16* %36 to <8 x i16>*
store <8 x i16> %39, <8 x i16>* %43
%44 = getelementptr i16, i16* %36, i64 8
%45 = bitcast i16* %44 to <8 x i16>*
store <8 x i16> %42, <8 x i16>* %45
%46 = add nuw nsw i64 %2, 64
%47 = getelementptr i16, i16* inttoptr (i64 753664 to i16*), i64 %46
%48 = getelementptr inbounds i16, i16* %47, i64 80
%49 = bitcast i16* %48 to <8 x i16>*
%50 = load <8 x i16>, <8 x i16>* %49
%51 = getelementptr inbounds i16, i16* %48, i64 8
%52 = bitcast i16* %51 to <8 x i16>*
%53 = load <8 x i16>, <8 x i16>* %52
%54 = bitcast i16* %47 to <8 x i16>*
store <8 x i16> %50, <8 x i16>* %54
%55 = getelementptr i16, i16* %47, i64 8
%56 = bitcast i16* %55 to <8 x i16>*
store <8 x i16> %53, <8 x i16>* %56
%57 = add nuw nsw i64 %2, 80
%58 = icmp eq i64 %57, 2000
br i1 %58, label %59, label %1
59: ; preds = %1
ret void
}