#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 */
int /*<<< orphan*/ fp_borwein_tchebysheff(int /*<<< orphan*/, int, int, int);
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                unsigned int);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
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*/ mpf_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_ui_pow_ui(int /*<<< orphan*/, int, unsigned int);
void fp_borwein_zeta(mpf_t zeta, unsigned int s, int prec) {
  double nterms = 0.69 + 2.302585093 * prec;
  nterms *= 0.567296329;
  int n = (int)(nterms + 1.0);
  mpz_t ip;
  mpz_init(ip);
  mpf_t d_n, po, term, twon;
  mpf_init(d_n);
  mpf_init(po);
  mpf_init(term);
  mpf_init(twon);
  fp_borwein_tchebysheff(d_n, n, n, prec);
  mpf_set_ui(zeta, 0);
  int k;
  for (k = 0; k < n; k++) {
    fp_borwein_tchebysheff(term, n, k, prec);
    mpf_sub(term, term, d_n);
    mpz_ui_pow_ui(ip, k + 1, s);
    mpf_set_z(po, ip);
    mpf_div(term, term, po);
    if (k % 2) {
      mpf_sub(zeta, zeta, term);
    } else {
      mpf_add(zeta, zeta, term);
    }
  }
  mpf_div(zeta, zeta, d_n);
  mpf_neg(zeta, zeta);
  mpf_set_ui(twon, 1);
  mpf_div_2exp(twon, twon, s - 1);
  mpf_set_ui(term, 1);
  mpf_sub(term, term, twon);
  mpf_div(zeta, zeta, term);
  mpz_clear(ip);
  mpf_clear(twon);
  mpf_clear(term);
  mpf_clear(po);
  mpf_clear(d_n);
}


