#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__ mandelbrot(double, double, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int main() {
  double x_max = 1, x_min = -2, y_max = 1, y_min = -1, dx = 0.05, dy = 0.05;
  int x_length = (x_max - x_min) / dx;
  for (double y = y_max; y > y_min; y -= dy) {
    for (double x = x_min; x < x_max; x += dx)
      putchar(mandelbrot(x, y, 300) == 0 ? '*' : ' ');
    puts("");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1243 <main+0x113>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    121f <main+0xef>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    $0x12c,%edi
call   1050 <mandelbrot@plt>
mov    %rax,%rdx
mov    $0x20,%eax
mov    $0x2a,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11c7 <main+0x97>
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11ad <main+0x7d>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movsd  0xed3(%rip),%xmm0
mov    $0x2a,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movsd  0xebb(%rip),%xmm1
nopl   (%rax)
movsd  %xmm1,0x8(%rsp)
movaps %xmm1,%xmm0
movsd  (%rsp),%xmm1
mov    $0x12c,%edi
call   1040 <mandelbrot@plt>
test   %rax,%rax
mov    $0x20,%edi
cmove  %ebx,%edi
call   1030 <putchar@plt>
movsd  0x8(%rsp),%xmm1
addsd  0xe8a(%rip),%xmm1
movsd  0xe72(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1150 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  (%rsp),%xmm0
addsd  0xe6d(%rip),%xmm0
ucomisd 0xe6d(%rip),%xmm0
ja     1140 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double -2.000000e+00, double* %3
store double 1.000000e+00, double* %4
store double -1.000000e+00, double* %5
store double 5.000000e-02, double* %6
store double 5.000000e-02, double* %7
%11 = load double, double* %2
%12 = load double, double* %3
%13 = fsub double %11, %12
%14 = load double, double* %6
%15 = fdiv double %13, %14
%16 = fptosi double %15 to i32
store i32 %16, i32* %8
%17 = load double, double* %4
store double %17, double* %9
br label %18
18: ; preds = %43, %0
%19 = load double, double* %9
%20 = load double, double* %5
%21 = fcmp ogt double %19, %20
br i1 %21, label %22, label %47
22: ; preds = %18
%23 = load double, double* %3
store double %23, double* %10
br label %24
24: ; preds = %37, %22
%25 = load double, double* %10
%26 = load double, double* %2
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %41
28: ; preds = %24
%29 = load double, double* %10
%30 = load double, double* %9
%31 = call i64 @mandelbrot(double %29, double %30, i32 300)
%32 = icmp eq i64 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i32 42, i32 32
%35 = trunc i32 %34 to i8
%36 = call i32 @putchar(i8 signext %35)
br label %37
37: ; preds = %28
%38 = load double, double* %6
%39 = load double, double* %10
%40 = fadd double %39, %38
store double %40, double* %10
br label %24
41: ; preds = %24
%42 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41
%44 = load double, double* %7
%45 = load double, double* %9
%46 = fsub double %45, %44
store double %46, double* %9
br label %18
47: ; preds = %18
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %0, %4
%2 = phi double [ 1.000000e+00, %0 ], [ %6, %4 ]
br label %8
3: ; preds = %4
ret i32 0
4: ; preds = %8
%5 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
%6 = fadd double %2, -5.000000e-02
%7 = fcmp ogt double %6, -1.000000e+00
br i1 %7, label %1, label %3
8: ; preds = %1, %8
%9 = phi double [ -2.000000e+00, %1 ], [ %14, %8 ]
%10 = tail call i64 @mandelbrot(double %9, double %2, i32 300)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8 42, i8 32
%13 = tail call i32 @putchar(i8 signext %12)
%14 = fadd double %9, 5.000000e-02
%15 = fcmp olt double %14, 1.000000e+00
br i1 %15, label %8, label %4
}