int main() {
  unsigned char *vmem = (unsigned char *)0x91000000;
  unsigned int *volatile cr = (unsigned int *)((0x80000000U + (4 * 1)));
  printf("Startup.\n");
  printf("CR address: 0x%08x\n", (unsigned int)cr);
  printf("Reading from CR: 0x%08x\n", *cr);
  printf("Filling upper screen white, lower screen black\n");
  for (unsigned int y = 0; y < 240; y++)
    for (unsigned int x = 0; x < 640; x++)
      setPixel(vmem, x, y, 0xff, 0xff, 0xff);
  for (unsigned int y = 240; y < 480; y++)
    for (unsigned int x = 0; x < 640; x++)
      setPixel(vmem, x, y, 0, 0, 0);
  usleep(2000000);
  printf("Clearing DVI_CR_EN_MASK in CR\n");
  *cr &= ~(1 << 0);
  printf("Reading from CR: 0x%08x\n", *cr);
  usleep(2000000);
  printf("Filling screen red, you should NOT SEE ANY CHANGES (display is "
         "disabled)\n");
  fillScreen(vmem, 0xff, 0, 0);
  usleep(2000000);
  printf("Setting DVI_CR_EN_MASK in CR, you should then see the red screen\n");
  *cr |= (1 << 0);
  printf("Reading from CR: 0x%08x\n", *cr);
  usleep(2000000);
  printf("Writing DVI_CR_DSC_MASK to CR (inversing scan direction)\n");
  *cr |= (1 << 1);
  printf("Reading from CR: 0x%08x\n", *cr);
  usleep(2000000);
  printf("Filling upper screen white, lower screen black (you should see the "
         "opposite)\n");
  for (unsigned int y = 0; y < 240; y++)
    for (unsigned int x = 0; x < 640; x++)
      setPixel(vmem, x, y, 0xff, 0xff, 0xff);
  for (unsigned int y = 240; y < 480; y++)
    for (unsigned int x = 0; x < 640; x++)
      setPixel(vmem, x, y, 0, 0, 0);
  usleep(2000000);
  printf("Clearing DVI_CR_DSC_MASK in CR (restoring scan direction), you "
         "should see upper white, lower black again\n");
  *cr &= ~(1 << 1);
  printf("Reading from CR: 0x%08x\n", *cr);
  usleep(2000000);
  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)
