long escape_iteration_count(double cx, double cy) {
  double zx = 0, zy = 0, zx2 = 0, zy2 = 0;
  unsigned long i = 0;
  unsigned long const iteration_limit = 256;
  while (((zx2 + zy2) < 4.0) && (i < iteration_limit)) {
    double tx, ty;
    zx2 = (zx * zx);
    zy2 = (zy * zy);
    tx = cx + (zx2 - zy2);
    ty = cy + (2 * zx * zy);
    i++;
    zx = tx;
    zy = ty;
  }
  return (i == iteration_limit) ? -1 : i;
}


x86 assembly (clang, -O0):
<escape_iteration_count>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x100,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
xor    %eax,%eax
movsd  0xeae(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x51(%rbp)
jbe    116d <escape_iteration_count+0x6d>
cmpq   $0x100,-0x38(%rbp)
setb   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    117d <escape_iteration_count+0x7d>
jmp    11fc <escape_iteration_count+0xfc>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xe48(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    113e <escape_iteration_count+0x3e>
cmpq   $0x100,-0x38(%rbp)
jne    121a <escape_iteration_count+0x11a>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x60(%rbp)
jmp    1222 <escape_iteration_count+0x122>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape_iteration_count>:
xorpd  %xmm3,%xmm3
xor    %eax,%eax
movsd  0xef2(%rip),%xmm2
xorpd  %xmm4,%xmm4
movapd %xmm3,%xmm5
cs nopw 0x0(%rax,%rax,1)
mulsd  %xmm5,%xmm5
movapd %xmm4,%xmm6
mulsd  %xmm4,%xmm6
lea    0x1(%rax),%rcx
movapd %xmm6,%xmm7
addsd  %xmm5,%xmm7
ucomisd %xmm7,%xmm2
jbe    1161 <escape_iteration_count+0x61>
subsd  %xmm6,%xmm5
addsd  %xmm0,%xmm5
addsd  %xmm3,%xmm3
mulsd  %xmm3,%xmm4
addsd  %xmm1,%xmm4
movapd %xmm5,%xmm3
cmp    $0xff,%rax
mov    %rcx,%rax
jb     1120 <escape_iteration_count+0x20>
cmp    $0x100,%rcx
mov    $0xffffffffffffffff,%rax
cmovne %rcx,%rax
ret

LLVM IR (-O0):
define i64 @escape_iteration_count(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i64
%10 = alloca i64
%11 = alloca double
%12 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store i64 0, i64* %9
store i64 256, i64* %10
br label %13
13: ; preds = %23, %2
%14 = load double, double* %7
%15 = load double, double* %8
%16 = fadd double %14, %15
%17 = fcmp olt double %16, 4.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i64, i64* %9
%20 = icmp ult i64 %19, 256
br label %21
21: ; preds = %18, %13
%22 = phi i1 [ false, %13 ], [ %20, %18 ]
br i1 %22, label %23, label %44
23: ; preds = %21
%24 = load double, double* %5
%25 = load double, double* %5
%26 = fmul double %24, %25
store double %26, double* %7
%27 = load double, double* %6
%28 = load double, double* %6
%29 = fmul double %27, %28
store double %29, double* %8
%30 = load double, double* %3
%31 = load double, double* %7
%32 = load double, double* %8
%33 = fsub double %31, %32
%34 = fadd double %30, %33
store double %34, double* %11
%35 = load double, double* %4
%36 = load double, double* %5
%37 = fmul double 2.000000e+00, %36
%38 = load double, double* %6
%39 = call double @llvm.fmuladd.f64(double %37, double %38, double %35)
store double %39, double* %12
%40 = load i64, i64* %9
%41 = add i64 %40, 1
store i64 %41, i64* %9
%42 = load double, double* %11
store double %42, double* %5
%43 = load double, double* %12
store double %43, double* %6
br label %13
44: ; preds = %21
%45 = load i64, i64* %9
%46 = icmp eq i64 %45, 256
br i1 %46, label %47, label %48
47: ; preds = %44
br label %50
48: ; preds = %44
%49 = load i64, i64* %9
br label %50
50: ; preds = %48, %47
%51 = phi i64 [ -1, %47 ], [ %49, %48 ]
ret i64 %51
}

LLVM IR (-O2):
define i64 @escape_iteration_count(double %0, double %1) {
br label %3
3: ; preds = %2, %3
%4 = phi double [ 0.000000e+00, %2 ], [ %10, %3 ]
%5 = phi double [ 0.000000e+00, %2 ], [ %12, %3 ]
%6 = phi i64 [ 0, %2 ], [ %13, %3 ]
%7 = fmul double %4, %4
%8 = fmul double %5, %5
%9 = fsub double %7, %8
%10 = fadd double %9, %0
%11 = fmul double %4, 2.000000e+00
%12 = tail call double @llvm.fmuladd.f64(double %11, double %5, double %1)
%13 = add nuw nsw i64 %6, 1
%14 = fadd double %8, %7
%15 = fcmp olt double %14, 4.000000e+00
%16 = icmp ult i64 %6, 255
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %3, label %18
18: ; preds = %3
%19 = icmp eq i64 %13, 256
%20 = select i1 %19, i64 -1, i64 %13
ret i64 %20
}