#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 */
double dbl(double);
int /*<<< orphan*/ putchar(char);
int main() {
  int w, h, x, y;
  int i, iter = 1000;
  double limit = 2.0;
  double zr, zi, zr2, zi2, cr, ci, tr, ti;
  w = 400;
  h = w;
  for (y = 0; y < h; y++) {
    for (x = 0; x < w; x++) {
      zr = 0.0;
      zi = 0.0;
      zr2 = 0.0;
      zi2 = 0.0;
      cr = (dbl((double)x) / w - 1.5);
      ci = (dbl((double)y) / h - 1.0);
      for (i = 0; i < iter; i++) {
        tr = zr2 - zi2 + cr;
        ti = dbl(zr) * zi + ci;
        zr = tr;
        zi = ti;
        zr2 = zr * zr;
        zi2 = zi * zi;
        if (zr2 + zi2 > limit * limit) {
          putchar('0');
          goto cont;
        }
      }
      putchar('1');
    cont:;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x1c(%rbp)
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x190,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c8 <main+0x1a8>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b5 <main+0x195>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
call   1040 <dbl@plt>
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe5f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
call   1040 <dbl@plt>
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe33(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1298 <main+0x178>
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <dbl@plt>
movsd  -0x38(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1285 <main+0x165>
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    12a2 <main+0x182>
jmp    128a <main+0x16a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e5 <main+0xc5>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    12a7 <main+0x187>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116a <main+0x4a>
jmp    12ba <main+0x19a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <main+0x37>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
xor    %r14d,%r14d
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    1163 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
addsd  0xed3(%rip),%xmm0
movsd  %xmm0,(%rsp)
add    $0x1,%r14d
cmp    $0x190,%r14d
je     1257 <main+0x137>
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
jmp    1193 <main+0x73>
nopl   0x0(%rax,%rax,1)
mov    $0x30,%al
movzbl %al,%edi
call   1030 <putchar@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe98(%rip),%xmm0
add    $0x1,%ebp
cmp    $0x190,%ebp
je     1140 <main+0x20>
movsd  %xmm0,0x8(%rsp)
call   1040 <dbl@plt>
movapd %xmm0,%xmm1
movsd  0xe56(%rip),%xmm0
divsd  %xmm0,%xmm1
addsd  0xe52(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1040 <dbl@plt>
divsd  0xe32(%rip),%xmm0
addsd  0xe3a(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm3,%xmm3
mov    $0x3e8,%ebx
xorpd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
xorps  %xmm4,%xmm4
movsd  %xmm4,0x28(%rsp)
movapd %xmm3,%xmm0
subsd  %xmm2,%xmm1
addsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
call   1040 <dbl@plt>
movsd  0x28(%rsp),%xmm4
movsd  0x20(%rsp),%xmm3
mulsd  %xmm0,%xmm4
addsd  0x10(%rsp),%xmm4
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm4,%xmm2
mulsd  %xmm4,%xmm2
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
ucomisd 0xdd3(%rip),%xmm0
ja     1170 <main+0x50>
add    $0xffffffff,%ebx
jne    11f0 <main+0xd0>
mov    $0x31,%al
jmp    1172 <main+0x52>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 0, i32* %1
store i32 1000, i32* %7
store double 2.000000e+00, double* %8
store i32 400, i32* %2
%17 = load i32, i32* %2
store i32 %17, i32* %3
store i32 0, i32* %5
br label %18
18: ; preds = %85, %0
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %88
22: ; preds = %18
store i32 0, i32* %4
br label %23
23: ; preds = %81, %22
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %84
27: ; preds = %23
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to double
%30 = call double @dbl(double %29)
%31 = load i32, i32* %2
%32 = sitofp i32 %31 to double
%33 = fdiv double %30, %32
%34 = fsub double %33, 1.500000e+00
store double %34, double* %13
%35 = load i32, i32* %5
%36 = sitofp i32 %35 to double
%37 = call double @dbl(double %36)
%38 = load i32, i32* %3
%39 = sitofp i32 %38 to double
%40 = fdiv double %37, %39
%41 = fsub double %40, 1.000000e+00
store double %41, double* %14
store i32 0, i32* %6
br label %42
42: ; preds = %75, %27
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %78
46: ; preds = %42
%47 = load double, double* %11
%48 = load double, double* %12
%49 = fsub double %47, %48
%50 = load double, double* %13
%51 = fadd double %49, %50
store double %51, double* %15
%52 = load double, double* %9
%53 = call double @dbl(double %52)
%54 = load double, double* %10
%55 = load double, double* %14
%56 = call double @llvm.fmuladd.f64(double %53, double %54, double %55)
store double %56, double* %16
%57 = load double, double* %15
store double %57, double* %9
%58 = load double, double* %16
store double %58, double* %10
%59 = load double, double* %9
%60 = load double, double* %9
%61 = fmul double %59, %60
store double %61, double* %11
%62 = load double, double* %10
%63 = load double, double* %10
%64 = fmul double %62, %63
store double %64, double* %12
%65 = load double, double* %11
%66 = load double, double* %12
%67 = fadd double %65, %66
%68 = load double, double* %8
%69 = load double, double* %8
%70 = fmul double %68, %69
%71 = fcmp ogt double %67, %70
br i1 %71, label %72, label %74
72: ; preds = %46
%73 = call i32 @putchar(i8 signext 48)
br label %80
74: ; preds = %46
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %42
78: ; preds = %42
%79 = call i32 @putchar(i8 signext 49)
br label %80
80: ; preds = %78, %72
br label %81
81: ; preds = %80
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %23
84: ; preds = %23
br label %85
85: ; preds = %84
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
br label %18
88: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %0, %35
%2 = phi i32 [ 0, %0 ], [ %36, %35 ]
%3 = sitofp i32 %2 to double
br label %4
4: ; preds = %1, %30
%5 = phi i32 [ 0, %1 ], [ %33, %30 ]
%6 = sitofp i32 %5 to double
%7 = tail call double @dbl(double %6)
%8 = fdiv double %7, 4.000000e+02
%9 = fadd double %8, -1.500000e+00
%10 = tail call double @dbl(double %3)
%11 = fdiv double %10, 4.000000e+02
%12 = fadd double %11, -1.000000e+00
br label %16
13: ; preds = %16
%14 = add nuw nsw i32 %17, 1
%15 = icmp eq i32 %14, 1000
br i1 %15, label %30, label %16
16: ; preds = %4, %13
%17 = phi i32 [ 0, %4 ], [ %14, %13 ]
%18 = phi double [ 0.000000e+00, %4 ], [ %23, %13 ]
%19 = phi double [ 0.000000e+00, %4 ], [ %27, %13 ]
%20 = phi double [ 0.000000e+00, %4 ], [ %26, %13 ]
%21 = phi double [ 0.000000e+00, %4 ], [ %25, %13 ]
%22 = fsub double %20, %19
%23 = fadd double %9, %22
%24 = tail call double @dbl(double %18)
%25 = tail call double @llvm.fmuladd.f64(double %24, double %21, double %12)
%26 = fmul double %23, %23
%27 = fmul double %25, %25
%28 = fadd double %26, %27
%29 = fcmp ogt double %28, 4.000000e+00
br i1 %29, label %30, label %13
30: ; preds = %13, %16
%31 = phi i8 [ 48, %16 ], [ 49, %13 ]
%32 = tail call i32 @putchar(i8 signext %31)
%33 = add nuw nsw i32 %5, 1
%34 = icmp eq i32 %33, 400
br i1 %34, label %35, label %4
35: ; preds = %30
%36 = add nuw nsw i32 %2, 1
%37 = icmp eq i32 %36, 400
br i1 %37, label %38, label %1
38: ; preds = %35
ret i32 0
}