#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 */
typedef int /*<<< orphan*/ colour;

/* Variables and functions */
int /*<<< orphan*/ write(int, char *, int);
void calcPoint(int socket, double *seed, double x, double y, int iteration) {
  char colour[3] = {iteration, iteration, iteration};
  if (iteration == 255) {
    write(socket, colour, sizeof(colour));
  } else if ((x * x + y * y) >= 4.0) {
    write(socket, colour, sizeof(colour));
  } else {
    double x_new = seed[0] + (x * x - y * y);
    double y_new = seed[1] + (2.0 * x * y);
    calcPoint(socket, seed, x_new, y_new, iteration + 1);
  }
}


x86 assembly (clang, -O0):
<calcPoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %al,-0x27(%rbp)
mov    -0x24(%rbp),%eax
mov    %al,-0x26(%rbp)
mov    -0x24(%rbp),%eax
mov    %al,-0x25(%rbp)
cmpl   $0xff,-0x24(%rbp)
jne    1171 <calcPoint+0x51>
mov    -0x4(%rbp),%edi
lea    -0x27(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
jmp    1242 <calcPoint+0x122>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11b5 <calcPoint+0x95>
mov    -0x4(%rbp),%edi
lea    -0x27(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
jmp    123d <calcPoint+0x11d>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
mulsd  -0x20(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0xdfe(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    -0x24(%rbp),%edx
add    $0x1,%edx
call   1040 <calcPoint@plt>
jmp    1242 <calcPoint+0x122>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcPoint>:
push   %rax
mov    %dl,0x5(%rsp)
mov    %dl,0x6(%rsp)
mov    %dl,0x7(%rsp)
cmp    $0xff,%edx
je     1179 <calcPoint+0x59>
movapd %xmm0,%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm0
movapd %xmm0,%xmm4
addsd  %xmm3,%xmm4
ucomisd 0xeab(%rip),%xmm4
jae    1179 <calcPoint+0x59>
subsd  %xmm3,%xmm0
addsd  (%rsi),%xmm0
addsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm2
addsd  0x8(%rsi),%xmm2
add    $0x1,%edx
movapd %xmm2,%xmm1
pop    %rax
jmp    1040 <calcPoint@plt>
lea    0x5(%rsp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @calcPoint(i32 %0, double* %1, double %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca [3 x i8]
%12 = alloca double
%13 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%15 = load i32, i32* %10
%16 = trunc i32 %15 to i8
store i8 %16, i8* %14
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = load i32, i32* %10
%19 = trunc i32 %18 to i8
store i8 %19, i8* %17
%20 = getelementptr inbounds i8, i8* %17, i64 1
%21 = load i32, i32* %10
%22 = trunc i32 %21 to i8
store i8 %22, i8* %20
%23 = load i32, i32* %10
%24 = icmp eq i32 %23, 255
br i1 %24, label %25, label %29
25: ; preds = %5
%26 = load i32, i32* %6
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%28 = call i32 @write(i32 %26, i8* %27, i32 3)
br label %67
29: ; preds = %5
%30 = load double, double* %8
%31 = load double, double* %8
%32 = load double, double* %9
%33 = load double, double* %9
%34 = fmul double %32, %33
%35 = call double @llvm.fmuladd.f64(double %30, double %31, double %34)
%36 = fcmp oge double %35, 4.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %29
%38 = load i32, i32* %6
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%40 = call i32 @write(i32 %38, i8* %39, i32 3)
br label %66
41: ; preds = %29
%42 = load double*, double** %7
%43 = getelementptr inbounds double, double* %42, i64 0
%44 = load double, double* %43
%45 = load double, double* %8
%46 = load double, double* %8
%47 = load double, double* %9
%48 = load double, double* %9
%49 = fmul double %47, %48
%50 = fneg double %49
%51 = call double @llvm.fmuladd.f64(double %45, double %46, double %50)
%52 = fadd double %44, %51
store double %52, double* %12
%53 = load double*, double** %7
%54 = getelementptr inbounds double, double* %53, i64 1
%55 = load double, double* %54
%56 = load double, double* %8
%57 = fmul double 2.000000e+00, %56
%58 = load double, double* %9
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double %55)
store double %59, double* %13
%60 = load i32, i32* %6
%61 = load double*, double** %7
%62 = load double, double* %12
%63 = load double, double* %13
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
br label %66
66: ; preds = %41, %37
br label %67
67: ; preds = %66, %25
ret void
}

LLVM IR (-O2):
define void @calcPoint(i32 %0, double* nocapture %1, double %2, double %3, i32 %4) {
%6 = alloca [3 x i8]
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%8 = trunc i32 %4 to i8
store i8 %8, i8* %7
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 1
store i8 %8, i8* %9
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 2
store i8 %8, i8* %10
%11 = icmp eq i32 %4, 255
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = call i32 @write(i32 %0, i8* %7, i32 3)
br label %30
14: ; preds = %5
%15 = fmul double %3, %3
%16 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %15)
%17 = fcmp ult double %16, 4.000000e+00
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 @write(i32 %0, i8* %7, i32 3)
br label %30
20: ; preds = %14
%21 = load double, double* %1
%22 = fneg double %15
%23 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %22)
%24 = fadd double %23, %21
%25 = getelementptr inbounds double, double* %1, i64 1
%26 = load double, double* %25
%27 = fmul double %2, 2.000000e+00
%28 = tail call double @llvm.fmuladd.f64(double %27, double %3, double %26)
%29 = add nsw i32 %4, 1
tail call void @calcPoint(i32 %0, double* %1, double %24, double %28, i32 %29)
br label %30
30: ; preds = %18, %20, %12
ret void
}