mov    $0x80000004,%eax
mov    %rax,-0x18(%rbp)
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf0,-0x1c(%rbp)
jae    120b <main+0xcb>
movl   $0x0,-0x20(%rbp)
cmpl   $0x280,-0x20(%rbp)
jae    11f8 <main+0xb8>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    $0xff,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1050 <setPixel@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c0 <main+0x80>
jmp    11fd <main+0xbd>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x6c>
movl   $0xf0,-0x24(%rbp)
cmpl   $0x1e0,-0x24(%rbp)
jae    126e <main+0x12e>
movl   $0x0,-0x28(%rbp)
cmpl   $0x280,-0x28(%rbp)
jae    125b <main+0x11b>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1050 <setPixel@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1226 <main+0xe6>
jmp    1260 <main+0x120>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1212 <main+0xd2>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0xff,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
mov    $0x0,%al
call   1030 <fillScreen@plt>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0xf0,-0x2c(%rbp)
jae    13c7 <main+0x287>
movl   $0x0,-0x30(%rbp)
cmpl   $0x280,-0x30(%rbp)
jae    13b4 <main+0x274>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    $0xff,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1050 <setPixel@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    137c <main+0x23c>
jmp    13b9 <main+0x279>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1368 <main+0x228>
movl   $0xf0,-0x34(%rbp)
cmpl   $0x1e0,-0x34(%rbp)
jae    142a <main+0x2ea>
movl   $0x0,-0x38(%rbp)
cmpl   $0x280,-0x38(%rbp)
jae    1417 <main+0x2d7>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1050 <setPixel@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    13e2 <main+0x2a2>
jmp    141c <main+0x2dc>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13ce <main+0x28e>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xbc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1e8480,%edi
mov    $0x0,%al
call   1060 <usleep@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x91000000,%eax
add    $0xffffffffef000004,%rax
mov    %rax,(%rsp)
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rsi
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rax
mov    (%rax),%esi
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x91000000,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    $0xff,%ecx
mov    $0xff,%r8d
mov    $0xff,%r9d
xor    %eax,%eax
call   1060 <setPixel@plt>
add    $0x1,%ebp
cmp    $0x280,%ebp
jne    11c0 <main+0x70>
add    $0x1,%ebx
cmp    $0xf0,%ebx
jne    11b0 <main+0x60>
mov    $0xf0,%ebx
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x91000000,%edi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1060 <setPixel@plt>
add    $0x1,%ebp
cmp    $0x280,%ebp
jne    1210 <main+0xc0>
add    $0x1,%ebx
cmp    $0x1e0,%ebx
jne    1200 <main+0xb0>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
lea    0xe14(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rax
andb   $0xfe,(%rax)
mov    (%rsp),%rax
mov    (%rax),%esi
lea    0xdaa(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
lea    0xdfc(%rip),%rdi
call   1040 <puts@plt>
mov    $0x91000000,%edi
mov    $0xff,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <fillScreen@plt>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
lea    0xe18(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rax
orb    $0x1,(%rax)
mov    (%rsp),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
lea    0xe2a(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rax
orb    $0x2,(%rax)
mov    (%rsp),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x91000000,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    $0xff,%ecx
mov    $0xff,%r8d
mov    $0xff,%r9d
xor    %eax,%eax
call   1060 <setPixel@plt>
add    $0x1,%ebp
cmp    $0x280,%ebp
jne    1330 <main+0x1e0>
add    $0x1,%ebx
cmp    $0xf0,%ebx
jne    1320 <main+0x1d0>
mov    $0xf0,%ebx
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x91000000,%edi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1060 <setPixel@plt>
add    $0x1,%ebp
cmp    $0x280,%ebp
jne    1380 <main+0x230>
add    $0x1,%ebx
cmp    $0x1e0,%ebx
jne    1370 <main+0x220>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
lea    0xdd2(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rax
andb   $0xfd,(%rax)
mov    (%rsp),%rax
mov    (%rax),%esi
lea    0xc3a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1e8480,%edi
xor    %eax,%eax
call   1070 <usleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Startup.\0A\00"
@.str.1 = [20 x i8] c"CR address: 0x%08x\0A\00"
@.str.2 = [25 x i8] c"Reading from CR: 0x%08x\0A\00"
@.str.3 = [48 x i8] c"Filling upper screen white, lower screen black\0A\00"
@.str.4 = [31 x i8] c"Clearing DVI_CR_EN_MASK in CR\0A\00"
@.str.5 = [74 x i8] c"Filling screen red, you should NOT SEE ANY CHANGES (display is disabled)\0A\00"
@.str.6 = [66 x i8] c"Setting DVI_CR_EN_MASK in CR, you should then see the red screen\0A\00"
@.str.7 = [58 x i8] c"Writing DVI_CR_DSC_MASK to CR (inversing scan direction)\0A\00"
@.str.8 = [78 x i8] c"Filling upper screen white, lower screen black (you should see the opposite)\0A\00"
@.str.9 = [106 x i8] c"Clearing DVI_CR_DSC_MASK in CR (restoring scan direction), you should see upper white, lower black again\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
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store i8* inttoptr (i64 2432696320 to i8*), i8** %2
store volatile i32* inttoptr (i64 2147483652 to i32*), i32** %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = load volatile i32*, i32** %3
%14 = ptrtoint i32* %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load volatile i32*, i32** %3
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %20
20: ; preds = %36, %0
%21 = load i32, i32* %4
%22 = icmp ult i32 %21, 240
br i1 %22, label %23, label %39
23: ; preds = %20
store i32 0, i32* %5
br label %24
24: ; preds = %32, %23
%25 = load i32, i32* %5
%26 = icmp ult i32 %25, 640
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i8*, i8** %2
%29 = load i32, i32* %5
%30 = load i32, i32* %4
%31 = call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* %28, i32 %29, i32 %30, i32 255, i32 255, i32 255)
br label %32
32: ; preds = %27
%33 = load i32, i32* %5
%34 = add i32 %33, 1
store i32 %34, i32* %5
br label %24
35: ; preds = %24
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add i32 %37, 1
store i32 %38, i32* %4
br label %20
39: ; preds = %20
store i32 240, i32* %6
br label %40
40: ; preds = %56, %39
%41 = load i32, i32* %6
%42 = icmp ult i32 %41, 480
br i1 %42, label %43, label %59
43: ; preds = %40
store i32 0, i32* %7
br label %44
44: ; preds = %52, %43
%45 = load i32, i32* %7
%46 = icmp ult i32 %45, 640
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load i8*, i8** %2
%49 = load i32, i32* %7
%50 = load i32, i32* %6
%51 = call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* %48, i32 %49, i32 %50, i32 0, i32 0, i32 0)
br label %52
52: ; preds = %47
%53 = load i32, i32* %7
%54 = add i32 %53, 1
store i32 %54, i32* %7
br label %44
55: ; preds = %44
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add i32 %57, 1
store i32 %58, i32* %6
br label %40
59: ; preds = %40
%60 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%62 = load volatile i32*, i32** %3
%63 = load i32, i32* %62
%64 = and i32 %63, -2
store i32 %64, i32* %62
%65 = load volatile i32*, i32** %3
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %66)
%68 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0))
%70 = load i8*, i8** %2
%71 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @fillScreen to i32 (i8*, i32, i32, i32, ...)*)(i8* %70, i32 255, i32 0, i32 0)
%72 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
%74 = load volatile i32*, i32** %3
%75 = load i32, i32* %74
%76 = or i32 %75, 1
store i32 %76, i32* %74
%77 = load volatile i32*, i32** %3
%78 = load i32, i32* %77
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %78)
%80 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%82 = load volatile i32*, i32** %3
%83 = load i32, i32* %82
%84 = or i32 %83, 2
store i32 %84, i32* %82
%85 = load volatile i32*, i32** %3
%86 = load i32, i32* %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %86)
%88 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %8
br label %90
90: ; preds = %106, %59
%91 = load i32, i32* %8
%92 = icmp ult i32 %91, 240
br i1 %92, label %93, label %109
93: ; preds = %90
store i32 0, i32* %9
br label %94
94: ; preds = %102, %93
%95 = load i32, i32* %9
%96 = icmp ult i32 %95, 640
br i1 %96, label %97, label %105
97: ; preds = %94
%98 = load i8*, i8** %2
%99 = load i32, i32* %9
%100 = load i32, i32* %8
%101 = call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* %98, i32 %99, i32 %100, i32 255, i32 255, i32 255)
br label %102
102: ; preds = %97
%103 = load i32, i32* %9
%104 = add i32 %103, 1
store i32 %104, i32* %9
br label %94
105: ; preds = %94
br label %106
106: ; preds = %105
%107 = load i32, i32* %8
%108 = add i32 %107, 1
store i32 %108, i32* %8
br label %90
109: ; preds = %90
store i32 240, i32* %10
br label %110
110: ; preds = %126, %109
%111 = load i32, i32* %10
%112 = icmp ult i32 %111, 480
br i1 %112, label %113, label %129
113: ; preds = %110
store i32 0, i32* %11
br label %114
114: ; preds = %122, %113
%115 = load i32, i32* %11
%116 = icmp ult i32 %115, 640
br i1 %116, label %117, label %125
117: ; preds = %114
%118 = load i8*, i8** %2
%119 = load i32, i32* %11
%120 = load i32, i32* %10
%121 = call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* %118, i32 %119, i32 %120, i32 0, i32 0, i32 0)
br label %122
122: ; preds = %117
%123 = load i32, i32* %11
%124 = add i32 %123, 1
store i32 %124, i32* %11
br label %114
125: ; preds = %114
br label %126
126: ; preds = %125
%127 = load i32, i32* %10
%128 = add i32 %127, 1
store i32 %128, i32* %10
br label %110
129: ; preds = %110
%130 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.9, i64 0, i64 0))
%132 = load volatile i32*, i32** %3
%133 = load i32, i32* %132
%134 = and i32 %133, -3
store i32 %134, i32* %132
%135 = load volatile i32*, i32** %3
%136 = load i32, i32* %135
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %136)
%138 = call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"CR address: 0x%08x\0A\00"
@.str.2 = [25 x i8] c"Reading from CR: 0x%08x\0A\00"
@str = [9 x i8] c"Startup.\00"
@str.10 = [47 x i8] c"Filling upper screen white, lower screen black\00"
@str.11 = [30 x i8] c"Clearing DVI_CR_EN_MASK in CR\00"
@str.12 = [73 x i8] c"Filling screen red, you should NOT SEE ANY CHANGES (display is disabled)\00"
@str.13 = [65 x i8] c"Setting DVI_CR_EN_MASK in CR, you should then see the red screen\00"
@str.14 = [57 x i8] c"Writing DVI_CR_DSC_MASK to CR (inversing scan direction)\00"
@str.15 = [77 x i8] c"Filling upper screen white, lower screen black (you should see the opposite)\00"
@str.16 = [105 x i8] c"Clearing DVI_CR_DSC_MASK in CR (restoring scan direction), you should see upper white, lower black again\00"
define i32 @main() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
store volatile i32* inttoptr (i64 2147483652 to i32*), i32** %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = load volatile i32*, i32** %1
%5 = ptrtoint i32* %4 to i64
%6 = trunc i64 %5 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load volatile i32*, i32** %1
%9 = load i32, i32* %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.10, i64 0, i64 0))
br label %12
12: ; preds = %0, %14
%13 = phi i32 [ 0, %0 ], [ %15, %14 ]
br label %17
14: ; preds = %17
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, 240
br i1 %16, label %22, label %12
17: ; preds = %12, %17
%18 = phi i32 [ 0, %12 ], [ %20, %17 ]
%19 = tail call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* inttoptr (i64 2432696320 to i8*), i32 %18, i32 %13, i32 255, i32 255, i32 255)
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, 640
br i1 %21, label %14, label %17
22: ; preds = %14, %54
%23 = phi i32 [ %55, %54 ], [ 240, %14 ]
br label %57
24: ; preds = %54
%25 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.11, i64 0, i64 0))
%27 = load volatile i32*, i32** %1
%28 = load i32, i32* %27
%29 = and i32 %28, -2
store i32 %29, i32* %27
%30 = load volatile i32*, i32** %1
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.12, i64 0, i64 0))
%35 = tail call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @fillScreen to i32 (i8*, i32, i32, i32, ...)*)(i8* inttoptr (i64 2432696320 to i8*), i32 255, i32 0, i32 0)
%36 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.13, i64 0, i64 0))
%38 = load volatile i32*, i32** %1
%39 = load i32, i32* %38
%40 = or i32 %39, 1
store i32 %40, i32* %38
%41 = load volatile i32*, i32** %1
%42 = load i32, i32* %41
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.14, i64 0, i64 0))
%46 = load volatile i32*, i32** %1
%47 = load i32, i32* %46
%48 = or i32 %47, 2
store i32 %48, i32* %46
%49 = load volatile i32*, i32** %1
%50 = load i32, i32* %49
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.15, i64 0, i64 0))
br label %62
54: ; preds = %57
%55 = add nuw nsw i32 %23, 1
%56 = icmp eq i32 %55, 480
br i1 %56, label %24, label %22
57: ; preds = %22, %57
%58 = phi i32 [ 0, %22 ], [ %60, %57 ]
%59 = tail call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* inttoptr (i64 2432696320 to i8*), i32 %58, i32 %23, i32 0, i32 0, i32 0)
%60 = add nuw nsw i32 %58, 1
%61 = icmp eq i32 %60, 640
br i1 %61, label %54, label %57
62: ; preds = %24, %64
%63 = phi i32 [ 0, %24 ], [ %65, %64 ]
br label %67
64: ; preds = %67
%65 = add nuw nsw i32 %63, 1
%66 = icmp eq i32 %65, 240
br i1 %66, label %72, label %62
67: ; preds = %62, %67
%68 = phi i32 [ 0, %62 ], [ %70, %67 ]
%69 = tail call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* inttoptr (i64 2432696320 to i8*), i32 %68, i32 %63, i32 255, i32 255, i32 255)
%70 = add nuw nsw i32 %68, 1
%71 = icmp eq i32 %70, 640
br i1 %71, label %64, label %67
72: ; preds = %64, %84
%73 = phi i32 [ %85, %84 ], [ 240, %64 ]
br label %87
74: ; preds = %84
%75 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([105 x i8], [105 x i8]* @str.16, i64 0, i64 0))
%77 = load volatile i32*, i32** %1
%78 = load i32, i32* %77
%79 = and i32 %78, -3
store i32 %79, i32* %77
%80 = load volatile i32*, i32** %1
%81 = load i32, i32* %80
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %81)
%83 = tail call i32 (i32, ...) bitcast (i32 (...)* @usleep to i32 (i32, ...)*)(i32 2000000)
ret i32 0
84: ; preds = %87
%85 = add nuw nsw i32 %73, 1
%86 = icmp eq i32 %85, 480
br i1 %86, label %74, label %72
87: ; preds = %72, %87
%88 = phi i32 [ 0, %72 ], [ %90, %87 ]
%89 = tail call i32 (i8*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @setPixel to i32 (i8*, i32, i32, i32, i32, i32, ...)*)(i8* inttoptr (i64 2432696320 to i8*), i32 %88, i32 %73, i32 0, i32 0, i32 0)
%90 = add nuw nsw i32 %88, 1
%91 = icmp eq i32 %90, 640
br i1 %91, label %84, label %87
}