#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;
typedef double mp_bitcnt_t;

/* Variables and functions */
int /*<<< orphan*/ fp_pi_half(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ fp_sine(int /*<<< orphan*/, int /*<<< orphan*/,
                           unsigned int);
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init2(int /*<<< orphan*/, double);
int /*<<< orphan*/ mpf_set(int /*<<< orphan*/, int /*<<< orphan*/ const);
void fp_cosine(mpf_t si, const mpf_t z, unsigned int prec) {
  mp_bitcnt_t bits = ((double)prec) * 3.322 + 50;
  mpf_t zee, pih;
  mpf_init2(zee, bits);
  mpf_init2(pih, bits);
  mpf_set(zee, z);
  fp_pi_half(pih, prec);
  mpf_add(zee, zee, pih);
  fp_sine(si, zee, prec);
  mpf_clear(zee);
  mpf_clear(pih);
}


x86 assembly (clang, -O0):
<fp_cosine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1080 <mpf_init2@plt>
mov    -0x20(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1080 <mpf_init2@plt>
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <mpf_set@plt>
mov    -0x20(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <fp_pi_half@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <mpf_add@plt>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <fp_sine@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpf_clear@plt>
mov    -0x20(%rbp),%edi
call   1050 <mpf_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_cosine>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r14d
mov    %edx,%eax
cvtsi2sd %rax,%xmm0
mulsd  0xe82(%rip),%xmm0
addsd  0xe82(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1080 <mpf_init2@plt>
movsd  0x8(%rsp),%xmm0
call   1080 <mpf_init2@plt>
mov    %ebp,%esi
call   1060 <mpf_set@plt>
mov    %ebx,%esi
call   1030 <fp_pi_half@plt>
call   1040 <mpf_add@plt>
mov    %r14d,%edi
mov    %ebx,%edx
call   1070 <fp_sine@plt>
call   1050 <mpf_clear@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <mpf_clear@plt>

LLVM IR (-O0):
define void @fp_cosine(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = uitofp i32 %10 to double
%12 = call double @llvm.fmuladd.f64(double %11, double 3.322000e+00, double 5.000000e+01)
store double %12, double* %7
%13 = load i32, i32* %8
%14 = load double, double* %7
%15 = call i32 @mpf_init2(i32 %13, double %14)
%16 = load i32, i32* %9
%17 = load double, double* %7
%18 = call i32 @mpf_init2(i32 %16, double %17)
%19 = load i32, i32* %8
%20 = load i32, i32* %5
%21 = call i32 @mpf_set(i32 %19, i32 %20)
%22 = load i32, i32* %9
%23 = load i32, i32* %6
%24 = call i32 @fp_pi_half(i32 %22, i32 %23)
%25 = load i32, i32* %8
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = call i32 @mpf_add(i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* %4
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = call i32 @fp_sine(i32 %29, i32 %30, i32 %31)
%33 = load i32, i32* %8
%34 = call i32 @mpf_clear(i32 %33)
%35 = load i32, i32* %9
%36 = call i32 @mpf_clear(i32 %35)
ret void
}

LLVM IR (-O2):
define void @fp_cosine(i32 %0, i32 %1, i32 %2) {
%4 = uitofp i32 %2 to double
%5 = tail call double @llvm.fmuladd.f64(double %4, double 3.322000e+00, double 5.000000e+01)
%6 = tail call i32 @mpf_init2(i32 undef, double %5)
%7 = tail call i32 @mpf_init2(i32 undef, double %5)
%8 = tail call i32 @mpf_set(i32 undef, i32 %1)
%9 = tail call i32 @fp_pi_half(i32 undef, i32 %2)
%10 = tail call i32 @mpf_add(i32 undef, i32 undef, i32 undef)
%11 = tail call i32 @fp_sine(i32 %0, i32 undef, i32 %2)
%12 = tail call i32 @mpf_clear(i32 undef)
%13 = tail call i32 @mpf_clear(i32 undef)
ret void
}