#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 */

/* Variables and functions */
double displacement(double, double);
int escapeSteps(double Re, double Im) {
  double RPart = Re;
  double IPart = Im;
  double ReTemp = 0;
  double ImTemp = 0;
  int count = 0;
  int escapeLoop = 0;
  while (count <= 255 && escapeLoop == 0) {
    double displacementValue = displacement(ReTemp, ImTemp);
    if (displacementValue > 2) {
      escapeLoop = 1;
    } else {
      RPart = ReTemp;
      IPart = ImTemp;
      ReTemp = (RPart * RPart) - (IPart * IPart) + Re;
      ImTemp = (2 * RPart * IPart) + Im;
      count++;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<escapeSteps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0xff,-0x34(%rbp)
mov    %al,-0x41(%rbp)
jg     1170 <escapeSteps+0x60>
cmpl   $0x0,-0x38(%rbp)
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1180 <escapeSteps+0x70>
jmp    123a <escapeSteps+0x12a>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1030 <displacement@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b7 <escapeSteps+0xa7>
movl   $0x1,-0x38(%rbp)
jmp    1235 <escapeSteps+0x125>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdf0(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1154 <escapeSteps+0x44>
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escapeSteps>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
call   1030 <displacement@plt>
movsd  0xeb7(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1197 <escapeSteps+0x87>
lea    0x1(%rbx),%eax
ucomisd %xmm1,%xmm0
ja     1199 <escapeSteps+0x89>
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm2
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
subsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
cmp    $0xff,%ebx
mov    %eax,%ebx
jb     1130 <escapeSteps+0x20>
jmp    1199 <escapeSteps+0x89>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @escapeSteps(double %0, double %1) {
br label %3
3: ; preds = %2, %9
%4 = phi i32 [ 0, %2 ], [ %16, %9 ]
%5 = phi double [ 0.000000e+00, %2 ], [ %15, %9 ]
%6 = phi double [ 0.000000e+00, %2 ], [ %13, %9 ]
%7 = tail call double @displacement(double %6, double %5)
%8 = fcmp ogt double %7, 2.000000e+00
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = fneg double %5
%11 = fmul double %5, %10
%12 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %11)
%13 = fadd double %12, %0
%14 = fmul double %6, 2.000000e+00
%15 = tail call double @llvm.fmuladd.f64(double %14, double %5, double %1)
%16 = add nuw nsw i32 %4, 1
%17 = icmp ugt i32 %4, 254
%18 = or i1 %8, %17
br i1 %18, label %19, label %3
19: ; preds = %3, %9
%20 = phi i32 [ %16, %9 ], [ %4, %3 ]
ret i32 %20
}