#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*/ mpfr_t;

/* Variables and functions */
int /*<<< orphan*/ GMP_RNDN;
int /*<<< orphan*/ mpfr_clears(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpfr_cos(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
double mpfr_get_d(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_inits(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpfr_set_d(int /*<<< orphan*/, double, int /*<<< orphan*/);
double cosfr(double d) {
  mpfr_t frx;
  mpfr_inits(frx, NULL);
  mpfr_set_d(frx, d, GMP_RNDN);
  mpfr_cos(frx, frx, GMP_RNDN);
  double ret = mpfr_get_d(frx, GMP_RNDN);
  mpfr_clears(frx, NULL);
  return ret;
}


x86 assembly (clang, -O0):
<cosfr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <mpfr_inits@plt>
mov    -0xc(%rbp),%edi
movsd  -0x8(%rbp),%xmm0
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x2e54(%rip),%rax
mov    (%rax),%edx
call   1060 <mpfr_cos@plt>
mov    -0xc(%rbp),%edi
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
call   1030 <mpfr_get_d@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <mpfr_clears@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosfr>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
xor    %esi,%esi
call   1070 <mpfr_inits@plt>
mov    0x2e77(%rip),%rbx
mov    (%rbx),%esi
movsd  0x8(%rsp),%xmm0
call   1040 <mpfr_set_d@plt>
mov    (%rbx),%edx
call   1060 <mpfr_cos@plt>
mov    (%rbx),%esi
call   1030 <mpfr_get_d@plt>
movsd  %xmm0,0x8(%rsp)
xor    %esi,%esi
call   1050 <mpfr_clears@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@GMP_RNDN = global i32 0
define double @cosfr(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store double %0, double* %2
%5 = load i32, i32* %3
%6 = call i32 @mpfr_inits(i32 %5, i32* null)
%7 = load i32, i32* %3
%8 = load double, double* %2
%9 = load i32, i32* @GMP_RNDN
%10 = call i32 @mpfr_set_d(i32 %7, double %8, i32 %9)
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* @GMP_RNDN
%14 = call i32 @mpfr_cos(i32 %11, i32 %12, i32 %13)
%15 = load i32, i32* %3
%16 = load i32, i32* @GMP_RNDN
%17 = call double @mpfr_get_d(i32 %15, i32 %16)
store double %17, double* %4
%18 = load i32, i32* %3
%19 = call i32 @mpfr_clears(i32 %18, i32* null)
%20 = load double, double* %4
ret double %20
}

LLVM IR (-O2):
@GMP_RNDN = global i32 0
define double @cosfr(double %0) {
%2 = tail call i32 @mpfr_inits(i32 undef, i32* null)
%3 = load i32, i32* @GMP_RNDN
%4 = tail call i32 @mpfr_set_d(i32 undef, double %0, i32 %3)
%5 = load i32, i32* @GMP_RNDN
%6 = tail call i32 @mpfr_cos(i32 undef, i32 undef, i32 %5)
%7 = load i32, i32* @GMP_RNDN
%8 = tail call double @mpfr_get_d(i32 undef, i32 %7)
%9 = tail call i32 @mpfr_clears(i32 undef, i32* null)
ret double %8
}