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

/* Variables and functions */
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
int mpf_cmp_d(int /*<<< orphan*/, double);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_d(int /*<<< orphan*/, double);
int /*<<< orphan*/ mpf_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int calc_point(mpf_t cx, mpf_t cy, int iterations) {
  mpf_t zx, zy, zxn, zyn, zx2, zy2, zx2_fast, t1;
  double er = 2.0;
  int i, k;
  mpf_init(zx);
  mpf_init(zy);
  mpf_init(t1);
  mpf_init(zxn);
  mpf_init(zyn);
  mpf_init(zx2);
  mpf_init(zy2);
  mpf_set_d(zx, 0.0);
  mpf_set_d(zy, 0.0);
  for (i = 0; i < iterations; i++) {
    mpf_mul(zx2, zx, zx);
    mpf_mul(zy2, zy, zy);
    mpf_sub(zxn, zx2, zy2);
    mpf_add(zxn, zxn, cx);
    mpf_mul_ui(zyn, zx, 2);
    mpf_mul(zyn, zyn, zy);
    mpf_add(zyn, zyn, cy);
    mpf_set(zx, zxn);
    mpf_set(zy, zyn);
    mpf_add(t1, zx2, zy2);
    k = mpf_cmp_d(t1, er * er);
    if (k > 0) {
      break;
    }
  }
  mpf_clear(zx);
  mpf_clear(zy);
  mpf_clear(t1);
  mpf_clear(zxn);
  mpf_clear(zyn);
  mpf_clear(zx2);
  mpf_clear(zy2);
  return i;
}


