#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*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int write(int, char *, int);
int main(void) {
  int y = 500, x = 500, fd, ret;
  fd = open("/dev/fb0", O_RDWR);
  if (fd < 0) {
    perror("Can't open file");
    return fd;
  }
  if ((ret = lseek(fd, 640 * y + x, SEEK_SET)) == -1) {
    perror("Can't move cursor");
    return ret;
  }
  if ((ret = write(fd, "\377\377\377\377", 4)) == -1) {
    perror("Can't write to monitor");
    return ret;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1f4,-0x8(%rbp)
movl   $0x1f4,-0xc(%rbp)
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
lea    0xe93(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1196 <main+0x56>
lea    0xe83(%rip),%rdi
call   1060 <perror@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <main+0xd2>
mov    -0x10(%rbp),%edi
imul   $0x280,-0x8(%rbp),%esi
add    -0xc(%rbp),%esi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11d4 <main+0x94>
lea    0xe55(%rip),%rdi
call   1060 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <main+0xd2>
mov    -0x10(%rbp),%edi
lea    0xe4d(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    120b <main+0xcb>
lea    0xe35(%rip),%rdi
call   1060 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <main+0xd2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1194 <main+0x54>
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0x4e3f4,%esi
call   1040 <lseek@plt>
cmp    $0xffffffff,%eax
je     119d <main+0x5d>
lea    0xeae(%rip),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
je     11a6 <main+0x66>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe6e(%rip),%rdi
jmp    11b2 <main+0x72>
lea    0xe75(%rip),%rdi
jmp    11ad <main+0x6d>
lea    0xe83(%rip),%rdi
mov    $0xffffffff,%ebx
call   1060 <perror@plt>
jmp    1190 <main+0x50>

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@.str.1 = [16 x i8] c"Can't open file\00"
@SEEK_SET = global i32 0
@.str.2 = [18 x i8] c"Can't move cursor\00"
@.str.3 = [5 x i8] c"\FF\FF\FF\FF\00"
@.str.4 = [23 x i8] c"Can't write to monitor\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 500, i32* %2
store i32 500, i32* %3
%6 = load i32, i32* @O_RDWR
%7 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %4
store i32 %12, i32* %1
br label %33
13: ; preds = %0
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = mul nsw i32 640, %15
%17 = load i32, i32* %3
%18 = add nsw i32 %16, %17
%19 = load i32, i32* @SEEK_SET
%20 = call i32 @lseek(i32 %14, i32 %18, i32 %19)
store i32 %20, i32* %5
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %5
store i32 %24, i32* %1
br label %33
25: ; preds = %13
%26 = load i32, i32* %4
%27 = call i32 @write(i32 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
store i32 %27, i32* %5
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* %5
store i32 %31, i32* %1
br label %33
32: ; preds = %25
store i32 0, i32* %1
br label %33
33: ; preds = %32, %29, %22, %10
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@.str.1 = [16 x i8] c"Can't open file\00"
@SEEK_SET = global i32 0
@.str.2 = [18 x i8] c"Can't move cursor\00"
@.str.3 = [5 x i8] c"\FF\FF\FF\FF\00"
@.str.4 = [23 x i8] c"Can't write to monitor\00"
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %0
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @lseek(i32 %2, i32 320500, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %8, %4, %0
%12 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), %8 ]
%13 = phi i32 [ %2, %0 ], [ -1, %4 ], [ -1, %8 ]
%14 = tail call i32 @perror(i8* %12)
br label %15
15: ; preds = %11, %8
%16 = phi i32 [ 0, %8 ], [ %13, %11 ]
ret i32 %16
}