#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*/);
long double mpfr_get_ld(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_inits(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpfr_set_ld(int /*<<< orphan*/, long double,
                               int /*<<< orphan*/);
long double coslfr(long double d) {
  mpfr_t frx;
  mpfr_inits(frx, NULL);
  mpfr_set_ld(frx, d, GMP_RNDN);
  mpfr_cos(frx, frx, GMP_RNDN);
  long double ret = mpfr_get_ld(frx, GMP_RNDN);
  mpfr_clears(frx, NULL);
  return ret;
}


x86 assembly (clang, -O0):
<coslfr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,-0x38(%rbp)
call   1070 <mpfr_inits@plt>
mov    -0x14(%rbp),%edi
fldt   -0x10(%rbp)
mov    0x2e65(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    (%rax),%esi
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <mpfr_set_ld@plt>
mov    -0x40(%rbp),%rax
mov    -0x14(%rbp),%esi
mov    (%rax),%edx
mov    %esi,%edi
call   1050 <mpfr_cos@plt>
mov    -0x40(%rbp),%rax
mov    -0x14(%rbp),%edi
mov    (%rax),%esi
call   1060 <mpfr_get_ld@plt>
mov    -0x38(%rbp),%rsi
fstpt  -0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <mpfr_clears@plt>
fldt   -0x30(%rbp)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coslfr>:
push   %rbx
sub    $0x20,%rsp
fldt   0x30(%rsp)
fstpt  0x14(%rsp)
xor    %esi,%esi
call   1070 <mpfr_inits@plt>
mov    0x2e75(%rip),%rbx
mov    (%rbx),%esi
fldt   0x14(%rsp)
fstpt  (%rsp)
call   1030 <mpfr_set_ld@plt>
mov    (%rbx),%edx
call   1050 <mpfr_cos@plt>
mov    (%rbx),%esi
call   1060 <mpfr_get_ld@plt>
fstpt  0x14(%rsp)
xor    %esi,%esi
call   1040 <mpfr_clears@plt>
fldt   0x14(%rsp)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@GMP_RNDN = global i32 0
define x86_fp80 @coslfr(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca i32
%4 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %2
%5 = load i32, i32* %3
%6 = call i32 @mpfr_inits(i32 %5, i32* null)
%7 = load i32, i32* %3
%8 = load x86_fp80, x86_fp80* %2
%9 = load i32, i32* @GMP_RNDN
%10 = call i32 @mpfr_set_ld(i32 %7, x86_fp80 %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 x86_fp80 @mpfr_get_ld(i32 %15, i32 %16)
store x86_fp80 %17, x86_fp80* %4
%18 = load i32, i32* %3
%19 = call i32 @mpfr_clears(i32 %18, i32* null)
%20 = load x86_fp80, x86_fp80* %4
ret x86_fp80 %20
}

LLVM IR (-O2):
@GMP_RNDN = global i32 0
define x86_fp80 @coslfr(x86_fp80 %0) {
%2 = tail call i32 @mpfr_inits(i32 undef, i32* null)
%3 = load i32, i32* @GMP_RNDN
%4 = tail call i32 @mpfr_set_ld(i32 undef, x86_fp80 %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 x86_fp80 @mpfr_get_ld(i32 undef, i32 %7)
%9 = tail call i32 @mpfr_clears(i32 undef, i32* null)
ret x86_fp80 %8
}