void scroll_up_line() {
  for (int i = 80; i < (80 * 25); i++) {
    ((unsigned short *)(0xB8000 + 0xffff800000000000ULL))[i - 80] =
        ((unsigned short *)(0xB8000 + 0xffff800000000000ULL))[i];
  }
  for (int i = (80 * 25) - 80; i < (80 * 25); i++) {
    ((unsigned short *)(0xB8000 + 0xffff800000000000ULL))[i] = 0x0F20;
  }
}


x86 assembly (clang, -O0):
<scroll_up_line>:
push   %rbp
mov    %rsp,%rbp
movl   $0x50,-0x4(%rbp)
cmpl   $0x7d0,-0x4(%rbp)
jge    114f <scroll_up_line+0x4f>
movslq -0x4(%rbp),%rcx
movabs $0xffff8000000b8000,%rax
80 ff ff
mov    (%rax,%rcx,2),%dx
mov    -0x4(%rbp),%eax
sub    $0x50,%eax
movslq %eax,%rcx
movabs $0xffff8000000b8000,%rax
80 ff ff
mov    %dx,(%rax,%rcx,2)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <scroll_up_line+0xb>
movl   $0x780,-0x8(%rbp)
cmpl   $0x7d0,-0x8(%rbp)
jge    1185 <scroll_up_line+0x85>
movslq -0x8(%rbp),%rcx
movabs $0xffff8000000b8000,%rax
80 ff ff
movw   $0xf20,(%rax,%rcx,2)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <scroll_up_line+0x56>
pop    %rbp
ret

x86 assembly (clang, -O2):
<scroll_up_line>:
movabs $0xffff8000000b8110,%rax
80 ff ff
xor    %ecx,%ecx
nopl   0x0(%rax)
movaps -0x70(%rax,%rcx,2),%xmm0
movaps -0x60(%rax,%rcx,2),%xmm1
movaps -0x50(%rax,%rcx,2),%xmm2
movaps -0x40(%rax,%rcx,2),%xmm3
movaps %xmm0,-0x110(%rax,%rcx,2)
ff
movaps %xmm1,-0x100(%rax,%rcx,2)
ff
movaps %xmm2,-0xf0(%rax,%rcx,2)
ff
movaps %xmm3,-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    $0x40,%rcx
cmp    $0x780,%rcx
jne    1110 <scroll_up_line+0x10>
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0xdf0(%rax)
movaps %xmm0,0xe00(%rax)
movaps %xmm0,0xe10(%rax)
movaps %xmm0,0xe20(%rax)
movaps %xmm0,0xe30(%rax)
movaps %xmm0,0xe40(%rax)
movaps %xmm0,0xe50(%rax)
movaps %xmm0,0xe60(%rax)
movaps %xmm0,0xe70(%rax)
movaps %xmm0,0xe80(%rax)
ret

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

LLVM IR (-O2):
define void @scroll_up_line() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %50, %1 ]
%3 = add nuw nsw i64 %2, 80
%4 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %3
%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 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %2
%11 = bitcast i16* %10 to <8 x i16>*
store <8 x i16> %6, <8 x i16>* %11
%12 = getelementptr inbounds i16, i16* %10, i64 8
%13 = bitcast i16* %12 to <8 x i16>*
store <8 x i16> %9, <8 x i16>* %13
%14 = or i64 %2, 16
%15 = add nuw nsw i64 %2, 96
%16 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %15
%17 = bitcast i16* %16 to <8 x i16>*
%18 = load <8 x i16>, <8 x i16>* %17
%19 = getelementptr inbounds i16, i16* %16, i64 8
%20 = bitcast i16* %19 to <8 x i16>*
%21 = load <8 x i16>, <8 x i16>* %20
%22 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %14
%23 = bitcast i16* %22 to <8 x i16>*
store <8 x i16> %18, <8 x i16>* %23
%24 = getelementptr inbounds i16, i16* %22, i64 8
%25 = bitcast i16* %24 to <8 x i16>*
store <8 x i16> %21, <8 x i16>* %25
%26 = or i64 %2, 32
%27 = add nuw nsw i64 %2, 112
%28 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %27
%29 = bitcast i16* %28 to <8 x i16>*
%30 = load <8 x i16>, <8 x i16>* %29
%31 = getelementptr inbounds i16, i16* %28, i64 8
%32 = bitcast i16* %31 to <8 x i16>*
%33 = load <8 x i16>, <8 x i16>* %32
%34 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %26
%35 = bitcast i16* %34 to <8 x i16>*
store <8 x i16> %30, <8 x i16>* %35
%36 = getelementptr inbounds i16, i16* %34, i64 8
%37 = bitcast i16* %36 to <8 x i16>*
store <8 x i16> %33, <8 x i16>* %37
%38 = or i64 %2, 48
%39 = add nuw nsw i64 %2, 128
%40 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %39
%41 = bitcast i16* %40 to <8 x i16>*
%42 = load <8 x i16>, <8 x i16>* %41
%43 = getelementptr inbounds i16, i16* %40, i64 8
%44 = bitcast i16* %43 to <8 x i16>*
%45 = load <8 x i16>, <8 x i16>* %44
%46 = getelementptr inbounds i16, i16* inttoptr (i64 -140737487601664 to i16*), i64 %38
%47 = bitcast i16* %46 to <8 x i16>*
store <8 x i16> %42, <8 x i16>* %47
%48 = getelementptr inbounds i16, i16* %46, i64 8
%49 = bitcast i16* %48 to <8 x i16>*
store <8 x i16> %45, <8 x i16>* %49
%50 = add nuw nsw i64 %2, 64
%51 = icmp eq i64 %50, 1920
br i1 %51, label %52, label %1
52: ; preds = %1
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597824 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597808 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597792 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597776 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597760 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597744 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597728 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597712 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597696 to <8 x i16>*)
store <8 x i16> <i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872, i16 3872>, <8 x i16>* inttoptr (i64 -140737487597680 to <8 x i16>*)
ret void
}