#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*/ fp_bin_xform_pow(int /*<<< orphan*/, int, unsigned 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_div_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
void fp_hasse_zeta_compute(mpf_t zeta, unsigned int s, int prec) {
  int nmax = (3.321928 * prec + 3);
  int n;
  mpf_t twon, term;
  mpf_init(twon);
  mpf_init(term);
  mpf_set_ui(twon, 1);
  mpf_div_ui(twon, twon, 2);
  mpf_set_ui(zeta, 0);
  for (n = 0; n < nmax; n++) {
    fp_bin_xform_pow(term, n, s);
    mpf_mul(term, term, twon);
    mpf_add(zeta, zeta, term);
    mpf_div_ui(twon, twon, 2);
  }
  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);
  mpf_clear(twon);
  mpf_clear(term);
}


x86 assembly (clang, -O0):
<fp_hasse_zeta_compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <mpf_init@plt>
mov    -0x1c(%rbp),%edi
call   1060 <mpf_init@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1090 <mpf_set_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
call   1080 <mpf_div_ui@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1090 <mpf_set_ui@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1267 <fp_hasse_zeta_compute+0xc7>
mov    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <fp_bin_xform_pow@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10b0 <mpf_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <mpf_add@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
call   1080 <mpf_div_ui@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1213 <fp_hasse_zeta_compute+0x73>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1090 <mpf_set_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1040 <mpf_div_2exp@plt>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1090 <mpf_set_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10a0 <mpf_sub@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10c0 <mpf_div@plt>
mov    -0x18(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x1c(%rbp),%edi
call   1070 <mpf_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_hasse_zeta_compute>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
cvtsi2sd %edx,%xmm0
mulsd  0xe48(%rip),%xmm0
addsd  0xe48(%rip),%xmm0
cvttsd2si %xmm0,%r15d
call   1060 <mpf_init@plt>
call   1060 <mpf_init@plt>
mov    $0x1,%esi
call   1090 <mpf_set_ui@plt>
mov    $0x2,%edx
call   1080 <mpf_div_ui@plt>
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1090 <mpf_set_ui@plt>
test   %r15d,%r15d
jle    122a <fp_hasse_zeta_compute+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <fp_bin_xform_pow@plt>
call   10b0 <mpf_mul@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1050 <mpf_add@plt>
mov    $0x2,%edx
call   1080 <mpf_div_ui@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1200 <fp_hasse_zeta_compute+0x60>
mov    $0x1,%esi
call   1090 <mpf_set_ui@plt>
add    $0xffffffff,%r14d
mov    %r14d,%edx
call   1040 <mpf_div_2exp@plt>
mov    $0x1,%esi
call   1090 <mpf_set_ui@plt>
call   10a0 <mpf_sub@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   10c0 <mpf_div@plt>
call   1070 <mpf_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <mpf_clear@plt>

LLVM IR (-O0):
define void @fp_hasse_zeta_compute(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
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = sitofp i32 %11 to double
%13 = call double @llvm.fmuladd.f64(double 0x400A934EFCBD5561, double %12, double 3.000000e+00)
%14 = fptosi double %13 to i32
store i32 %14, i32* %7
%15 = load i32, i32* %9
%16 = call i32 @mpf_init(i32 %15)
%17 = load i32, i32* %10
%18 = call i32 @mpf_init(i32 %17)
%19 = load i32, i32* %9
%20 = call i32 @mpf_set_ui(i32 %19, i32 1)
%21 = load i32, i32* %9
%22 = load i32, i32* %9
%23 = call i32 @mpf_div_ui(i32 %21, i32 %22, i32 2)
%24 = load i32, i32* %4
%25 = call i32 @mpf_set_ui(i32 %24, i32 0)
store i32 0, i32* %8
br label %26
26: ; preds = %46, %3
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %49
30: ; preds = %26
%31 = load i32, i32* %10
%32 = load i32, i32* %8
%33 = load i32, i32* %5
%34 = call i32 @fp_bin_xform_pow(i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %10
%36 = load i32, i32* %10
%37 = load i32, i32* %9
%38 = call i32 @mpf_mul(i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %4
%40 = load i32, i32* %4
%41 = load i32, i32* %10
%42 = call i32 @mpf_add(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %9
%44 = load i32, i32* %9
%45 = call i32 @mpf_div_ui(i32 %43, i32 %44, i32 2)
br label %46
46: ; preds = %30
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %26
49: ; preds = %26
%50 = load i32, i32* %9
%51 = call i32 @mpf_set_ui(i32 %50, i32 1)
%52 = load i32, i32* %9
%53 = load i32, i32* %9
%54 = load i32, i32* %5
%55 = sub i32 %54, 1
%56 = call i32 @mpf_div_2exp(i32 %52, i32 %53, i32 %55)
%57 = load i32, i32* %10
%58 = call i32 @mpf_set_ui(i32 %57, i32 1)
%59 = load i32, i32* %10
%60 = load i32, i32* %10
%61 = load i32, i32* %9
%62 = call i32 @mpf_sub(i32 %59, i32 %60, i32 %61)
%63 = load i32, i32* %4
%64 = load i32, i32* %4
%65 = load i32, i32* %10
%66 = call i32 @mpf_div(i32 %63, i32 %64, i32 %65)
%67 = load i32, i32* %9
%68 = call i32 @mpf_clear(i32 %67)
%69 = load i32, i32* %10
%70 = call i32 @mpf_clear(i32 %69)
ret void
}

LLVM IR (-O2):
define void @fp_hasse_zeta_compute(i32 %0, i32 %1, i32 %2) {
%4 = sitofp i32 %2 to double
%5 = tail call double @llvm.fmuladd.f64(double %4, double 0x400A934EFCBD5561, double 3.000000e+00)
%6 = fptosi double %5 to i32
%7 = tail call i32 @mpf_init(i32 undef)
%8 = tail call i32 @mpf_init(i32 undef)
%9 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%10 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 2)
%11 = tail call i32 @mpf_set_ui(i32 %0, i32 0)
%12 = icmp sgt i32 %6, 0
br i1 %12, label %13, label %21
13: ; preds = %3, %13
%14 = phi i32 [ %19, %13 ], [ 0, %3 ]
%15 = tail call i32 @fp_bin_xform_pow(i32 undef, i32 %14, i32 %1)
%16 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%17 = tail call i32 @mpf_add(i32 %0, i32 %0, i32 undef)
%18 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 2)
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, %6
br i1 %20, label %21, label %13
21: ; preds = %13, %3
%22 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%23 = add i32 %1, -1
%24 = tail call i32 @mpf_div_2exp(i32 undef, i32 undef, i32 %23)
%25 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%26 = tail call i32 @mpf_sub(i32 undef, i32 undef, i32 undef)
%27 = tail call i32 @mpf_div(i32 %0, i32 %0, i32 undef)
%28 = tail call i32 @mpf_clear(i32 undef)
%29 = tail call i32 @mpf_clear(i32 undef)
ret void
}