#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 /*<<< orphan*/ putchar(char const);
int /*<<< orphan*/ puts(char *);
void mandelbrot(int w, int h) {
  static const char sym[] = " .:-;!/>)|&IH%*#";
  float i, j, r, x, y;
  int k;
  for (y = -h / 2; y <= h / 2; y++) {
    puts("");
    for (x = 0; x < w; x++) {
      i = j = k = r = 0;
      do {
        j = r * r - i * i - 2 + x / 25;
        i = 2 * r * i + y / 10;
        r = j;
      } while (j * j + i * i < 11 && k++ < 111);
      putchar(sym[k & 15]);
    }
  }
  puts("");
}


x86 assembly (clang, -O0):
<mandelbrot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
ucomiss %xmm1,%xmm0
jb     12cd <mandelbrot+0x1ad>
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm1
cvtsi2ssl -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    12b1 <mandelbrot+0x191>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xe30(%rip),%xmm1
subss  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
movss  0xe23(%rip),%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe0a(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
movss  0xdef(%rip),%xmm3
divss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
xor    %eax,%eax
movss  0xdba(%rip),%xmm0
ucomiss %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jbe    1276 <mandelbrot+0x156>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x6f,%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a7 <mandelbrot+0x87>
mov    -0x20(%rbp),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xd8f(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
movss  0xd5e(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1175 <mandelbrot+0x55>
jmp    12b6 <mandelbrot+0x196>
movss  0xd42(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1144 <mandelbrot+0x24>
lea    0xd5d(%rip),%rdi
call   1040 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mandelbrot>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
sar    %eax
cvtsi2ss %eax,%xmm0
neg    %eax
cvtsi2ss %eax,%xmm1
movss  %xmm0,0x8(%rsp)
movss  %xmm1,0x4(%rsp)
ucomiss %xmm1,%xmm0
jae    114a <mandelbrot+0x3a>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>
mov    %edi,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xec0(%rip),%rbx
jmp    118f <mandelbrot+0x7f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  0x4(%rsp),%xmm1
addss  0xe92(%rip),%xmm1
movss  0x8(%rsp),%xmm0
movss  %xmm1,0x4(%rsp)
ucomiss %xmm1,%xmm0
jb     113a <mandelbrot+0x2a>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    1170 <mandelbrot+0x60>
movss  0x4(%rsp),%xmm7
divss  0xe55(%rip),%xmm7
xorps  %xmm1,%xmm1
movss  %xmm7,0x10(%rsp)
jmp    11eb <mandelbrot+0xdb>
cs nopw 0x0(%rax,%rax,1)
and    $0xf,%eax
movsbl (%rax,%rbx,1),%edi
call   1030 <putchar@plt>
movss  0x14(%rsp),%xmm1
addss  0xe36(%rip),%xmm1
movss  0xc(%rsp),%xmm0
ucomiss %xmm1,%xmm0
movss  0x10(%rsp),%xmm7
jbe    1170 <mandelbrot+0x60>
movss  %xmm1,0x14(%rsp)
movaps %xmm1,%xmm0
divss  0xe08(%rip),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
movss  0xdfc(%rip),%xmm5
movss  0xdf8(%rip),%xmm6
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movaps %xmm2,%xmm3
movaps %xmm1,%xmm4
mulss  %xmm1,%xmm4
mulss  %xmm2,%xmm2
subss  %xmm4,%xmm2
addss  %xmm5,%xmm2
addss  %xmm0,%xmm2
addss  %xmm3,%xmm3
mulss  %xmm3,%xmm1
addss  %xmm7,%xmm1
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm3
movaps %xmm2,%xmm4
mulss  %xmm2,%xmm4
addss  %xmm3,%xmm4
ucomiss %xmm4,%xmm6
jbe    11c0 <mandelbrot+0xb0>
add    $0x1,%eax
cmp    $0x70,%eax
jne    1220 <mandelbrot+0x110>
mov    $0x70,%eax
jmp    11c0 <mandelbrot+0xb0>

LLVM IR (-O0):
@mandelbrot.sym = internal constant [17 x i8] c" .:-;!/>)|&IH%*#\00"
@.str = [1 x i8] zeroinitializer
define void @mandelbrot(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%11 = load i32, i32* %4
%12 = sub nsw i32 0, %11
%13 = sdiv i32 %12, 2
%14 = sitofp i32 %13 to float
store float %14, float* %9
br label %15
15: ; preds = %73, %2
%16 = load float, float* %9
%17 = load i32, i32* %4
%18 = sdiv i32 %17, 2
%19 = sitofp i32 %18 to float
%20 = fcmp ole float %16, %19
br i1 %20, label %21, label %76
21: ; preds = %15
%22 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %8
br label %23
23: ; preds = %69, %21
%24 = load float, float* %8
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to float
%27 = fcmp olt float %24, %26
br i1 %27, label %28, label %72
28: ; preds = %23
store float 0.000000e+00, float* %7
store i32 0, i32* %10
store float 0.000000e+00, float* %6
store float 0.000000e+00, float* %5
br label %29
29: ; preds = %60, %28
%30 = load float, float* %7
%31 = load float, float* %7
%32 = load float, float* %5
%33 = load float, float* %5
%34 = fmul float %32, %33
%35 = fneg float %34
%36 = call float @llvm.fmuladd.f32(float %30, float %31, float %35)
%37 = fsub float %36, 2.000000e+00
%38 = load float, float* %8
%39 = fdiv float %38, 2.500000e+01
%40 = fadd float %37, %39
store float %40, float* %6
%41 = load float, float* %7
%42 = fmul float 2.000000e+00, %41
%43 = load float, float* %5
%44 = load float, float* %9
%45 = fdiv float %44, 1.000000e+01
%46 = call float @llvm.fmuladd.f32(float %42, float %43, float %45)
store float %46, float* %5
%47 = load float, float* %6
store float %47, float* %7
br label %48
48: ; preds = %29
%49 = load float, float* %6
%50 = load float, float* %6
%51 = load float, float* %5
%52 = load float, float* %5
%53 = fmul float %51, %52
%54 = call float @llvm.fmuladd.f32(float %49, float %50, float %53)
%55 = fcmp olt float %54, 1.100000e+01
br i1 %55, label %56, label %60
56: ; preds = %48
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
%59 = icmp slt i32 %57, 111
br label %60
60: ; preds = %56, %48
%61 = phi i1 [ false, %48 ], [ %59, %56 ]
br i1 %61, label %29, label %62
62: ; preds = %60
%63 = load i32, i32* %10
%64 = and i32 %63, 15
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [17 x i8], [17 x i8]* @mandelbrot.sym, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = call i32 @putchar(i8 signext %67)
br label %69
69: ; preds = %62
%70 = load float, float* %8
%71 = fadd float %70, 1.000000e+00
store float %71, float* %8
br label %23
72: ; preds = %23
br label %73
73: ; preds = %72
%74 = load float, float* %9
%75 = fadd float %74, 1.000000e+00
store float %75, float* %9
br label %15
76: ; preds = %15
%77 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@mandelbrot.sym = internal unnamed_addr constant [17 x i8] c" .:-;!/>)|&IH%*#\00"
define void @mandelbrot(i32 %0, i32 %1) {
%3 = sdiv i32 %1, -2
%4 = sitofp i32 %3 to float
%5 = sdiv i32 %1, 2
%6 = sitofp i32 %5 to float
%7 = fcmp ugt float %4, %6
br i1 %7, label %48, label %8
8: ; preds = %2
%9 = sitofp i32 %0 to float
%10 = icmp sgt i32 %0, 0
br label %11
11: ; preds = %8, %45
%12 = phi float [ %4, %8 ], [ %46, %45 ]
%13 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
br i1 %10, label %14, label %45
14: ; preds = %11
%15 = fdiv float %12, 1.000000e+01
br label %16
16: ; preds = %14, %36
%17 = phi float [ 0.000000e+00, %14 ], [ %43, %36 ]
%18 = fdiv float %17, 2.500000e+01
br label %19
19: ; preds = %16, %33
%20 = phi float [ %29, %33 ], [ 0.000000e+00, %16 ]
%21 = phi float [ %27, %33 ], [ 0.000000e+00, %16 ]
%22 = phi i32 [ %34, %33 ], [ 0, %16 ]
%23 = fneg float %20
%24 = fmul float %20, %23
%25 = tail call float @llvm.fmuladd.f32(float %21, float %21, float %24)
%26 = fadd float %25, -2.000000e+00
%27 = fadd float %18, %26
%28 = fmul float %21, 2.000000e+00
%29 = tail call float @llvm.fmuladd.f32(float %28, float %20, float %15)
%30 = fmul float %29, %29
%31 = tail call float @llvm.fmuladd.f32(float %27, float %27, float %30)
%32 = fcmp olt float %31, 1.100000e+01
br i1 %32, label %33, label %36
33: ; preds = %19
%34 = add nuw nsw i32 %22, 1
%35 = icmp eq i32 %34, 112
br i1 %35, label %36, label %19
36: ; preds = %19, %33
%37 = phi i32 [ 112, %33 ], [ %22, %19 ]
%38 = and i32 %37, 15
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [17 x i8], [17 x i8]* @mandelbrot.sym, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = tail call i32 @putchar(i8 signext %41)
%43 = fadd float %17, 1.000000e+00
%44 = fcmp olt float %43, %9
br i1 %44, label %16, label %45
45: ; preds = %36, %11
%46 = fadd float %12, 1.000000e+00
%47 = fcmp ugt float %46, %6
br i1 %47, label %48, label %11
48: ; preds = %45, %2
%49 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret void
}