x86 assembly (clang, -O0):
<fp_borwein_zeta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdfd(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xde3(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x24(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x28(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x2c(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x30(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x24(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <fp_borwein_tchebysheff@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   10a0 <mpf_set_ui@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1310 <fp_borwein_zeta+0x140>
mov    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <fp_borwein_tchebysheff@plt>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10c0 <mpf_sub@plt>
mov    -0x20(%rbp),%edi
mov    -0x34(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%edx
call   10f0 <mpz_ui_pow_ui@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10b0 <mpf_set_z@plt>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   10e0 <mpf_div@plt>
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12ef <fp_borwein_zeta+0x11f>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10c0 <mpf_sub@plt>
jmp    12fd <fp_borwein_zeta+0x12d>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1060 <mpf_add@plt>
jmp    1302 <fp_borwein_zeta+0x132>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1273 <fp_borwein_zeta+0xa3>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10e0 <mpf_div@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <mpf_neg@plt>
mov    -0x30(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    -0x30(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1030 <mpf_div_2exp@plt>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   10c0 <mpf_sub@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10e0 <mpf_div@plt>
mov    -0x20(%rbp),%edi
call   10d0 <mpz_clear@plt>
mov    -0x30(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x2c(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x28(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x24(%rbp),%edi
call   1090 <mpf_clear@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_borwein_zeta>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%r12d
cvtsi2sd %edx,%xmm0
mulsd  0xe10(%rip),%xmm0
addsd  0xe10(%rip),%xmm0
mulsd  0xe10(%rip),%xmm0
addsd  0xe10(%rip),%xmm0
cvttsd2si %xmm0,%r13d
call   1070 <mpz_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
mov    %r13d,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
call   1040 <fp_borwein_tchebysheff@plt>
xor    %ebx,%ebx
mov    %r12d,%edi
xor    %esi,%esi
call   10a0 <mpf_set_ui@plt>
test   %r13d,%r13d
jg     125a <fp_borwein_zeta+0x8a>
jmp    129b <fp_borwein_zeta+0xcb>
nopw   0x0(%rax,%rax,1)
call   1060 <mpf_add@plt>
cmp    %ebx,%r13d
je     129b <fp_borwein_zeta+0xcb>
mov    %ebx,%ebp
mov    %r13d,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
call   1040 <fp_borwein_tchebysheff@plt>
call   10c0 <mpf_sub@plt>
lea    0x1(%rbp),%ebx
mov    %ebx,%esi
mov    %r14d,%edx
call   10f0 <mpz_ui_pow_ui@plt>
call   10b0 <mpf_set_z@plt>
call   10e0 <mpf_div@plt>
mov    %r12d,%edi
mov    %r12d,%esi
test   $0x1,%bpl
je     1250 <fp_borwein_zeta+0x80>
call   10c0 <mpf_sub@plt>
cmp    %ebx,%r13d
jne    125a <fp_borwein_zeta+0x8a>
mov    %r12d,%edi
mov    %r12d,%esi
call   10e0 <mpf_div@plt>
mov    %r12d,%edi
mov    %r12d,%esi
call   1050 <mpf_neg@plt>
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
add    $0xffffffff,%r14d
mov    %r14d,%edx
call   1030 <mpf_div_2exp@plt>
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
call   10c0 <mpf_sub@plt>
mov    %r12d,%edi
mov    %r12d,%esi
call   10e0 <mpf_div@plt>
call   10d0 <mpz_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <mpf_clear@plt>

LLVM IR (-O0):
define void @fp_borwein_zeta(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%15 = load i32, i32* %6
%16 = sitofp i32 %15 to double
%17 = call double @llvm.fmuladd.f64(double 0x40026BB1BBB58975, double %16, double 6.900000e-01)
store double %17, double* %7
%18 = load double, double* %7
%19 = fmul double %18, 0x3FE2274AA1864475
store double %19, double* %7
%20 = load double, double* %7
%21 = fadd double %20, 1.000000e+00
%22 = fptosi double %21 to i32
store i32 %22, i32* %8
%23 = load i32, i32* %9
%24 = call i32 @mpz_init(i32 %23)
%25 = load i32, i32* %10
%26 = call i32 @mpf_init(i32 %25)
%27 = load i32, i32* %11
%28 = call i32 @mpf_init(i32 %27)
%29 = load i32, i32* %12
%30 = call i32 @mpf_init(i32 %29)
%31 = load i32, i32* %13
%32 = call i32 @mpf_init(i32 %31)
%33 = load i32, i32* %10
%34 = load i32, i32* %8
%35 = load i32, i32* %8
%36 = load i32, i32* %6
%37 = call i32 @fp_borwein_tchebysheff(i32 %33, i32 %34, i32 %35, i32 %36)
%38 = load i32, i32* %4
%39 = call i32 @mpf_set_ui(i32 %38, i32 0)
store i32 0, i32* %14
br label %40
40: ; preds = %80, %3
%41 = load i32, i32* %14
%42 = load i32, i32* %8
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %83
44: ; preds = %40
%45 = load i32, i32* %12
%46 = load i32, i32* %8
%47 = load i32, i32* %14
%48 = load i32, i32* %6
%49 = call i32 @fp_borwein_tchebysheff(i32 %45, i32 %46, i32 %47, i32 %48)
%50 = load i32, i32* %12
%51 = load i32, i32* %12
%52 = load i32, i32* %10
%53 = call i32 @mpf_sub(i32 %50, i32 %51, i32 %52)
%54 = load i32, i32* %9
%55 = load i32, i32* %14
%56 = add nsw i32 %55, 1
%57 = load i32, i32* %5
%58 = call i32 @mpz_ui_pow_ui(i32 %54, i32 %56, i32 %57)
%59 = load i32, i32* %11
%60 = load i32, i32* %9
%61 = call i32 @mpf_set_z(i32 %59, i32 %60)
%62 = load i32, i32* %12
%63 = load i32, i32* %12
%64 = load i32, i32* %11
%65 = call i32 @mpf_div(i32 %62, i32 %63, i32 %64)
%66 = load i32, i32* %14
%67 = srem i32 %66, 2
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %44
%70 = load i32, i32* %4
%71 = load i32, i32* %4
%72 = load i32, i32* %12
%73 = call i32 @mpf_sub(i32 %70, i32 %71, i32 %72)
br label %79
74: ; preds = %44
%75 = load i32, i32* %4
%76 = load i32, i32* %4
%77 = load i32, i32* %12
%78 = call i32 @mpf_add(i32 %75, i32 %76, i32 %77)
br label %79
79: ; preds = %74, %69
br label %80
80: ; preds = %79
%81 = load i32, i32* %14
%82 = add nsw i32 %81, 1
store i32 %82, i32* %14
br label %40
83: ; preds = %40
%84 = load i32, i32* %4
%85 = load i32, i32* %4
%86 = load i32, i32* %10
%87 = call i32 @mpf_div(i32 %84, i32 %85, i32 %86)
%88 = load i32, i32* %4
%89 = load i32, i32* %4
%90 = call i32 @mpf_neg(i32 %88, i32 %89)
%91 = load i32, i32* %13
%92 = call i32 @mpf_set_ui(i32 %91, i32 1)
%93 = load i32, i32* %13
%94 = load i32, i32* %13
%95 = load i32, i32* %5
%96 = sub i32 %95, 1
%97 = call i32 @mpf_div_2exp(i32 %93, i32 %94, i32 %96)
%98 = load i32, i32* %12
%99 = call i32 @mpf_set_ui(i32 %98, i32 1)
%100 = load i32, i32* %12
%101 = load i32, i32* %12
%102 = load i32, i32* %13
%103 = call i32 @mpf_sub(i32 %100, i32 %101, i32 %102)
%104 = load i32, i32* %4
%105 = load i32, i32* %4
%106 = load i32, i32* %12
%107 = call i32 @mpf_div(i32 %104, i32 %105, i32 %106)
%108 = load i32, i32* %9
%109 = call i32 @mpz_clear(i32 %108)
%110 = load i32, i32* %13
%111 = call i32 @mpf_clear(i32 %110)
%112 = load i32, i32* %12
%113 = call i32 @mpf_clear(i32 %112)
%114 = load i32, i32* %11
%115 = call i32 @mpf_clear(i32 %114)
%116 = load i32, i32* %10
%117 = call i32 @mpf_clear(i32 %116)
ret void
}

LLVM IR (-O2):
define void @fp_borwein_zeta(i32 %0, i32 %1, i32 %2) {
%4 = sitofp i32 %2 to double
%5 = tail call double @llvm.fmuladd.f64(double %4, double 0x40026BB1BBB58975, double 6.900000e-01)
%6 = fmul double %5, 0x3FE2274AA1864475
%7 = fadd double %6, 1.000000e+00
%8 = fptosi double %7 to i32
%9 = tail call i32 @mpz_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 @mpf_init(i32 undef)
%14 = tail call i32 @fp_borwein_tchebysheff(i32 undef, i32 %8, i32 %8, i32 %2)
%15 = tail call i32 @mpf_set_ui(i32 %0, i32 0)
%16 = icmp sgt i32 %8, 0
br i1 %16, label %17, label %33
17: ; preds = %3, %31
%18 = phi i32 [ %21, %31 ], [ 0, %3 ]
%19 = tail call i32 @fp_borwein_tchebysheff(i32 undef, i32 %8, i32 %18, i32 %2)
%20 = tail call i32 @mpf_sub(i32 undef, i32 undef, i32 undef)
%21 = add nuw nsw i32 %18, 1
%22 = tail call i32 @mpz_ui_pow_ui(i32 undef, i32 %21, i32 %1)
%23 = tail call i32 @mpf_set_z(i32 undef, i32 undef)
%24 = tail call i32 @mpf_div(i32 undef, i32 undef, i32 undef)
%25 = and i32 %18, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %17
%28 = tail call i32 @mpf_sub(i32 %0, i32 %0, i32 undef)
br label %31
29: ; preds = %17
%30 = tail call i32 @mpf_add(i32 %0, i32 %0, i32 undef)
br label %31
31: ; preds = %27, %29
%32 = icmp eq i32 %21, %8
br i1 %32, label %33, label %17
33: ; preds = %31, %3
%34 = tail call i32 @mpf_div(i32 %0, i32 %0, i32 undef)
%35 = tail call i32 @mpf_neg(i32 %0, i32 %0)
%36 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%37 = add i32 %1, -1
%38 = tail call i32 @mpf_div_2exp(i32 undef, i32 undef, i32 %37)
%39 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%40 = tail call i32 @mpf_sub(i32 undef, i32 undef, i32 undef)
%41 = tail call i32 @mpf_div(i32 %0, i32 %0, i32 undef)
%42 = tail call i32 @mpz_clear(i32 undef)
%43 = tail call i32 @mpf_clear(i32 undef)
%44 = tail call i32 @mpf_clear(i32 undef)
%45 = tail call i32 @mpf_clear(i32 undef)
%46 = tail call i32 @mpf_clear(i32 undef)
ret void
}