x86 assembly (clang, -O0):
<calc_point>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x14(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x2c(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x18(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x20(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x24(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x10(%rbp),%edi
xorps  %xmm0,%xmm0
call   1080 <mpf_set_d@plt>
mov    -0x14(%rbp),%edi
xorps  %xmm0,%xmm0
call   1080 <mpf_set_d@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12ce <calc_point+0x13e>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
call   10b0 <mpf_mul@plt>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10b0 <mpf_mul@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10a0 <mpf_sub@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1030 <mpf_add@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x2,%edx
call   1090 <mpf_mul_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10b0 <mpf_mul@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <mpf_add@plt>
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <mpf_set@plt>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1070 <mpf_set@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <mpf_add@plt>
mov    -0x2c(%rbp),%edi
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <mpf_cmp_d@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jle    12bb <calc_point+0x12b>
jmp    12ce <calc_point+0x13e>
jmp    12c0 <calc_point+0x130>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1203 <calc_point+0x73>
mov    -0x10(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x14(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x2c(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x18(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x1c(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x20(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x24(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_point>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
xorps  %xmm0,%xmm0
call   1080 <mpf_set_d@plt>
xorps  %xmm0,%xmm0
call   1080 <mpf_set_d@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
jle    1237 <calc_point+0xa7>
nopl   0x0(%rax,%rax,1)
call   10b0 <mpf_mul@plt>
call   10b0 <mpf_mul@plt>
call   10a0 <mpf_sub@plt>
mov    %r15d,%edx
call   1030 <mpf_add@plt>
mov    $0x2,%edx
call   1090 <mpf_mul_ui@plt>
call   10b0 <mpf_mul@plt>
mov    %r14d,%edx
call   1030 <mpf_add@plt>
call   1070 <mpf_set@plt>
call   1070 <mpf_set@plt>
call   1030 <mpf_add@plt>
movsd  0xddb(%rip),%xmm0
call   1040 <mpf_cmp_d@plt>
test   %eax,%eax
jg     1237 <calc_point+0xa7>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    11e0 <calc_point+0x50>
mov    %ebp,%ebx
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @calc_point(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 2.000000e+00, double* %15
%18 = load i32, i32* %7
%19 = call i32 @mpf_init(i32 %18)
%20 = load i32, i32* %8
%21 = call i32 @mpf_init(i32 %20)
%22 = load i32, i32* %14
%23 = call i32 @mpf_init(i32 %22)
%24 = load i32, i32* %9
%25 = call i32 @mpf_init(i32 %24)
%26 = load i32, i32* %10
%27 = call i32 @mpf_init(i32 %26)
%28 = load i32, i32* %11
%29 = call i32 @mpf_init(i32 %28)
%30 = load i32, i32* %12
%31 = call i32 @mpf_init(i32 %30)
%32 = load i32, i32* %7
%33 = call i32 @mpf_set_d(i32 %32, double 0.000000e+00)
%34 = load i32, i32* %8
%35 = call i32 @mpf_set_d(i32 %34, double 0.000000e+00)
store i32 0, i32* %16
br label %36
36: ; preds = %87, %3
%37 = load i32, i32* %16
%38 = load i32, i32* %6
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %90
40: ; preds = %36
%41 = load i32, i32* %11
%42 = load i32, i32* %7
%43 = load i32, i32* %7
%44 = call i32 @mpf_mul(i32 %41, i32 %42, i32 %43)
%45 = load i32, i32* %12
%46 = load i32, i32* %8
%47 = load i32, i32* %8
%48 = call i32 @mpf_mul(i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* %9
%50 = load i32, i32* %11
%51 = load i32, i32* %12
%52 = call i32 @mpf_sub(i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* %9
%54 = load i32, i32* %9
%55 = load i32, i32* %4
%56 = call i32 @mpf_add(i32 %53, i32 %54, i32 %55)
%57 = load i32, i32* %10
%58 = load i32, i32* %7
%59 = call i32 @mpf_mul_ui(i32 %57, i32 %58, i32 2)
%60 = load i32, i32* %10
%61 = load i32, i32* %10
%62 = load i32, i32* %8
%63 = call i32 @mpf_mul(i32 %60, i32 %61, i32 %62)
%64 = load i32, i32* %10
%65 = load i32, i32* %10
%66 = load i32, i32* %5
%67 = call i32 @mpf_add(i32 %64, i32 %65, i32 %66)
%68 = load i32, i32* %7
%69 = load i32, i32* %9
%70 = call i32 @mpf_set(i32 %68, i32 %69)
%71 = load i32, i32* %8
%72 = load i32, i32* %10
%73 = call i32 @mpf_set(i32 %71, i32 %72)
%74 = load i32, i32* %14
%75 = load i32, i32* %11
%76 = load i32, i32* %12
%77 = call i32 @mpf_add(i32 %74, i32 %75, i32 %76)
%78 = load i32, i32* %14
%79 = load double, double* %15
%80 = load double, double* %15
%81 = fmul double %79, %80
%82 = call i32 @mpf_cmp_d(i32 %78, double %81)
store i32 %82, i32* %17
%83 = load i32, i32* %17
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %40
br label %90
86: ; preds = %40
br label %87
87: ; preds = %86
%88 = load i32, i32* %16
%89 = add nsw i32 %88, 1
store i32 %89, i32* %16
br label %36
90: ; preds = %85, %36
%91 = load i32, i32* %7
%92 = call i32 @mpf_clear(i32 %91)
%93 = load i32, i32* %8
%94 = call i32 @mpf_clear(i32 %93)
%95 = load i32, i32* %14
%96 = call i32 @mpf_clear(i32 %95)
%97 = load i32, i32* %9
%98 = call i32 @mpf_clear(i32 %97)
%99 = load i32, i32* %10
%100 = call i32 @mpf_clear(i32 %99)
%101 = load i32, i32* %11
%102 = call i32 @mpf_clear(i32 %101)
%103 = load i32, i32* %12
%104 = call i32 @mpf_clear(i32 %103)
%105 = load i32, i32* %16
ret i32 %105
}

LLVM IR (-O2):
define i32 @calc_point(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @mpf_init(i32 undef)
%5 = tail call i32 @mpf_init(i32 undef)
%6 = tail call i32 @mpf_init(i32 undef)
%7 = tail call i32 @mpf_init(i32 undef)
%8 = tail call i32 @mpf_init(i32 undef)
%9 = tail call i32 @mpf_init(i32 undef)
%10 = tail call i32 @mpf_init(i32 undef)
%11 = tail call i32 @mpf_set_d(i32 undef, double 0.000000e+00)
%12 = tail call i32 @mpf_set_d(i32 undef, double 0.000000e+00)
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %31
14: ; preds = %3, %28
%15 = phi i32 [ %29, %28 ], [ 0, %3 ]
%16 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%17 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%18 = tail call i32 @mpf_sub(i32 undef, i32 undef, i32 undef)
%19 = tail call i32 @mpf_add(i32 undef, i32 undef, i32 %0)
%20 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 2)
%21 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%22 = tail call i32 @mpf_add(i32 undef, i32 undef, i32 %1)
%23 = tail call i32 @mpf_set(i32 undef, i32 undef)
%24 = tail call i32 @mpf_set(i32 undef, i32 undef)
%25 = tail call i32 @mpf_add(i32 undef, i32 undef, i32 undef)
%26 = tail call i32 @mpf_cmp_d(i32 undef, double 4.000000e+00)
%27 = icmp sgt i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %14
%29 = add nuw nsw i32 %15, 1
%30 = icmp eq i32 %29, %2
br i1 %30, label %31, label %14
31: ; preds = %28, %14, %3
%32 = phi i32 [ 0, %3 ], [ %15, %14 ], [ %2, %28 ]
%33 = tail call i32 @mpf_clear(i32 undef)
%34 = tail call i32 @mpf_clear(i32 undef)
%35 = tail call i32 @mpf_clear(i32 undef)
%36 = tail call i32 @mpf_clear(i32 undef)
%37 = tail call i32 @mpf_clear(i32 undef)
%38 = tail call i32 @mpf_clear(i32 undef)
%39 = tail call i32 @mpf_clear(i32 undef)
ret i32 %32
}