void changeDisplayColor(void) {
  volatile unsigned int *ptr = (volatile unsigned int *)0x55000000;
  unsigned int addr = 0;
  unsigned int colors[] = {0xFF0000, 0x00FF00, 0x0000FF, 0, 0xFFFFFF};
  static int index = 0;
  for (int y = 0; y <= 271; ++y) {
    for (int x = 0; x <= 479; ++x) {
      ptr[addr++] = colors[index];
    }
  }
  if (++index == 5)
    index = 0;
  return;
}


x86 assembly (clang, -O0):
<changeDisplayColor>:
push   %rbp
mov    %rsp,%rbp
mov    $0x55000000,%eax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xee5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xee2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xee0(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x10f,-0x24(%rbp)
jg     119b <changeDisplayColor+0x9b>
movl   $0x0,-0x28(%rbp)
cmpl   $0x1df,-0x28(%rbp)
jg     1188 <changeDisplayColor+0x88>
movslq 0x2ec2(%rip),%rax
mov    -0x20(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114e <changeDisplayColor+0x4e>
jmp    118d <changeDisplayColor+0x8d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <changeDisplayColor+0x3a>
mov    0x2e83(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e7a(%rip)
cmp    $0x5,%eax
jne    11bd <changeDisplayColor+0xbd>
movl   $0x0,0x2e67(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<changeDisplayColor>:
xor    %eax,%eax
mov    $0x55000000,%ecx
lea    0xef2(%rip),%rdx
xchg   %ax,%ax
mov    $0x3,%esi
cs nopw 0x0(%rax,%rax,1)
nop
movslq 0x2efd(%rip),%rdi
mov    (%rdx,%rdi,4),%edi
mov    %edi,-0xc(%rcx,%rsi,4)
movslq 0x2eef(%rip),%rdi
mov    (%rdx,%rdi,4),%edi
mov    %edi,-0x8(%rcx,%rsi,4)
movslq 0x2ee1(%rip),%rdi
mov    (%rdx,%rdi,4),%edi
mov    %edi,-0x4(%rcx,%rsi,4)
movslq 0x2ed3(%rip),%rdi
mov    (%rdx,%rdi,4),%edi
mov    %edi,(%rcx,%rsi,4)
add    $0x4,%rsi
cmp    $0x1e3,%esi
jne    1120 <changeDisplayColor+0x20>
add    $0x1,%eax
add    $0x780,%rcx
cmp    $0x110,%eax
jne    1110 <changeDisplayColor+0x10>
mov    0x2eaa(%rip),%eax
add    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x5,%eax
cmovne %eax,%ecx
mov    %ecx,0x2e99(%rip)
ret

LLVM IR (-O0):
@__const.changeDisplayColor.colors = [5 x i32] [i32 16711680, i32 65280, i32 255, i32 0, i32 16777215]
@changeDisplayColor.index = internal global i32 0
define void @changeDisplayColor() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca i32
%5 = alloca i32
store i32* inttoptr (i64 1426063360 to i32*), i32** %1
store i32 0, i32* %2
%6 = bitcast [5 x i32]* %3 to i8*
store i32 0, i32* %4
br label %7
7: ; preds = %28, %0
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 271
br i1 %9, label %10, label %31
10: ; preds = %7
store i32 0, i32* %5
br label %11
11: ; preds = %24, %10
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 479
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i32, i32* @changeDisplayColor.index
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32*, i32** %1
%20 = load i32, i32* %2
%21 = add i32 %20, 1
store i32 %21, i32* %2
%22 = zext i32 %20 to i64
%23 = getelementptr inbounds i32, i32* %19, i64 %22
store volatile i32 %18, i32* %23
br label %24
24: ; preds = %14
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %11
27: ; preds = %11
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %7
31: ; preds = %7
%32 = load i32, i32* @changeDisplayColor.index
%33 = add nsw i32 %32, 1
store i32 %33, i32* @changeDisplayColor.index
%34 = icmp eq i32 %33, 5
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 0, i32* @changeDisplayColor.index
br label %36
36: ; preds = %35, %31
ret void
}

LLVM IR (-O2):
@__const.changeDisplayColor.colors = [5 x i32] [i32 16711680, i32 65280, i32 255, i32 0, i32 16777215]
@changeDisplayColor.index = internal unnamed_addr global i32 0
define void @changeDisplayColor() {
br label %1
1: ; preds = %0, %10
%2 = phi i32 [ 0, %0 ], [ %11, %10 ]
%3 = phi i32 [ 0, %0 ], [ %4, %10 ]
%4 = add i32 %3, 480
br label %13
5: ; preds = %10
%6 = load i32, i32* @changeDisplayColor.index
%7 = add nsw i32 %6, 1
%8 = icmp eq i32 %7, 5
%9 = select i1 %8, i32 0, i32 %7
store i32 %9, i32* @changeDisplayColor.index
ret void
10: ; preds = %13
%11 = add nuw nsw i32 %2, 1
%12 = icmp eq i32 %11, 272
br i1 %12, label %5, label %1
13: ; preds = %13, %1
%14 = phi i32 [ %3, %1 ], [ %40, %13 ]
%15 = load i32, i32* @changeDisplayColor.index
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.changeDisplayColor.colors, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = or i32 %14, 1
%20 = zext i32 %14 to i64
%21 = getelementptr inbounds i32, i32* inttoptr (i64 1426063360 to i32*), i64 %20
store volatile i32 %18, i32* %21
%22 = load i32, i32* @changeDisplayColor.index
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.changeDisplayColor.colors, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = or i32 %14, 2
%27 = zext i32 %19 to i64
%28 = getelementptr inbounds i32, i32* inttoptr (i64 1426063360 to i32*), i64 %27
store volatile i32 %25, i32* %28
%29 = load i32, i32* @changeDisplayColor.index
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.changeDisplayColor.colors, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = or i32 %14, 3
%34 = zext i32 %26 to i64
%35 = getelementptr inbounds i32, i32* inttoptr (i64 1426063360 to i32*), i64 %34
store volatile i32 %32, i32* %35
%36 = load i32, i32* @changeDisplayColor.index
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.changeDisplayColor.colors, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add nuw nsw i32 %14, 4
%41 = zext i32 %33 to i64
%42 = getelementptr inbounds i32, i32* inttoptr (i64 1426063360 to i32*), i64 %41
store volatile i32 %39, i32* %42
%43 = icmp eq i32 %40, %4
br i1 %43, label %10, label %13
}