int scroll(int pos) {
  int i;
  char *fb = (char *)0xC00b8000;
  for (i = 160; i < 2000; i++)
    fb[i - 160] = fb[i];
  return pos - 160;
}


x86 assembly (clang, -O0):
<scroll>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0xc00b8000,%eax
mov    %rax,-0x10(%rbp)
movl   $0xa0,-0x8(%rbp)
cmpl   $0x7d0,-0x8(%rbp)
jge    1150 <scroll+0x50>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0xa0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1117 <scroll+0x17>
mov    -0x4(%rbp),%eax
sub    $0xa0,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<scroll>:
mov    %edi,%eax
mov    $0xc00b80f0,%ecx
xor    %edx,%edx
nopl   0x0(%rax)
movaps -0x50(%rcx,%rdx,1),%xmm0
movaps -0x40(%rcx,%rdx,1),%xmm1
movaps -0x30(%rcx,%rdx,1),%xmm2
movaps -0x20(%rcx,%rdx,1),%xmm3
movaps %xmm0,-0xf0(%rcx,%rdx,1)
ff
movaps %xmm1,-0xe0(%rcx,%rdx,1)
ff
movaps %xmm2,-0xd0(%rcx,%rdx,1)
ff
movaps %xmm3,-0xc0(%rcx,%rdx,1)
ff
movaps -0x10(%rcx,%rdx,1),%xmm0
movaps (%rcx,%rdx,1),%xmm1
movaps %xmm0,-0xb0(%rcx,%rdx,1)
ff
movaps %xmm1,-0xa0(%rcx,%rdx,1)
ff
add    $0x60,%rdx
cmp    $0x720,%rdx
jne    1110 <scroll+0x10>
movaps 0x6d0(%rcx),%xmm0
movaps %xmm0,0x630(%rcx)
add    $0xffffff60,%eax
ret

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

LLVM IR (-O2):
define i32 @scroll(i32 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %39, %2 ]
%4 = add nuw nsw i64 %3, 160
%5 = getelementptr inbounds i8, i8* inttoptr (i64 3221979136 to i8*), i64 %4
%6 = bitcast i8* %5 to <16 x i8>*
%7 = load <16 x i8>, <16 x i8>* %6
%8 = getelementptr inbounds i8, i8* %5, i64 16
%9 = bitcast i8* %8 to <16 x i8>*
%10 = load <16 x i8>, <16 x i8>* %9
%11 = getelementptr inbounds i8, i8* inttoptr (i64 3221979136 to i8*), i64 %3
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> %7, <16 x i8>* %12
%13 = getelementptr inbounds i8, i8* %11, i64 16
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> %10, <16 x i8>* %14
%15 = add nuw nsw i64 %3, 32
%16 = add nuw nsw i64 %3, 192
%17 = getelementptr inbounds i8, i8* inttoptr (i64 3221979136 to i8*), i64 %16
%18 = bitcast i8* %17 to <16 x i8>*
%19 = load <16 x i8>, <16 x i8>* %18
%20 = getelementptr inbounds i8, i8* %17, i64 16
%21 = bitcast i8* %20 to <16 x i8>*
%22 = load <16 x i8>, <16 x i8>* %21
%23 = getelementptr inbounds i8, i8* inttoptr (i64 3221979136 to i8*), i64 %15
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> %19, <16 x i8>* %24
%25 = getelementptr inbounds i8, i8* %23, i64 16
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> %22, <16 x i8>* %26
%27 = add nuw nsw i64 %3, 64
%28 = add nuw nsw i64 %3, 224
%29 = getelementptr inbounds i8, i8* inttoptr (i64 3221979136 to i8*), i64 %28
%30 = bitcast i8* %29 to <16 x i8>*
%31 = load <16 x i8>, <16 x i8>* %30
%32 = getelementptr inbounds i8, i8* %29, i64 16
%33 = bitcast i8* %32 to <16 x i8>*
%34 = load <16 x i8>, <16 x i8>* %33
%35 = getelementptr inbounds i8, i8* inttoptr (i64 3221979136 to i8*), i64 %27
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> %31, <16 x i8>* %36
%37 = getelementptr inbounds i8, i8* %35, i64 16
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %34, <16 x i8>* %38
%39 = add nuw nsw i64 %3, 96
%40 = icmp eq i64 %39, 1824
br i1 %40, label %41, label %2
41: ; preds = %2
%42 = load <8 x i8>, <8 x i8>* inttoptr (i64 3221981120 to <8 x i8>*)
store <8 x i8> %42, <8 x i8>* inttoptr (i64 3221980960 to <8 x i8>*)
%43 = load <8 x i8>, <8 x i8>* inttoptr (i64 3221981128 to <8 x i8>*)
store <8 x i8> %43, <8 x i8>* inttoptr (i64 3221980968 to <8 x i8>*)
%44 = add nsw i32 %0, -160
ret i32 %44
}