#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 */
scalar_t__ test_point_in_cardiod_or_2ndbud(float, float);
int mandelbrot_iteration(float cr, float ci, int max_iter) {
  float zi, zr, zrs, zis;
  zi = ci;
  zr = cr;
  zrs = zis = (float)0;
  int n_iter = 0;
  if (test_point_in_cardiod_or_2ndbud(zr, zi)) {
    n_iter = max_iter;
  } else {
    while (zrs + zis < (float)4 && n_iter < max_iter) {
      zrs = zr * zr;
      zis = zi * zi;
      zi = (float)2 * zr * zi + ci;
      zr = zrs - zis + cr;
      n_iter++;
    }
  }
  return n_iter;
}


x86 assembly (clang, -O0):
<mandelbrot_iteration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1030 <test_point_in_cardiod_or_2ndbud@plt>
cmp    $0x0,%rax
je     1174 <mandelbrot_iteration+0x64>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    121e <mandelbrot_iteration+0x10e>
jmp    1179 <mandelbrot_iteration+0x69>
movss  -0x18(%rbp),%xmm1
addss  -0x1c(%rbp),%xmm1
xor    %eax,%eax
movss  0xe73(%rip),%xmm0
ucomiss %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jbe    11a5 <mandelbrot_iteration+0x95>
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b5 <mandelbrot_iteration+0xa5>
jmp    1219 <mandelbrot_iteration+0x109>
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe29(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1179 <mandelbrot_iteration+0x69>
jmp    121e <mandelbrot_iteration+0x10e>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mandelbrot_iteration>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movss  %xmm0,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
call   1030 <test_point_in_cardiod_or_2ndbud@plt>
test   %rax,%rax
je     1135 <mandelbrot_iteration+0x25>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
movss  0x8(%rsp),%xmm7
movss  0xc(%rsp),%xmm6
xor    %eax,%eax
test   %ebx,%ebx
jle    112f <mandelbrot_iteration+0x1f>
movss  0xeb1(%rip),%xmm0
movaps %xmm7,%xmm3
movaps %xmm6,%xmm1
movaps %xmm7,%xmm2
nopl   0x0(%rax,%rax,1)
mulss  %xmm2,%xmm2
movaps %xmm1,%xmm4
mulss  %xmm1,%xmm4
add    $0x1,%eax
movaps %xmm4,%xmm5
addss  %xmm2,%xmm5
ucomiss %xmm5,%xmm0
jbe    112f <mandelbrot_iteration+0x1f>
addss  %xmm3,%xmm3
mulss  %xmm3,%xmm1
addss  %xmm6,%xmm1
subss  %xmm4,%xmm2
addss  %xmm7,%xmm2
movaps %xmm2,%xmm3
cmp    %ebx,%eax
jl     1160 <mandelbrot_iteration+0x50>
jmp    112f <mandelbrot_iteration+0x1f>

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

LLVM IR (-O2):
define i32 @mandelbrot_iteration(float %0, float %1, i32 %2) {
%4 = tail call i64 @test_point_in_cardiod_or_2ndbud(float %0, float %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %23
8: ; preds = %6, %8
%9 = phi i32 [ %18, %8 ], [ 0, %6 ]
%10 = phi float [ %17, %8 ], [ %0, %6 ]
%11 = phi float [ %15, %8 ], [ %1, %6 ]
%12 = fmul float %10, %10
%13 = fmul float %11, %11
%14 = fmul float %10, 2.000000e+00
%15 = tail call float @llvm.fmuladd.f32(float %14, float %11, float %1)
%16 = fsub float %12, %13
%17 = fadd float %16, %0
%18 = add nuw nsw i32 %9, 1
%19 = fadd float %13, %12
%20 = fcmp olt float %19, 4.000000e+00
%21 = icmp slt i32 %18, %2
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %8, label %23
23: ; preds = %8, %6, %3
%24 = phi i32 [ %2, %3 ], [ 0, %6 ], [ %18, %8 ]
ret i32 %24
}