#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 timeval {
  int tv_sec;
  int tv_usec;
};
struct fb_var_screeninfo {
  int xres;
  int yres;
  int bits_per_pixel;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ PROT_WRITE;
int atoi(char *);
int /*<<< orphan*/ close(int);
char *getenv(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
unsigned char *mmap(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/,
                    int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(unsigned char *, size_t);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int main(int argc, char **argv) {
  int fd, width, height, posx, posy;
  struct fb_var_screeninfo info;
  size_t len;
  unsigned char *buffer, *data, r, g, b;
  unsigned int w, h, i, j, x, y, start, end, count;
  struct timeval tv;
  fd = getenv("FRAMEBUFFER") ? open(getenv("FRAMEBUFFER"), O_RDWR)
                             : open("/dev/fb0", O_RDWR);
  ioctl(fd, FBIOGET_VSCREENINFO, &info);
  if (getenv("WIDTH"))
    width = atoi(getenv("WIDTH"));
  else
    width = info.xres;
  if (getenv("HEIGHT"))
    height = atoi(getenv("HEIGHT"));
  else
    height = info.yres;
  if (getenv("POSX"))
    posx = atoi(getenv("POSX"));
  else
    posx = 0;
  if (getenv("POSY"))
    posy = atoi(getenv("POSY"));
  else
    posy = 0;
  len = info.xres * info.yres * info.bits_per_pixel / 8;
  buffer = mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0);
  w = width >> 2;
  h = height >> 2;
  count = 0;
  gettimeofday(&tv, NULL);
  start = tv.tv_sec * 1000 + tv.tv_usec / 1000;
  do {
    r = rand() % 256;
    g = rand() % 256;
    b = rand() % 256;
    x = rand() % (width - w);
    y = rand() % (height - h);
    data = buffer + (posy + y) * info.xres * info.bits_per_pixel / 8 +
           (posx + x) * info.bits_per_pixel / 8;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        data[info.bits_per_pixel / 8 * j + 2] = r;
        data[info.bits_per_pixel / 8 * j + 1] = g;
        data[info.bits_per_pixel / 8 * j] = b;
      }
      data += info.xres * info.bits_per_pixel / 8;
    }
    count++;
    gettimeofday(&tv, NULL);
    end = tv.tv_sec * 1000 + tv.tv_usec / 1000;
  } while (end < (start + 5000));
  printf("Rectangle frame buffer test bench\n");
  printf("Benchmarking %dx%d size: %.2f MPixels/second\n", w, h,
         count * w * h / ((end - start) * 1000.));
  munmap(buffer, len);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe48(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11f4 <main+0x54>
lea    0xe32(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x7c(%rbp)
jmp    120c <main+0x6c>
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
lea    0xe10(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2dac(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
lea    0xdef(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1259 <main+0xb9>
lea    0xdd9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    125f <main+0xbf>
mov    -0x30(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xdbd(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1291 <main+0xf1>
lea    0xda7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1297 <main+0xf7>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xd8c(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     12c9 <main+0x129>
lea    0xd76(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    12d0 <main+0x130>
movl   $0x0,-0x20(%rbp)
lea    0xd58(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1302 <main+0x162>
lea    0xd42(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1309 <main+0x169>
movl   $0x0,-0x24(%rbp)
mov    -0x30(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
mov    0x2ca3(%rip),%rax
mov    (%rax),%edx
mov    0x2cba(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x70(%rbp)
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
imul   $0x3e8,-0x78(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x74(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x49(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x4a(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x4b(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    -0x18(%rbp),%ecx
sub    -0x50(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x60(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    -0x1c(%rbp),%ecx
sub    -0x54(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x64(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x64(%rbp),%ecx
imul   -0x30(%rbp),%ecx
imul   -0x28(%rbp),%ecx
shr    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    -0x20(%rbp),%ecx
add    -0x60(%rbp),%ecx
imul   -0x28(%rbp),%ecx
shr    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jae    1531 <main+0x391>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jae    1504 <main+0x364>
mov    -0x49(%rbp),%al
mov    %al,-0xa9(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0xa9(%rbp),%dl
mov    %eax,%ecx
mov    -0xa8(%rbp),%rax
imul   -0x5c(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x4a(%rbp),%al
mov    %al,-0x99(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x99(%rbp),%dl
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
imul   -0x5c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x4b(%rbp),%al
mov    %al,-0x89(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x89(%rbp),%dl
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
imul   -0x5c(%rbp),%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    143f <main+0x29f>
mov    -0x30(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    142c <main+0x28c>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
imul   $0x3e8,-0x78(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x74(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xb0(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    -0x68(%rbp),%ecx
add    $0x1388,%ecx
cmp    %ecx,%eax
jb     1391 <main+0x1f1>
lea    0xaad(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x50(%rbp),%esi
mov    -0x54(%rbp),%edx
mov    -0x70(%rbp),%eax
imul   %esi,%eax
imul   %edx,%eax
cvtsi2sd %rax,%xmm0
mov    -0x6c(%rbp),%eax
mov    -0x68(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %rax,%xmm1
movsd  0xa49(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xa91(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <munmap@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe43(%rip),%rdi
call   1030 <getenv@plt>
mov    0x2e0f(%rip),%rcx
mov    (%rcx),%esi
test   %rax,%rax
je     11dd <main+0x2d>
mov    %rax,%rdi
jmp    11e4 <main+0x34>
lea    0xe30(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%ebx
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1080 <ioctl@plt>
lea    0xe18(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1219 <main+0x69>
mov    %rax,%rdi
call   10c0 <atoi@plt>
jmp    121c <main+0x6c>
mov    (%rsp),%eax
mov    %eax,0x14(%rsp)
lea    0xdfc(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     123b <main+0x8b>
mov    %rax,%rdi
call   10c0 <atoi@plt>
jmp    123f <main+0x8f>
mov    0x4(%rsp),%eax
mov    %eax,0x10(%rsp)
lea    0xde0(%rip),%rdi
call   1030 <getenv@plt>
movl   $0x0,0x24(%rsp)
movl   $0x0,0x20(%rsp)
test   %rax,%rax
je     1270 <main+0xc0>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,0x20(%rsp)
lea    0xdb8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     128d <main+0xdd>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,0x24(%rsp)
mov    0x4(%rsp),%eax
imul   (%rsp),%eax
imul   0x8(%rsp),%eax
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x3,%ecx
movslq %ecx,%rsi
mov    0x2d21(%rip),%rax
mov    (%rax),%edx
mov    0x2d38(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %rsi,0x50(%rsp)
mov    %ebx,0x34(%rsp)
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,0x48(%rsp)
mov    0x14(%rsp),%ebx
mov    %ebx,%ebp
sar    $0x2,%ebp
mov    0x10(%rsp),%r14d
mov    %r14d,%r15d
sar    $0x2,%r15d
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
imul   $0x3e8,0x18(%rsp),%eax
movslq 0x1c(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x28(%rsp)
sub    %ebp,%ebx
mov    %ebx,0x3c(%rsp)
sub    %r15d,%r14d
mov    %r14d,0x38(%rsp)
add    %ecx,%eax
add    $0x1388,%eax
mov    %eax,0x40(%rsp)
cmp    $0x2,%ebp
mov    $0x1,%r13d
mov    $0x1,%ebx
mov    %ebp,0x30(%rsp)
cmovae %ebp,%ebx
cmp    $0x2,%r15d
mov    %r15d,0x2c(%rsp)
cmovae %r15d,%r13d
add    $0xffffffff,%ebx
xor    %r14d,%r14d
jmp    13b2 <main+0x202>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x44(%rsp),%r14d
add    $0x1,%r14d
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
imul   $0x3e8,0x18(%rsp),%eax
movslq 0x1c(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rbp
mov    %rbp,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rbp
add    %ecx,%ebp
add    %eax,%ebp
cmp    0x40(%rsp),%ebp
jae    14d5 <main+0x325>
mov    %r14d,0x44(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10d0 <rand@plt>
cmpl   $0x4,0x10(%rsp)
mov    0x14(%rsp),%r8d
jb     1370 <main+0x1c0>
mov    %ebp,%r9d
mov    (%rsp),%ebp
mov    0x8(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
divl   0x38(%rsp)
mov    %edx,%ecx
add    0x24(%rsp),%ecx
imul   %ebp,%ecx
imul   %edi,%ecx
shr    $0x3,%ecx
add    0x48(%rsp),%rcx
mov    %r9d,%eax
xor    %edx,%edx
divl   0x3c(%rsp)
add    0x20(%rsp),%edx
imul   %edi,%edx
shr    $0x3,%edx
add    %rcx,%rdx
jmp    1469 <main+0x2b9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rsp),%ebp
mov    0x8(%rsp),%edi
mov    %edi,%eax
imul   %ebp,%eax
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x3,%ecx
movslq %ecx,%rax
add    %rax,%rdx
add    $0x1,%esi
cmp    %r13d,%esi
je     1370 <main+0x1c0>
cmp    $0x4,%r8d
jb     1447 <main+0x297>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x7(%rdi),%ecx
test   %edi,%edi
cmovns %edi,%ecx
sar    $0x3,%ecx
imul   %eax,%ecx
add    $0x2,%ecx
mov    %r15b,(%rdx,%rcx,1)
mov    0x8(%rsp),%ecx
lea    0x7(%rcx),%edi
test   %ecx,%ecx
cmovns %ecx,%edi
sar    $0x3,%edi
imul   %eax,%edi
add    $0x1,%edi
mov    %r12b,(%rdx,%rdi,1)
mov    0x8(%rsp),%ecx
lea    0x7(%rcx),%edi
test   %ecx,%ecx
cmovns %ecx,%edi
sar    $0x3,%edi
imul   %eax,%edi
mov    %r14b,(%rdx,%rdi,1)
cmp    %eax,%ebx
je     1440 <main+0x290>
mov    0x8(%rsp),%edi
add    $0x1,%eax
jmp    1480 <main+0x2d0>
lea    0xb86(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c(%rsp),%edx
mov    %edx,%eax
mov    0x30(%rsp),%esi
imul   %esi,%eax
imul   %r14d,%eax
cvtsi2sd %rax,%xmm0
sub    0x28(%rsp),%ebp
cvtsi2sd %rbp,%xmm1
mulsd  0xaf8(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xb21(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    0x48(%rsp),%rdi
mov    0x50(%rsp),%rsi
call   10a0 <munmap@plt>
mov    0x34(%rsp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32, i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [12 x i8] c"FRAMEBUFFER\00"
@O_RDWR = global i32 0
@.str.1 = [9 x i8] c"/dev/fb0\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [6 x i8] c"WIDTH\00"
@.str.3 = [7 x i8] c"HEIGHT\00"
@.str.4 = [5 x i8] c"POSX\00"
@.str.5 = [5 x i8] c"POSY\00"
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [35 x i8] c"Rectangle frame buffer test bench\0A\00"
@.str.7 = [46 x i8] c"Benchmarking %dx%d size: %.2f MPixels/second\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.fb_var_screeninfo
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%28 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %34
30: ; preds = %2
%31 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%32 = load i32, i32* @O_RDWR
%33 = call i32 @open(i8* %31, i32 %32)
br label %37
34: ; preds = %2
%35 = load i32, i32* @O_RDWR
%36 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34, %30
%38 = phi i32 [ %33, %30 ], [ %36, %34 ]
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = load i32, i32* @FBIOGET_VSCREENINFO
%41 = call i32 @ioctl(i32 %39, i32 %40, %struct.fb_var_screeninfo* %11)
%42 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %7
br label %50
47: ; preds = %37
%48 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%49 = load i32, i32* %48
store i32 %49, i32* %7
br label %50
50: ; preds = %47, %44
%51 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %8
br label %59
56: ; preds = %50
%57 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%58 = load i32, i32* %57
store i32 %58, i32* %8
br label %59
59: ; preds = %56, %53
%60 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @atoi(i8* %63)
store i32 %64, i32* %9
br label %66
65: ; preds = %59
store i32 0, i32* %9
br label %66
66: ; preds = %65, %62
%67 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%71 = call i32 @atoi(i8* %70)
store i32 %71, i32* %10
br label %73
72: ; preds = %66
store i32 0, i32* %10
br label %73
73: ; preds = %72, %69
%74 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%75 = load i32, i32* %74
%76 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%77 = load i32, i32* %76
%78 = mul nsw i32 %75, %77
%79 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%80 = load i32, i32* %79
%81 = mul nsw i32 %78, %80
%82 = sdiv i32 %81, 8
%83 = sext i32 %82 to i64
store i64 %83, i64* %12
%84 = load i64, i64* %12
%85 = load i32, i32* @PROT_WRITE
%86 = load i32, i32* @MAP_SHARED
%87 = load i32, i32* %6
%88 = call i8* @mmap(i32* null, i64 %84, i32 %85, i32 %86, i32 %87, i32 0)
store i8* %88, i8** %13
%89 = load i32, i32* %7
%90 = ashr i32 %89, 2
store i32 %90, i32* %18
%91 = load i32, i32* %8
%92 = ashr i32 %91, 2
store i32 %92, i32* %19
store i32 0, i32* %26
%93 = call i32 @gettimeofday(%struct.timeval* %27, i32* null)
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
%95 = load i32, i32* %94
%96 = mul nsw i32 %95, 1000
%97 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 1
%98 = load i32, i32* %97
%99 = sdiv i32 %98, 1000
%100 = add nsw i32 %96, %99
store i32 %100, i32* %24
br label %101
101: ; preds = %209, %73
%102 = call i32 (...) @rand()
%103 = srem i32 %102, 256
%104 = trunc i32 %103 to i8
store i8 %104, i8* %15
%105 = call i32 (...) @rand()
%106 = srem i32 %105, 256
%107 = trunc i32 %106 to i8
store i8 %107, i8* %16
%108 = call i32 (...) @rand()
%109 = srem i32 %108, 256
%110 = trunc i32 %109 to i8
store i8 %110, i8* %17
%111 = call i32 (...) @rand()
%112 = load i32, i32* %7
%113 = load i32, i32* %18
%114 = sub i32 %112, %113
%115 = urem i32 %111, %114
store i32 %115, i32* %22
%116 = call i32 (...) @rand()
%117 = load i32, i32* %8
%118 = load i32, i32* %19
%119 = sub i32 %117, %118
%120 = urem i32 %116, %119
store i32 %120, i32* %23
%121 = load i8*, i8** %13
%122 = load i32, i32* %10
%123 = load i32, i32* %23
%124 = add i32 %122, %123
%125 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%126 = load i32, i32* %125
%127 = mul i32 %124, %126
%128 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%129 = load i32, i32* %128
%130 = mul i32 %127, %129
%131 = udiv i32 %130, 8
%132 = zext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %121, i64 %132
%134 = load i32, i32* %9
%135 = load i32, i32* %22
%136 = add i32 %134, %135
%137 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%138 = load i32, i32* %137
%139 = mul i32 %136, %138
%140 = udiv i32 %139, 8
%141 = zext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %133, i64 %141
store i8* %142, i8** %14
store i32 0, i32* %20
br label %143
143: ; preds = %195, %101
%144 = load i32, i32* %20
%145 = load i32, i32* %19
%146 = icmp ult i32 %144, %145
br i1 %146, label %147, label %198
147: ; preds = %143
store i32 0, i32* %21
br label %148
148: ; preds = %182, %147
%149 = load i32, i32* %21
%150 = load i32, i32* %18
%151 = icmp ult i32 %149, %150
br i1 %151, label %152, label %185
152: ; preds = %148
%153 = load i8, i8* %15
%154 = load i8*, i8** %14
%155 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%156 = load i32, i32* %155
%157 = sdiv i32 %156, 8
%158 = load i32, i32* %21
%159 = mul i32 %157, %158
%160 = add i32 %159, 2
%161 = zext i32 %160 to i64
%162 = getelementptr inbounds i8, i8* %154, i64 %161
store i8 %153, i8* %162
%163 = load i8, i8* %16
%164 = load i8*, i8** %14
%165 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%166 = load i32, i32* %165
%167 = sdiv i32 %166, 8
%168 = load i32, i32* %21
%169 = mul i32 %167, %168
%170 = add i32 %169, 1
%171 = zext i32 %170 to i64
%172 = getelementptr inbounds i8, i8* %164, i64 %171
store i8 %163, i8* %172
%173 = load i8, i8* %17
%174 = load i8*, i8** %14
%175 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%176 = load i32, i32* %175
%177 = sdiv i32 %176, 8
%178 = load i32, i32* %21
%179 = mul i32 %177, %178
%180 = zext i32 %179 to i64
%181 = getelementptr inbounds i8, i8* %174, i64 %180
store i8 %173, i8* %181
br label %182
182: ; preds = %152
%183 = load i32, i32* %21
%184 = add i32 %183, 1
store i32 %184, i32* %21
br label %148
185: ; preds = %148
%186 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%187 = load i32, i32* %186
%188 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%189 = load i32, i32* %188
%190 = mul nsw i32 %187, %189
%191 = sdiv i32 %190, 8
%192 = load i8*, i8** %14
%193 = sext i32 %191 to i64
%194 = getelementptr inbounds i8, i8* %192, i64 %193
store i8* %194, i8** %14
br label %195
195: ; preds = %185
%196 = load i32, i32* %20
%197 = add i32 %196, 1
store i32 %197, i32* %20
br label %143
198: ; preds = %143
%199 = load i32, i32* %26
%200 = add i32 %199, 1
store i32 %200, i32* %26
%201 = call i32 @gettimeofday(%struct.timeval* %27, i32* null)
%202 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
%203 = load i32, i32* %202
%204 = mul nsw i32 %203, 1000
%205 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 1
%206 = load i32, i32* %205
%207 = sdiv i32 %206, 1000
%208 = add nsw i32 %204, %207
store i32 %208, i32* %25
br label %209
209: ; preds = %198
%210 = load i32, i32* %25
%211 = load i32, i32* %24
%212 = add i32 %211, 5000
%213 = icmp ult i32 %210, %212
br i1 %213, label %101, label %214
214: ; preds = %209
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%216 = load i32, i32* %18
%217 = load i32, i32* %19
%218 = load i32, i32* %26
%219 = load i32, i32* %18
%220 = mul i32 %218, %219
%221 = load i32, i32* %19
%222 = mul i32 %220, %221
%223 = uitofp i32 %222 to double
%224 = load i32, i32* %25
%225 = load i32, i32* %24
%226 = sub i32 %224, %225
%227 = uitofp i32 %226 to double
%228 = fmul double %227, 1.000000e+03
%229 = fdiv double %223, %228
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %216, i32 %217, double %229)
%231 = load i8*, i8** %13
%232 = load i64, i64* %12
%233 = call i32 @munmap(i8* %231, i64 %232)
%234 = load i32, i32* %6
%235 = call i32 @close(i32 %234)
ret i32 0
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32, i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [12 x i8] c"FRAMEBUFFER\00"
@O_RDWR = global i32 0
@.str.1 = [9 x i8] c"/dev/fb0\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [6 x i8] c"WIDTH\00"
@.str.3 = [7 x i8] c"HEIGHT\00"
@.str.4 = [5 x i8] c"POSX\00"
@.str.5 = [5 x i8] c"POSY\00"
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.7 = [46 x i8] c"Benchmarking %dx%d size: %.2f MPixels/second\0A\00"
@str = [34 x i8] c"Rectangle frame buffer test bench\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.fb_var_screeninfo
%4 = alloca %struct.timeval
%5 = bitcast %struct.fb_var_screeninfo* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
%9 = load i32, i32* @O_RDWR
br i1 %8, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @open(i8* %7, i32 %9)
br label %14
12: ; preds = %2
%13 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ]
%16 = load i32, i32* @FBIOGET_VSCREENINFO
%17 = call i32 @ioctl(i32 %15, i32 %16, %struct.fb_var_screeninfo* %3)
%18 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = call i32 @atoi(i8* %18)
br label %25
22: ; preds = %14
%23 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 0
%24 = load i32, i32* %23
br label %25
25: ; preds = %22, %20
%26 = phi i32 [ %21, %20 ], [ %24, %22 ]
%27 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @atoi(i8* %27)
br label %34
31: ; preds = %25
%32 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 1
%33 = load i32, i32* %32
br label %34
34: ; preds = %31, %29
%35 = phi i32 [ %30, %29 ], [ %33, %31 ]
%36 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i8* %36, null
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 @atoi(i8* %36)
br label %40
40: ; preds = %34, %38
%41 = phi i32 [ %39, %38 ], [ 0, %34 ]
%42 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp eq i8* %42, null
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = call i32 @atoi(i8* %42)
br label %46
46: ; preds = %40, %44
%47 = phi i32 [ %45, %44 ], [ 0, %40 ]
%48 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 0
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 1
%51 = load i32, i32* %50
%52 = mul nsw i32 %51, %49
%53 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 2
%54 = load i32, i32* %53
%55 = mul nsw i32 %52, %54
%56 = sdiv i32 %55, 8
%57 = sext i32 %56 to i64
%58 = load i32, i32* @PROT_WRITE
%59 = load i32, i32* @MAP_SHARED
%60 = call i8* @mmap(i32* null, i64 %57, i32 %58, i32 %59, i32 %15, i32 0)
%61 = ashr i32 %26, 2
%62 = ashr i32 %35, 2
%63 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%64 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%65 = load i32, i32* %64
%66 = mul nsw i32 %65, 1000
%67 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%68 = load i32, i32* %67
%69 = sdiv i32 %68, 1000
%70 = add nsw i32 %69, %66
%71 = sub i32 %26, %61
%72 = sub i32 %35, %62
%73 = icmp ult i32 %35, 4
%74 = icmp ult i32 %26, 4
%75 = add i32 %70, 5000
%76 = call i32 @llvm.umax.i32(i32 %61, i32 1)
%77 = call i32 @llvm.umax.i32(i32 %62, i32 1)
br label %78
78: ; preds = %144, %46
%79 = phi i32 [ 0, %46 ], [ %145, %144 ]
%80 = call i32 (...) @rand()
%81 = trunc i32 %80 to i8
%82 = call i32 (...) @rand()
%83 = trunc i32 %82 to i8
%84 = call i32 (...) @rand()
%85 = trunc i32 %84 to i8
%86 = call i32 (...) @rand()
%87 = call i32 (...) @rand()
%88 = load i32, i32* %48
%89 = load i32, i32* %53
br i1 %73, label %144, label %90
90: ; preds = %78
%91 = urem i32 %87, %72
%92 = add i32 %91, %47
%93 = mul i32 %92, %88
%94 = mul i32 %93, %89
%95 = lshr i32 %94, 3
%96 = zext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %60, i64 %96
%98 = urem i32 %86, %71
%99 = add i32 %98, %41
%100 = mul i32 %89, %99
%101 = lshr i32 %100, 3
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %97, i64 %102
br label %104
104: ; preds = %90, %135
%105 = phi i32 [ %136, %135 ], [ %89, %90 ]
%106 = phi i32 [ %137, %135 ], [ %88, %90 ]
%107 = phi i32 [ %142, %135 ], [ 0, %90 ]
%108 = phi i8* [ %141, %135 ], [ %103, %90 ]
br i1 %74, label %135, label %109
109: ; preds = %104, %130
%110 = phi i32 [ %131, %130 ], [ %105, %104 ]
%111 = phi i32 [ %128, %130 ], [ 0, %104 ]
%112 = sdiv i32 %110, 8
%113 = mul i32 %112, %111
%114 = add i32 %113, 2
%115 = zext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %108, i64 %115
store i8 %81, i8* %116
%117 = load i32, i32* %53
%118 = sdiv i32 %117, 8
%119 = mul i32 %118, %111
%120 = add i32 %119, 1
%121 = zext i32 %120 to i64
%122 = getelementptr inbounds i8, i8* %108, i64 %121
store i8 %83, i8* %122
%123 = load i32, i32* %53
%124 = sdiv i32 %123, 8
%125 = mul i32 %124, %111
%126 = zext i32 %125 to i64
%127 = getelementptr inbounds i8, i8* %108, i64 %126
store i8 %85, i8* %127
%128 = add nuw i32 %111, 1
%129 = icmp eq i32 %128, %76
br i1 %129, label %132, label %130
130: ; preds = %109
%131 = load i32, i32* %53
br label %109
132: ; preds = %109
%133 = load i32, i32* %48
%134 = load i32, i32* %53
br label %135
135: ; preds = %132, %104
%136 = phi i32 [ %134, %132 ], [ %105, %104 ]
%137 = phi i32 [ %133, %132 ], [ %106, %104 ]
%138 = mul nsw i32 %136, %137
%139 = sdiv i32 %138, 8
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %108, i64 %140
%142 = add nuw i32 %107, 1
%143 = icmp eq i32 %142, %77
br i1 %143, label %144, label %104
144: ; preds = %135, %78
%145 = add i32 %79, 1
%146 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%147 = load i32, i32* %64
%148 = mul nsw i32 %147, 1000
%149 = load i32, i32* %67
%150 = sdiv i32 %149, 1000
%151 = add nsw i32 %150, %148
%152 = icmp ult i32 %151, %75
br i1 %152, label %78, label %153
153: ; preds = %144
%154 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%155 = mul i32 %62, %61
%156 = mul i32 %155, %145
%157 = uitofp i32 %156 to double
%158 = sub i32 %151, %70
%159 = uitofp i32 %158 to double
%160 = fmul double %159, 1.000000e+03
%161 = fdiv double %157, %160
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %61, i32 %62, double %161)
%163 = call i32 @munmap(i8* %60, i64 %57)
%164 = call i32 @close(i32 %15)
ret i32 0
}