#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*/ drawPixel(int, int, int);
int /*<<< orphan*/ flipBuffer();
int /*<<< orphan*/ waitForVerticalBlank();
void clearScreen(void) {
  int x;
  int y;
  for (y = 0; y < 160; y++) {
    for (x = 0; x < 120; x++) {
      drawPixel(x, y, 0x0000);
    }
  }
  waitForVerticalBlank();
  flipBuffer();
}


x86 assembly (clang, -O0):
<clearScreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0xa0,-0x8(%rbp)
jge    118b <clearScreen+0x5b>
movl   $0x0,-0x4(%rbp)
cmpl   $0x78,-0x4(%rbp)
jge    1178 <clearScreen+0x48>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %edx,%edx
call   1030 <drawPixel@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1153 <clearScreen+0x23>
jmp    117d <clearScreen+0x4d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113f <clearScreen+0xf>
mov    $0x0,%al
call   1040 <waitForVerticalBlank@plt>
mov    $0x0,%al
call   1050 <flipBuffer@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clearScreen>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <drawPixel@plt>
add    $0x1,%ebp
cmp    $0x78,%ebp
jne    1150 <clearScreen+0x20>
add    $0x1,%ebx
cmp    $0xa0,%ebx
jne    1140 <clearScreen+0x10>
xor    %eax,%eax
call   1040 <waitForVerticalBlank@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <flipBuffer@plt>

LLVM IR (-O0):
define void @clearScreen() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %18, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 160
br i1 %5, label %6, label %21
6: ; preds = %3
store i32 0, i32* %1
br label %7
7: ; preds = %14, %6
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 120
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @drawPixel(i32 %11, i32 %12, i32 0)
br label %14
14: ; preds = %10
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %7
17: ; preds = %7
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %3
21: ; preds = %3
%22 = call i32 (...) @waitForVerticalBlank()
%23 = call i32 (...) @flipBuffer()
ret void
}

LLVM IR (-O2):
define void @clearScreen() {
br label %1
1: ; preds = %0, %8
%2 = phi i32 [ 0, %0 ], [ %9, %8 ]
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %6, %3 ]
%5 = tail call i32 @drawPixel(i32 %4, i32 %2, i32 0)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 120
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = add nuw nsw i32 %2, 1
%10 = icmp eq i32 %9, 160
br i1 %10, label %11, label %1
11: ; preds = %8
%12 = tail call i32 (...) @waitForVerticalBlank()
%13 = tail call i32 (...) @flipBuffer()
ret void
}