#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 absval(int);
int square(int);
int checkpixel(int x, int y) {
  int real, imag, temp, iter, bail;
  real = 0;
  imag = 0;
  iter = 0;
  bail = 16000;
  while (iter < 255) {
    temp = square(real) - square(imag) + x;
    imag = ((2 * real * imag + 500) / 1000) + y;
    real = temp;
    if (absval(real) + absval(imag) > 5000) {
      return 0;
    }
    iter = iter + 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkpixel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x3e80,-0x20(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jge    11d9 <checkpixel+0xb9>
mov    -0x10(%rbp),%edi
call   1030 <square@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <square@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
imul   -0x14(%rbp),%eax
add    $0x1f4,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <absval@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <absval@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
cmp    $0x1388,%eax
jle    11cb <checkpixel+0xab>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <checkpixel+0xc0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <checkpixel+0x2a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkpixel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r12d
mov    $0xff,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r13d
mov    %ebx,%edi
call   1030 <square@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <square@plt>
sub    %eax,%ebx
add    %r12d,%ebx
imul   %r13d,%ebp
lea    0x1f4(%rbp,%rbp,1),%eax
cltq
imul   $0x10624dd3,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x26,%rbp
add    %eax,%ebp
add    %r15d,%ebp
mov    %ebx,%edi
call   1040 <absval@plt>
mov    %eax,%r13d
mov    %ebp,%edi
call   1040 <absval@plt>
add    %r13d,%eax
cmp    $0x1389,%eax
jge    11a4 <checkpixel+0x84>
add    $0xffffffff,%r14d
jne    1140 <checkpixel+0x20>
mov    $0x1,%eax
jmp    11a6 <checkpixel+0x86>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkpixel(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %9
store i32 16000, i32* %10
br label %11
11: ; preds = %38, %2
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 255
br i1 %13, label %14, label %41
14: ; preds = %11
%15 = load i32, i32* %6
%16 = call i32 @square(i32 %15)
%17 = load i32, i32* %7
%18 = call i32 @square(i32 %17)
%19 = sub nsw i32 %16, %18
%20 = load i32, i32* %4
%21 = add nsw i32 %19, %20
store i32 %21, i32* %8
%22 = load i32, i32* %6
%23 = mul nsw i32 2, %22
%24 = load i32, i32* %7
%25 = mul nsw i32 %23, %24
%26 = add nsw i32 %25, 500
%27 = sdiv i32 %26, 1000
%28 = load i32, i32* %5
%29 = add nsw i32 %27, %28
store i32 %29, i32* %7
%30 = load i32, i32* %8
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = call i32 @absval(i32 %31)
%33 = load i32, i32* %7
%34 = call i32 @absval(i32 %33)
%35 = add nsw i32 %32, %34
%36 = icmp sgt i32 %35, 5000
br i1 %36, label %37, label %38
37: ; preds = %14
store i32 0, i32* %3
br label %42
38: ; preds = %14
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %11
41: ; preds = %11
store i32 1, i32* %3
br label %42
42: ; preds = %41, %37
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @checkpixel(i32 %0, i32 %1) {
br label %6
3: ; preds = %6
%4 = add nuw nsw i32 %7, 1
%5 = icmp eq i32 %4, 255
br i1 %5, label %23, label %6
6: ; preds = %2, %3
%7 = phi i32 [ 0, %2 ], [ %4, %3 ]
%8 = phi i32 [ 0, %2 ], [ %13, %3 ]
%9 = phi i32 [ 0, %2 ], [ %18, %3 ]
%10 = tail call i32 @square(i32 %8)
%11 = tail call i32 @square(i32 %9)
%12 = sub nsw i32 %10, %11
%13 = add nsw i32 %12, %0
%14 = shl i32 %9, 1
%15 = mul i32 %14, %8
%16 = add nsw i32 %15, 500
%17 = sdiv i32 %16, 1000
%18 = add nsw i32 %17, %1
%19 = tail call i32 @absval(i32 %13)
%20 = tail call i32 @absval(i32 %18)
%21 = add nsw i32 %20, %19
%22 = icmp sgt i32 %21, 5000
br i1 %22, label %23, label %3
23: ; preds = %3, %6
%24 = phi i32 [ 0, %6 ], [ 1, %3 ]
ret i32 %24
}