#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 */
struct fb_var_screeninfo {
  int xres;
  int bits_per_pixel;
  int yres;
  scalar_t__ yoffset;
  scalar_t__ xoffset;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ FBIOPAN_DISPLAY;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
scalar_t__ mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
                int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int main() {
  int framebuffer_device;
  int line_size, buffer_size, i;
  char *screen_memory;
  struct fb_var_screeninfo var_info;
  framebuffer_device = open("/dev/fb0", O_RDWR);
  ioctl(framebuffer_device, FBIOGET_VSCREENINFO, &var_info);
  line_size = var_info.xres * var_info.bits_per_pixel / 8;
  buffer_size = line_size * var_info.yres;
  var_info.xoffset = 0;
  var_info.yoffset = 0;
  ioctl(framebuffer_device, FBIOPAN_DISPLAY, &var_info);
  screen_memory = (char *)mmap(0, buffer_size, PROT_READ | PROT_WRITE,
                               MAP_SHARED, framebuffer_device, 0);
  for (i = 0; i < buffer_size; i++) {
    *(screen_memory + i) = i;
  }
  sleep(2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xea1(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x40(%rbp),%eax
imul   -0x3c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x38(%rbp),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x10(%rbp),%esi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
mov    0x2df0(%rip),%rax
or     (%rax),%edx
mov    0x2e0f(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    121f <main+0xdf>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f5 <main+0xb5>
mov    $0x2,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xf38(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rdx
call   1040 <ioctl@plt>
mov    0x4(%rsp),%eax
imul   (%rsp),%eax
lea    0x7(%rax),%ebp
test   %eax,%eax
cmovns %eax,%ebp
sar    $0x3,%ebp
imul   0x8(%rsp),%ebp
pxor   %xmm0,%xmm0
movdqu %xmm0,0x10(%rsp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1040 <ioctl@plt>
mov    0x2e47(%rip),%rax
mov    0x2e08(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e25(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
test   %ebp,%ebp
jle    134c <main+0x20c>
mov    %ebp,%ecx
cmp    $0x20,%ebp
jae    11ea <main+0xaa>
xor    %edx,%edx
jmp    1340 <main+0x200>
mov    %ecx,%edx
and    $0xffffffe0,%edx
lea    -0x20(%rdx),%rbp
mov    %rbp,%rdi
shr    $0x5,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0x60,%rbp
jae    1218 <main+0xd8>
movdqa 0xdef(%rip),%xmm0
xor    %ebp,%ebp
jmp    12e8 <main+0x1a8>
and    $0xfffffffffffffffc,%rdi
movdqa 0xddc(%rip),%xmm0
xor    %ebp,%ebp
movdqa 0xde1(%rip),%xmm8
movdqa 0xde8(%rip),%xmm9
movdqa 0xdef(%rip),%xmm10
movdqa 0xdf7(%rip),%xmm4
movdqa 0xdff(%rip),%xmm5
movdqa 0xe07(%rip),%xmm6
movdqa 0xe0f(%rip),%xmm7
movdqa 0xe17(%rip),%xmm1
nopl   0x0(%rax)
movdqa %xmm0,%xmm2
paddb  %xmm8,%xmm2
movdqu %xmm0,(%rax,%rbp,1)
movdqu %xmm2,0x10(%rax,%rbp,1)
movdqa %xmm0,%xmm2
paddb  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddb  %xmm10,%xmm3
movdqu %xmm2,0x20(%rax,%rbp,1)
movdqu %xmm3,0x30(%rax,%rbp,1)
movdqa %xmm0,%xmm2
paddb  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddb  %xmm5,%xmm3
movdqu %xmm2,0x40(%rax,%rbp,1)
movdqu %xmm3,0x50(%rax,%rbp,1)
movdqa %xmm0,%xmm2
paddb  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddb  %xmm7,%xmm3
movdqu %xmm2,0x60(%rax,%rbp,1)
movdqu %xmm3,0x70(%rax,%rbp,1)
sub    $0xffffffffffffff80,%rbp
pxor   %xmm1,%xmm0
add    $0xfffffffffffffffc,%rdi
jne    1270 <main+0x130>
test   %rsi,%rsi
je     1330 <main+0x1f0>
lea    (%rax,%rbp,1),%rdi
add    $0x10,%rdi
shl    $0x5,%rsi
xor    %ebp,%ebp
movdqa 0xd0d(%rip),%xmm1
movdqa 0xd15(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm3
paddb  %xmm1,%xmm3
movdqu %xmm0,-0x10(%rdi,%rbp,1)
movdqu %xmm3,(%rdi,%rbp,1)
paddb  %xmm2,%xmm0
add    $0x20,%rbp
cmp    %rbp,%rsi
jne    1310 <main+0x1d0>
cmp    %rcx,%rdx
je     134c <main+0x20c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %dl,(%rax,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1340 <main+0x200>
mov    $0x2,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32, i32, i32, i64, i64 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@FBIOGET_VSCREENINFO = global i32 0
@FBIOPAN_DISPLAY = 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 i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.fb_var_screeninfo
store i32 0, i32* %1
%8 = load i32, i32* @O_RDWR
%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* %2
%11 = load i32, i32* @FBIOGET_VSCREENINFO
%12 = call i32 @ioctl(i32 %10, i32 %11, %struct.fb_var_screeninfo* %7)
%13 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 1
%16 = load i32, i32* %15
%17 = mul nsw i32 %14, %16
%18 = sdiv i32 %17, 8
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 2
%21 = load i32, i32* %20
%22 = mul nsw i32 %19, %21
store i32 %22, i32* %4
%23 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 4
store i64 0, i64* %23
%24 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 3
store i64 0, i64* %24
%25 = load i32, i32* %2
%26 = load i32, i32* @FBIOPAN_DISPLAY
%27 = call i32 @ioctl(i32 %25, i32 %26, %struct.fb_var_screeninfo* %7)
%28 = load i32, i32* %4
%29 = load i32, i32* @PROT_READ
%30 = load i32, i32* @PROT_WRITE
%31 = or i32 %29, %30
%32 = load i32, i32* @MAP_SHARED
%33 = load i32, i32* %2
%34 = call i64 @mmap(i32 0, i32 %28, i32 %31, i32 %32, i32 %33, i32 0)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %6
store i32 0, i32* %5
br label %36
36: ; preds = %47, %0
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load i32, i32* %5
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %6
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %40
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %36
50: ; preds = %36
%51 = call i32 @sleep(i32 2)
ret i32 0
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32, i32, i32, i64, i64 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@FBIOGET_VSCREENINFO = global i32 0
@FBIOPAN_DISPLAY = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i32 @main() {
%1 = alloca %struct.fb_var_screeninfo
%2 = bitcast %struct.fb_var_screeninfo* %1 to i8*
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @FBIOGET_VSCREENINFO
%6 = call i32 @ioctl(i32 %4, i32 %5, %struct.fb_var_screeninfo* %1)
%7 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, %8
%12 = sdiv i32 %11, 8
%13 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2
%14 = load i32, i32* %13
%15 = mul i32 %12, %14
%16 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 3
%17 = bitcast i64* %16 to i8*
%18 = load i32, i32* @FBIOPAN_DISPLAY
%19 = call i32 @ioctl(i32 %4, i32 %18, %struct.fb_var_screeninfo* %1)
%20 = load i32, i32* @PROT_READ
%21 = load i32, i32* @PROT_WRITE
%22 = or i32 %21, %20
%23 = load i32, i32* @MAP_SHARED
%24 = call i64 @mmap(i32 0, i32 %15, i32 %22, i32 %23, i32 %4, i32 0)
%25 = inttoptr i64 %24 to i8*
%26 = icmp sgt i32 %15, 0
br i1 %26, label %27, label %100
27: ; preds = %0
%28 = zext i32 %15 to i64
%29 = icmp ult i32 %15, 32
br i1 %29, label %92, label %30
30: ; preds = %27
%31 = and i64 %28, 4294967264
%32 = add nsw i64 %31, -32
%33 = lshr exact i64 %32, 5
%34 = add nuw nsw i64 %33, 1
%35 = and i64 %34, 3
%36 = icmp ult i64 %32, 96
br i1 %36, label %73, label %37
37: ; preds = %30
%38 = and i64 %34, 1152921504606846972
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %69, %39 ]
%41 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %37 ], [ %70, %39 ]
%42 = phi i64 [ 0, %37 ], [ %71, %39 ]
%43 = add <16 x i8> %41, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%44 = getelementptr inbounds i8, i8* %25, i64 %40
%45 = bitcast i8* %44 to <16 x i8>*
store <16 x i8> %41, <16 x i8>* %45
%46 = getelementptr inbounds i8, i8* %44, i64 16
%47 = bitcast i8* %46 to <16 x i8>*
store <16 x i8> %43, <16 x i8>* %47
%48 = or i64 %40, 32
%49 = add <16 x i8> %41, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%50 = add <16 x i8> %41, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%51 = getelementptr inbounds i8, i8* %25, i64 %48
%52 = bitcast i8* %51 to <16 x i8>*
store <16 x i8> %49, <16 x i8>* %52
%53 = getelementptr inbounds i8, i8* %51, i64 16
%54 = bitcast i8* %53 to <16 x i8>*
store <16 x i8> %50, <16 x i8>* %54
%55 = or i64 %40, 64
%56 = add <16 x i8> %41, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%57 = add <16 x i8> %41, <i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80>
%58 = getelementptr inbounds i8, i8* %25, i64 %55
%59 = bitcast i8* %58 to <16 x i8>*
store <16 x i8> %56, <16 x i8>* %59
%60 = getelementptr inbounds i8, i8* %58, i64 16
%61 = bitcast i8* %60 to <16 x i8>*
store <16 x i8> %57, <16 x i8>* %61
%62 = or i64 %40, 96
%63 = add <16 x i8> %41, <i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96>
%64 = add <16 x i8> %41, <i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112>
%65 = getelementptr inbounds i8, i8* %25, i64 %62
%66 = bitcast i8* %65 to <16 x i8>*
store <16 x i8> %63, <16 x i8>* %66
%67 = getelementptr inbounds i8, i8* %65, i64 16
%68 = bitcast i8* %67 to <16 x i8>*
store <16 x i8> %64, <16 x i8>* %68
%69 = add nuw i64 %40, 128
%70 = xor <16 x i8> %41, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%71 = add i64 %42, 4
%72 = icmp eq i64 %71, %38
br i1 %72, label %73, label %39
73: ; preds = %39, %30
%74 = phi i64 [ 0, %30 ], [ %69, %39 ]
%75 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %30 ], [ %70, %39 ]
%76 = icmp eq i64 %35, 0
br i1 %76, label %90, label %77
77: ; preds = %73, %77
%78 = phi i64 [ %86, %77 ], [ %74, %73 ]
%79 = phi <16 x i8> [ %87, %77 ], [ %75, %73 ]
%80 = phi i64 [ %88, %77 ], [ 0, %73 ]
%81 = add <16 x i8> %79, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%82 = getelementptr inbounds i8, i8* %25, i64 %78
%83 = bitcast i8* %82 to <16 x i8>*
store <16 x i8> %79, <16 x i8>* %83
%84 = getelementptr inbounds i8, i8* %82, i64 16
%85 = bitcast i8* %84 to <16 x i8>*
store <16 x i8> %81, <16 x i8>* %85
%86 = add nuw i64 %78, 32
%87 = add <16 x i8> %79, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%88 = add i64 %80, 1
%89 = icmp eq i64 %88, %35
br i1 %89, label %90, label %77
90: ; preds = %77, %73
%91 = icmp eq i64 %31, %28
br i1 %91, label %100, label %92
92: ; preds = %27, %90
%93 = phi i64 [ 0, %27 ], [ %31, %90 ]
br label %94
94: ; preds = %92, %94
%95 = phi i64 [ %98, %94 ], [ %93, %92 ]
%96 = trunc i64 %95 to i8
%97 = getelementptr inbounds i8, i8* %25, i64 %95
store i8 %96, i8* %97
%98 = add nuw nsw i64 %95, 1
%99 = icmp eq i64 %98, %28
br i1 %99, label %100, label %94
100: ; preds = %94, %90, %0
%101 = call i32 @sleep(i32 2)
ret i32 0
}