#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 count(double, double, double, int, int);
void mbrot(int *matrix, double r, double i, double step, int n) {
  int x, y;
  for (y = n - 1; y >= 0; y--)
    for (x = n - 1; x >= 0; x--)
      matrix[y * n + x] = count(r, i, step, x, y);
}


x86 assembly (clang, -O0):
<mbrot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     11a5 <mbrot+0x95>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1192 <mbrot+0x82>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <count@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    114a <mbrot+0x3a>
jmp    1197 <mbrot+0x87>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1137 <mbrot+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbrot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    11aa <mbrot+0x9a>
mov    %esi,%r15d
lea    -0x1(%r15),%r14
mov    %r15,%rax
imul   %r15,%rax
lea    (%rdi,%rax,4),%r12
add    $0xfffffffffffffffc,%r12
lea    0x0(,%r15,4),%r13
neg    %r13
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rbp
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <count@plt>
mov    %eax,0x0(%rbp)
add    $0xfffffffffffffffc,%rbp
test   %rbx,%rbx
jg     1170 <mbrot+0x60>
lea    -0x1(%r14),%rax
add    %r13,%r12
test   %r14,%r14
mov    %rax,%r14
jg     1160 <mbrot+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mbrot(i32* %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca i32*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%13 = load i32, i32* %10
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %12
br label %15
15: ; preds = %43, %5
%16 = load i32, i32* %12
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %46
18: ; preds = %15
%19 = load i32, i32* %10
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %11
br label %21
21: ; preds = %39, %18
%22 = load i32, i32* %11
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %42
24: ; preds = %21
%25 = load double, double* %7
%26 = load double, double* %8
%27 = load double, double* %9
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = call i32 @count(double %25, double %26, double %27, i32 %28, i32 %29)
%31 = load i32*, i32** %6
%32 = load i32, i32* %12
%33 = load i32, i32* %10
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %11
%36 = add nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %31, i64 %37
store i32 %30, i32* %38
br label %39
39: ; preds = %24
%40 = load i32, i32* %11
%41 = add nsw i32 %40, -1
store i32 %41, i32* %11
br label %21
42: ; preds = %21
br label %43
43: ; preds = %42
%44 = load i32, i32* %12
%45 = add nsw i32 %44, -1
store i32 %45, i32* %12
br label %15
46: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @mbrot(i32* nocapture writeonly %0, double %1, double %2, double %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %25
7: ; preds = %5
%8 = zext i32 %4 to i64
%9 = add nsw i64 %8, -1
br label %10
10: ; preds = %22, %7
%11 = phi i64 [ %9, %7 ], [ %23, %22 ]
%12 = mul nsw i64 %11, %8
%13 = trunc i64 %11 to i32
br label %14
14: ; preds = %10, %14
%15 = phi i64 [ %9, %10 ], [ %20, %14 ]
%16 = trunc i64 %15 to i32
%17 = tail call i32 @count(double %1, double %2, double %3, i32 %16, i32 %13)
%18 = add nsw i64 %15, %12
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %17, i32* %19
%20 = add nsw i64 %15, -1
%21 = icmp sgt i64 %15, 0
br i1 %21, label %14, label %22
22: ; preds = %14
%23 = add nsw i64 %11, -1
%24 = icmp sgt i64 %11, 0
br i1 %24, label %10, label %25
25: ; preds = %22, %5
ret void
}