void RollScreen() {
  int i, j;
  char *char_device = (char *)65536;
  for (i = 0; i < 24 - 1; i++) {
    for (j = 0; j < 40; j++) {
      *(char_device + 2 + i * 40 + j) = *(char_device + 2 + (i + 1) * 40 + j);
    }
  }
  for (j = 0; j < 40; j++) {
    *(char_device + 2 + (24 - 1) * 40 + j) = '\0';
  }
}


x86 assembly (clang, -O0):
<RollScreen>:
push   %rbp
mov    %rsp,%rbp
mov    $0x10000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x17,-0x4(%rbp)
jge    1187 <RollScreen+0x87>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    1174 <RollScreen+0x74>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
imul   $0x28,%ecx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
add    $0x2,%rax
imul   $0x28,-0x4(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x8(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <RollScreen+0x25>
jmp    1179 <RollScreen+0x79>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1114 <RollScreen+0x14>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    11b6 <RollScreen+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movb   $0x0,0x39a(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118e <RollScreen+0x8e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<RollScreen>:
mov    $0x70,%eax
mov    $0x10002,%ecx
nopw   0x0(%rax,%rax,1)
movups -0x48(%rcx,%rax,1),%xmm0
movups -0x38(%rcx,%rax,1),%xmm1
movups %xmm0,-0x70(%rcx,%rax,1)
movups %xmm1,-0x60(%rcx,%rax,1)
mov    -0x28(%rcx,%rax,1),%rdx
mov    %rdx,-0x50(%rcx,%rax,1)
cmp    $0x3e0,%rax
je     1159 <RollScreen+0x59>
movups -0x20(%rcx,%rax,1),%xmm0
movups -0x10(%rcx,%rax,1),%xmm1
movups %xmm0,-0x48(%rcx,%rax,1)
movups %xmm1,-0x38(%rcx,%rax,1)
mov    (%rcx,%rax,1),%rdx
mov    %rdx,-0x28(%rcx,%rax,1)
add    $0x50,%rax
jmp    1110 <RollScreen+0x10>
xorps  %xmm0,%xmm0
movups %xmm0,0x103aa
movups %xmm0,0x1039a
movq   $0x0,0x103ba
ret

LLVM IR (-O0):
define void @RollScreen() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i8* inttoptr (i64 65536 to i8*), i8** %3
store i32 0, i32* %1
br label %4
4: ; preds = %36, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 23
br i1 %6, label %7, label %39
7: ; preds = %4
store i32 0, i32* %2
br label %8
8: ; preds = %32, %7
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 40
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
%16 = mul nsw i32 %15, 40
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i32, i32* %1
%26 = mul nsw i32 %25, 40
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %22, i8* %31
br label %32
32: ; preds = %11
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %8
35: ; preds = %8
br label %36
36: ; preds = %35
%37 = load i32, i32* %1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %1
br label %4
39: ; preds = %4
store i32 0, i32* %2
br label %40
40: ; preds = %50, %39
%41 = load i32, i32* %2
%42 = icmp slt i32 %41, 40
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 2
%46 = getelementptr inbounds i8, i8* %45, i64 920
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 0, i8* %49
br label %50
50: ; preds = %43
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %40
53: ; preds = %40
ret void
}

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