#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 */
typedef long mpf_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(long *);
long *malloc(int);
int /*<<< orphan*/ mpf_add(long, long, long);
int /*<<< orphan*/ mpf_clear(long);
scalar_t__ mpf_cmp_d(long, int);
int /*<<< orphan*/ mpf_init(long);
int /*<<< orphan*/ mpf_init_set(long, long);
int /*<<< orphan*/ mpf_mul(long, long, long);
int /*<<< orphan*/ mpf_mul_ui(long, long, int);
int /*<<< orphan*/ mpf_out_str(int /*<<< orphan*/ *, int, int, long);
int /*<<< orphan*/ mpf_set(long, long);
int /*<<< orphan*/ mpf_sub(long, long, long);
int /*<<< orphan*/ printf(char *);
void mandelbrot_region(mpf_t start_x, mpf_t start_y, int increments_x,
                       int increments_y, mpf_t increment_size,
                       long max_iterations, int precision, char fname[]) {
  int n_pixels = increments_x * increments_y;
  long *iteration_count;
  iteration_count = malloc(sizeof(long) * n_pixels);
  mpf_t *escape_values;
  escape_values = malloc(n_pixels * sizeof(mpf_t) * 2);
  int q;
  for (q = 0; q < n_pixels * 2; q++) {
    mpf_init(escape_values[q]);
  }
  long int k = 0;
  mpf_t c_real;
  mpf_init_set(c_real, start_x);
  mpf_t c_imag;
  mpf_init_set(c_imag, start_y);
  mpf_t z_real;
  mpf_t z_imag;
  mpf_t new_z_real;
  mpf_t new_z_imag;
  mpf_t z_imag_sqrd;
  mpf_init(z_real);
  mpf_init(z_imag);
  mpf_init(new_z_real);
  mpf_init(new_z_imag);
  mpf_init(z_imag_sqrd);
  int escaped;
  for (int j = 0; j < increments_y; j++) {
    for (int i = 0; i < increments_x; i++) {
      mpf_set(z_real, c_real);
      mpf_set(z_imag, c_imag);
      escaped = 0;
      for (long n = 0; n < max_iterations; n++) {
        mpf_mul(new_z_real, z_real, z_real);
        mpf_mul(z_imag_sqrd, z_imag, z_imag);
        mpf_sub(new_z_real, new_z_real, z_imag_sqrd);
        mpf_add(new_z_real, new_z_real, c_real);
        mpf_mul(z_imag, z_real, z_imag);
        mpf_mul_ui(z_imag, z_imag, 2);
        mpf_add(z_imag, z_imag, c_imag);
        mpf_set(z_real, new_z_real);
        if (mpf_cmp_d(z_real, 2.) >= 0 || mpf_cmp_d(z_imag, 2.) >= 0 ||
            mpf_cmp_d(z_real, -2.) <= 0 || mpf_cmp_d(z_imag, -2.) <= 0) {
          escaped = 1;
          iteration_count[k] = n;
          break;
        }
      }
      if (escaped == 0) {
        iteration_count[k] = max_iterations + 1;
      }
      mpf_set(escape_values[2 * k], z_real);
      mpf_set(escape_values[2 * k + 1], z_imag);
      mpf_add(c_real, c_real, increment_size);
      k++;
    };
    mpf_sub(c_imag, c_imag, increment_size);
    mpf_set(c_real, start_x);
  };
  FILE *f = fopen(fname, "wb");
  if (f != NULL) {
    fprintf(f, "%d ", increments_x);
    fprintf(f, "%d ", increments_y);
    fprintf(f, "%ld ", max_iterations);
    fprintf(f, "%d", precision);
    for (int n = 0; n < n_pixels; n++) {
      fputs(" ", f);
      fprintf(f, "%ld ", iteration_count[n]);
      mpf_out_str(f, 10, precision, escape_values[2 * n]);
      fputs(" ", f);
      mpf_out_str(f, 10, precision, escape_values[2 * n + 1]);
    }
    fclose(f);
  } else {
    printf("Error opening file for writing.");
  }
  mpf_clear(c_real);
  mpf_clear(c_imag);
  mpf_clear(z_real);
  mpf_clear(z_imag);
  mpf_clear(new_z_real);
  mpf_clear(new_z_imag);
  mpf_clear(z_imag_sqrd);
  free(iteration_count);
  for (q = 0; q < n_pixels * 2; q++) {
    mpf_clear(escape_values[q]);
  }
  free(escape_values);
}


