#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 main(int argc, char **argv) {
  int fd, width, height, posx, posy;
  struct fb_var_screeninfo info;
  size_t len;
  unsigned char *buffer, c;
  unsigned int iters = 1, i, j, n;
  float a, b, tmp, x, y, seconds;
  struct timeval start, stop;
  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);
  gettimeofday(&start, NULL);
  while (iters <= 48) {
    for (i = 0; i < height; i++) {
      for (j = 0; j < width; j++) {
        x = y = c = 0;
        a = 3. * j / width - 2;
        b = 1 - 2. * i / height;
        do {
          tmp = x;
          x = x * x - y * y + a;
          y = 2 * tmp * y + b;
          if (x * x + y * y > 4)
            break;
        } while (++c < iters);
        for (n = 0; n < 3; n++) {
          buffer[(posy + i) * info.xres * info.bits_per_pixel / 8 +
                 (posx + j) * info.bits_per_pixel / 8 + n] = c * 255 / iters;
        }
      }
    }
    iters++;
  }
  gettimeofday(&stop, NULL);
  seconds =
      (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) / 1000000.;
  printf("Mandelbrot frame buffer test bench\n");
  printf("Benchmarking 48 iterations: %.2f seconds\n", seconds);
  munmap(buffer, len);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x48(%rbp)
