#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*/ write_byte(int, int /*<<< orphan*/);
void clearscreen(int screen) {
  int i;
  if (screen & 1)
    for (i = 0; i < 400 * 240 * 3; i++) {
      write_byte(0x20184E60 + i, 0);
      write_byte(0x201CB370 + i, 0);
      write_byte(0x20282160 + i, 0);
      write_byte(0x202C8670 + i, 0);
    }
  if (screen & 2)
    for (i = 0; i < 320 * 240 * 3; i++) {
      write_byte(0x202118E0 + i, 0);
      write_byte(0X20249CF0 + i, 0);
    }
}


x86 assembly (clang, -O0):
<clearscreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1191 <clearscreen+0x81>
movl   $0x0,-0x8(%rbp)
cmpl   $0x46500,-0x8(%rbp)
jge    118c <clearscreen+0x7c>
mov    -0x8(%rbp),%edi
add    $0x20184e60,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%edi
add    $0x201cb370,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%edi
add    $0x20282160,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%edi
add    $0x202c8670,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1131 <clearscreen+0x21>
jmp    1191 <clearscreen+0x81>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11e7 <clearscreen+0xd7>
movl   $0x0,-0x8(%rbp)
cmpl   $0x38400,-0x8(%rbp)
jge    11e2 <clearscreen+0xd2>
mov    -0x8(%rbp),%edi
add    $0x202118e0,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%edi
add    $0x20249cf0,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a7 <clearscreen+0x97>
jmp    11e7 <clearscreen+0xd7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clearscreen>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   $0x1,%bpl
je     115b <clearscreen+0x4b>
mov    $0x20184e60,%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
lea    0x46510(%rbx),%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
lea    0xfd300(%rbx),%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
lea    0x143810(%rbx),%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
add    $0x1,%ebx
cmp    $0x201cb360,%ebx
jne    1120 <clearscreen+0x10>
test   $0x2,%bpl
je     1191 <clearscreen+0x81>
mov    $0x202118e0,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
lea    0x38410(%rbx),%edi
xor    %esi,%esi
call   1030 <write_byte@plt>
add    $0x1,%ebx
cmp    $0x20249ce0,%ebx
jne    1170 <clearscreen+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @clearscreen(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %28
7: ; preds = %1
store i32 0, i32* %3
br label %8
8: ; preds = %24, %7
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 288000
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 538463840, %12
%14 = call i32 @write_byte(i32 %13, i32 0)
%15 = load i32, i32* %3
%16 = add nsw i32 538751856, %15
%17 = call i32 @write_byte(i32 %16, i32 0)
%18 = load i32, i32* %3
%19 = add nsw i32 539500896, %18
%20 = call i32 @write_byte(i32 %19, i32 0)
%21 = load i32, i32* %3
%22 = add nsw i32 539788912, %21
%23 = call i32 @write_byte(i32 %22, i32 0)
br label %24
24: ; preds = %11
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
br label %28
28: ; preds = %27, %1
%29 = load i32, i32* %2
%30 = and i32 %29, 2
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %28
store i32 0, i32* %3
br label %33
33: ; preds = %43, %32
%34 = load i32, i32* %3
%35 = icmp slt i32 %34, 230400
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i32, i32* %3
%38 = add nsw i32 539039968, %37
%39 = call i32 @write_byte(i32 %38, i32 0)
%40 = load i32, i32* %3
%41 = add nsw i32 539270384, %40
%42 = call i32 @write_byte(i32 %41, i32 0)
br label %43
43: ; preds = %36
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %33
46: ; preds = %33
br label %47
47: ; preds = %46, %28
ret void
}

LLVM IR (-O2):
define void @clearscreen(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %14, %4 ], [ 0, %1 ]
%6 = add nuw nsw i32 %5, 538463840
%7 = tail call i32 @write_byte(i32 %6, i32 0)
%8 = add nuw nsw i32 %5, 538751856
%9 = tail call i32 @write_byte(i32 %8, i32 0)
%10 = add nuw nsw i32 %5, 539500896
%11 = tail call i32 @write_byte(i32 %10, i32 0)
%12 = add nuw nsw i32 %5, 539788912
%13 = tail call i32 @write_byte(i32 %12, i32 0)
%14 = add nuw nsw i32 %5, 1
%15 = icmp eq i32 %14, 288000
br i1 %15, label %16, label %4
16: ; preds = %4, %1
%17 = and i32 %0, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %16, %19
%20 = phi i32 [ %25, %19 ], [ 0, %16 ]
%21 = add nuw nsw i32 %20, 539039968
%22 = tail call i32 @write_byte(i32 %21, i32 0)
%23 = add nuw nsw i32 %20, 539270384
%24 = tail call i32 @write_byte(i32 %23, i32 0)
%25 = add nuw nsw i32 %20, 1
%26 = icmp eq i32 %25, 230400
br i1 %26, label %27, label %19
27: ; preds = %19, %16
ret void
}