x86 assembly (clang, -O0):
<mandelbrot_region>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
shl    $0x1,%rax
mov    %eax,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    12a3 <mandelbrot_region+0x93>
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <mpf_init@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1273 <mandelbrot_region+0x63>
movq   $0x0,-0x50(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <mpf_init_set@plt>
mov    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <mpf_init_set@plt>
mov    -0x68(%rbp),%rdi
call   10a0 <mpf_init@plt>
mov    -0x70(%rbp),%rdi
call   10a0 <mpf_init@plt>
mov    -0x78(%rbp),%rdi
call   10a0 <mpf_init@plt>
mov    -0x80(%rbp),%rdi
call   10a0 <mpf_init@plt>
mov    -0x88(%rbp),%rdi
call   10a0 <mpf_init@plt>
movl   $0x0,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1547 <mandelbrot_region+0x337>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1515 <mandelbrot_region+0x305>
mov    -0x68(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   10d0 <mpf_set@plt>
mov    -0x70(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   10d0 <mpf_set@plt>
movl   $0x0,-0x8c(%rbp)
movq   $0x0,-0xa0(%rbp)
mov    -0xa0(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    1490 <mandelbrot_region+0x280>
mov    -0x78(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x68(%rbp),%rdx
call   1120 <mpf_mul@plt>
mov    -0x88(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    -0x70(%rbp),%rdx
call   1120 <mpf_mul@plt>
mov    -0x78(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x88(%rbp),%rdx
call   1100 <mpf_sub@plt>
mov    -0x78(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x58(%rbp),%rdx
call   1060 <mpf_add@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x70(%rbp),%rdx
call   1120 <mpf_mul@plt>
mov    -0x70(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    $0x2,%edx
call   10e0 <mpf_mul_ui@plt>
mov    -0x70(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    -0x60(%rbp),%rdx
call   1060 <mpf_add@plt>
mov    -0x68(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   10d0 <mpf_set@plt>
mov    -0x68(%rbp),%rdi
mov    $0x2,%esi
call   1090 <mpf_cmp_d@plt>
cmp    $0x0,%rax
jge    1452 <mandelbrot_region+0x242>
mov    -0x70(%rbp),%rdi
mov    $0x2,%esi
call   1090 <mpf_cmp_d@plt>
cmp    $0x0,%rax
jge    1452 <mandelbrot_region+0x242>
mov    -0x68(%rbp),%rdi
mov    $0xfffffffe,%esi
call   1090 <mpf_cmp_d@plt>
cmp    $0x0,%rax
jle    1452 <mandelbrot_region+0x242>
mov    -0x70(%rbp),%rdi
mov    $0xfffffffe,%esi
call   1090 <mpf_cmp_d@plt>
cmp    $0x0,%rax
jg     1474 <mandelbrot_region+0x264>
movl   $0x1,-0x8c(%rbp)
mov    -0xa0(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1490 <mandelbrot_region+0x280>
jmp    1479 <mandelbrot_region+0x269>
mov    -0xa0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa0(%rbp)
jmp    1356 <mandelbrot_region+0x146>
cmpl   $0x0,-0x8c(%rbp)
jne    14b1 <mandelbrot_region+0x2a1>
mov    -0x28(%rbp),%rdx
add    $0x1,%rdx
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%rcx
shl    $0x1,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x68(%rbp),%rsi
call   10d0 <mpf_set@plt>
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%rcx
shl    $0x1,%rcx
mov    0x8(%rax,%rcx,8),%rdi
mov    -0x70(%rbp),%rsi
call   10d0 <mpf_set@plt>
mov    -0x58(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <mpf_add@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1318 <mandelbrot_region+0x108>
mov    -0x60(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1100 <mpf_sub@plt>
mov    -0x58(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10d0 <mpf_set@plt>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    12ff <mandelbrot_region+0xef>
mov    0x18(%rbp),%rdi
lea    0xaae(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     16a1 <mandelbrot_region+0x491>
mov    -0xa8(%rbp),%rdi
movslq -0x14(%rbp),%rdx
lea    0xa85(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
movslq -0x18(%rbp),%rdx
lea    0xa6e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xa5b(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
movslq 0x10(%rbp),%rdx
lea    0xa49(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1690 <mandelbrot_region+0x480>
mov    -0xa8(%rbp),%rsi
lea    0xa16(%rip),%rdi
call   1080 <fputs@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x38(%rbp),%rax
movslq -0xac(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0x9f6(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    0x10(%rbp),%edx
mov    -0x40(%rbp),%rax
mov    -0xac(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    $0xa,%esi
call   1110 <mpf_out_str@plt>
mov    -0xa8(%rbp),%rsi
lea    0x9b9(%rip),%rdi
call   1080 <fputs@plt>
mov    -0xa8(%rbp),%rdi
mov    0x10(%rbp),%edx
mov    -0x40(%rbp),%rax
mov    -0xac(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    $0xa,%esi
call   1110 <mpf_out_str@plt>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    15d2 <mandelbrot_region+0x3c2>
mov    -0xa8(%rbp),%rdi
call   1040 <fclose@plt>
jmp    16ad <mandelbrot_region+0x49d>
lea    0x967(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x68(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x70(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x78(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x80(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x88(%rbp),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    172f <mandelbrot_region+0x51f>
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10c0 <mpf_clear@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    16ff <mandelbrot_region+0x4ef>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mandelbrot_region>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%r15
mov    %r8,0x40(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x38(%rsp)
mov    0x98(%rsp),%rax
mov    %rax,0x48(%rsp)
mov    0x90(%rsp),%eax
mov    %eax,0x28(%rsp)
mov    %ecx,0xc(%rsp)
mov    %ecx,%ebx
mov    %rdx,0x30(%rsp)
imul   %edx,%ebx
lea    0x0(,%rbx,8),%edi
call   10f0 <malloc@plt>
mov    %rax,%r12
mov    %ebx,%edi
shl    $0x4,%edi
call   10f0 <malloc@plt>
mov    %rax,%rbp
lea    (%rbx,%rbx,1),%r13d
mov    %rbx,0x10(%rsp)
test   %ebx,%ebx
jle    12a3 <mandelbrot_region+0x93>
cmp    $0x2,%r13d
mov    $0x1,%r14d
cmovge %r13d,%r14d
xor    %ebx,%ebx
nop
mov    0x0(%rbp,%rbx,8),%rdi
call   10a0 <mpf_init@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1290 <mandelbrot_region+0x80>
mov    %r13d,0x2c(%rsp)
mov    %rbp,0x20(%rsp)
mov    0x38(%rsp),%rsi
call   1070 <mpf_init_set@plt>
mov    0x18(%rsp),%rsi
call   1070 <mpf_init_set@plt>
call   10a0 <mpf_init@plt>
call   10a0 <mpf_init@plt>
call   10a0 <mpf_init@plt>
call   10a0 <mpf_init@plt>
call   10a0 <mpf_init@plt>
cmpl   $0x0,0xc(%rsp)
jle    1420 <mandelbrot_region+0x210>
lea    0x1(%r15),%rax
mov    %rax,0x18(%rsp)
xor    %ecx,%ecx
xor    %r13d,%r13d
mov    0x20(%rsp),%rbp
jmp    1326 <mandelbrot_region+0x116>
nopw   0x0(%rax,%rax,1)
mov    0x40(%rsp),%rdx
call   1100 <mpf_sub@plt>
mov    0x38(%rsp),%rsi
call   10d0 <mpf_set@plt>
mov    0x50(%rsp),%rcx
add    $0x1,%ecx
cmp    0xc(%rsp),%ecx
je     1420 <mandelbrot_region+0x210>
mov    0x30(%rsp),%rax
test   %eax,%eax
mov    %rcx,0x50(%rsp)
jle    1300 <mandelbrot_region+0xf0>
lea    (%rax,%r13,1),%r14d
jmp    1375 <mandelbrot_region+0x165>
nopw   0x0(%rax,%rax,1)
mov    %r12,(%rbx,%r13,8)
mov    %rbx,%r12
mov    %r13,%rbx
shl    $0x4,%rbx
mov    0x0(%rbp,%rbx,1),%rdi
call   10d0 <mpf_set@plt>
mov    0x8(%rbp,%rbx,1),%rdi
call   10d0 <mpf_set@plt>
mov    0x40(%rsp),%rdx
call   1060 <mpf_add@plt>
add    $0x1,%r13
cmp    %r13d,%r14d
je     1300 <mandelbrot_region+0xf0>
mov    %r12,%rbx
call   10d0 <mpf_set@plt>
call   10d0 <mpf_set@plt>
mov    0x18(%rsp),%r12
test   %r15,%r15
jle    1340 <mandelbrot_region+0x130>
xor    %r12d,%r12d
nop
call   1120 <mpf_mul@plt>
call   1120 <mpf_mul@plt>
call   1100 <mpf_sub@plt>
call   1060 <mpf_add@plt>
call   1120 <mpf_mul@plt>
mov    $0x2,%edx
call   10e0 <mpf_mul_ui@plt>
call   1060 <mpf_add@plt>
call   10d0 <mpf_set@plt>
mov    $0x2,%esi
call   1090 <mpf_cmp_d@plt>
test   %rax,%rax
jns    1340 <mandelbrot_region+0x130>
mov    $0x2,%esi
call   1090 <mpf_cmp_d@plt>
test   %rax,%rax
jns    1340 <mandelbrot_region+0x130>
mov    $0xfffffffe,%esi
call   1090 <mpf_cmp_d@plt>
test   %rax,%rax
jle    1340 <mandelbrot_region+0x130>
mov    $0xfffffffe,%esi
call   1090 <mpf_cmp_d@plt>
test   %rax,%rax
jle    1340 <mandelbrot_region+0x130>
add    $0x1,%r12
cmp    %r12,%r15
jne    1390 <mandelbrot_region+0x180>
mov    0x18(%rsp),%r12
jmp    1340 <mandelbrot_region+0x130>
lea    0xbd9(%rip),%rsi
mov    0x48(%rsp),%rdi
call   1130 <fopen@plt>
test   %rax,%rax
je     151d <mandelbrot_region+0x30d>
mov    %rax,%rbx
movslq 0x30(%rsp),%rdx
mov    %r12,%r14
lea    0xbb7(%rip),%r12
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <fprintf@plt>
movslq 0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <fprintf@plt>
lea    0xb99(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   10b0 <fprintf@plt>
mov    0x28(%rsp),%r15d
movslq %r15d,%rdx
lea    0xb84(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fprintf@plt>
cmpl   $0x0,0x10(%rsp)
mov    0x20(%rsp),%r13
jle    1510 <mandelbrot_region+0x300>
mov    0x10(%rsp),%r12d
shl    $0x3,%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
mov    (%r14,%rbp,1),%rdx
mov    %rbx,%rdi
lea    0xb3c(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x0(%r13,%rbp,2),%rcx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %r15d,%edx
call   1110 <mpf_out_str@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
mov    0x8(%r13,%rbp,2),%rcx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %r15d,%edx
call   1110 <mpf_out_str@plt>
add    $0x8,%rbp
cmp    %rbp,%r12
jne    14b0 <mandelbrot_region+0x2a0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%r12
jmp    152e <mandelbrot_region+0x31e>
lea    0xaeb(%rip),%rdi
call   1050 <printf@plt>
mov    0x20(%rsp),%r13
mov    0x10(%rsp),%rbx
call   10c0 <mpf_clear@plt>
call   10c0 <mpf_clear@plt>
call   10c0 <mpf_clear@plt>
call   10c0 <mpf_clear@plt>
call   10c0 <mpf_clear@plt>
call   10c0 <mpf_clear@plt>
call   10c0 <mpf_clear@plt>
mov    %r12,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
jle    1593 <mandelbrot_region+0x383>
mov    0x2c(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ebp
cmovge %eax,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rdi
call   10c0 <mpf_clear@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1580 <mandelbrot_region+0x370>
mov    %r13,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [5 x i8] c"%ld \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [32 x i8] c"Error opening file for writing.\00"
define void @mandelbrot_region(i64 %0, i64 %1, i32 %2, i32 %3, i64 %4, i64 %5, i32 %6, i8* %7) {
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i64*
%19 = alloca i64*
%20 = alloca i32
%21 = alloca i64
%22 = alloca i64
%23 = alloca i64
%24 = alloca i64
%25 = alloca i64
%26 = alloca i64
%27 = alloca i64
%28 = alloca i64
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i64
%33 = alloca i32*
%34 = alloca i32
store i64 %0, i64* %9
store i64 %1, i64* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i64 %4, i64* %13
store i64 %5, i64* %14
store i32 %6, i32* %15
store i8* %7, i8** %16
%35 = load i32, i32* %11
%36 = load i32, i32* %12
%37 = mul nsw i32 %35, %36
store i32 %37, i32* %17
%38 = load i32, i32* %17
%39 = sext i32 %38 to i64
%40 = mul i64 8, %39
%41 = trunc i64 %40 to i32
%42 = call i64* @malloc(i32 %41)
store i64* %42, i64** %18
%43 = load i32, i32* %17
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 8
%46 = mul i64 %45, 2
%47 = trunc i64 %46 to i32
%48 = call i64* @malloc(i32 %47)
store i64* %48, i64** %19
store i32 0, i32* %20
br label %49
49: ; preds = %61, %8
%50 = load i32, i32* %20
%51 = load i32, i32* %17
%52 = mul nsw i32 %51, 2
%53 = icmp slt i32 %50, %52
br i1 %53, label %54, label %64
54: ; preds = %49
%55 = load i64*, i64** %19
%56 = load i32, i32* %20
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i64, i64* %55, i64 %57
%59 = load i64, i64* %58
%60 = call i32 @mpf_init(i64 %59)
br label %61
61: ; preds = %54
%62 = load i32, i32* %20
%63 = add nsw i32 %62, 1
store i32 %63, i32* %20
br label %49
64: ; preds = %49
store i64 0, i64* %21
%65 = load i64, i64* %22
%66 = load i64, i64* %9
%67 = call i32 @mpf_init_set(i64 %65, i64 %66)
%68 = load i64, i64* %23
%69 = load i64, i64* %10
%70 = call i32 @mpf_init_set(i64 %68, i64 %69)
%71 = load i64, i64* %24
%72 = call i32 @mpf_init(i64 %71)
%73 = load i64, i64* %25
%74 = call i32 @mpf_init(i64 %73)
%75 = load i64, i64* %26
%76 = call i32 @mpf_init(i64 %75)
%77 = load i64, i64* %27
%78 = call i32 @mpf_init(i64 %77)
%79 = load i64, i64* %28
%80 = call i32 @mpf_init(i64 %79)
store i32 0, i32* %30
br label %81
81: ; preds = %198, %64
%82 = load i32, i32* %30
%83 = load i32, i32* %12
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %201
85: ; preds = %81
store i32 0, i32* %31
br label %86
86: ; preds = %187, %85
%87 = load i32, i32* %31
%88 = load i32, i32* %11
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %190
90: ; preds = %86
%91 = load i64, i64* %24
%92 = load i64, i64* %22
%93 = call i32 @mpf_set(i64 %91, i64 %92)
%94 = load i64, i64* %25
%95 = load i64, i64* %23
%96 = call i32 @mpf_set(i64 %94, i64 %95)
store i32 0, i32* %29
store i64 0, i64* %32
br label %97
97: ; preds = %153, %90
%98 = load i64, i64* %32
%99 = load i64, i64* %14
%100 = icmp slt i64 %98, %99
br i1 %100, label %101, label %156
101: ; preds = %97
%102 = load i64, i64* %26
%103 = load i64, i64* %24
%104 = load i64, i64* %24
%105 = call i32 @mpf_mul(i64 %102, i64 %103, i64 %104)
%106 = load i64, i64* %28
%107 = load i64, i64* %25
%108 = load i64, i64* %25
%109 = call i32 @mpf_mul(i64 %106, i64 %107, i64 %108)
%110 = load i64, i64* %26
%111 = load i64, i64* %26
%112 = load i64, i64* %28
%113 = call i32 @mpf_sub(i64 %110, i64 %111, i64 %112)
%114 = load i64, i64* %26
%115 = load i64, i64* %26
%116 = load i64, i64* %22
%117 = call i32 @mpf_add(i64 %114, i64 %115, i64 %116)
%118 = load i64, i64* %25
%119 = load i64, i64* %24
%120 = load i64, i64* %25
%121 = call i32 @mpf_mul(i64 %118, i64 %119, i64 %120)
%122 = load i64, i64* %25
%123 = load i64, i64* %25
%124 = call i32 @mpf_mul_ui(i64 %122, i64 %123, i32 2)
%125 = load i64, i64* %25
%126 = load i64, i64* %25
%127 = load i64, i64* %23
%128 = call i32 @mpf_add(i64 %125, i64 %126, i64 %127)
%129 = load i64, i64* %24
%130 = load i64, i64* %26
%131 = call i32 @mpf_set(i64 %129, i64 %130)
%132 = load i64, i64* %24
%133 = call i64 @mpf_cmp_d(i64 %132, i32 2)
%134 = icmp sge i64 %133, 0
br i1 %134, label %147, label %135
135: ; preds = %101
%136 = load i64, i64* %25
%137 = call i64 @mpf_cmp_d(i64 %136, i32 2)
%138 = icmp sge i64 %137, 0
br i1 %138, label %147, label %139
139: ; preds = %135
%140 = load i64, i64* %24
%141 = call i64 @mpf_cmp_d(i64 %140, i32 -2)
%142 = icmp sle i64 %141, 0
br i1 %142, label %147, label %143
143: ; preds = %139
%144 = load i64, i64* %25
%145 = call i64 @mpf_cmp_d(i64 %144, i32 -2)
%146 = icmp sle i64 %145, 0
br i1 %146, label %147, label %152
147: ; preds = %143, %139, %135, %101
store i32 1, i32* %29
%148 = load i64, i64* %32
%149 = load i64*, i64** %18
%150 = load i64, i64* %21
%151 = getelementptr inbounds i64, i64* %149, i64 %150
store i64 %148, i64* %151
br label %156
152: ; preds = %143
br label %153
153: ; preds = %152
%154 = load i64, i64* %32
%155 = add nsw i64 %154, 1
store i64 %155, i64* %32
br label %97
156: ; preds = %147, %97
%157 = load i32, i32* %29
%158 = icmp eq i32 %157, 0
br i1 %158, label %159, label %165
159: ; preds = %156
%160 = load i64, i64* %14
%161 = add nsw i64 %160, 1
%162 = load i64*, i64** %18
%163 = load i64, i64* %21
%164 = getelementptr inbounds i64, i64* %162, i64 %163
store i64 %161, i64* %164
br label %165
165: ; preds = %159, %156
%166 = load i64*, i64** %19
%167 = load i64, i64* %21
%168 = mul nsw i64 2, %167
%169 = getelementptr inbounds i64, i64* %166, i64 %168
%170 = load i64, i64* %169
%171 = load i64, i64* %24
%172 = call i32 @mpf_set(i64 %170, i64 %171)
%173 = load i64*, i64** %19
%174 = load i64, i64* %21
%175 = mul nsw i64 2, %174
%176 = add nsw i64 %175, 1
%177 = getelementptr inbounds i64, i64* %173, i64 %176
%178 = load i64, i64* %177
%179 = load i64, i64* %25
%180 = call i32 @mpf_set(i64 %178, i64 %179)
%181 = load i64, i64* %22
%182 = load i64, i64* %22
%183 = load i64, i64* %13
%184 = call i32 @mpf_add(i64 %181, i64 %182, i64 %183)
%185 = load i64, i64* %21
%186 = add nsw i64 %185, 1
store i64 %186, i64* %21
br label %187
187: ; preds = %165
%188 = load i32, i32* %31
%189 = add nsw i32 %188, 1
store i32 %189, i32* %31
br label %86
190: ; preds = %86
%191 = load i64, i64* %23
%192 = load i64, i64* %23
%193 = load i64, i64* %13
%194 = call i32 @mpf_sub(i64 %191, i64 %192, i64 %193)
%195 = load i64, i64* %22
%196 = load i64, i64* %9
%197 = call i32 @mpf_set(i64 %195, i64 %196)
br label %198
198: ; preds = %190
%199 = load i32, i32* %30
%200 = add nsw i32 %199, 1
store i32 %200, i32* %30
br label %81
201: ; preds = %81
%202 = load i8*, i8** %16
%203 = call i32* @fopen(i8* %202, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %203, i32** %33
%204 = load i32*, i32** %33
%205 = icmp ne i32* %204, null
br i1 %205, label %206, label %263
206: ; preds = %201
%207 = load i32*, i32** %33
%208 = load i32, i32* %11
%209 = sext i32 %208 to i64
%210 = call i32 @fprintf(i32* %207, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %209)
%211 = load i32*, i32** %33
%212 = load i32, i32* %12
%213 = sext i32 %212 to i64
%214 = call i32 @fprintf(i32* %211, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %213)
%215 = load i32*, i32** %33
%216 = load i64, i64* %14
%217 = call i32 @fprintf(i32* %215, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %216)
%218 = load i32*, i32** %33
%219 = load i32, i32* %15
%220 = sext i32 %219 to i64
%221 = call i32 @fprintf(i32* %218, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 %220)
store i32 0, i32* %34
br label %222
222: ; preds = %257, %206
%223 = load i32, i32* %34
%224 = load i32, i32* %17
%225 = icmp slt i32 %223, %224
br i1 %225, label %226, label %260
226: ; preds = %222
%227 = load i32*, i32** %33
%228 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %227)
%229 = load i32*, i32** %33
%230 = load i64*, i64** %18
%231 = load i32, i32* %34
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds i64, i64* %230, i64 %232
%234 = load i64, i64* %233
%235 = call i32 @fprintf(i32* %229, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %234)
%236 = load i32*, i32** %33
%237 = load i32, i32* %15
%238 = load i64*, i64** %19
%239 = load i32, i32* %34
%240 = mul nsw i32 2, %239
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds i64, i64* %238, i64 %241
%243 = load i64, i64* %242
%244 = call i32 @mpf_out_str(i32* %236, i32 10, i32 %237, i64 %243)
%245 = load i32*, i32** %33
%246 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %245)
%247 = load i32*, i32** %33
%248 = load i32, i32* %15
%249 = load i64*, i64** %19
%250 = load i32, i32* %34
%251 = mul nsw i32 2, %250
%252 = add nsw i32 %251, 1
%253 = sext i32 %252 to i64
%254 = getelementptr inbounds i64, i64* %249, i64 %253
%255 = load i64, i64* %254
%256 = call i32 @mpf_out_str(i32* %247, i32 10, i32 %248, i64 %255)
br label %257
257: ; preds = %226
%258 = load i32, i32* %34
%259 = add nsw i32 %258, 1
store i32 %259, i32* %34
br label %222
260: ; preds = %222
%261 = load i32*, i32** %33
%262 = call i32 @fclose(i32* %261)
br label %265
263: ; preds = %201
%264 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %265
265: ; preds = %263, %260
%266 = load i64, i64* %22
%267 = call i32 @mpf_clear(i64 %266)
%268 = load i64, i64* %23
%269 = call i32 @mpf_clear(i64 %268)
%270 = load i64, i64* %24
%271 = call i32 @mpf_clear(i64 %270)
%272 = load i64, i64* %25
%273 = call i32 @mpf_clear(i64 %272)
%274 = load i64, i64* %26
%275 = call i32 @mpf_clear(i64 %274)
%276 = load i64, i64* %27
%277 = call i32 @mpf_clear(i64 %276)
%278 = load i64, i64* %28
%279 = call i32 @mpf_clear(i64 %278)
%280 = load i64*, i64** %18
%281 = call i32 @free(i64* %280)
store i32 0, i32* %20
br label %282
282: ; preds = %294, %265
%283 = load i32, i32* %20
%284 = load i32, i32* %17
%285 = mul nsw i32 %284, 2
%286 = icmp slt i32 %283, %285
br i1 %286, label %287, label %297
287: ; preds = %282
%288 = load i64*, i64** %19
%289 = load i32, i32* %20
%290 = sext i32 %289 to i64
%291 = getelementptr inbounds i64, i64* %288, i64 %290
%292 = load i64, i64* %291
%293 = call i32 @mpf_clear(i64 %292)
br label %294
294: ; preds = %287
%295 = load i32, i32* %20
%296 = add nsw i32 %295, 1
store i32 %296, i32* %20
br label %282
297: ; preds = %282
%298 = load i64*, i64** %19
%299 = call i32 @free(i64* %298)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [5 x i8] c"%ld \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [32 x i8] c"Error opening file for writing.\00"
define void @mandelbrot_region(i64 %0, i64 %1, i32 %2, i32 %3, i64 %4, i64 %5, i32 %6, i8* nocapture %7) {
%9 = mul nsw i32 %3, %2
%10 = shl i32 %9, 3
%11 = tail call i64* @malloc(i32 %10)
%12 = shl i32 %9, 4
%13 = tail call i64* @malloc(i32 %12)
%14 = shl i32 %9, 1
%15 = icmp sgt i32 %9, 0
br i1 %15, label %16, label %26
16: ; preds = %8
%17 = call i32 @llvm.smax.i32(i32 %14, i32 1)
%18 = zext i32 %17 to i64
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %24, %19 ]
%21 = getelementptr inbounds i64, i64* %13, i64 %20
%22 = load i64, i64* %21
%23 = tail call i32 @mpf_init(i64 %22)
%24 = add nuw nsw i64 %20, 1
%25 = icmp eq i64 %24, %18
br i1 %25, label %26, label %19
26: ; preds = %19, %8
%27 = tail call i32 @mpf_init_set(i64 undef, i64 %0)
%28 = tail call i32 @mpf_init_set(i64 undef, i64 %1)
%29 = tail call i32 @mpf_init(i64 undef)
%30 = tail call i32 @mpf_init(i64 undef)
%31 = tail call i32 @mpf_init(i64 undef)
%32 = tail call i32 @mpf_init(i64 undef)
%33 = tail call i32 @mpf_init(i64 undef)
%34 = icmp sgt i32 %3, 0
br i1 %34, label %35, label %45
35: ; preds = %26
%36 = icmp sgt i32 %2, 0
%37 = icmp sgt i64 %5, 0
%38 = add nsw i64 %5, 1
br label %39
39: ; preds = %35, %48
%40 = phi i32 [ 0, %35 ], [ %52, %48 ]
%41 = phi i64 [ 0, %35 ], [ %49, %48 ]
br i1 %36, label %42, label %48
42: ; preds = %39
%43 = trunc i64 %41 to i32
%44 = add i32 %43, %2
br label %54
45: ; preds = %48, %26
%46 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%47 = icmp eq i32* %46, null
br i1 %47, label %126, label %97
48: ; preds = %82, %39
%49 = phi i64 [ %41, %39 ], [ %94, %82 ]
%50 = tail call i32 @mpf_sub(i64 undef, i64 undef, i64 %4)
%51 = tail call i32 @mpf_set(i64 undef, i64 %0)
%52 = add nuw nsw i32 %40, 1
%53 = icmp eq i32 %52, %3
br i1 %53, label %45, label %39
54: ; preds = %42, %82
%55 = phi i64 [ %94, %82 ], [ %41, %42 ]
%56 = tail call i32 @mpf_set(i64 undef, i64 undef)
%57 = tail call i32 @mpf_set(i64 undef, i64 undef)
br i1 %37, label %58, label %82
58: ; preds = %54, %79
%59 = phi i64 [ %80, %79 ], [ 0, %54 ]
%60 = tail call i32 @mpf_mul(i64 undef, i64 undef, i64 undef)
%61 = tail call i32 @mpf_mul(i64 undef, i64 undef, i64 undef)
%62 = tail call i32 @mpf_sub(i64 undef, i64 undef, i64 undef)
%63 = tail call i32 @mpf_add(i64 undef, i64 undef, i64 undef)
%64 = tail call i32 @mpf_mul(i64 undef, i64 undef, i64 undef)
%65 = tail call i32 @mpf_mul_ui(i64 undef, i64 undef, i32 2)
%66 = tail call i32 @mpf_add(i64 undef, i64 undef, i64 undef)
%67 = tail call i32 @mpf_set(i64 undef, i64 undef)
%68 = tail call i64 @mpf_cmp_d(i64 undef, i32 2)
%69 = icmp sgt i64 %68, -1
br i1 %69, label %82, label %70
70: ; preds = %58
%71 = tail call i64 @mpf_cmp_d(i64 undef, i32 2)
%72 = icmp sgt i64 %71, -1
br i1 %72, label %82, label %73
73: ; preds = %70
%74 = tail call i64 @mpf_cmp_d(i64 undef, i32 -2)
%75 = icmp slt i64 %74, 1
br i1 %75, label %82, label %76
76: ; preds = %73
%77 = tail call i64 @mpf_cmp_d(i64 undef, i32 -2)
%78 = icmp slt i64 %77, 1
br i1 %78, label %82, label %79
79: ; preds = %76
%80 = add nuw nsw i64 %59, 1
%81 = icmp eq i64 %80, %5
br i1 %81, label %82, label %58
82: ; preds = %79, %58, %70, %73, %76, %54
%83 = phi i64 [ %38, %54 ], [ %59, %76 ], [ %59, %73 ], [ %59, %70 ], [ %59, %58 ], [ %38, %79 ]
%84 = getelementptr inbounds i64, i64* %11, i64 %55
store i64 %83, i64* %84
%85 = shl nsw i64 %55, 1
%86 = getelementptr inbounds i64, i64* %13, i64 %85
%87 = load i64, i64* %86
%88 = tail call i32 @mpf_set(i64 %87, i64 undef)
%89 = or i64 %85, 1
%90 = getelementptr inbounds i64, i64* %13, i64 %89
%91 = load i64, i64* %90
%92 = tail call i32 @mpf_set(i64 %91, i64 undef)
%93 = tail call i32 @mpf_add(i64 undef, i64 undef, i64 %4)
%94 = add i64 %55, 1
%95 = trunc i64 %94 to i32
%96 = icmp eq i32 %44, %95
br i1 %96, label %48, label %54
97: ; preds = %45
%98 = sext i32 %2 to i64
%99 = tail call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %98)
%100 = sext i32 %3 to i64
%101 = tail call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %100)
%102 = tail call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %5)
%103 = sext i32 %6 to i64
%104 = tail call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 %103)
br i1 %15, label %105, label %107
105: ; preds = %97
%106 = zext i32 %9 to i64
br label %109
107: ; preds = %109, %97
%108 = tail call i32 @fclose(i32* %46)
br label %128
109: ; preds = %105, %109
%110 = phi i64 [ 0, %105 ], [ %124, %109 ]
%111 = tail call i32 @fputc(i32 32, i32* %46)
%112 = getelementptr inbounds i64, i64* %11, i64 %110
%113 = load i64, i64* %112
%114 = tail call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %113)
%115 = shl nuw nsw i64 %110, 1
%116 = getelementptr inbounds i64, i64* %13, i64 %115
%117 = load i64, i64* %116
%118 = tail call i32 @mpf_out_str(i32* %46, i32 10, i32 %6, i64 %117)
%119 = tail call i32 @fputc(i32 32, i32* %46)
%120 = or i64 %115, 1
%121 = getelementptr inbounds i64, i64* %13, i64 %120
%122 = load i64, i64* %121
%123 = tail call i32 @mpf_out_str(i32* %46, i32 10, i32 %6, i64 %122)
%124 = add nuw nsw i64 %110, 1
%125 = icmp eq i64 %124, %106
br i1 %125, label %107, label %109
126: ; preds = %45
%127 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %128
128: ; preds = %126, %107
%129 = tail call i32 @mpf_clear(i64 undef)
%130 = tail call i32 @mpf_clear(i64 undef)
%131 = tail call i32 @mpf_clear(i64 undef)
%132 = tail call i32 @mpf_clear(i64 undef)
%133 = tail call i32 @mpf_clear(i64 undef)
%134 = tail call i32 @mpf_clear(i64 undef)
%135 = tail call i32 @mpf_clear(i64 undef)
%136 = tail call i32 @free(i64* %11)
br i1 %15, label %137, label %147
137: ; preds = %128
%138 = call i32 @llvm.smax.i32(i32 %14, i32 1)
%139 = zext i32 %138 to i64
br label %140
140: ; preds = %137, %140
%141 = phi i64 [ 0, %137 ], [ %145, %140 ]
%142 = getelementptr inbounds i64, i64* %13, i64 %141
%143 = load i64, i64* %142
%144 = tail call i32 @mpf_clear(i64 %143)
%145 = add nuw nsw i64 %141, 1
%146 = icmp eq i64 %145, %139
br i1 %146, label %147, label %140
147: ; preds = %140, %128
%148 = tail call i32 @free(i64* %13)
ret void
}