#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 */
int colorOf(int);
int /*<<< orphan*/ printf(char *, ...);
double sqrt(long double);
void dot(long double r, long double i, int ic) {
  int iteration = 0;
  long double fr = 0;
  long double fi = 0;
  for (;; iteration++) {
    if (sqrt(fr * fr + fi * fi) > 2) {
      break;
    }
    long double fr_ = fr * fr - fi * fi;
    fi = fi * fr * 2 + i;
    fr = fr_ + r;
    if (iteration > ic || sqrt(fr * fr + fi * fi) < 0.0000001) {
      printf(" ");
      return;
    }
  }
  printf("\033[48;5;%dm \033[0m", colorOf(iteration));
}


x86 assembly (clang, -O0):
<dot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fstpt  -0x20(%rbp)
mov    %edi,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
fldz
fld    %st(0)
fstpt  -0x40(%rbp)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
fld    %st(0)
fldt   -0x50(%rbp)
fld    %st(0)
fmulp  %st,%st(1)
fxch   %st(1)
fmulp  %st,%st(2)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <sqrt@plt>
movsd  0xe84(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118b <dot+0x5b>
jmp    121e <dot+0xee>
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
fmul   %st,%st(0)
fxch   %st(1)
fmul   %st,%st(0)
fsubp  %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
fmulp  %st,%st(1)
fldt   -0x20(%rbp)
fxch   %st(1)
fadd   %st,%st(0)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x60(%rbp)
fldt   -0x10(%rbp)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11f8 <dot+0xc8>
fldt   -0x40(%rbp)
fld    %st(0)
fldt   -0x50(%rbp)
fld    %st(0)
fmulp  %st,%st(1)
fxch   %st(1)
fmulp  %st,%st(2)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    120b <dot+0xdb>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1236 <dot+0x106>
jmp    1210 <dot+0xe0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1158 <dot+0x28>
mov    -0x28(%rbp),%edi
call   1040 <colorOf@plt>
mov    %eax,%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dot>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %edi,%r14d
fldt   0x90(%rsp)
fstpt  0x30(%rsp)
fldt   0x80(%rsp)
fstpt  0x24(%rsp)
fldz
fld    %st(0)
fstpt  0x18(%rsp)
fstpt  (%rsp)
call   1060 <sqrt@plt>
xor    %ebx,%ebx
ucomisd 0xe85(%rip),%xmm0
fldz
fldz
ja     123b <dot+0xfb>
fstp   %st(1)
fstp   %st(0)
test   %r14d,%r14d
mov    $0xffffffff,%ebp
cmovns %r14d,%ebp
add    $0x1,%ebp
xor    %ebx,%ebx
fldt   0x18(%rsp)
fld    %st(0)
fxch   %st(1)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
fld    %st(1)
fxch   %st(2)
fmul   %st,%st(0)
fldt   0x18(%rsp)
fsubrp %st,%st(1)
fxch   %st(1)
fmulp  %st,%st(2)
fldt   0x24(%rsp)
faddp  %st,%st(1)
fxch   %st(1)
fadd   %st,%st(0)
fldt   0x30(%rsp)
faddp  %st,%st(1)
cmp    %ebx,%ebp
je     125e <dot+0x11e>
fld    %st(0)
fmul   %st(1),%st
fld    %st(2)
fmul   %st(3),%st
fld    %st(1)
fstpt  0x18(%rsp)
faddp  %st,%st(1)
fld    %st(0)
fstpt  0x3c(%rsp)
fstpt  (%rsp)
fstpt  0x54(%rsp)
fstpt  0x48(%rsp)
call   1060 <sqrt@plt>
movsd  0xe02(%rip),%xmm1
ucomisd %xmm0,%xmm1
fldz
fldz
fxch   %st(1)
ja     125e <dot+0x11e>
fstp   %st(0)
fstp   %st(0)
add    $0x1,%ebx
fldt   0x3c(%rsp)
fstpt  (%rsp)
call   1060 <sqrt@plt>
fldt   0x48(%rsp)
fldt   0x54(%rsp)
ucomisd 0xdcb(%rip),%xmm0
jbe    11b0 <dot+0x70>
fstp   %st(1)
fstp   %st(0)
mov    %ebx,%edi
call   1050 <colorOf@plt>
lea    0xdc3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>
fstp   %st(0)
fstp   %st(0)
mov    $0x20,%edi
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [16 x i8] c"\1B[48;5;%dm \1B[0m\00"
define void @dot(x86_fp80 %0, x86_fp80 %1, i32 %2) {
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca x86_fp80
%9 = alloca x86_fp80
%10 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store x86_fp80 0xK00000000000000000000, x86_fp80* %8
store x86_fp80 0xK00000000000000000000, x86_fp80* %9
br label %11
11: ; preds = %52, %3
%12 = load x86_fp80, x86_fp80* %8
%13 = load x86_fp80, x86_fp80* %8
%14 = load x86_fp80, x86_fp80* %9
%15 = load x86_fp80, x86_fp80* %9
%16 = fmul x86_fp80 %14, %15
%17 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %13, x86_fp80 %16)
%18 = call double @sqrt(x86_fp80 %17)
%19 = fcmp ogt double %18, 2.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %11
br label %55
21: ; preds = %11
%22 = load x86_fp80, x86_fp80* %8
%23 = load x86_fp80, x86_fp80* %8
%24 = load x86_fp80, x86_fp80* %9
%25 = load x86_fp80, x86_fp80* %9
%26 = fmul x86_fp80 %24, %25
%27 = fneg x86_fp80 %26
%28 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %22, x86_fp80 %23, x86_fp80 %27)
store x86_fp80 %28, x86_fp80* %10
%29 = load x86_fp80, x86_fp80* %9
%30 = load x86_fp80, x86_fp80* %8
%31 = fmul x86_fp80 %29, %30
%32 = load x86_fp80, x86_fp80* %5
%33 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %31, x86_fp80 0xK40008000000000000000, x86_fp80 %32)
store x86_fp80 %33, x86_fp80* %9
%34 = load x86_fp80, x86_fp80* %10
%35 = load x86_fp80, x86_fp80* %4
%36 = fadd x86_fp80 %34, %35
store x86_fp80 %36, x86_fp80* %8
%37 = load i32, i32* %7
%38 = load i32, i32* %6
%39 = icmp sgt i32 %37, %38
br i1 %39, label %49, label %40
40: ; preds = %21
%41 = load x86_fp80, x86_fp80* %8
%42 = load x86_fp80, x86_fp80* %8
%43 = load x86_fp80, x86_fp80* %9
%44 = load x86_fp80, x86_fp80* %9
%45 = fmul x86_fp80 %43, %44
%46 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %41, x86_fp80 %42, x86_fp80 %45)
%47 = call double @sqrt(x86_fp80 %46)
%48 = fcmp olt double %47, 0x3E7AD7F29ABCAF48
br i1 %48, label %49, label %51
49: ; preds = %40, %21
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %59
51: ; preds = %40
br label %52
52: ; preds = %51
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %11
55: ; preds = %20
%56 = load i32, i32* %7
%57 = call i32 @colorOf(i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %55, %49
ret void
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"\1B[48;5;%dm \1B[0m\00"
define void @dot(x86_fp80 %0, x86_fp80 %1, i32 %2) {
%4 = tail call double @sqrt(x86_fp80 0xK00000000000000000000)
%5 = fcmp ogt double %4, 2.000000e+00
br i1 %5, label %31, label %6
6: ; preds = %3
%7 = call i32 @llvm.smax.i32(i32 %2, i32 -1)
%8 = add i32 %7, 1
br label %9
9: ; preds = %6, %27
%10 = phi x86_fp80 [ %21, %27 ], [ 0xK00000000000000000000, %6 ]
%11 = phi i32 [ %28, %27 ], [ 0, %6 ]
%12 = phi x86_fp80 [ %18, %27 ], [ 0xK00000000000000000000, %6 ]
%13 = phi x86_fp80 [ %17, %27 ], [ 0xK00000000000000000000, %6 ]
%14 = fneg x86_fp80 %10
%15 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %12, x86_fp80 %14)
%16 = fmul x86_fp80 %13, %12
%17 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %16, x86_fp80 0xK40008000000000000000, x86_fp80 %1)
%18 = fadd x86_fp80 %15, %0
%19 = icmp eq i32 %11, %8
br i1 %19, label %25, label %20
20: ; preds = %9
%21 = fmul x86_fp80 %17, %17
%22 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 %18, x86_fp80 %21)
%23 = tail call double @sqrt(x86_fp80 %22)
%24 = fcmp olt double %23, 0x3E7AD7F29ABCAF48
br i1 %24, label %25, label %27
25: ; preds = %20, %9
%26 = tail call i32 @putchar(i32 32)
br label %35
27: ; preds = %20
%28 = add nuw i32 %11, 1
%29 = tail call double @sqrt(x86_fp80 %22)
%30 = fcmp ogt double %29, 2.000000e+00
br i1 %30, label %31, label %9
31: ; preds = %27, %3
%32 = phi i32 [ 0, %3 ], [ %28, %27 ]
%33 = tail call i32 @colorOf(i32 %32)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %25, %31
ret void
}