#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;
unsigned short _FPU_DEFAULT;
unsigned short _FPU_DOUBLE;
unsigned short _FPU_EXTENDED;
int /*<<< orphan*/ _FPU_GETCW(unsigned short);
int /*<<< orphan*/ _FPU_SETCW(unsigned short);
int /*<<< orphan*/ mpfr_set(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
void f(mpfr_t y, mpfr_t xMpfr) {
  unsigned short oldcw, cw;
  _FPU_GETCW(oldcw);
  cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
  _FPU_SETCW(cw);
  mpfr_set(y, xMpfr, GMP_RNDN);
  _FPU_SETCW(oldcw);
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movzwl -0xa(%rbp),%edi
call   1030 <_FPU_GETCW@plt>
mov    0x2e92(%rip),%rax
movzwl (%rax),%eax
mov    0x2e70(%rip),%rcx
movzwl (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    0x2e91(%rip),%rcx
movzwl (%rcx),%ecx
or     %ecx,%eax
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%edi
call   1050 <_FPU_SETCW@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
call   1040 <mpfr_set@plt>
movzwl -0xa(%rbp),%edi
call   1050 <_FPU_SETCW@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
call   1030 <_FPU_GETCW@plt>
mov    0x2e9b(%rip),%rax
mov    0x2e7c(%rip),%rcx
movzwl (%rcx),%ecx
not    %ecx
and    (%rax),%cx
mov    0x2e9d(%rip),%rax
or     (%rax),%cx
movzwl %cx,%edi
call   1050 <_FPU_SETCW@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <mpfr_set@plt>
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <_FPU_SETCW@plt>

LLVM IR (-O0):
@_FPU_DEFAULT = global i16 0
@_FPU_EXTENDED = global i16 0
@_FPU_DOUBLE = global i16 0
@GMP_RNDN = global i32 0
define void @f(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i16
%6 = alloca i16
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i16, i16* %5
%8 = call i32 @_FPU_GETCW(i16 zeroext %7)
%9 = load i16, i16* @_FPU_DEFAULT
%10 = zext i16 %9 to i32
%11 = load i16, i16* @_FPU_EXTENDED
%12 = zext i16 %11 to i32
%13 = xor i32 %12, -1
%14 = and i32 %10, %13
%15 = load i16, i16* @_FPU_DOUBLE
%16 = zext i16 %15 to i32
%17 = or i32 %14, %16
%18 = trunc i32 %17 to i16
store i16 %18, i16* %6
%19 = load i16, i16* %6
%20 = call i32 @_FPU_SETCW(i16 zeroext %19)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = load i32, i32* @GMP_RNDN
%24 = call i32 @mpfr_set(i32 %21, i32 %22, i32 %23)
%25 = load i16, i16* %5
%26 = call i32 @_FPU_SETCW(i16 zeroext %25)
ret void
}

LLVM IR (-O2):
@_FPU_DEFAULT = global i16 0
@_FPU_EXTENDED = global i16 0
@_FPU_DOUBLE = global i16 0
@GMP_RNDN = global i32 0
define void @f(i32 %0, i32 %1) {
%3 = tail call i32 @_FPU_GETCW(i16 zeroext undef)
%4 = load i16, i16* @_FPU_DEFAULT
%5 = load i16, i16* @_FPU_EXTENDED
%6 = xor i16 %5, -1
%7 = and i16 %4, %6
%8 = load i16, i16* @_FPU_DOUBLE
%9 = or i16 %7, %8
%10 = tail call i32 @_FPU_SETCW(i16 zeroext %9)
%11 = load i32, i32* @GMP_RNDN
%12 = tail call i32 @mpfr_set(i32 %0, i32 %1, i32 %11)
%13 = tail call i32 @_FPU_SETCW(i16 zeroext undef)
ret void
}