#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ CloseXWindows();
int /*<<< orphan*/ SetupXWindows(int, int, int, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ShowLine(unsigned char *, int, int);
int atoi(char *);
double diffmsec(struct timeval, struct timeval);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
double sqrt(double);
int main(int argc, char **argv) {
  double init_a = -2.125, init_b = -1.5, range = 3.0;
  int j, i, k;
  double step, im, a, b, a2, b2, cr;
  unsigned char *M;
  int dim = 800, niter = 1024;
  struct timeval t1, t2;
  int r, retries = 1;
  double avg = 0, var, *runs;
  if (argc < 3) {
    printf("Usage: mandel_seq size niterations retries\n\n\n");
  } else {
    dim = atoi(argv[1]);
    niter = atoi(argv[2]);
    step = range / ((double)dim);
    retries = atoi(argv[3]);
  }
  runs = (double *)malloc(retries * sizeof(double));
  M = (unsigned char *)malloc(dim);
  printf("Mandebroot set from (%g+I %g) to (%g+I %g)\n", init_a, init_b,
         init_a + range, init_b + range);
  printf("resolution %d pixel, Max. n. of iterations %d\n", dim * dim, 1024);
  step = range / ((double)dim);
  SetupXWindows(dim, dim, 1, NULL, "Sequential Mandelbroot");
  for (r = 0; r < retries; r++) {
    gettimeofday(&t1, NULL);
    for (i = 0; i < dim; i++) {
      im = init_b + (step * i);
      for (j = 0; j < dim; j++) {
        a = cr = init_a + step * j;
        b = im;
        k = 0;
        for (k = 0; k < niter; k++) {
          a2 = a * a;
          b2 = b * b;
          if ((a2 + b2) > 4.0)
            break;
          b = 2 * a * b + im;
          a = a2 - b2 + cr;
        }
        M[j] = (unsigned char)255 - ((k * 255 / niter));
      }
      ShowLine(M, dim, i);
    }
    gettimeofday(&t2, NULL);
    avg += runs[r] = diffmsec(t2, t1);
    printf("Run [%d] DONE, time= %f (ms)\n", r, runs[r]);
  }
  avg = avg / (double)retries;
  var = 0;
  for (r = 0; r < retries; r++) {
    var += (runs[r] - avg) * (runs[r] - avg);
  }
  var /= retries;
  printf("Average on %d experiments = %f (ms) Std. Dev. %f\n\nPress a key\n",
         retries, avg, sqrt(avg));
  getchar();
  CloseXWindows();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xe4f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe3a(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe25(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x320,-0x7c(%rbp)
movl   $0x400,-0x80(%rbp)
movl   $0x1,-0x98(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
cmpl   $0x3,-0x8(%rbp)
jge    1220 <main+0x80>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1266 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x80(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x7c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x98(%rbp)
movslq -0x98(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0xb0(%rbp)
mov    -0x7c(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
addsd  -0x28(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
addsd  -0x28(%rbp),%xmm3
lea    0xda6(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    -0x7c(%rbp),%esi
imul   -0x7c(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x400,%edx
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x7c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x7c(%rbp),%edi
mov    -0x7c(%rbp),%esi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xdb7(%rip),%r8
call   1070 <SetupXWindows@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
jge    1502 <main+0x362>
lea    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    1483 <main+0x2e3>
movsd  -0x20(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    1466 <main+0x2c6>
movsd  -0x18(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x80(%rbp),%eax
jge    1437 <main+0x297>
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  0xc36(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13f1 <main+0x251>
jmp    1437 <main+0x297>
movsd  0xc27(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13a6 <main+0x206>
imul   $0xff,-0x34(%rbp),%eax
cltd
idivl  -0x80(%rbp)
mov    %eax,%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,%dl
mov    -0x78(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1361 <main+0x1c1>
mov    -0x78(%rbp),%rdi
mov    -0x7c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1040 <ShowLine@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1332 <main+0x192>
lea    -0x90(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x90(%rbp),%edi
mov    -0x88(%rbp),%esi
call   1030 <diffmsec@plt>
mov    -0xb0(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
addsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x94(%rbp),%esi
mov    -0xb0(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xbe1(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1309 <main+0x169>
movsd  -0xa0(%rbp),%xmm0
ff
cvtsi2sdl -0x98(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
jge    15a7 <main+0x407>
mov    -0xb0(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0xa0(%rbp),%xmm0
ff
mov    -0xb0(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0xa0(%rbp),%xmm2
ff
movsd  -0xa8(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1533 <main+0x393>
cvtsi2sdl -0x98(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x98(%rbp),%eax
mov    %eax,-0xbc(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
call   10c0 <sqrt@plt>
mov    -0xbc(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
lea    0xae2(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    $0x0,%al
call   10a0 <CloseXWindows@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jg     11e2 <main+0x32>
lea    0xf45(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
mov    $0x400,%ebx
mov    $0x320,%r12d
jmp    1208 <main+0x58>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r12d
mov    0x10(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
mov    0x18(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r14,8),%edi
call   10a0 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    %r12d,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbp
lea    0xe14(%rip),%rdi
movsd  0xdcc(%rip),%xmm0
movsd  0xdcc(%rip),%xmm1
movsd  0xdcc(%rip),%xmm2
movsd  0xdcc(%rip),%xmm3
mov    $0x4,%al
call   1060 <printf@plt>
mov    %r12d,%esi
imul   %r12d,%esi
lea    0xe0b(%rip),%rdi
mov    $0x400,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe27(%rip),%r8
mov    %r12d,%edi
mov    %r12d,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <SetupXWindows@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14,0x20(%rsp)
test   %r14d,%r14d
jle    142d <main+0x27d>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  0xd72(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rsp)
mov    0x20(%rsp),%eax
mov    %rax,0x28(%rsp)
mov    %r12d,%r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %r13d,%r13d
jmp    1334 <main+0x184>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    0x10(%rsp),%edi
mov    0x18(%rsp),%esi
call   1030 <diffmsec@plt>
mov    0x30(%rsp),%rax
movsd  %xmm0,(%rax,%r13,8)
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xd97(%rip),%rdi
mov    %r13d,%esi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%r13
cmp    0x28(%rsp),%r13
je     142d <main+0x27d>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
test   %r12d,%r12d
jle    12e0 <main+0x130>
xor    %r14d,%r14d
xorpd  %xmm1,%xmm1
jmp    1379 <main+0x1c9>
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1050 <ShowLine@plt>
movsd  0x40(%rsp),%xmm1
addsd  0xcc4(%rip),%xmm1
add    $0x1,%r14d
cmp    %r12d,%r14d
je     12e0 <main+0x130>
movsd  0x38(%rsp),%xmm8
movapd %xmm8,%xmm0
movsd  %xmm1,0x40(%rsp)
mulsd  %xmm1,%xmm0
addsd  0xc71(%rip),%xmm0
xor    %ecx,%ecx
movsd  0xc5e(%rip),%xmm9
movsd  0xc7e(%rip),%xmm7
jmp    13c9 <main+0x219>
nopl   0x0(%rax)
mov    %edx,%eax
shl    $0x8,%eax
sub    %edx,%eax
cltd
idiv   %ebx
not    %al
mov    %al,0x0(%rbp,%rcx,1)
add    $0x1,%rcx
cmp    %r15,%rcx
je     1350 <main+0x1a0>
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
mulsd  %xmm8,%xmm1
addsd  %xmm9,%xmm1
xor    %edx,%edx
test   %ebx,%ebx
jle    13b0 <main+0x200>
movapd %xmm1,%xmm4
movapd %xmm0,%xmm2
movapd %xmm1,%xmm3
nopl   0x0(%rax)
mulsd  %xmm3,%xmm3
movapd %xmm2,%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm5,%xmm6
addsd  %xmm3,%xmm6
ucomisd %xmm7,%xmm6
ja     13b0 <main+0x200>
addsd  %xmm4,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm0,%xmm2
subsd  %xmm5,%xmm3
addsd  %xmm1,%xmm3
add    $0x1,%edx
movapd %xmm3,%xmm4
cmp    %edx,%ebx
jne    13f0 <main+0x240>
mov    %ebx,%edx
jmp    13b0 <main+0x200>
mov    0x20(%rsp),%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ucomisd 0xbe9(%rip),%xmm1
jb     145a <main+0x2aa>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    1475 <main+0x2c5>
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   10d0 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
lea    0xc54(%rip),%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
xor    %eax,%eax
call   10b0 <CloseXWindows@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [46 x i8] c"Usage: mandel_seq size niterations retries\0A\0A\0A\00"
@.str.1 = [44 x i8] c"Mandebroot set from (%g+I %g) to (%g+I %g)\0A\00"
@.str.2 = [47 x i8] c"resolution %d pixel, Max. n. of iterations %d\0A\00"
@.str.3 = [23 x i8] c"Sequential Mandelbroot\00"
@.str.4 = [30 x i8] c"Run [%d] DONE, time= %f (ms)\0A\00"
@.str.5 = [63 x i8] c"Average on %d experiments = %f (ms) Std. Dev. %f\0A\0APress a key\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca %struct.timeval
%23 = alloca %struct.timeval
%24 = alloca i32
%25 = alloca i32
%26 = alloca double
%27 = alloca double
%28 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double -2.125000e+00, double* %6
store double -1.500000e+00, double* %7
store double 3.000000e+00, double* %8
store i32 800, i32* %20
store i32 1024, i32* %21
store i32 1, i32* %25
store double 0.000000e+00, double* %26
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %50
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %20
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %21
%42 = load double, double* %8
%43 = load i32, i32* %20
%44 = sitofp i32 %43 to double
%45 = fdiv double %42, %44
store double %45, double* %12
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %25
br label %50
50: ; preds = %33, %31
%51 = load i32, i32* %25
%52 = sext i32 %51 to i64
%53 = mul i64 %52, 8
%54 = trunc i64 %53 to i32
%55 = call i64 @malloc(i32 %54)
%56 = inttoptr i64 %55 to double*
store double* %56, double** %28
%57 = load i32, i32* %20
%58 = call i64 @malloc(i32 %57)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %19
%60 = load double, double* %6
%61 = load double, double* %7
%62 = load double, double* %6
%63 = load double, double* %8
%64 = fadd double %62, %63
%65 = load double, double* %7
%66 = load double, double* %8
%67 = fadd double %65, %66
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %60, double %61, double %64, double %67)
%69 = load i32, i32* %20
%70 = load i32, i32* %20
%71 = mul nsw i32 %69, %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %71, i32 1024)
%73 = load double, double* %8
%74 = load i32, i32* %20
%75 = sitofp i32 %74 to double
%76 = fdiv double %73, %75
store double %76, double* %12
%77 = load i32, i32* %20
%78 = load i32, i32* %20
%79 = call i32 @SetupXWindows(i32 %77, i32 %78, i32 1, i32* null, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %24
br label %80
80: ; preds = %179, %50
%81 = load i32, i32* %24
%82 = load i32, i32* %25
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %182
84: ; preds = %80
%85 = call i32 @gettimeofday(%struct.timeval* %22, i32* null)
store i32 0, i32* %10
br label %86
86: ; preds = %156, %84
%87 = load i32, i32* %10
%88 = load i32, i32* %20
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %159
90: ; preds = %86
%91 = load double, double* %7
%92 = load double, double* %12
%93 = load i32, i32* %10
%94 = sitofp i32 %93 to double
%95 = call double @llvm.fmuladd.f64(double %92, double %94, double %91)
store double %95, double* %13
store i32 0, i32* %9
br label %96
96: ; preds = %148, %90
%97 = load i32, i32* %9
%98 = load i32, i32* %20
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %151
100: ; preds = %96
%101 = load double, double* %6
%102 = load double, double* %12
%103 = load i32, i32* %9
%104 = sitofp i32 %103 to double
%105 = call double @llvm.fmuladd.f64(double %102, double %104, double %101)
store double %105, double* %18
store double %105, double* %14
%106 = load double, double* %13
store double %106, double* %15
store i32 0, i32* %11
store i32 0, i32* %11
br label %107
107: ; preds = %134, %100
%108 = load i32, i32* %11
%109 = load i32, i32* %21
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %137
111: ; preds = %107
%112 = load double, double* %14
%113 = load double, double* %14
%114 = fmul double %112, %113
store double %114, double* %16
%115 = load double, double* %15
%116 = load double, double* %15
%117 = fmul double %115, %116
store double %117, double* %17
%118 = load double, double* %16
%119 = load double, double* %17
%120 = fadd double %118, %119
%121 = fcmp ogt double %120, 4.000000e+00
br i1 %121, label %122, label %123
122: ; preds = %111
br label %137
123: ; preds = %111
%124 = load double, double* %14
%125 = fmul double 2.000000e+00, %124
%126 = load double, double* %15
%127 = load double, double* %13
%128 = call double @llvm.fmuladd.f64(double %125, double %126, double %127)
store double %128, double* %15
%129 = load double, double* %16
%130 = load double, double* %17
%131 = fsub double %129, %130
%132 = load double, double* %18
%133 = fadd double %131, %132
store double %133, double* %14
br label %134
134: ; preds = %123
%135 = load i32, i32* %11
%136 = add nsw i32 %135, 1
store i32 %136, i32* %11
br label %107
137: ; preds = %122, %107
%138 = load i32, i32* %11
%139 = mul nsw i32 %138, 255
%140 = load i32, i32* %21
%141 = sdiv i32 %139, %140
%142 = sub nsw i32 255, %141
%143 = trunc i32 %142 to i8
%144 = load i8*, i8** %19
%145 = load i32, i32* %9
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds i8, i8* %144, i64 %146
store i8 %143, i8* %147
br label %148
148: ; preds = %137
%149 = load i32, i32* %9
%150 = add nsw i32 %149, 1
store i32 %150, i32* %9
br label %96
151: ; preds = %96
%152 = load i8*, i8** %19
%153 = load i32, i32* %20
%154 = load i32, i32* %10
%155 = call i32 @ShowLine(i8* %152, i32 %153, i32 %154)
br label %156
156: ; preds = %151
%157 = load i32, i32* %10
%158 = add nsw i32 %157, 1
store i32 %158, i32* %10
br label %86
159: ; preds = %86
%160 = call i32 @gettimeofday(%struct.timeval* %23, i32* null)
%161 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
%162 = load i32, i32* %161
%163 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 0
%164 = load i32, i32* %163
%165 = call double @diffmsec(i32 %162, i32 %164)
%166 = load double*, double** %28
%167 = load i32, i32* %24
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds double, double* %166, i64 %168
store double %165, double* %169
%170 = load double, double* %26
%171 = fadd double %170, %165
store double %171, double* %26
%172 = load i32, i32* %24
%173 = load double*, double** %28
%174 = load i32, i32* %24
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds double, double* %173, i64 %175
%177 = load double, double* %176
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %172, double %177)
br label %179
179: ; preds = %159
%180 = load i32, i32* %24
%181 = add nsw i32 %180, 1
store i32 %181, i32* %24
br label %80
182: ; preds = %80
%183 = load double, double* %26
%184 = load i32, i32* %25
%185 = sitofp i32 %184 to double
%186 = fdiv double %183, %185
store double %186, double* %26
store double 0.000000e+00, double* %27
store i32 0, i32* %24
br label %187
187: ; preds = %208, %182
%188 = load i32, i32* %24
%189 = load i32, i32* %25
%190 = icmp slt i32 %188, %189
br i1 %190, label %191, label %211
191: ; preds = %187
%192 = load double*, double** %28
%193 = load i32, i32* %24
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %192, i64 %194
%196 = load double, double* %195
%197 = load double, double* %26
%198 = fsub double %196, %197
%199 = load double*, double** %28
%200 = load i32, i32* %24
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds double, double* %199, i64 %201
%203 = load double, double* %202
%204 = load double, double* %26
%205 = fsub double %203, %204
%206 = load double, double* %27
%207 = call double @llvm.fmuladd.f64(double %198, double %205, double %206)
store double %207, double* %27
br label %208
208: ; preds = %191
%209 = load i32, i32* %24
%210 = add nsw i32 %209, 1
store i32 %210, i32* %24
br label %187
211: ; preds = %187
%212 = load i32, i32* %25
%213 = sitofp i32 %212 to double
%214 = load double, double* %27
%215 = fdiv double %214, %213
store double %215, double* %27
%216 = load i32, i32* %25
%217 = load double, double* %26
%218 = load double, double* %26
%219 = call double @sqrt(double %218)
%220 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0), i32 %216, double %217, double %219)
%221 = call i32 (...) @getchar()
%222 = call i32 (...) @CloseXWindows()
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str.1 = [44 x i8] c"Mandebroot set from (%g+I %g) to (%g+I %g)\0A\00"
@.str.2 = [47 x i8] c"resolution %d pixel, Max. n. of iterations %d\0A\00"
@.str.3 = [23 x i8] c"Sequential Mandelbroot\00"
@.str.4 = [30 x i8] c"Run [%d] DONE, time= %f (ms)\0A\00"
@.str.5 = [63 x i8] c"Average on %d experiments = %f (ms) Std. Dev. %f\0A\0APress a key\0A\00"
@str = [45 x i8] c"Usage: mandel_seq size niterations retries\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %20
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
br label %20
20: ; preds = %10, %8
%21 = phi i32 [ 800, %8 ], [ %13, %10 ]
%22 = phi i32 [ 1024, %8 ], [ %16, %10 ]
%23 = phi i32 [ 1, %8 ], [ %19, %10 ]
%24 = shl i32 %23, 3
%25 = tail call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to double*
%27 = tail call i64 @malloc(i32 %21)
%28 = inttoptr i64 %27 to i8*
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double -2.125000e+00, double -1.500000e+00, double 8.750000e-01, double 1.500000e+00)
%30 = mul nsw i32 %21, %21
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 1024)
%32 = sitofp i32 %21 to double
%33 = fdiv double 3.000000e+00, %32
%34 = tail call i32 @SetupXWindows(i32 %21, i32 %21, i32 1, i32* null, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp sgt i32 %23, 0
br i1 %35, label %36, label %95
36: ; preds = %20
%37 = icmp sgt i32 %21, 0
%38 = icmp sgt i32 %22, 0
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%41 = zext i32 %23 to i64
%42 = zext i32 %21 to i64
br label %43
43: ; preds = %36, %84
%44 = phi i64 [ 0, %36 ], [ %93, %84 ]
%45 = phi double [ 0.000000e+00, %36 ], [ %90, %84 ]
%46 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %37, label %47, label %84
47: ; preds = %43, %80
%48 = phi i32 [ %82, %80 ], [ 0, %43 ]
%49 = sitofp i32 %48 to double
%50 = tail call double @llvm.fmuladd.f64(double %33, double %49, double -1.500000e+00)
br label %51
51: ; preds = %47, %71
%52 = phi i64 [ 0, %47 ], [ %78, %71 ]
%53 = trunc i64 %52 to i32
%54 = sitofp i32 %53 to double
%55 = tail call double @llvm.fmuladd.f64(double %33, double %54, double -2.125000e+00)
br i1 %38, label %56, label %71
56: ; preds = %51, %64
%57 = phi i32 [ %69, %64 ], [ 0, %51 ]
%58 = phi double [ %68, %64 ], [ %55, %51 ]
%59 = phi double [ %66, %64 ], [ %50, %51 ]
%60 = fmul double %58, %58
%61 = fmul double %59, %59
%62 = fadd double %61, %60
%63 = fcmp ogt double %62, 4.000000e+00
br i1 %63, label %71, label %64
64: ; preds = %56
%65 = fmul double %58, 2.000000e+00
%66 = tail call double @llvm.fmuladd.f64(double %65, double %59, double %50)
%67 = fsub double %60, %61
%68 = fadd double %55, %67
%69 = add nuw nsw i32 %57, 1
%70 = icmp eq i32 %69, %22
br i1 %70, label %71, label %56
71: ; preds = %64, %56, %51
%72 = phi i32 [ 0, %51 ], [ %57, %56 ], [ %22, %64 ]
%73 = mul nsw i32 %72, 255
%74 = sdiv i32 %73, %22
%75 = trunc i32 %74 to i8
%76 = xor i8 %75, -1
%77 = getelementptr inbounds i8, i8* %28, i64 %52
store i8 %76, i8* %77
%78 = add nuw nsw i64 %52, 1
%79 = icmp eq i64 %78, %42
br i1 %79, label %80, label %51
80: ; preds = %71
%81 = tail call i32 @ShowLine(i8* %28, i32 %21, i32 %48)
%82 = add nuw nsw i32 %48, 1
%83 = icmp eq i32 %82, %21
br i1 %83, label %84, label %47
84: ; preds = %80, %43
%85 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%86 = load i32, i32* %39
%87 = load i32, i32* %40
%88 = tail call double @diffmsec(i32 %86, i32 %87)
%89 = getelementptr inbounds double, double* %26, i64 %44
store double %88, double* %89
%90 = fadd double %45, %88
%91 = trunc i64 %44 to i32
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %91, double %88)
%93 = add nuw nsw i64 %44, 1
%94 = icmp eq i64 %93, %41
br i1 %94, label %95, label %43
95: ; preds = %84, %20
%96 = phi double [ 0.000000e+00, %20 ], [ %90, %84 ]
%97 = sitofp i32 %23 to double
%98 = fdiv double %96, %97
%99 = tail call double @sqrt(double %98)
%100 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0), i32 %23, double %98, double %99)
%101 = tail call i32 (...) @getchar()
%102 = tail call i32 (...) @CloseXWindows()
ret i32 0
}