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

/* Variables and functions */
scalar_t__ floor(double);
int /*<<< orphan*/ fp_two_pi(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ mpf_abs(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
scalar_t__ mpf_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div_2exp(int /*<<< orphan*/, int /*<<< orphan*/, long);
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_neg(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set_z(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_bin_uiui(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
void topsin_series(mpf_t a_k, unsigned int k, unsigned int prec) {
  unsigned int n;
  mpf_t fourpi, numer, fact, low_bound, term, xterm;
  mpz_t bino;
  mpf_set_ui(a_k, 0);
  if (0 == k)
    return;
  mpf_init(fourpi);
  mpf_init(numer);
  mpf_init(fact);
  mpf_init(low_bound);
  mpf_init(term);
  mpf_init(xterm);
  mpz_init(bino);
  fp_two_pi(numer, prec);
  mpf_neg(numer, numer);
  mpf_mul(fourpi, numer, numer);
  mpf_neg(fourpi, fourpi);
  mpf_set_ui(fact, 1);
  long nbits = (long)floor(3.321 * prec);
  mpf_div_2exp(low_bound, fact, nbits + 32);
  for (n = 0; n < 2023123123; n++) {
    mpz_bin_uiui(bino, 2 * n + k, 2 * n);
    mpf_set_z(term, bino);
    mpf_mul(xterm, term, numer);
    mpf_div(term, xterm, fact);
    mpf_add(a_k, a_k, term);
    mpf_abs(xterm, term);
    if (mpf_cmp(xterm, low_bound) < 0)
      break;
    mpf_mul(numer, numer, fourpi);
    mpf_mul_ui(fact, fact, (2 * n + 3) * 2 * (n + 1));
  }
  if (k % 2 == 0)
    mpf_neg(a_k, a_k);
  mpf_clear(fourpi);
  mpf_clear(numer);
  mpf_clear(fact);
  mpf_clear(low_bound);
  mpf_clear(term);
  mpf_clear(xterm);
  mpz_clear(bino);
}


x86 assembly (clang, -O0):
<topsin_series>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   10c0 <mpf_set_ui@plt>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    123b <topsin_series+0x2b>
jmp    13ef <topsin_series+0x1df>
mov    -0x14(%rbp),%edi
call   10a0 <mpf_init@plt>
mov    -0x18(%rbp),%edi
call   10a0 <mpf_init@plt>
mov    -0x1c(%rbp),%edi
call   10a0 <mpf_init@plt>
mov    -0x20(%rbp),%edi
call   10a0 <mpf_init@plt>
mov    -0x24(%rbp),%edi
call   10a0 <mpf_init@plt>
mov    -0x28(%rbp),%edi
call   10a0 <mpf_init@plt>
mov    -0x2c(%rbp),%edi
call   1090 <mpz_init@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
call   10d0 <fp_two_pi@plt>
mov    -0x18(%rbp),%esi
mov    %esi,%edi
call   1070 <mpf_neg@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    %edx,%esi
call   1100 <mpf_mul@plt>
mov    -0x14(%rbp),%esi
mov    %esi,%edi
call   1070 <mpf_neg@plt>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   10c0 <mpf_set_ui@plt>
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  0xd44(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1130 <floor@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x38(%rbp),%rdx
add    $0x20,%rdx
call   1040 <mpf_div_2exp@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x789668b3,-0x10(%rbp)
jae    139d <topsin_series+0x18d>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%esi
shl    $0x1,%esi
add    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
shl    $0x1,%edx
call   1060 <mpz_bin_uiui@plt>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   10f0 <mpf_set_z@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1100 <mpf_mul@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1120 <mpf_div@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <mpf_add@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <mpf_abs@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <mpf_cmp@plt>
cmp    $0x0,%rax
jge    1361 <topsin_series+0x151>
jmp    139d <topsin_series+0x18d>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1100 <mpf_mul@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
shl    $0x1,%edx
add    $0x3,%edx
shl    $0x1,%edx
mov    -0x10(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edx
call   10e0 <mpf_mul_ui@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12e3 <topsin_series+0xd3>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    13b7 <topsin_series+0x1a7>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1070 <mpf_neg@plt>
mov    -0x14(%rbp),%edi
call   10b0 <mpf_clear@plt>
mov    -0x18(%rbp),%edi
call   10b0 <mpf_clear@plt>
mov    -0x1c(%rbp),%edi
call   10b0 <mpf_clear@plt>
mov    -0x20(%rbp),%edi
call   10b0 <mpf_clear@plt>
mov    -0x24(%rbp),%edi
call   10b0 <mpf_clear@plt>
mov    -0x28(%rbp),%edi
call   10b0 <mpf_clear@plt>
mov    -0x2c(%rbp),%edi
call   1110 <mpz_clear@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<topsin_series>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%r12d
xor    %r13d,%r13d
xor    %esi,%esi
call   10c0 <mpf_set_ui@plt>
test   %r14d,%r14d
je     1348 <topsin_series+0x138>
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>
call   10a0 <mpf_init@plt>
call   1090 <mpz_init@plt>
mov    %r15d,%esi
call   10d0 <fp_two_pi@plt>
call   1070 <mpf_neg@plt>
call   1100 <mpf_mul@plt>
call   1070 <mpf_neg@plt>
mov    $0x1,%ebp
mov    $0x1,%esi
call   10c0 <mpf_set_ui@plt>
mov    %r15d,%eax
cvtsi2sd %rax,%xmm0
mulsd  0xd70(%rip),%xmm0
call   1130 <floor@plt>
lea    0x20(%rax),%rdx
call   1040 <mpf_div_2exp@plt>
mov    $0x6,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%r13,1),%esi
mov    %r13d,%edx
call   1060 <mpz_bin_uiui@plt>
call   10f0 <mpf_set_z@plt>
call   1100 <mpf_mul@plt>
call   1120 <mpf_div@plt>
mov    %r12d,%edi
mov    %r12d,%esi
call   1080 <mpf_add@plt>
call   1030 <mpf_abs@plt>
call   1050 <mpf_cmp@plt>
test   %rax,%rax
js     1306 <topsin_series+0xf6>
call   1100 <mpf_mul@plt>
mov    %ebx,%edx
imul   %ebp,%edx
call   10e0 <mpf_mul_ui@plt>
add    $0x4,%ebx
add    $0x1,%ebp
add    $0x2,%r13d
cmp    $0x789668b4,%ebp
jne    12b0 <topsin_series+0xa0>
test   $0x1,%r14b
jne    1317 <topsin_series+0x107>
mov    %r12d,%edi
mov    %r12d,%esi
call   1070 <mpf_neg@plt>
call   10b0 <mpf_clear@plt>
call   10b0 <mpf_clear@plt>
call   10b0 <mpf_clear@plt>
call   10b0 <mpf_clear@plt>
call   10b0 <mpf_clear@plt>
call   10b0 <mpf_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1110 <mpz_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @topsin_series(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 i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%16 = load i32, i32* %4
%17 = call i32 @mpf_set_ui(i32 %16, i32 0)
%18 = load i32, i32* %5
%19 = icmp eq i32 0, %18
br i1 %19, label %20, label %21
20: ; preds = %3
br label %136
21: ; preds = %3
%22 = load i32, i32* %8
%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* %13
%33 = call i32 @mpf_init(i32 %32)
%34 = load i32, i32* %14
%35 = call i32 @mpz_init(i32 %34)
%36 = load i32, i32* %9
%37 = load i32, i32* %6
%38 = call i32 @fp_two_pi(i32 %36, i32 %37)
%39 = load i32, i32* %9
%40 = load i32, i32* %9
%41 = call i32 @mpf_neg(i32 %39, i32 %40)
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = load i32, i32* %9
%45 = call i32 @mpf_mul(i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %8
%47 = load i32, i32* %8
%48 = call i32 @mpf_neg(i32 %46, i32 %47)
%49 = load i32, i32* %10
%50 = call i32 @mpf_set_ui(i32 %49, i32 1)
%51 = load i32, i32* %6
%52 = uitofp i32 %51 to double
%53 = fmul double 3.321000e+00, %52
%54 = call i64 @floor(double %53)
store i64 %54, i64* %15
%55 = load i32, i32* %11
%56 = load i32, i32* %10
%57 = load i64, i64* %15
%58 = add nsw i64 %57, 32
%59 = call i32 @mpf_div_2exp(i32 %55, i32 %56, i64 %58)
store i32 0, i32* %7
br label %60
60: ; preds = %110, %21
%61 = load i32, i32* %7
%62 = icmp ult i32 %61, 2023123123
br i1 %62, label %63, label %113
63: ; preds = %60
%64 = load i32, i32* %14
%65 = load i32, i32* %7
%66 = mul i32 2, %65
%67 = load i32, i32* %5
%68 = add i32 %66, %67
%69 = load i32, i32* %7
%70 = mul i32 2, %69
%71 = call i32 @mpz_bin_uiui(i32 %64, i32 %68, i32 %70)
%72 = load i32, i32* %12
%73 = load i32, i32* %14
%74 = call i32 @mpf_set_z(i32 %72, i32 %73)
%75 = load i32, i32* %13
%76 = load i32, i32* %12
%77 = load i32, i32* %9
%78 = call i32 @mpf_mul(i32 %75, i32 %76, i32 %77)
%79 = load i32, i32* %12
%80 = load i32, i32* %13
%81 = load i32, i32* %10
%82 = call i32 @mpf_div(i32 %79, i32 %80, i32 %81)
%83 = load i32, i32* %4
%84 = load i32, i32* %4
%85 = load i32, i32* %12
%86 = call i32 @mpf_add(i32 %83, i32 %84, i32 %85)
%87 = load i32, i32* %13
%88 = load i32, i32* %12
%89 = call i32 @mpf_abs(i32 %87, i32 %88)
%90 = load i32, i32* %13
%91 = load i32, i32* %11
%92 = call i64 @mpf_cmp(i32 %90, i32 %91)
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %63
br label %113
95: ; preds = %63
%96 = load i32, i32* %9
%97 = load i32, i32* %9
%98 = load i32, i32* %8
%99 = call i32 @mpf_mul(i32 %96, i32 %97, i32 %98)
%100 = load i32, i32* %10
%101 = load i32, i32* %10
%102 = load i32, i32* %7
%103 = mul i32 2, %102
%104 = add i32 %103, 3
%105 = mul i32 %104, 2
%106 = load i32, i32* %7
%107 = add i32 %106, 1
%108 = mul i32 %105, %107
%109 = call i32 @mpf_mul_ui(i32 %100, i32 %101, i32 %108)
br label %110
110: ; preds = %95
%111 = load i32, i32* %7
%112 = add i32 %111, 1
store i32 %112, i32* %7
br label %60
113: ; preds = %94, %60
%114 = load i32, i32* %5
%115 = urem i32 %114, 2
%116 = icmp eq i32 %115, 0
br i1 %116, label %117, label %121
117: ; preds = %113
%118 = load i32, i32* %4
%119 = load i32, i32* %4
%120 = call i32 @mpf_neg(i32 %118, i32 %119)
br label %121
121: ; preds = %117, %113
%122 = load i32, i32* %8
%123 = call i32 @mpf_clear(i32 %122)
%124 = load i32, i32* %9
%125 = call i32 @mpf_clear(i32 %124)
%126 = load i32, i32* %10
%127 = call i32 @mpf_clear(i32 %126)
%128 = load i32, i32* %11
%129 = call i32 @mpf_clear(i32 %128)
%130 = load i32, i32* %12
%131 = call i32 @mpf_clear(i32 %130)
%132 = load i32, i32* %13
%133 = call i32 @mpf_clear(i32 %132)
%134 = load i32, i32* %14
%135 = call i32 @mpz_clear(i32 %134)
br label %136
136: ; preds = %121, %20
ret void
}

LLVM IR (-O2):
define void @topsin_series(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @mpf_set_ui(i32 %0, i32 0)
%5 = icmp eq i32 %1, 0
br i1 %5, label %57, label %6
6: ; preds = %3
%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_init(i32 undef)
%12 = tail call i32 @mpf_init(i32 undef)
%13 = tail call i32 @mpz_init(i32 undef)
%14 = tail call i32 @fp_two_pi(i32 undef, i32 %2)
%15 = tail call i32 @mpf_neg(i32 undef, i32 undef)
%16 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%17 = tail call i32 @mpf_neg(i32 undef, i32 undef)
%18 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%19 = uitofp i32 %2 to double
%20 = fmul double %19, 3.321000e+00
%21 = tail call i64 @floor(double %20)
%22 = add nsw i64 %21, 32
%23 = tail call i32 @mpf_div_2exp(i32 undef, i32 undef, i64 %22)
br label %24
24: ; preds = %6, %36
%25 = phi i32 [ 0, %6 ], [ %40, %36 ]
%26 = shl nuw i32 %25, 1
%27 = add i32 %26, %1
%28 = tail call i32 @mpz_bin_uiui(i32 undef, i32 %27, i32 %26)
%29 = tail call i32 @mpf_set_z(i32 undef, i32 undef)
%30 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%31 = tail call i32 @mpf_div(i32 undef, i32 undef, i32 undef)
%32 = tail call i32 @mpf_add(i32 %0, i32 %0, i32 undef)
%33 = tail call i32 @mpf_abs(i32 undef, i32 undef)
%34 = tail call i64 @mpf_cmp(i32 undef, i32 undef)
%35 = icmp slt i64 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %24
%37 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%38 = shl i32 %25, 2
%39 = add i32 %38, 6
%40 = add nuw nsw i32 %25, 1
%41 = mul i32 %39, %40
%42 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 %41)
%43 = icmp eq i32 %40, 2023123123
br i1 %43, label %44, label %24
44: ; preds = %24, %36
%45 = and i32 %1, 1
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = tail call i32 @mpf_neg(i32 %0, i32 %0)
br label %49
49: ; preds = %47, %44
%50 = tail call i32 @mpf_clear(i32 undef)
%51 = tail call i32 @mpf_clear(i32 undef)
%52 = tail call i32 @mpf_clear(i32 undef)
%53 = tail call i32 @mpf_clear(i32 undef)
%54 = tail call i32 @mpf_clear(i32 undef)
%55 = tail call i32 @mpf_clear(i32 undef)
%56 = tail call i32 @mpz_clear(i32 undef)
br label %57
57: ; preds = %3, %49
ret void
}