#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 */
scalar_t__ ML_vram_adress();
void ML_clear_vram() {
  int i, end, *pointer_long, vram;
  char *pointer_byte;
  vram = (int)ML_vram_adress();
  end = 4 - vram & 3;
  pointer_byte = (char *)vram;
  for (i = 0; i < end; i++)
    pointer_byte[i] = 0;
  pointer_long = (int *)(vram + end);
  for (i = 0; i < 255; i++)
    pointer_long[i] = 0;
  pointer_byte += 1020 + end;
  end = vram & 3;
  for (i = 0; i < end; i++)
    pointer_byte[i] = 0;
}


x86 assembly (clang, -O0):
<ML_clear_vram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <ML_vram_adress@plt>
mov    %eax,-0x14(%rbp)
mov    $0x4,%eax
sub    -0x14(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x8(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1165 <ML_clear_vram+0x55>
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <ML_clear_vram+0x2f>
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xff,-0x4(%rbp)
jge    11a2 <ML_clear_vram+0x92>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1178 <ML_clear_vram+0x68>
mov    -0x8(%rbp),%ecx
add    $0x3fc,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ef <ML_clear_vram+0xdf>
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <ML_clear_vram+0xb9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ML_clear_vram>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <ML_vram_adress@plt>
mov    %rax,%r15
mov    %r15d,%ebx
neg    %ebx
movslq %r15d,%r14
and    $0x3,%ebx
je     114e <ML_clear_vram+0x2e>
mov    %r15d,%edx
neg    %edx
and    $0x3,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
lea    (%rbx,%r15,1),%eax
movslq %eax,%rdi
mov    $0x3fc,%edx
xor    %esi,%esi
call   1030 <memset@plt>
test   $0x3,%r15b
je     1181 <ML_clear_vram+0x61>
or     $0x3fc,%ebx
add    %rbx,%r14
and    $0x3,%r15d
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <memset@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ML_clear_vram() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = call i64 (...) @ML_vram_adress()
%7 = trunc i64 %6 to i32
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = sub nsw i32 4, %8
%10 = and i32 %9, 3
store i32 %10, i32* %2
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %5
store i32 0, i32* %1
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %14
26: ; preds = %14
%27 = load i32, i32* %4
%28 = load i32, i32* %2
%29 = add nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
store i32* %31, i32** %3
store i32 0, i32* %1
br label %32
32: ; preds = %40, %26
%33 = load i32, i32* %1
%34 = icmp slt i32 %33, 255
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load i32*, i32** %3
%37 = load i32, i32* %1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 0, i32* %39
br label %40
40: ; preds = %35
%41 = load i32, i32* %1
%42 = add nsw i32 %41, 1
store i32 %42, i32* %1
br label %32
43: ; preds = %32
%44 = load i32, i32* %2
%45 = add nsw i32 1020, %44
%46 = load i8*, i8** %5
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i8, i8* %46, i64 %47
store i8* %48, i8** %5
%49 = load i32, i32* %4
%50 = and i32 %49, 3
store i32 %50, i32* %2
store i32 0, i32* %1
br label %51
51: ; preds = %60, %43
%52 = load i32, i32* %1
%53 = load i32, i32* %2
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %63
55: ; preds = %51
%56 = load i8*, i8** %5
%57 = load i32, i32* %1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
br label %60
60: ; preds = %55
%61 = load i32, i32* %1
%62 = add nsw i32 %61, 1
store i32 %62, i32* %1
br label %51
63: ; preds = %51
ret void
}

LLVM IR (-O2):
define void @ML_clear_vram() {
%1 = tail call i64 (...) @ML_vram_adress()
%2 = trunc i64 %1 to i32
%3 = sub i32 0, %2
%4 = and i32 %3, 3
%5 = shl i64 %1, 32
%6 = ashr exact i64 %5, 32
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i32 %4, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = sub i64 0, %1
%11 = and i64 %10, 3
br label %12
12: ; preds = %9, %0
%13 = add nsw i32 %4, %2
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
%16 = and i32 %2, 3
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %12
%19 = or i32 %4, 1020
%20 = zext i32 %19 to i64
%21 = getelementptr i8, i8* %7, i64 %20
%22 = and i64 %1, 3
br label %23
23: ; preds = %18, %12
ret void
}