lea    0xe79(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11ee <main+0x5e>
lea    0xe63(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x84(%rbp)
jmp    1209 <main+0x79>
mov    0x2deb(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x84(%rbp)
mov    -0x84(%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    0xe17(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1259 <main+0xc9>
lea    0xe01(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    125f <main+0xcf>
mov    -0x30(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xde5(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1291 <main+0x101>
lea    0xdcf(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1297 <main+0x107>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xdb4(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     12c9 <main+0x139>
lea    0xd9e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    12d0 <main+0x140>
movl   $0x0,-0x20(%rbp)
lea    0xd80(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1302 <main+0x172>
lea    0xd6a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1309 <main+0x179>
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)
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
cmpl   $0x30,-0x48(%rbp)
ja     153b <main+0x3ab>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    152d <main+0x39d>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    151a <main+0x38a>
movb   $0x0,-0x41(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x50(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xc6d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xc60(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x58(%rbp)
mov    -0x4c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xc33(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xc16(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x64(%rbp),%xmm0
movss  -0x64(%rbp),%xmm2
movss  -0x68(%rbp),%xmm1
mulss  -0x68(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x58(%rbp),%xmm0
movss  %xmm0,-0x64(%rbp)
movss  0xbe8(%rip),%xmm0
mulss  -0x60(%rbp),%xmm0
movss  -0x68(%rbp),%xmm2
movss  -0x5c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x68(%rbp)
movss  -0x64(%rbp),%xmm0
movss  -0x64(%rbp),%xmm2
movss  -0x68(%rbp),%xmm1
mulss  -0x68(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xba4(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1492 <main+0x302>
jmp    14ab <main+0x31b>
jmp    1497 <main+0x307>
mov    -0x41(%rbp),%al
add    $0x1,%al
mov    %al,-0x41(%rbp)
movzbl %al,%eax
cmp    -0x48(%rbp),%eax
jb     13ff <main+0x26f>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jae    1507 <main+0x377>
movzbl -0x41(%rbp),%eax
imul   $0xff,%eax,%eax
xor    %edx,%edx
divl   -0x48(%rbp)
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x4c(%rbp),%ecx
imul   -0x30(%rbp),%ecx
imul   -0x28(%rbp),%ecx
shr    $0x3,%ecx
mov    -0x20(%rbp),%esi
add    -0x50(%rbp),%esi
imul   -0x28(%rbp),%esi
shr    $0x3,%esi
add    %esi,%ecx
add    -0x54(%rbp),%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    14b2 <main+0x322>
jmp    150c <main+0x37c>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    137d <main+0x1ed>
jmp    151f <main+0x38f>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    136a <main+0x1da>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1359 <main+0x1c9>
lea    -0x80(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x80(%rbp),%eax
sub    -0x78(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x7c(%rbp),%eax
sub    -0x74(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xa9c(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x6c(%rbp)
lea    0xae0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xaed(%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    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe6f(%rip),%rdi
call   1030 <getenv@plt>
mov    0x2e1f(%rip),%rcx
mov    (%rcx),%esi
test   %rax,%rax
je     11cd <main+0x2d>
mov    %rax,%rdi
jmp    11d4 <main+0x34>
lea    0xe5c(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%ebx
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1080 <ioctl@plt>
lea    0xe42(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     120e <main+0x6e>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,%r13d
jmp    1213 <main+0x73>
mov    0x8(%rsp),%r13d
lea    0xe25(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1231 <main+0x91>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,%r12d
jmp    1236 <main+0x96>
mov    0xc(%rsp),%r12d
lea    0xe09(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebp,%ebp
mov    $0x0,%r15d
test   %rax,%rax
je     125a <main+0xba>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,%r15d
lea    0xdea(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1275 <main+0xd5>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%eax
imul   0x8(%rsp),%eax
imul   0x10(%rsp),%eax
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x3,%ecx
movslq %ecx,%rsi
mov    0x2d38(%rip),%rax
mov    (%rax),%edx
mov    0x2d4f(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %rsi,0x30(%rsp)
mov    %ebx,0x1c(%rsp)
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%r14
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
cvtsi2sd %r13d,%xmm13
cvtsi2sd %r12d,%xmm8
mov    $0x1,%ecx
movsd  0xd20(%rip),%xmm12
movsd  0xd1f(%rip),%xmm10
movsd  0xd1e(%rip),%xmm11
movss  0xd26(%rip),%xmm5
mov    %rbp,%r9
jmp    130c <main+0x16c>
nop
add    $0x1,%ecx
cmp    $0x31,%ecx
je     145b <main+0x2bb>
test   %r12d,%r12d
je     1300 <main+0x160>
xor    %r8d,%r8d
xorpd  %xmm9,%xmm9
jmp    132e <main+0x18e>
nopl   0x0(%rax,%rax,1)
addsd  %xmm12,%xmm9
add    $0x1,%r8d
cmp    %r12d,%r8d
je     1300 <main+0x160>
test   %r13d,%r13d
je     1320 <main+0x180>
movapd %xmm9,%xmm1
addsd  %xmm9,%xmm1
divsd  %xmm8,%xmm1
movapd %xmm12,%xmm3
subsd  %xmm1,%xmm3
cvtsd2ss %xmm3,%xmm7
lea    (%r8,%r9,1),%edi
xor    %esi,%esi
xorpd  %xmm1,%xmm1
jmp    13df <main+0x23f>
xchg   %ax,%ax
movzbl %al,%edx
mov    %edx,%eax
shl    $0x8,%eax
sub    %edx,%eax
xor    %edx,%edx
div    %ecx
lea    (%rsi,%r15,1),%edx
mov    0x8(%rsp),%ebp
imul   %edi,%ebp
mov    0x10(%rsp),%ebx
imul   %ebx,%ebp
shr    $0x3,%ebp
imul   %edx,%ebx
shr    $0x3,%ebx
add    %rbx,%rbp
mov    %al,(%r14,%rbp,1)
mov    0x8(%rsp),%ebp
imul   %edi,%ebp
mov    0x10(%rsp),%ebx
imul   %ebx,%ebp
shr    $0x3,%ebp
imul   %edx,%ebx
shr    $0x3,%ebx
add    %rbx,%rbp
mov    %al,0x1(%r14,%rbp,1)
mov    0x8(%rsp),%ebp
imul   %edi,%ebp
mov    0x10(%rsp),%ebx
imul   %ebx,%ebp
shr    $0x3,%ebp
imul   %edx,%ebx
shr    $0x3,%ebx
add    %rbx,%rbp
mov    %al,0x2(%r14,%rbp,1)
addsd  %xmm12,%xmm1
add    $0x1,%esi
cmp    %r13d,%esi
je     1320 <main+0x180>
movapd %xmm1,%xmm3
mulsd  %xmm10,%xmm3
divsd  %xmm13,%xmm3
addsd  %xmm11,%xmm3
xorps  %xmm6,%xmm6
cvtsd2ss %xmm3,%xmm6
xorps  %xmm3,%xmm3
xor    %eax,%eax
xorps  %xmm4,%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movaps %xmm3,%xmm2
movaps %xmm4,%xmm0
mulss  %xmm4,%xmm0
mulss  %xmm3,%xmm3
subss  %xmm0,%xmm3
addss  %xmm6,%xmm3
addss  %xmm2,%xmm2
mulss  %xmm2,%xmm4
addss  %xmm7,%xmm4
movaps %xmm4,%xmm0
mulss  %xmm4,%xmm0
movaps %xmm3,%xmm2
mulss  %xmm3,%xmm2
addss  %xmm0,%xmm2
ucomiss %xmm5,%xmm2
ja     1360 <main+0x1c0>
add    $0x1,%eax
cmp    %eax,%ecx
jne    1410 <main+0x270>
mov    %ecx,%eax
jmp    1360 <main+0x1c0>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    0x20(%rsp),%eax
mov    0x24(%rsp),%ecx
sub    0x28(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
sub    0x2c(%rsp),%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  0xb8b(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x18(%rsp)
lea    0xbd5(%rip),%rdi
call   1040 <puts@plt>
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xb95(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r14,%rdi
mov    0x30(%rsp),%rsi
call   10a0 <munmap@plt>
mov    0x1c(%rsp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x38,%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 = [36 x i8] c"Mandelbrot frame buffer test bench\0A\00"
@.str.7 = [42 x i8] c"Benchmarking 48 iterations: %.2f seconds\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 i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca %struct.timeval
%26 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %15
%27 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %33
29: ; preds = %2
%30 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @O_RDWR
%32 = call i32 @open(i8* %30, i32 %31)
br label %36
33: ; preds = %2
%34 = load i32, i32* @O_RDWR
%35 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %29
%37 = phi i32 [ %32, %29 ], [ %35, %33 ]
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = load i32, i32* @FBIOGET_VSCREENINFO
%40 = call i32 @ioctl(i32 %38, i32 %39, %struct.fb_var_screeninfo* %11)
%41 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %36
%44 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %7
br label %49
46: ; preds = %36
%47 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%48 = load i32, i32* %47
store i32 %48, i32* %7
br label %49
49: ; preds = %46, %43
%50 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @atoi(i8* %53)
store i32 %54, i32* %8
br label %58
55: ; preds = %49
%56 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%57 = load i32, i32* %56
store i32 %57, i32* %8
br label %58
58: ; preds = %55, %52
%59 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%63 = call i32 @atoi(i8* %62)
store i32 %63, i32* %9
br label %65
64: ; preds = %58
store i32 0, i32* %9
br label %65
65: ; preds = %64, %61
%66 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%70 = call i32 @atoi(i8* %69)
store i32 %70, i32* %10
br label %72
71: ; preds = %65
store i32 0, i32* %10
br label %72
72: ; preds = %71, %68
%73 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%74 = load i32, i32* %73
%75 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%76 = load i32, i32* %75
%77 = mul nsw i32 %74, %76
%78 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%79 = load i32, i32* %78
%80 = mul nsw i32 %77, %79
%81 = sdiv i32 %80, 8
%82 = sext i32 %81 to i64
store i64 %82, i64* %12
%83 = load i64, i64* %12
%84 = load i32, i32* @PROT_WRITE
%85 = load i32, i32* @MAP_SHARED
%86 = load i32, i32* %6
%87 = call i8* @mmap(i32* null, i64 %83, i32 %84, i32 %85, i32 %86, i32 0)
store i8* %87, i8** %13
%88 = call i32 @gettimeofday(%struct.timeval* %25, i32* null)
br label %89
89: ; preds = %195, %72
%90 = load i32, i32* %15
%91 = icmp ule i32 %90, 48
br i1 %91, label %92, label %198
92: ; preds = %89
store i32 0, i32* %16
br label %93
93: ; preds = %192, %92
%94 = load i32, i32* %16
%95 = load i32, i32* %8
%96 = icmp ult i32 %94, %95
br i1 %96, label %97, label %195
97: ; preds = %93
store i32 0, i32* %17
br label %98
98: ; preds = %188, %97
%99 = load i32, i32* %17
%100 = load i32, i32* %7
%101 = icmp ult i32 %99, %100
br i1 %101, label %102, label %191
102: ; preds = %98
store i8 0, i8* %14
store float 0.000000e+00, float* %23
store float 0.000000e+00, float* %22
%103 = load i32, i32* %17
%104 = uitofp i32 %103 to double
%105 = fmul double 3.000000e+00, %104
%106 = load i32, i32* %7
%107 = sitofp i32 %106 to double
%108 = fdiv double %105, %107
%109 = fsub double %108, 2.000000e+00
%110 = fptrunc double %109 to float
store float %110, float* %19
%111 = load i32, i32* %16
%112 = uitofp i32 %111 to double
%113 = fmul double 2.000000e+00, %112
%114 = load i32, i32* %8
%115 = sitofp i32 %114 to double
%116 = fdiv double %113, %115
%117 = fsub double 1.000000e+00, %116
%118 = fptrunc double %117 to float
store float %118, float* %20
br label %119
119: ; preds = %144, %102
%120 = load float, float* %22
store float %120, float* %21
%121 = load float, float* %22
%122 = load float, float* %22
%123 = load float, float* %23
%124 = load float, float* %23
%125 = fmul float %123, %124
%126 = fneg float %125
%127 = call float @llvm.fmuladd.f32(float %121, float %122, float %126)
%128 = load float, float* %19
%129 = fadd float %127, %128
store float %129, float* %22
%130 = load float, float* %21
%131 = fmul float 2.000000e+00, %130
%132 = load float, float* %23
%133 = load float, float* %20
%134 = call float @llvm.fmuladd.f32(float %131, float %132, float %133)
store float %134, float* %23
%135 = load float, float* %22
%136 = load float, float* %22
%137 = load float, float* %23
%138 = load float, float* %23
%139 = fmul float %137, %138
%140 = call float @llvm.fmuladd.f32(float %135, float %136, float %139)
%141 = fcmp ogt float %140, 4.000000e+00
br i1 %141, label %142, label %143
142: ; preds = %119
br label %150
143: ; preds = %119
br label %144
144: ; preds = %143
%145 = load i8, i8* %14
%146 = add i8 %145, 1
store i8 %146, i8* %14
%147 = zext i8 %146 to i32
%148 = load i32, i32* %15
%149 = icmp ult i32 %147, %148
br i1 %149, label %119, label %150
150: ; preds = %144, %142
store i32 0, i32* %18
br label %151
151: ; preds = %184, %150
%152 = load i32, i32* %18
%153 = icmp ult i32 %152, 3
br i1 %153, label %154, label %187
154: ; preds = %151
%155 = load i8, i8* %14
%156 = zext i8 %155 to i32
%157 = mul nsw i32 %156, 255
%158 = load i32, i32* %15
%159 = udiv i32 %157, %158
%160 = trunc i32 %159 to i8
%161 = load i8*, i8** %13
%162 = load i32, i32* %10
%163 = load i32, i32* %16
%164 = add i32 %162, %163
%165 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%166 = load i32, i32* %165
%167 = mul i32 %164, %166
%168 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%169 = load i32, i32* %168
%170 = mul i32 %167, %169
%171 = udiv i32 %170, 8
%172 = load i32, i32* %9
%173 = load i32, i32* %17
%174 = add i32 %172, %173
%175 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%176 = load i32, i32* %175
%177 = mul i32 %174, %176
%178 = udiv i32 %177, 8
%179 = add i32 %171, %178
%180 = load i32, i32* %18
%181 = add i32 %179, %180
%182 = zext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %161, i64 %182
store i8 %160, i8* %183
br label %184
184: ; preds = %154
%185 = load i32, i32* %18
%186 = add i32 %185, 1
store i32 %186, i32* %18
br label %151
187: ; preds = %151
br label %188
188: ; preds = %187
%189 = load i32, i32* %17
%190 = add i32 %189, 1
store i32 %190, i32* %17
br label %98
191: ; preds = %98
br label %192
192: ; preds = %191
%193 = load i32, i32* %16
%194 = add i32 %193, 1
store i32 %194, i32* %16
br label %93
195: ; preds = %93
%196 = load i32, i32* %15
%197 = add i32 %196, 1
store i32 %197, i32* %15
br label %89
198: ; preds = %89
%199 = call i32 @gettimeofday(%struct.timeval* %26, i32* null)
%200 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 0
%201 = load i32, i32* %200
%202 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
%203 = load i32, i32* %202
%204 = sub nsw i32 %201, %203
%205 = sitofp i32 %204 to double
%206 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 1
%207 = load i32, i32* %206
%208 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 1
%209 = load i32, i32* %208
%210 = sub nsw i32 %207, %209
%211 = sitofp i32 %210 to double
%212 = fdiv double %211, 1.000000e+06
%213 = fadd double %205, %212
%214 = fptrunc double %213 to float
store float %214, float* %24
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%216 = load float, float* %24
%217 = fpext float %216 to double
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), double %217)
%219 = load i8*, i8** %13
%220 = load i64, i64* %12
%221 = call i32 @munmap(i8* %219, i64 %220)
%222 = load i32, i32* %6
%223 = call i32 @close(i32 %222)
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 = [42 x i8] c"Benchmarking 48 iterations: %.2f seconds\0A\00"
@str = [35 x i8] c"Mandelbrot 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 = alloca %struct.timeval
%6 = bitcast %struct.fb_var_screeninfo* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = bitcast %struct.timeval* %5 to i8*
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
%11 = load i32, i32* @O_RDWR
br i1 %10, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @open(i8* %9, i32 %11)
br label %16
14: ; preds = %2
%15 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %16
16: ; preds = %14, %12
%17 = phi i32 [ %13, %12 ], [ %15, %14 ]
%18 = load i32, i32* @FBIOGET_VSCREENINFO
%19 = call i32 @ioctl(i32 %17, i32 %18, %struct.fb_var_screeninfo* %3)
%20 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 @atoi(i8* %20)
br label %27
24: ; preds = %16
%25 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 0
%26 = load i32, i32* %25
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ %23, %22 ], [ %26, %24 ]
%29 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = call i32 @atoi(i8* %29)
br label %36
33: ; preds = %27
%34 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 1
%35 = load i32, i32* %34
br label %36
36: ; preds = %33, %31
%37 = phi i32 [ %32, %31 ], [ %35, %33 ]
%38 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i8* %38, null
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = call i32 @atoi(i8* %38)
br label %42
42: ; preds = %36, %40
%43 = phi i32 [ %41, %40 ], [ 0, %36 ]
%44 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp eq i8* %44, null
br i1 %45, label %48, label %46
46: ; preds = %42
%47 = call i32 @atoi(i8* %44)
br label %48
48: ; preds = %42, %46
%49 = phi i32 [ %47, %46 ], [ 0, %42 ]
%50 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 1
%53 = load i32, i32* %52
%54 = mul nsw i32 %53, %51
%55 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 2
%56 = load i32, i32* %55
%57 = mul nsw i32 %54, %56
%58 = sdiv i32 %57, 8
%59 = sext i32 %58 to i64
%60 = load i32, i32* @PROT_WRITE
%61 = load i32, i32* @MAP_SHARED
%62 = call i8* @mmap(i32* null, i64 %59, i32 %60, i32 %61, i32 %17, i32 0)
%63 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%64 = icmp eq i32 %37, 0
%65 = icmp eq i32 %28, 0
%66 = sitofp i32 %28 to double
%67 = sitofp i32 %37 to double
br label %68
68: ; preds = %48, %146
%69 = phi i32 [ 1, %48 ], [ %147, %146 ]
br i1 %64, label %146, label %70
70: ; preds = %68, %143
%71 = phi i32 [ %144, %143 ], [ 0, %68 ]
br i1 %65, label %143, label %72
72: ; preds = %70
%73 = uitofp i32 %71 to double
%74 = fmul double %73, 2.000000e+00
%75 = fdiv double %74, %67
%76 = fsub double 1.000000e+00, %75
%77 = fptrunc double %76 to float
%78 = add i32 %71, %49
br label %79
79: ; preds = %72, %102
%80 = phi i32 [ 0, %72 ], [ %141, %102 ]
%81 = uitofp i32 %80 to double
%82 = fmul double %81, 3.000000e+00
%83 = fdiv double %82, %66
%84 = fadd double %83, -2.000000e+00
%85 = fptrunc double %84 to float
br label %86
86: ; preds = %99, %79
%87 = phi i32 [ %100, %99 ], [ 0, %79 ]
%88 = phi float [ %93, %99 ], [ 0.000000e+00, %79 ]
%89 = phi float [ %95, %99 ], [ 0.000000e+00, %79 ]
%90 = fneg float %89
%91 = fmul float %89, %90
%92 = call float @llvm.fmuladd.f32(float %88, float %88, float %91)
%93 = fadd float %92, %85
%94 = fmul float %88, 2.000000e+00
%95 = call float @llvm.fmuladd.f32(float %94, float %89, float %77)
%96 = fmul float %95, %95
%97 = call float @llvm.fmuladd.f32(float %93, float %93, float %96)
%98 = fcmp ogt float %97, 4.000000e+00
br i1 %98, label %102, label %99
99: ; preds = %86
%100 = add nuw nsw i32 %87, 1
%101 = icmp eq i32 %100, %69
br i1 %101, label %102, label %86
102: ; preds = %86, %99
%103 = phi i32 [ %87, %86 ], [ %69, %99 ]
%104 = and i32 %103, 255
%105 = mul nuw nsw i32 %104, 255
%106 = udiv i32 %105, %69
%107 = trunc i32 %106 to i8
%108 = add i32 %80, %43
%109 = load i32, i32* %50
%110 = mul i32 %109, %78
%111 = load i32, i32* %55
%112 = mul i32 %110, %111
%113 = lshr i32 %112, 3
%114 = mul i32 %111, %108
%115 = lshr i32 %114, 3
%116 = add nuw nsw i32 %115, %113
%117 = zext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %62, i64 %117
store i8 %107, i8* %118
%119 = load i32, i32* %50
%120 = mul i32 %119, %78
%121 = load i32, i32* %55
%122 = mul i32 %120, %121
%123 = lshr i32 %122, 3
%124 = mul i32 %121, %108
%125 = lshr i32 %124, 3
%126 = add nuw nsw i32 %125, 1
%127 = add nuw nsw i32 %126, %123
%128 = zext i32 %127 to i64
%129 = getelementptr inbounds i8, i8* %62, i64 %128
store i8 %107, i8* %129
%130 = load i32, i32* %50
%131 = mul i32 %130, %78
%132 = load i32, i32* %55
%133 = mul i32 %131, %132
%134 = lshr i32 %133, 3
%135 = mul i32 %132, %108
%136 = lshr i32 %135, 3
%137 = add nuw nsw i32 %136, 2
%138 = add nuw nsw i32 %137, %134
%139 = zext i32 %138 to i64
%140 = getelementptr inbounds i8, i8* %62, i64 %139
store i8 %107, i8* %140
%141 = add nuw i32 %80, 1
%142 = icmp eq i32 %141, %28
br i1 %142, label %143, label %79
143: ; preds = %102, %70
%144 = add nuw i32 %71, 1
%145 = icmp eq i32 %144, %37
br i1 %145, label %146, label %70
146: ; preds = %143, %68
%147 = add nuw nsw i32 %69, 1
%148 = icmp eq i32 %147, 49
br i1 %148, label %149, label %68
149: ; preds = %146
%150 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%151 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%152 = load i32, i32* %151
%153 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%154 = load i32, i32* %153
%155 = sub nsw i32 %152, %154
%156 = sitofp i32 %155 to double
%157 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%158 = load i32, i32* %157
%159 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%160 = load i32, i32* %159
%161 = sub nsw i32 %158, %160
%162 = sitofp i32 %161 to double
%163 = fdiv double %162, 1.000000e+06
%164 = fadd double %163, %156
%165 = fptrunc double %164 to float
%166 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%167 = fpext float %165 to double
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), double %167)
%169 = call i32 @munmap(i8* %62, i64 %59)
%170 = call i32 @close(i32 %17)
ret i32 0
}