#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 */
long escape_iteration_count(double, double);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, long const, long const);
int /*<<< orphan*/ putrgb(char *, long const, long, long, long, long, long);
int /*<<< orphan*/ write(int, char *, long const);
int main(int argc, char *argv[]) {
  long const width = 1024;
  long const height = 1024;
  long y, x;
  char buf[width * height * 3];
  printf("P6 %d %d 255\n", width, height);
  fflush(NULL);
  for (y = 0; y < height; y++) {
    for (x = 0; x < width; x++) {
      long i = escape_iteration_count(-2.0 + (x * (4.0 / width)),
                                      -2.0 + (y * (4.0 / height)));
      long b = (i == -1) ? 0 : i;
      putrgb(buf, width, x, y, b, b, b);
    }
  }
  write(1, buf, width * height * 3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300060,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x400,-0x18(%rbp)
movq   $0x400,-0x20(%rbp)
mov    %rsp,%rax
mov    %rax,-0x38(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x400,%edx
mov    %rdx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0x400,-0x28(%rbp)
jge    128d <main+0x13d>
movq   $0x0,-0x30(%rbp)
cmpq   $0x400,-0x30(%rbp)
jge    1277 <main+0x127>
cvtsi2sdq -0x30(%rbp),%xmm0
movsd  0xe29(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
movsd  0xe0b(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe07(%rip),%xmm2
addsd  %xmm2,%xmm1
call   1070 <escape_iteration_count@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0xffffffffffffffff,-0x40(%rbp)
jne    1227 <main+0xd7>
xor    %eax,%eax
mov    %rax,-0x300058(%rbp)
jmp    1232 <main+0xe2>
mov    -0x40(%rbp),%rax
mov    %rax,-0x300058(%rbp)
mov    -0x300058(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    -0x48(%rbp),%rax
lea    -0x300050(%rbp),%rdi
mov    $0x400,%esi
mov    %rax,(%rsp)
call   1050 <putrgb@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11bb <main+0x6b>
jmp    127c <main+0x12c>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11a5 <main+0x55>
mov    $0x1,%edi
lea    -0x300050(%rbp),%rsi
mov    $0x300000,%edx
call   1030 <write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x300060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x300010,%rsp
lea    0xead(%rip),%rdi
mov    $0x400,%esi
mov    $0x400,%edx
call   1040 <printf@plt>
xor    %r15d,%r15d
xor    %edi,%edi
call   1060 <fflush@plt>
movsd  0xe7c(%rip),%xmm1
movsd  0xe7c(%rip),%xmm2
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm1
call   1070 <escape_iteration_count@plt>
cmp    $0xffffffffffffffff,%rax
mov    $0x0,%r8d
cmovne %rax,%r8
mov    %r8,(%rsp)
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r8,%r9
call   1050 <putrgb@plt>
movsd  0xdfd(%rip),%xmm2
movsd  0xded(%rip),%xmm1
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    11c0 <main+0x70>
add    $0x1,%r15
cmp    $0x400,%r15
jne    11a0 <main+0x50>
lea    0x10(%rsp),%rsi
mov    $0x300000,%edx
mov    $0x1,%edi
call   1030 <write@plt>
xor    %eax,%eax
add    $0x300010,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"P6 %d %d 255\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1024, i64* %6
store i64 1024, i64* %7
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %10
%14 = alloca i8, i64 3145728
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 1024, i64 1024)
%16 = call i32 @fflush(i32* null)
store i64 0, i64* %8
br label %17
17: ; preds = %49, %2
%18 = load i64, i64* %8
%19 = icmp slt i64 %18, 1024
br i1 %19, label %20, label %52
20: ; preds = %17
store i64 0, i64* %9
br label %21
21: ; preds = %45, %20
%22 = load i64, i64* %9
%23 = icmp slt i64 %22, 1024
br i1 %23, label %24, label %48
24: ; preds = %21
%25 = load i64, i64* %9
%26 = sitofp i64 %25 to double
%27 = call double @llvm.fmuladd.f64(double %26, double 3.906250e-03, double -2.000000e+00)
%28 = load i64, i64* %8
%29 = sitofp i64 %28 to double
%30 = call double @llvm.fmuladd.f64(double %29, double 3.906250e-03, double -2.000000e+00)
%31 = call i64 @escape_iteration_count(double %27, double %30)
store i64 %31, i64* %11
%32 = load i64, i64* %11
%33 = icmp eq i64 %32, -1
br i1 %33, label %34, label %35
34: ; preds = %24
br label %37
35: ; preds = %24
%36 = load i64, i64* %11
br label %37
37: ; preds = %35, %34
%38 = phi i64 [ 0, %34 ], [ %36, %35 ]
store i64 %38, i64* %12
%39 = load i64, i64* %9
%40 = load i64, i64* %8
%41 = load i64, i64* %12
%42 = load i64, i64* %12
%43 = load i64, i64* %12
%44 = call i32 @putrgb(i8* %14, i64 1024, i64 %39, i64 %40, i64 %41, i64 %42, i64 %43)
br label %45
45: ; preds = %37
%46 = load i64, i64* %9
%47 = add nsw i64 %46, 1
store i64 %47, i64* %9
br label %21
48: ; preds = %21
br label %49
49: ; preds = %48
%50 = load i64, i64* %8
%51 = add nsw i64 %50, 1
store i64 %51, i64* %8
br label %17
52: ; preds = %17
%53 = call i32 @write(i32 1, i8* %14, i64 3145728)
store i32 0, i32* %3
%54 = load i8*, i8** %10
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [14 x i8] c"P6 %d %d 255\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3145728 x i8]
%4 = getelementptr inbounds [3145728 x i8], [3145728 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 1024, i64 1024)
%6 = tail call i32 @fflush(i32* null)
br label %7
7: ; preds = %2, %21
%8 = phi i64 [ 0, %2 ], [ %22, %21 ]
%9 = sitofp i64 %8 to double
%10 = call double @llvm.fmuladd.f64(double %9, double 3.906250e-03, double -2.000000e+00)
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %19, %11 ]
%13 = sitofp i64 %12 to double
%14 = call double @llvm.fmuladd.f64(double %13, double 3.906250e-03, double -2.000000e+00)
%15 = call i64 @escape_iteration_count(double %14, double %10)
%16 = icmp eq i64 %15, -1
%17 = select i1 %16, i64 0, i64 %15
%18 = call i32 @putrgb(i8* %4, i64 1024, i64 %12, i64 %8, i64 %17, i64 %17, i64 %17)
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, 1024
br i1 %20, label %21, label %11
21: ; preds = %11
%22 = add nuw nsw i64 %8, 1
%23 = icmp eq i64 %22, 1024
br i1 %23, label %24, label %7
24: ; preds = %21
%25 = call i32 @write(i32 1, i8* %4, i64 3145728)
ret i32 0
}