#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*/ MAP_SHARED;
int O_EXCL;
int O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ memcpy(char *, unsigned int *, int);
char *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int);
int main(void) {
  int lcd = open("/dev/fb0", O_RDWR | O_EXCL);
  char *p_lcd;
  p_lcd = mmap(NULL, 800 * 480 * 4, PROT_READ | PROT_WRITE, MAP_SHARED, lcd, 0);
  unsigned x = 0xFFFFFFFF;
  int i;
  for (i = 0; i < 800 * 480; i++) {
    memcpy(p_lcd + (4 * i), &x, 4);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    0x2e79(%rip),%rax
or     (%rax),%esi
lea    0xea8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    0x2e50(%rip),%rax
or     (%rax),%edx
mov    0x2e6f(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x177000,%esi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x5dc00,-0x18(%rbp)
jge    11da <main+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
cltq
add    %rax,%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a2 <main+0x72>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e98(%rip),%rax
mov    0x2e81(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xeae(%rip),%rdi
call   1050 <open@plt>
mov    0x2e9a(%rip),%rcx
mov    0x2e5b(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2e78(%rip),%rcx
mov    (%rcx),%ecx
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x177000,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%r15
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
lea    (%r15,%rbx,1),%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
add    $0x4,%rbx
cmp    $0x177000,%rbx
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @O_RDWR
%7 = load i32, i32* @O_EXCL
%8 = or i32 %6, %7
%9 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %2
%10 = load i32, i32* @PROT_READ
%11 = load i32, i32* @PROT_WRITE
%12 = or i32 %10, %11
%13 = load i32, i32* @MAP_SHARED
%14 = load i32, i32* %2
%15 = call i8* @mmap(i32* null, i32 1536000, i32 %12, i32 %13, i32 %14, i32 0)
store i8* %15, i8** %3
store i32 -1, i32* %4
store i32 0, i32* %5
br label %16
16: ; preds = %26, %0
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 384000
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = mul nsw i32 4, %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @memcpy(i8* %24, i32* %4, i32 4)
br label %26
26: ; preds = %19
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %16
29: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @O_RDWR
%3 = load i32, i32* @O_EXCL
%4 = or i32 %3, %2
%5 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @PROT_READ
%7 = load i32, i32* @PROT_WRITE
%8 = or i32 %7, %6
%9 = load i32, i32* @MAP_SHARED
%10 = tail call i8* @mmap(i32* null, i32 1536000, i32 %8, i32 %9, i32 %5, i32 0)
%11 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
br label %12
12: ; preds = %0, %12
%13 = phi i64 [ 0, %0 ], [ %17, %12 ]
%14 = shl nuw nsw i64 %13, 2
%15 = getelementptr inbounds i8, i8* %10, i64 %14
%16 = call i32 @memcpy(i8* %15, i32* %1, i32 4)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, 384000
br i1 %18, label %19, label %12
19: ; preds = %12
ret i32 0
}