#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setPixel(unsigned char *, unsigned int, unsigned int,
                            int /*<<< orphan*/, int, int);
int /*<<< orphan*/ usleep(int);
int main() {
  unsigned char *vmem = (unsigned char *)0x91000000;
  printf("Startup.\n");
  while (1) {
    printf("Filling the screen red.\n");
    for (unsigned int y = 0; y < 480; y++) {
      unsigned int *pixel = (unsigned int *)(vmem + ((1024 * 4) * y));
      for (unsigned int x = 0; x < 640; x++)
        *pixel++ = 255 << 16;
    }
    usleep(1000000);
    printf("Filling the screen green.\n");
    for (unsigned int y = 0; y < 480; y++)
      for (unsigned int x = 0; x < 640; x++)
        setPixel(vmem, x, y, 0, 255, 0);
    usleep(1000000);
    printf("Filling the screen blue.\n");
    for (unsigned int y = 0; y < 480; y++)
      for (unsigned int x = 0; x < 640; x++)
        setPixel(vmem, x, y, 0, 0, 255);
    usleep(1000000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x91000000,%eax
mov    %rax,-0x10(%rbp)
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1e0,-0x14(%rbp)
jae    11d1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0xc,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x280,-0x24(%rbp)
jae    11be <main+0x8e>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xff0000,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <main+0x5e>
jmp    11c3 <main+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <main+0x37>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x1e0,-0x28(%rbp)
jae    124b <main+0x11b>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x280,-0x2c(%rbp)
jae    1238 <main+0x108>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
xor    %r9d,%r9d
mov    $0xff,%r8d
mov    %r9d,%ecx
call   1040 <setPixel@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1202 <main+0xd2>
jmp    123d <main+0x10d>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ee <main+0xbe>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x1e0,-0x30(%rbp)
jae    12c5 <main+0x195>
movl   $0x0,-0x34(%rbp)
cmpl   $0x280,-0x34(%rbp)
jae    12b2 <main+0x182>
mov    -0x10(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
xor    %r8d,%r8d
mov    $0xff,%r9d
mov    %r8d,%ecx
call   1040 <setPixel@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    127c <main+0x14c>
jmp    12b7 <main+0x187>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1268 <main+0x138>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
jmp    1154 <main+0x24>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%r14
lea    0xedf(%rip),%r15
lea    0xef2(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x91000000,%eax
xor    %ecx,%ecx
movaps 0xe8a(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
mov    $0x3c,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movaps %xmm0,-0xf0(%rax,%rdx,4)
ff
movaps %xmm0,-0xe0(%rax,%rdx,4)
ff
movaps %xmm0,-0xd0(%rax,%rdx,4)
ff
movaps %xmm0,-0xc0(%rax,%rdx,4)
ff
movaps %xmm0,-0xb0(%rax,%rdx,4)
ff
movaps %xmm0,-0xa0(%rax,%rdx,4)
ff
movaps %xmm0,-0x90(%rax,%rdx,4)
ff
movaps %xmm0,-0x80(%rax,%rdx,4)
movaps %xmm0,-0x70(%rax,%rdx,4)
movaps %xmm0,-0x60(%rax,%rdx,4)
movaps %xmm0,-0x50(%rax,%rdx,4)
movaps %xmm0,-0x40(%rax,%rdx,4)
movaps %xmm0,-0x30(%rax,%rdx,4)
movaps %xmm0,-0x20(%rax,%rdx,4)
movaps %xmm0,-0x10(%rax,%rdx,4)
movaps %xmm0,(%rax,%rdx,4)
add    $0x40,%rdx
cmp    $0x2bc,%rdx
jne    1190 <main+0x60>
add    $0x1,%rcx
add    $0x1000,%rax
cmp    $0x1e0,%rcx
jne    1180 <main+0x50>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x91000000,%edi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    $0xff,%r8d
xor    %r9d,%r9d
call   1040 <setPixel@plt>
add    $0x1,%ebx
cmp    $0x280,%ebx
jne    1240 <main+0x110>
add    $0x1,%ebp
cmp    $0x1e0,%ebp
jne    1230 <main+0x100>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x91000000,%edi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0xff,%r9d
call   1040 <setPixel@plt>
add    $0x1,%ebx
cmp    $0x280,%ebx
jne    12a0 <main+0x170>
add    $0x1,%ebp
cmp    $0x1e0,%ebp
jne    1290 <main+0x160>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
jmp    1160 <main+0x30>

LLVM IR (-O0):
@.str = [10 x i8] c"Startup.\0A\00"
@.str.1 = [25 x i8] c"Filling the screen red.\0A\00"
@.str.2 = [27 x i8] c"Filling the screen green.\0A\00"
@.str.3 = [26 x i8] c"Filling the screen blue.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i8* inttoptr (i64 2432696320 to i8*), i8** %2
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %0, %80
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %13
13: ; preds = %33, %11
%14 = load i32, i32* %3
%15 = icmp ult i32 %14, 480
br i1 %15, label %16, label %36
16: ; preds = %13
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = mul i32 4096, %18
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = bitcast i8* %21 to i32*
store i32* %22, i32** %4
store i32 0, i32* %5
br label %23
23: ; preds = %29, %16
%24 = load i32, i32* %5
%25 = icmp ult i32 %24, 640
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %4
store i32 16711680, i32* %27
br label %29
29: ; preds = %26
%30 = load i32, i32* %5
%31 = add i32 %30, 1
store i32 %31, i32* %5
br label %23
32: ; preds = %23
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add i32 %34, 1
store i32 %35, i32* %3
br label %13
36: ; preds = %13
%37 = call i32 @usleep(i32 1000000)
%38 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %39
39: ; preds = %55, %36
%40 = load i32, i32* %6
%41 = icmp ult i32 %40, 480
br i1 %41, label %42, label %58
42: ; preds = %39
store i32 0, i32* %7
br label %43
43: ; preds = %51, %42
%44 = load i32, i32* %7
%45 = icmp ult i32 %44, 640
br i1 %45, label %46, label %54
46: ; preds = %43
%47 = load i8*, i8** %2
%48 = load i32, i32* %7
%49 = load i32, i32* %6
%50 = call i32 @setPixel(i8* %47, i32 %48, i32 %49, i32 0, i32 255, i32 0)
br label %51
51: ; preds = %46
%52 = load i32, i32* %7
%53 = add i32 %52, 1
store i32 %53, i32* %7
br label %43
54: ; preds = %43
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add i32 %56, 1
store i32 %57, i32* %6
br label %39
58: ; preds = %39
%59 = call i32 @usleep(i32 1000000)
%60 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %8
br label %61
61: ; preds = %77, %58
%62 = load i32, i32* %8
%63 = icmp ult i32 %62, 480
br i1 %63, label %64, label %80
64: ; preds = %61
store i32 0, i32* %9
br label %65
65: ; preds = %73, %64
%66 = load i32, i32* %9
%67 = icmp ult i32 %66, 640
br i1 %67, label %68, label %76
68: ; preds = %65
%69 = load i8*, i8** %2
%70 = load i32, i32* %9
%71 = load i32, i32* %8
%72 = call i32 @setPixel(i8* %69, i32 %70, i32 %71, i32 0, i32 0, i32 255)
br label %73
73: ; preds = %68
%74 = load i32, i32* %9
%75 = add i32 %74, 1
store i32 %75, i32* %9
br label %65
76: ; preds = %65
br label %77
77: ; preds = %76
%78 = load i32, i32* %8
%79 = add i32 %78, 1
store i32 %79, i32* %8
br label %61
80: ; preds = %61
%81 = call i32 @usleep(i32 1000000)
br label %11
}

LLVM IR (-O2):
@str = [9 x i8] c"Startup.\00"
@str.4 = [24 x i8] c"Filling the screen red.\00"
@str.5 = [26 x i8] c"Filling the screen green.\00"
@str.6 = [25 x i8] c"Filling the screen blue.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %73, %0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
br label %7
4: ; preds = %55
%5 = tail call i32 @usleep(i32 1000000)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0))
br label %58
7: ; preds = %2, %55
%8 = phi i64 [ 0, %2 ], [ %56, %55 ]
%9 = shl nuw nsw i64 %8, 12
%10 = getelementptr inbounds i8, i8* inttoptr (i64 2432696320 to i8*), i64 %9
%11 = bitcast i8* %10 to i32*
br label %12
12: ; preds = %12, %7
%13 = phi i64 [ 0, %7 ], [ %53, %12 ]
%14 = getelementptr i32, i32* %11, i64 %13
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %15
%16 = getelementptr i32, i32* %14, i64 4
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %17
%18 = or i64 %13, 8
%19 = getelementptr i32, i32* %11, i64 %18
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %20
%21 = getelementptr i32, i32* %19, i64 4
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %22
%23 = or i64 %13, 16
%24 = getelementptr i32, i32* %11, i64 %23
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %25
%26 = getelementptr i32, i32* %24, i64 4
%27 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %27
%28 = or i64 %13, 24
%29 = getelementptr i32, i32* %11, i64 %28
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %30
%31 = getelementptr i32, i32* %29, i64 4
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %32
%33 = or i64 %13, 32
%34 = getelementptr i32, i32* %11, i64 %33
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %35
%36 = getelementptr i32, i32* %34, i64 4
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %37
%38 = or i64 %13, 40
%39 = getelementptr i32, i32* %11, i64 %38
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %40
%41 = getelementptr i32, i32* %39, i64 4
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %42
%43 = or i64 %13, 48
%44 = getelementptr i32, i32* %11, i64 %43
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %45
%46 = getelementptr i32, i32* %44, i64 4
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %47
%48 = or i64 %13, 56
%49 = getelementptr i32, i32* %11, i64 %48
%50 = bitcast i32* %49 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %50
%51 = getelementptr i32, i32* %49, i64 4
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> <i32 16711680, i32 16711680, i32 16711680, i32 16711680>, <4 x i32>* %52
%53 = add nuw nsw i64 %13, 64
%54 = icmp eq i64 %53, 640
br i1 %54, label %55, label %12
55: ; preds = %12
%56 = add nuw nsw i64 %8, 1
%57 = icmp eq i64 %56, 480
br i1 %57, label %4, label %7
58: ; preds = %4, %63
%59 = phi i32 [ 0, %4 ], [ %64, %63 ]
br label %66
60: ; preds = %63
%61 = tail call i32 @usleep(i32 1000000)
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %71
63: ; preds = %66
%64 = add nuw nsw i32 %59, 1
%65 = icmp eq i32 %64, 480
br i1 %65, label %60, label %58
66: ; preds = %58, %66
%67 = phi i32 [ 0, %58 ], [ %69, %66 ]
%68 = tail call i32 @setPixel(i8* inttoptr (i64 2432696320 to i8*), i32 %67, i32 %59, i32 0, i32 255, i32 0)
%69 = add nuw nsw i32 %67, 1
%70 = icmp eq i32 %69, 640
br i1 %70, label %63, label %66
71: ; preds = %60, %75
%72 = phi i32 [ 0, %60 ], [ %76, %75 ]
br label %78
73: ; preds = %75
%74 = tail call i32 @usleep(i32 1000000)
br label %2
75: ; preds = %78
%76 = add nuw nsw i32 %72, 1
%77 = icmp eq i32 %76, 480
br i1 %77, label %73, label %71
78: ; preds = %71, %78
%79 = phi i32 [ 0, %71 ], [ %81, %78 ]
%80 = tail call i32 @setPixel(i8* inttoptr (i64 2432696320 to i8*), i32 %79, i32 %72, i32 0, i32 0, i32 255)
%81 = add nuw nsw i32 %79, 1
%82 = icmp eq i32 %81, 640
br i1 %82, label %75, label %78
}